Skip to content

Commit c8cd426

Browse files
committed
[update] tutorials.
1 parent d6774e1 commit c8cd426

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Indexed Draws and Multiple Vertex Buffers"
33
document_id: "indexed-draws-multiple-vertex-buffers-tutorial-2025-11-22"
44
status: "draft"
55
created: "2025-11-22T00:00:00Z"
6-
last_updated: "2026-01-16T00:00:00Z"
7-
version: "0.3.1"
6+
last_updated: "2026-01-24T00:00:00Z"
7+
version: "0.3.3"
88
engine_workspace_version: "2023.1.30"
99
wgpu_version: "26.0.1"
1010
shader_backend_default: "naga"
1111
winit_version: "0.29.10"
12-
repo_commit: "9435ad1491b5930054117406abe08dd1c37f2102"
12+
repo_commit: "df476b77e1f2a17818869c3218cf223ab935c456"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["tutorial", "graphics", "indexed-draws", "vertex-buffers", "rust", "wgpu"]
@@ -123,14 +123,18 @@ struct PositionVertex {
123123
position: [f32; 3],
124124
}
125125

126+
unsafe impl lambda::pod::PlainOldData for PositionVertex {}
127+
126128
#[repr(C)]
127129
#[derive(Clone, Copy, Debug)]
128130
struct ColorVertex {
129131
color: [f32; 3],
130132
}
133+
134+
unsafe impl lambda::pod::PlainOldData for ColorVertex {}
131135
```
132136

133-
The shader `location` qualifiers match the vertex buffer layouts declared on the pipeline, and the `PositionVertex` and `ColorVertex` types mirror the `vec3` inputs as `[f32; 3]` arrays in Rust.
137+
The shader `location` qualifiers match the vertex buffer layouts declared on the pipeline, and the `PositionVertex` and `ColorVertex` types mirror the `vec3` inputs as `[f32; 3]` arrays in Rust. The `PlainOldData` implementations mark the types as safe for `BufferBuilder` uploads.
134138

135139
### Step 2 — Component State and Shader Construction <a name="step-2"></a>
136140

@@ -498,6 +502,8 @@ This tutorial demonstrates how indexed draws and multiple vertex buffers combine
498502

499503
## Changelog <a name="changelog"></a>
500504

505+
- 2026-01-24 (v0.3.3) — Move `PlainOldData` to `lambda::pod::PlainOldData`.
506+
- 2026-01-24 (v0.3.2) — Add `PlainOldData` requirements for typed buffer data.
501507
- 2026-01-16 (v0.3.1) — Update resize handling examples to use `event_mask()` and `on_window_event`.
502508
- 2025-12-15 (v0.3.0) — Update builder API calls to use `render_context.gpu()` and add `surface_format`/`depth_format` parameters to `RenderPassBuilder` and `RenderPipelineBuilder`.
503509
- 2025-11-23 (v0.2.0) — Filled in the implementation steps for the indexed draws and multiple vertex buffers tutorial and aligned the narrative with the `indexed_multi_vertex_buffers` example.

docs/tutorials/instanced-quads.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Instanced Rendering: Grid of Colored Quads"
33
document_id: "instanced-quads-tutorial-2025-11-25"
44
status: "draft"
55
created: "2025-11-25T00:00:00Z"
6-
last_updated: "2026-01-16T00:00:00Z"
7-
version: "0.2.1"
6+
last_updated: "2026-01-24T00:00:00Z"
7+
version: "0.2.3"
88
engine_workspace_version: "2023.1.30"
99
wgpu_version: "26.0.1"
1010
shader_backend_default: "naga"
1111
winit_version: "0.29.10"
12-
repo_commit: "9435ad1491b5930054117406abe08dd1c37f2102"
12+
repo_commit: "df476b77e1f2a17818869c3218cf223ab935c456"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["tutorial", "graphics", "instancing", "vertex-buffers", "rust", "wgpu"]
@@ -156,13 +156,17 @@ struct QuadVertex {
156156
position: [f32; 3],
157157
}
158158

159+
unsafe impl lambda::pod::PlainOldData for QuadVertex {}
160+
159161
#[repr(C)]
160162
#[derive(Clone, Copy, Debug)]
161163
struct InstanceData {
162164
offset: [f32; 3],
163165
color: [f32; 3],
164166
}
165167

168+
unsafe impl lambda::pod::PlainOldData for InstanceData {}
169+
166170
pub struct InstancedQuadsExample {
167171
vertex_shader: Shader,
168172
fragment_shader: Shader,
@@ -210,7 +214,7 @@ impl Default for InstancedQuadsExample {
210214
}
211215
```
212216

213-
The `QuadVertex` and `InstanceData` structures mirror the GLSL inputs as arrays of `f32`, and the component tracks resource identifiers and counts that are populated during attachment. The `Default` implementation constructs shader objects from the GLSL source so that the component is ready to build a pipeline when it receives a `RenderContext`.
217+
The `QuadVertex` and `InstanceData` structures mirror the GLSL inputs as arrays of `f32`, and the component tracks resource identifiers and counts that are populated during attachment. The `PlainOldData` implementations mark the types as safe for `BufferBuilder` uploads, which reinterpret values as raw bytes when initializing GPU buffers. The `Default` implementation constructs shader objects from the GLSL source so that the component is ready to build a pipeline when it receives a `RenderContext`.
214218

215219
### Step 3 — Render Pass, Geometry, Instances, and Buffers <a name="step-3"></a>
216220

@@ -510,6 +514,8 @@ This tutorial demonstrates how the `lambda-rs` crate uses per-vertex and per-ins
510514

511515
## Changelog <a name="changelog"></a>
512516

517+
- 2026-01-24 (v0.2.3) — Move `PlainOldData` to `lambda::pod::PlainOldData`.
518+
- 2026-01-24 (v0.2.2) — Add `PlainOldData` requirements for typed buffer data.
513519
- 2026-01-16 (v0.2.1) — Update resize handling examples to use `event_mask()` and `on_window_event`.
514520
- 2025-12-15 (v0.2.0) — Update builder API calls to use `render_context.gpu()` and add `surface_format`/`depth_format` parameters to `RenderPassBuilder` and `RenderPipelineBuilder`.
515521
- 2025-11-25 (v0.1.1) — Align feature naming with `render-validation-instancing` and update metadata.

docs/tutorials/uniform-buffers.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Uniform Buffers: Build a Spinning Triangle"
33
document_id: "uniform-buffers-tutorial-2025-10-17"
44
status: "draft"
55
created: "2025-10-17T00:00:00Z"
6-
last_updated: "2026-01-16T00:00:00Z"
7-
version: "0.5.1"
6+
last_updated: "2026-01-24T00:00:00Z"
7+
version: "0.5.3"
88
engine_workspace_version: "2023.1.30"
99
wgpu_version: "26.0.1"
1010
shader_backend_default: "naga"
1111
winit_version: "0.29.10"
12-
repo_commit: "9435ad1491b5930054117406abe08dd1c37f2102"
12+
repo_commit: "df476b77e1f2a17818869c3218cf223ab935c456"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["tutorial", "graphics", "uniform-buffers", "rust", "wgpu"]
@@ -222,14 +222,16 @@ let mesh: Mesh = mesh_builder
222222

223223
### Step 4 — Uniform Data Layout in Rust <a name="step-4"></a>
224224

225-
Mirror the shader’s uniform block with a Rust structure. Use `#[repr(C)]` so the memory layout is predictable. A `mat4` in the shader corresponds to a 4×4 `f32` array here. Many GPU interfaces expect column‑major matrices; transpose before upload if the local math library is row‑major. This avoids implicit driver conversions and prevents incorrect transforms.
225+
Mirror the shader’s uniform block with a Rust structure. Use `#[repr(C)]` so the memory layout is predictable. A `mat4` in the shader corresponds to a 4×4 `f32` array here. `PlainOldData` MUST be implemented so the engine can upload the uniform by reinterpreting its bytes. Many GPU interfaces expect column‑major matrices; transpose before upload if the local math library is row‑major. This avoids implicit driver conversions and prevents incorrect transforms.
226226

227227
```rust
228228
#[repr(C)]
229229
#[derive(Debug, Clone, Copy)]
230230
pub struct GlobalsUniform {
231231
pub render_matrix: [[f32; 4]; 4],
232232
}
233+
234+
unsafe impl lambda::pod::PlainOldData for GlobalsUniform {}
233235
```
234236

235237
### Step 5 — Bind Group Layout at Set 0 <a name="step-5"></a>
@@ -443,6 +445,8 @@ multiple objects and passes.
443445

444446
## Changelog <a name="changelog"></a>
445447

448+
- 0.5.3 (2026-01-24): Move `PlainOldData` to `lambda::pod::PlainOldData`.
449+
- 0.5.2 (2026-01-24): Add `PlainOldData` requirements for uniform buffer data.
446450
- 0.5.1 (2026-01-16): Replace `on_event` resize handling with `event_mask()` and `on_window_event`.
447451
- 0.5.0 (2025-12-15): Update builder API calls to use `render_context.gpu()` and add `surface_format`/`depth_format` parameters to `RenderPassBuilder` and `RenderPipelineBuilder`.
448452
- 0.4.1 (2025‑11‑10): Add Conclusion section summarizing accomplishments; update

0 commit comments

Comments
 (0)