Skip to content

Commit d401b8b

Browse files
committed
[update] documentation to reflect new changes to the render context.
1 parent 7125638 commit d401b8b

13 files changed

+341
-120
lines changed

docs/feature_roadmap_and_snippets.md

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
---
2+
title: "Lambda RS: Immediate Feature Ideas and Example APIs"
3+
document_id: "feature-roadmap-snippets-2025-09-24"
4+
status: "living"
5+
created: "2025-09-24T00:00:00Z"
6+
last_updated: "2025-12-15T00:00:00Z"
7+
version: "0.2.0"
8+
engine_workspace_version: "2023.1.30"
9+
wgpu_version: "26.0.1"
10+
shader_backend_default: "naga"
11+
winit_version: "0.29.10"
12+
repo_commit: "71256389b9efe247a59aabffe9de58147b30669d"
13+
owners: ["lambda-sh"]
14+
reviewers: ["engine", "rendering"]
15+
tags: ["roadmap", "features", "api-design", "rendering"]
16+
---
17+
118
# Lambda RS: Immediate Feature Ideas + Example APIs
219

320
This document proposes high‑impact features to add next to the Lambda RS
@@ -23,27 +40,34 @@ use lambda::render::{
2340
// Layout: set(0) has a uniform buffer at binding(0)
2441
let layout = BindGroupLayoutBuilder::new()
2542
.with_uniform(binding = 0, visibility = PipelineStage::VERTEX)
26-
.build(&mut rc);
43+
.build(rc.gpu());
2744

2845
// Create and upload a uniform buffer
2946
let ubo = BufferBuilder::new()
3047
.with_length(std::mem::size_of::<Globals>())
3148
.with_usage(Usage::UNIFORM)
3249
.with_properties(Properties::CPU_VISIBLE)
3350
.with_label("globals")
34-
.build(&mut rc, vec![initial_globals])?;
51+
.build(rc.gpu(), vec![initial_globals])?;
3552

3653
// Bind group that points the layout(0)@binding(0) to our UBO
3754
let group0 = BindGroupBuilder::new()
3855
.with_layout(&layout)
3956
.with_uniform(binding = 0, &ubo)
40-
.build(&mut rc);
57+
.build(rc.gpu());
4158

4259
// Pipeline accepts optional bind group layouts
4360
let pipe = RenderPipelineBuilder::new()
4461
.with_layouts(&[&layout])
4562
.with_buffer(vbo, attributes)
46-
.build(&mut rc, &pass, &vs, Some(&fs));
63+
.build(
64+
rc.gpu(),
65+
rc.surface_format(),
66+
rc.depth_format(),
67+
&pass,
68+
&vs,
69+
Some(&fs),
70+
);
4771

4872
// Commands inside a render pass
4973
RC::SetPipeline { pipeline: pipe_id },
@@ -64,25 +88,25 @@ let texture = TextureBuilder::new_2d(TextureFormat::Rgba8UnormSrgb)
6488
.with_size(512, 512)
6589
.with_data(&pixels)
6690
.with_label("albedo")
67-
.build(&mut rc);
91+
.build(rc.gpu());
6892

6993
let sampler = SamplerBuilder::new()
7094
.linear_clamp()
71-
.build(&mut rc);
95+
.build(rc.gpu());
7296

7397
// Layout: binding(0) uniform buffer, binding(1) sampled texture, binding(2) sampler
7498
let layout = BindGroupLayoutBuilder::new()
7599
.with_uniform(0, PipelineStage::VERTEX | PipelineStage::FRAGMENT)
76100
.with_sampled_texture(1)
77101
.with_sampler(2)
78-
.build(&mut rc);
102+
.build(rc.gpu());
79103

80104
let group = BindGroupBuilder::new()
81105
.with_layout(&layout)
82106
.with_uniform(0, &ubo)
83107
.with_texture(1, &texture)
84108
.with_sampler(2, &sampler)
85-
.build(&mut rc);
109+
.build(rc.gpu());
86110

87111
RC::BindGroup { set: 0, group: group_id, offsets: &[] },
88112
```
@@ -105,12 +129,23 @@ let pass = RenderPassBuilder::new()
105129
depth_compare = wgpu::CompareFunction::Less,
106130
)
107131
.with_msaa(samples = 4)
108-
.build(&rc);
132+
.build(
133+
rc.gpu(),
134+
rc.surface_format(),
135+
rc.depth_format(),
136+
);
109137

110138
let pipe = RenderPipelineBuilder::new()
111139
.with_msaa(samples = 4)
112140
.with_depth_format(wgpu::TextureFormat::Depth32Float)
113-
.build(&mut rc, &pass, &vs, Some(&fs));
141+
.build(
142+
rc.gpu(),
143+
rc.surface_format(),
144+
rc.depth_format(),
145+
&pass,
146+
&vs,
147+
Some(&fs),
148+
);
114149
```
115150

116151
## 4) Indexed Draw + Multiple Vertex Buffers
@@ -140,13 +175,21 @@ let offscreen = RenderTargetBuilder::new()
140175
.with_color(TextureFormat::Rgba8UnormSrgb, width, height)
141176
.with_depth(TextureFormat::Depth32Float)
142177
.with_label("offscreen")
143-
.build(&mut rc);
178+
.build(rc.gpu());
144179

145180
// Pass 1: draw scene into `offscreen`
146-
let p1 = RenderPassBuilder::new().with_target(&offscreen).build(&rc);
181+
let p1 = RenderPassBuilder::new().with_target(&offscreen).build(
182+
rc.gpu(),
183+
rc.surface_format(),
184+
rc.depth_format(),
185+
);
147186

148187
// Pass 2: sample offscreen color into swapchain
149-
let p2 = RenderPassBuilder::new().build(&rc);
188+
let p2 = RenderPassBuilder::new().build(
189+
rc.gpu(),
190+
rc.surface_format(),
191+
rc.depth_format(),
192+
);
150193

151194
// Commands
152195
RC::BeginRenderPass { render_pass: p1_id, viewport },
@@ -246,4 +289,3 @@ These proposals aim to keep Lambda’s surface area small while unlocking common
246289
workflows (texturing, uniforms, depth/MSAA, compute, multipass). I can begin
247290
implementing any of them next; uniform buffers/bind groups and depth/MSAA are
248291
usually the quickest wins for examples and demos.
249-

docs/game_roadmap_and_prototype.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Lambda RS: Gaps, Roadmap, and Prototype Plan"
33
document_id: "game-roadmap-2025-09-24"
44
status: "living"
55
created: "2025-09-24T05:09:25Z"
6-
last_updated: "2025-09-26T19:37:55Z"
7-
version: "0.2.0"
6+
last_updated: "2025-12-15T00:00:00Z"
7+
version: "0.3.0"
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: "2e7a3abcf60a780fa6bf089ca8a6f4124e60f660"
12+
repo_commit: "71256389b9efe247a59aabffe9de58147b30669d"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["roadmap","games","2d","3d","desktop"]
@@ -53,22 +53,29 @@ Bind groups and uniforms (value: larger, structured GPU data; portable across ad
5353
// Layout with one uniform buffer at set(0) binding(0)
5454
let layout = BindGroupLayoutBuilder::new()
5555
.with_uniform(0, PipelineStage::VERTEX)
56-
.build(&mut rc);
56+
.build(rc.gpu());
5757

5858
let ubo = BufferBuilder::new()
5959
.with_length(std::mem::size_of::<Globals>())
6060
.with_usage(Usage::UNIFORM)
6161
.with_properties(Properties::CPU_VISIBLE)
62-
.build(&mut rc, vec![initial_globals])?;
62+
.build(rc.gpu(), vec![initial_globals])?;
6363

6464
let group = BindGroupBuilder::new(&layout)
6565
.with_uniform(0, &ubo)
66-
.build(&mut rc);
66+
.build(rc.gpu());
6767

6868
let pipe = RenderPipelineBuilder::new()
6969
.with_layouts(&[&layout])
7070
.with_buffer(vbo, attrs)
71-
.build(&mut rc, &pass, &vs, Some(&fs));
71+
.build(
72+
rc.gpu(),
73+
rc.surface_format(),
74+
rc.depth_format(),
75+
&pass,
76+
&vs,
77+
Some(&fs),
78+
);
7279

7380
// Commands inside a pass
7481
RC::SetPipeline { pipeline: pipe_id };
@@ -85,17 +92,17 @@ Textures and samplers (value: sprites, materials, UI images; sRGB correctness):
8592
let tex = TextureBuilder::new_2d(TextureFormat::Rgba8UnormSrgb)
8693
.with_size(w, h)
8794
.with_data(&pixels)
88-
.build(&mut rc);
89-
let samp = SamplerBuilder::linear_clamp().build(&mut rc);
95+
.build(rc.gpu());
96+
let samp = SamplerBuilder::linear_clamp().build(rc.gpu());
9097

9198
let tex_layout = BindGroupLayoutBuilder::new()
9299
.with_sampled_texture(0)
93100
.with_sampler(1)
94-
.build(&mut rc);
101+
.build(rc.gpu());
95102
let tex_group = BindGroupBuilder::new(&tex_layout)
96103
.with_texture(0, &tex)
97104
.with_sampler(1, &samp)
98-
.build(&mut rc);
105+
.build(rc.gpu());
99106

100107
// In fragment shader, sample with: sampler2D + UVs; ensure vertex inputs provide UVs.
101108
// Upload path should convert source assets to sRGB formats when appropriate.
@@ -128,11 +135,22 @@ let pass = RenderPassBuilder::new()
128135
.with_clear_color(wgpu::Color::BLACK)
129136
.with_depth_stencil(wgpu::TextureFormat::Depth32Float, 1.0, true, wgpu::CompareFunction::Less)
130137
.with_msaa(4)
131-
.build(&rc);
138+
.build(
139+
rc.gpu(),
140+
rc.surface_format(),
141+
rc.depth_format(),
142+
);
132143

133144
let pipe = RenderPipelineBuilder::new()
134145
.with_depth_format(wgpu::TextureFormat::Depth32Float)
135-
.build(&mut rc, &pass, &vs, Some(&fs));
146+
.build(
147+
rc.gpu(),
148+
rc.surface_format(),
149+
rc.depth_format(),
150+
&pass,
151+
&vs,
152+
Some(&fs),
153+
);
136154
```
137155

138156
Notes
@@ -144,10 +162,18 @@ Offscreen render targets (value: post‑processing, shadow maps, UI composition,
144162
let offscreen = RenderTargetBuilder::new()
145163
.with_color(TextureFormat::Rgba8UnormSrgb, width, height)
146164
.with_depth(TextureFormat::Depth32Float)
147-
.build(&mut rc);
148-
149-
let pass1 = RenderPassBuilder::new().with_target(&offscreen).build(&rc);
150-
let pass2 = RenderPassBuilder::new().build(&rc); // backbuffer
165+
.build(rc.gpu());
166+
167+
let pass1 = RenderPassBuilder::new().with_target(&offscreen).build(
168+
rc.gpu(),
169+
rc.surface_format(),
170+
rc.depth_format(),
171+
);
172+
let pass2 = RenderPassBuilder::new().build(
173+
rc.gpu(),
174+
rc.surface_format(),
175+
rc.depth_format(),
176+
); // backbuffer
151177

152178
// Pass 1: draw scene
153179
RC::BeginRenderPass { render_pass: pass1_id, viewport };

docs/rendering.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
---
2+
title: "Lambda RS Rendering Guide"
3+
document_id: "rendering-guide-2025-09-24"
4+
status: "living"
5+
created: "2025-09-24T00:00:00Z"
6+
last_updated: "2025-12-15T00:00:00Z"
7+
version: "0.2.0"
8+
engine_workspace_version: "2023.1.30"
9+
wgpu_version: "26.0.1"
10+
shader_backend_default: "naga"
11+
winit_version: "0.29.10"
12+
repo_commit: "71256389b9efe247a59aabffe9de58147b30669d"
13+
owners: ["lambda-sh"]
14+
reviewers: ["engine", "rendering"]
15+
tags: ["guide", "rendering", "wgpu", "shaders", "pipelines"]
16+
---
17+
118
# Lambda RS Rendering Guide (wgpu backend)
219

320
This guide shows how to build windows, compile shaders, create pipelines,
@@ -117,7 +134,11 @@ use lambda_platform::wgpu::types as wgpu;
117134

118135
let pass = RenderPassBuilder::new()
119136
.with_clear_color(wgpu::Color { r: 0.02, g: 0.02, b: 0.06, a: 1.0 })
120-
.build(&render_context);
137+
.build(
138+
render_context.gpu(),
139+
render_context.surface_format(),
140+
render_context.depth_format(),
141+
);
121142
```
122143

123144
## Vertex Data: Mesh and Buffer
@@ -212,4 +233,3 @@ if let Events::Window { event: WindowEvent::Resize { width, height }, .. } = e {
212233
the feature flag `with-shaderc`.
213234
- All examples live under `crates/lambda-rs/examples/` and are runnable via:
214235
`cargo run -p lambda-rs --example <name>`
215-

docs/specs/depth-stencil-msaa.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Depth/Stencil and Multi-Sample Rendering"
33
document_id: "depth-stencil-msaa-2025-11-11"
44
status: "draft"
55
created: "2025-11-11T00:00:00Z"
6-
last_updated: "2025-11-21T22:00:00Z"
7-
version: "0.4.1"
6+
last_updated: "2025-12-15T00:00:00Z"
7+
version: "0.5.0"
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: "415167f4238c21debb385eef1192e2da7476c586"
12+
repo_commit: "71256389b9efe247a59aabffe9de58147b30669d"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["spec", "rendering", "depth", "stencil", "msaa"]
@@ -94,13 +94,24 @@ App Code
9494
.with_clear_color([0.0, 0.0, 0.0, 1.0])
9595
.with_depth_clear(1.0)
9696
.with_multi_sample(4)
97-
.build(&render_context);
97+
.build(
98+
render_context.gpu(),
99+
render_context.surface_format(),
100+
render_context.depth_format(),
101+
);
98102

99103
let pipeline = RenderPipelineBuilder::new()
100104
.with_multi_sample(4)
101105
.with_depth_format(DepthFormat::Depth32Float)
102106
.with_depth_compare(CompareFunction::Less)
103-
.build(&mut render_context, &pass, &vertex_shader, Some(&fragment_shader));
107+
.build(
108+
render_context.gpu(),
109+
render_context.surface_format(),
110+
render_context.depth_format(),
111+
&pass,
112+
&vertex_shader,
113+
Some(&fragment_shader),
114+
);
104115
```
105116
- Behavior
106117
- Defaults
@@ -243,6 +254,7 @@ Always-on safeguards (release and debug)
243254
defaults (no depth, no multi-sampling) unless explicitly configured.
244255

245256
## Changelog
257+
- 2025-12-15 (v0.5.0) — Update example code to use `render_context.gpu()` and add `surface_format`/`depth_format` parameters to `RenderPassBuilder` and `RenderPipelineBuilder`.
246258
- 2025-11-21 (v0.4.1) — Clarify depth attachment and clear behavior for
247259
stencil-only passes; align specification with engine behavior that preserves
248260
depth when only stencil operations are configured.

0 commit comments

Comments
 (0)