@@ -3,13 +3,13 @@ title: "Textures and Samplers"
33document_id : " texture-sampler-spec-2025-10-30"
44status : " draft"
55created : " 2025-10-30T00:00:00Z"
6- last_updated : " 2025-10-30T00:10 :00Z"
7- version : " 0.2.0 "
6+ last_updated : " 2025-11-10T00:00 :00Z"
7+ version : " 0.3.1 "
88engine_workspace_version : " 2023.1.30"
99wgpu_version : " 26.0.1"
1010shader_backend_default : " naga"
1111winit_version : " 0.29.10"
12- repo_commit : " d3dc4356c165c596e0b9f84b3687b1018eeb1a91 "
12+ repo_commit : " fc5eb52c74eb0835225959f941db8e991112b87d "
1313owners : ["lambda-sh"]
1414reviewers : ["engine", "rendering"]
1515tags : ["spec", "rendering", "textures", "samplers", "wgpu"]
@@ -41,10 +41,14 @@ Summary
4141
4242### Non-Goals
4343
44- - Storage textures, depth textures, cube maps, and 2D/3D array textures.
45- - Multisampled textures and render target (color attachment) workflows.
46- - Mipmap generation (automatic or offline); only level 0 is supported.
47- - Partial sub-rect updates; uploads are whole-image at creation time.
44+ - Storage textures, depth textures, cube maps, and 2D/3D array textures
45+ are out of scope for this revision and tracked under “Future Extensions”.
46+ - Multisampled textures and render target (color attachment) workflows are
47+ out of scope for this revision and tracked under “Future Extensions”.
48+ - Mipmap generation (automatic or offline); only level 0 is supported in this
49+ revision. See “Future Extensions”.
50+ - Partial sub-rect updates; uploads are whole-image at creation time in this
51+ revision. See “Future Extensions”.
4852
4953## Terminology
5054
@@ -97,7 +101,8 @@ Render pass: SetPipeline -> SetBindGroup -> Draw
97101### API Surface
98102
99103- Platform layer (` lambda-rs-platform ` , module ` lambda_platform::wgpu::texture ` )
100- - Types: ` Texture ` , ` TextureView ` , ` Sampler ` (own raw ` wgpu ` handles).
104+ - Types: ` Texture ` , ` Sampler ` (own raw ` wgpu ` handles). A default
105+ full-range view is created and owned by ` Texture ` for binding.
101106 - Enums: ` TextureFormat ` , ` TextureDimension ` (` D2 ` , ` D3 ` ), ` ViewDimension `
102107 (` D2 ` , ` D3 ` ), ` FilterMode ` , ` AddressMode ` .
103108 - Builders:
@@ -121,20 +126,23 @@ Render pass: SetPipeline -> SetBindGroup -> Draw
121126 - Mip filtering and level-of-detail: ` with_lod(min, max) ` ,
122127 ` with_mip_filter(mode) ` (default ` Nearest ` ).
123128 - ` with_label(label: &str) `
124- - ` build(&mut RenderContext) ` -> ` Result< Sampler, Error> `
129+ - ` build(&mut RenderContext) ` -> ` Sampler `
125130
126131- High-level layer (` lambda-rs ` , module ` lambda::render::texture ` )
127132 - Mirrors platform builders and enums; returns high-level ` Texture ` and
128133 ` Sampler ` wrappers with no ` wgpu ` exposure.
129134 - Adds convenience methods consistent with the repository style (for example,
130- ` SamplerBuilder::linear_clamp() ` ).
135+ ` SamplerBuilder::linear_clamp() ` ). Usage toggles MAY be exposed at the
136+ high level or fixed to stable defaults.
131137
132138- Bind group integration (` lambda::render::bind ` )
133139 - ` BindGroupLayoutBuilder ` additions:
134- - ` with_sampled_texture(binding: u32) ` — 2D, filterable float; shorthand.
135- - ` with_sampled_texture_dim(binding: u32, dim: ViewDimension) ` — explicit
136- dimension (` D2 ` or ` D3 ` ), float sample type, not multisampled.
137- - ` with_sampler(binding: u32) ` — filtering sampler type.
140+ - ` with_sampled_texture(binding: u32) ` — 2D, filterable float; shorthand,
141+ default visibility Fragment.
142+ - ` with_sampled_texture_dim(binding: u32, dim: ViewDimension, visibility: BindingVisibility) ` —
143+ explicit dimension (` D2 ` or ` D3 ` ), float sample type, not multisampled.
144+ - ` with_sampler(binding: u32) ` — filtering sampler type; default visibility
145+ Fragment.
138146 - ` BindGroupBuilder ` additions:
139147 - ` with_texture(binding: u32, texture: &Texture) ` — uses the default view
140148 that matches the texture’s dimension.
@@ -160,11 +168,14 @@ Render pass: SetPipeline -> SetBindGroup -> Draw
160168
161169- Binding
162170 - ` with_sampled_texture ` declares a 2D filterable float texture binding at
163- the specified index; shaders declare ` texture_2d<f32> ` .
171+ the specified index with Fragment visibility; shaders declare
172+ ` texture_2d<f32> ` .
164173 - ` with_sampled_texture_dim ` declares a texture binding with explicit view
165- dimension; shaders declare ` texture_2d<f32> ` or ` texture_3d<f32> ` .
166- - ` with_sampler ` declares a filtering sampler binding at the specified index;
167- shaders declare ` sampler ` and combine with the texture in sampling calls.
174+ dimension and visibility; shaders declare ` texture_2d<f32> ` or
175+ ` texture_3d<f32> ` .
176+ - ` with_sampler ` declares a filtering sampler binding at the specified index
177+ with Fragment visibility; shaders declare ` sampler ` and combine with the
178+ texture in sampling calls.
168179
169180### Validation and Errors
170181
@@ -188,7 +199,8 @@ Render pass: SetPipeline -> SetBindGroup -> Draw
188199 - The platform layer performs padding to satisfy the 256-byte
189200 ` bytes_per_row ` requirement and sets ` rows_per_image ` appropriately;
190201 mismatched lengths or overflows MUST return an error before encoding.
191- - If ` with_data ` is used, usage MUST include ` COPY_DST ` .
202+ - If ` with_data ` is used, usage MUST include ` COPY_DST ` . An implementation
203+ MAY automatically add ` COPY_DST ` for build-time uploads to avoid errors.
192204
193205- Bindings
194206 - ` with_texture ` and ` with_sampler ` MUST reference resources compatible with
@@ -231,26 +243,39 @@ Render pass: SetPipeline -> SetBindGroup -> Draw
231243## Requirements Checklist
232244
233245- Functionality
234- - [ ] Feature flags defined (if applicable)
235- - [ ] 2D texture creation and upload
236- - [ ] 3D texture creation and upload
237- - [ ] Sampler creation (U, V, W addressing)
238- - [ ] Bind group layout and binding for texture + sampler (2D/3D)
246+ - [x ] Feature flags defined (if applicable) (N/A )
247+ - [x ] 2D texture creation and upload
248+ - [x ] 3D texture creation and upload
249+ - [x ] Sampler creation (U, V, W addressing)
250+ - [x ] Bind group layout and binding for texture + sampler (2D/3D)
239251- API Surface
240- - [ ] Public builders and enums in ` lambda-rs `
241- - [ ] Platform wrappers in ` lambda-rs-platform `
242- - [ ] Backwards compatibility assessed
252+ - [x ] Public builders and enums in ` lambda-rs `
253+ - [x ] Platform wrappers in ` lambda-rs-platform `
254+ - [x ] Backwards compatibility assessed
243255- Validation and Errors
244256 - [ ] Dimension and limit checks (2D/3D)
245- - [ ] Format compatibility checks
246- - [ ] Data length and row padding/rows-per-image validation
257+ - [x ] Format compatibility checks
258+ - [x ] Data length and row padding/rows-per-image validation
247259- Performance
248- - [ ] Upload path reasoned and documented
260+ - [x ] Upload path reasoned and documented
249261 - [ ] Memory footprint characterized for common formats
250262- Documentation and Examples
251- - [ ] User-facing docs updated
252- - [ ] Minimal example rendering a textured triangle
253- - [ ] Migration notes (if applicable)
263+ - [x] User-facing docs updated
264+ - [x] Minimal example rendering a textured quad (equivalent)
265+ - [x] Migration notes (if applicable) (N/A)
266+
267+ - Extensions (Planned)
268+ - [ ] Mipmapping: generation, ` mip_level_count ` , mip view selection
269+ - [ ] Texture arrays and cube maps: array/cube view dimensions and layout entries
270+ - [ ] Storage textures: read-write bindings and storage-capable formats
271+ - [ ] Render-target textures (color): ` RENDER_ATTACHMENT ` usage and MSAA resolve
272+ - [ ] Additional color formats: ` R8Unorm ` , ` Rg8Unorm ` , ` Rgba16Float ` , others
273+ - [ ] Compressed textures: BCn/ASTC/ETC via KTX2/BasisU
274+ - [ ] Anisotropic filtering and border color: anisotropy and ` ClampToBorder `
275+ - [ ] Sub-rect updates and streaming: partial ` write_texture ` , buffer-to-texture
276+ - [ ] Alternate view formats: ` view_formats ` and view creation over subsets
277+ - [ ] Compare samplers (shadow sampling): comparison binding type and sampling
278+ - [ ] LOD bias and per-sample control: expose LOD bias and overrides
254279
255280## Verification and Testing
256281
@@ -294,20 +319,20 @@ let texture2d = TextureBuilder::new_2d(TextureFormat::Rgba8UnormSrgb)
294319let sampler = SamplerBuilder :: new ()
295320 . linear_clamp ()
296321 . with_label (" albedo-sampler" )
297- . build (& mut render_context )? ;
322+ . build (& mut render_context );
298323
299324let layout2d = BindGroupLayoutBuilder :: new ()
300- . with_uniform (0 , BindingVisibility :: Vertex | BindingVisibility :: Fragment )
325+ . with_uniform (0 , BindingVisibility :: VertexAndFragment )
301326 . with_sampled_texture (1 ) // 2D shorthand
302327 . with_sampler (2 )
303- . build (& mut render_context )? ;
328+ . build (& mut render_context );
304329
305330let group2d = BindGroupBuilder :: new ()
306331 . with_layout (& layout2d )
307332 . with_uniform (0 , & uniform_buffer )
308333 . with_texture (1 , & texture2d )
309334 . with_sampler (2 , & sampler )
310- . build (& mut render_context )? ;
335+ . build (& mut render_context );
311336
312337RC :: SetBindGroup { set : 0 , group : group_id , dynamic_offsets : vec! [] };
313338```
@@ -329,6 +354,7 @@ Rust (3D high level)
329354use lambda :: render :: texture :: {TextureBuilder , TextureFormat };
330355use lambda :: render :: bind :: {BindGroupLayoutBuilder , BindGroupBuilder };
331356use lambda :: render :: texture :: ViewDimension ;
357+ use lambda :: render :: bind :: BindingVisibility ;
332358
333359let texture3d = TextureBuilder :: new_3d (TextureFormat :: Rgba8Unorm )
334360 . with_size_3d (128 , 128 , 64 )
@@ -337,15 +363,15 @@ let texture3d = TextureBuilder::new_3d(TextureFormat::Rgba8Unorm)
337363 . build (& mut render_context )? ;
338364
339365let layout3d = BindGroupLayoutBuilder :: new ()
340- . with_sampled_texture_dim (1 , ViewDimension :: D3 )
366+ . with_sampled_texture_dim (1 , ViewDimension :: D3 , BindingVisibility :: Fragment )
341367 . with_sampler (2 )
342- . build (& mut render_context )? ;
368+ . build (& mut render_context );
343369
344370let group3d = BindGroupBuilder :: new ()
345371 . with_layout (& layout3d )
346372 . with_texture (1 , & texture3d )
347373 . with_sampler (2 , & sampler )
348- . build (& mut render_context )? ;
374+ . build (& mut render_context );
349375```
350376
351377WGSL snippet (3D)
@@ -363,6 +389,15 @@ fn fs_main(in_uv: vec2<f32>) -> @location(0) vec4<f32> {
363389
364390## Changelog
365391
392+ - 2025-11-10 (v0.3.1) — Merge “Future Extensions” into the Requirements
393+ Checklist and mark implemented status; metadata updated.
394+ - 2025-11-09 (v0.3.0) — Clarify layout visibility parameters; make sampler
395+ build infallible; correct ` BindingVisibility ` usage in examples;
396+ add “Future Extensions” with planned texture features; metadata updated.
366397- 2025-10-30 (v0.2.0) — Add 3D textures, explicit dimensions in layout and
367398 builders, W address mode, validation and examples updated.
368399- 2025-10-30 (v0.1.0) — Initial draft.
400+
401+ ## Future Extensions
402+
403+ Moved into the Requirements Checklist under “Extensions (Planned)”.
0 commit comments