Skip to content

Commit 1d131c0

Browse files
committed
[update] documentation to clarify offsets.
1 parent 3fa70c2 commit 1d131c0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/specs/indexed-draws-and-multiple-vertex-buffers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ App Code
108108
- `fn build<T: Copy>(self, render_context: &mut RenderContext, data: Vec<T>) -> Result<Buffer, Error>`.
109109
- `fn build_from_mesh(self, render_context: &mut RenderContext, mesh: Mesh) -> Result<Buffer, Error>` for convenience.
110110
- Vertex input definition (`lambda::render::vertex` and `lambda::render::pipeline`)
111-
- `struct VertexAttribute { location: u32, offset: u32, element: VertexElement }`.
111+
- `struct VertexAttribute { location: u32, offset: u32, element: VertexElement }`. The effective byte offset of a vertex attribute is computed as `offset + element.offset`, where `offset` is a base offset within the buffer element and `element.offset` is the offset of the field within the logical vertex or instance struct.
112112
- `RenderPipelineBuilder::with_buffer(buffer: Buffer, attributes: Vec<VertexAttribute>) -> Self`:
113113
- Each call declares a vertex buffer slot with a stride and attribute list.
114114
- Slots are assigned in call order starting at zero.

docs/tutorials/instanced-quads.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn on_attach(
343343
}
344344
```
345345

346-
The first buffer created by `with_buffer` is treated as a per-vertex buffer in slot `0`, while `with_instance_buffer` registers the instance buffer in slot `1` with per-instance step mode. The `vertex_attributes` and `instance_attributes` vectors connect shader locations `0`, `1`, and `2` to their corresponding buffer slots and formats, and the component records index and instance counts for later draws.
346+
The first buffer created by `with_buffer` is treated as a per-vertex buffer in slot `0`, while `with_instance_buffer` registers the instance buffer in slot `1` with per-instance step mode. The `vertex_attributes` and `instance_attributes` vectors connect shader locations `0`, `1`, and `2` to their corresponding buffer slots and formats, and the component records index and instance counts for later draws. The effective byte offset of each attribute is computed as `attribute.offset + attribute.element.offset`. In this example `attribute.offset` is kept at `0` for all attributes, and the struct layout is expressed entirely through `VertexElement::offset` (for example, the `color` field in `InstanceData` starts 12 bytes after the `offset` field). More complex layouts MAY use a non-zero `attribute.offset` to reuse the same attribute description at different base positions within a vertex or instance element.
347347

348348
### Step 4 — Resize Handling and Updates <a name="step-4"></a>
349349
Step 4 wires window resize events into the component and implements detach and update hooks. The resize handler keeps `width` and `height` in sync with the window so that the viewport matches the surface size.

0 commit comments

Comments
 (0)