@@ -3,13 +3,13 @@ title: "Depth/Stencil and Multi-Sample Rendering"
33document_id : " depth-stencil-msaa-2025-11-11"
44status : " draft"
55created : " 2025-11-11T00:00:00Z"
6- last_updated : " 2025-11-13T00:00:00Z "
7- version : " 0.1.4 "
6+ last_updated : " 2025-11-17T00:19:24Z "
7+ version : " 0.2.0 "
88engine_workspace_version : " 2023.1.30"
99wgpu_version : " 26.0.1"
1010shader_backend_default : " naga"
1111winit_version : " 0.29.10"
12- repo_commit : " 21d0a5b511144db31f10ee07b2efb640ca990daf "
12+ repo_commit : " ceaf345777d871912b2f92ae629a34b8e6f8654a "
1313owners : ["lambda-sh"]
1414reviewers : ["engine", "rendering"]
1515tags : ["spec", "rendering", "depth", "stencil", "msaa"]
@@ -20,14 +20,15 @@ tags: ["spec", "rendering", "depth", "stencil", "msaa"]
2020Summary
2121- Add configurable depth testing/writes and multi-sample anti-aliasing (MSAA)
2222 to the high-level rendering API via builders, without exposing ` wgpu ` types.
23- - Provide strict validation at build time and predictable defaults to enable
24- 3D scenes and higher-quality rasterization in example and production code.
23+ - Provide validation and predictable defaults to enable 3D scenes and
24+ higher-quality rasterization in example and production code.
2525
2626## Scope
2727
2828- Goals
2929 - Expose depth/stencil and multi-sample configuration on ` RenderPassBuilder `
30- and ` RenderPipelineBuilder ` using ` lambda-rs ` types only.
30+ and ` RenderPipelineBuilder ` using engine/platform types; ` wgpu ` types are
31+ not exposed.
3132 - Validate device capabilities and configuration consistency at build time.
3233 - Define defaults for depth clear, compare operation, and sample count.
3334 - Map high-level configuration to ` lambda-rs-platform ` and ` wgpu ` internally.
@@ -49,14 +50,14 @@ Summary
4950## Architecture Overview
5051
5152- High-level builders in ` lambda-rs ` collect depth/stencil and multi-sample
52- configuration using engine-defined types.
53+ configuration using engine/platform types.
5354- ` lambda-rs-platform ` translates those types into backend-specific
5455 representations for ` wgpu ` creation of textures, passes, and pipelines.
5556
5657```
5758App Code
5859 └── lambda-rs (RenderPassBuilder / RenderPipelineBuilder)
59- └── DepthStencil + MultiSample config (engine types)
60+ └── DepthStencil + MultiSample config (engine/platform types)
6061 └── lambda-rs-platform (mapping/validation)
6162 └── wgpu device/pipeline/pass
6263```
@@ -83,26 +84,30 @@ App Code
8384 - ` RenderPipelineBuilder::with_multi_sample(u32) -> Self `
8485 - Example (engine types only)
8586 ``` rust
86- use lambda_rs :: render :: {Color , DepthFormat , CompareFunction , DepthStencil , MultiSample };
87+ use lambda :: render :: render_pass :: RenderPassBuilder ;
88+ use lambda :: render :: pipeline :: {RenderPipelineBuilder , CompareFunction };
89+ use lambda :: render :: texture :: DepthFormat ;
8790
8891 let pass = RenderPassBuilder :: new ()
8992 . with_clear_color ([0.0 , 0.0 , 0.0 , 1.0 ])
9093 . with_depth_clear (1.0 )
9194 . with_multi_sample (4 )
92- . build (& render_context )? ;
95+ . build (& render_context );
9396
9497 let pipeline = RenderPipelineBuilder :: new ()
9598 . with_multi_sample (4 )
9699 . with_depth_format (DepthFormat :: Depth32Float )
97100 . with_depth_compare (CompareFunction :: Less )
98- . build (& mut render_context , & pass , & vertex_shader , Some (& fragment_shader ))? ;
101+ . build (& mut render_context , & pass , & vertex_shader , Some (& fragment_shader ));
99102 ```
100103- Behavior
101104 - Defaults
102- - If `with_depth_stencil ` is not called , the pass MUST NOT create a depth
103- attachment and depth testing is disabled .
104- - `DepthStencil . clear_value` defaults to `1.0 ` (furthest depth ).
105- - `DepthStencil . compare` defaults to `CompareFunction :: Less `.
105+ - If depth is not requested on the pass (`with_depth * `), the pass MUST NOT
106+ create a depth attachment and depth testing is disabled .
107+ - Depth clear defaults to `1.0 ` when depth is enabled on the pass and no
108+ explicit clear is provided .
109+ - Pipeline depth compare defaults to `CompareFunction :: Less ` when depth is
110+ enabled for a pipeline and no explicit compare is provided .
106111 - `MultiSample . sample_count` defaults to `1 ` (no multi - sampling ).
107112 - Attachment creation
108113 - When depth is requested (`with_depth `/ `with_depth_clear `), the pass MUST
0 commit comments