-
Notifications
You must be signed in to change notification settings - Fork 2
deps(lambda-rs): Update to wgpu & naga to v28 and replace push constants with immediates #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR successfully migrates the lambda-rs rendering engine from wgpu v26 to v28, addressing the major breaking change where "push constants" were renamed to "immediates." The migration is comprehensive, updating not only the core engine code but also all examples, tools, tutorials, and documentation to reflect the new terminology and API changes.
Key Changes:
- Updated wgpu dependency from v26.0.1 to v28.0.0 and naga from v26.0.0 to v28.0.0
- Migrated from
Features::PUSH_CONSTANTStoFeatures::IMMEDIATESwith updated pipeline layout API (usingimmediate_sizeinstead ofpush_constant_ranges) - Renamed all public APIs, types, and documentation from "push constants" terminology to "immediates"
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.lock |
Updates wgpu ecosystem dependencies (wgpu, wgpu-core, wgpu-hal, wgpu-types, naga) from v26 to v28 along with transitive dependencies |
crates/lambda-rs-platform/Cargo.toml |
Updates naga to v28.0.0 and wgpu to v28.0.0 with reformatted feature declarations |
crates/lambda-rs-platform/src/wgpu/gpu.rs |
Replaces Features::PUSH_CONSTANTS with Features::IMMEDIATES and adds experimental_features field to device descriptor |
crates/lambda-rs-platform/src/wgpu/pipeline.rs |
Renames PushConstantRange to ImmediateDataRange, migrates pipeline layout from push_constant_ranges array to single immediate_size scalar, updates multiview to multiview_mask |
crates/lambda-rs-platform/src/wgpu/render_pass.rs |
Removes set_push_constants method, adds set_immediates method, adds multiview_mask field to render pass descriptor |
crates/lambda-rs-platform/src/wgpu/surface.rs |
Removes wildcard pattern from PresentMode::from_wgpu match (all variants now explicitly covered) |
crates/lambda-rs-platform/src/wgpu/texture.rs |
Adds to_wgpu_mipmap method returning MipmapFilterMode (separate from FilterMode in wgpu v28), updates sampler and test assertions |
crates/lambda-rs/src/render/gpu.rs |
Updates comment from "Push constants enabled" to "Immediates enabled" |
crates/lambda-rs/src/render/pipeline.rs |
Renames PushConstantUpload to ImmediateDataUpload, renames push_constants field to immediate_data, renames with_push_constant to with_immediate_data, updates platform layer calls |
crates/lambda-rs/src/render/mod.rs |
Updates comment references, implements RenderCommand::Immediates handler calling set_immediates |
crates/lambda-rs/src/render/encoder.rs |
Removes set_push_constants method, adds set_immediates method with documentation |
crates/lambda-rs/src/render/command.rs |
Renames RenderCommand::PushConstants to RenderCommand::Immediates with updated documentation |
crates/lambda-rs/examples/immediates.rs |
Renames types and functions from push constants to immediates, updates comments and window title |
crates/lambda-rs/examples/triangles.rs |
Migrates from PushConstant to ImmediateData, updates API calls to use with_immediate_data and RenderCommand::Immediates |
crates/lambda-rs/examples/textured_cube.rs |
Migrates from PushConstant to ImmediateData, updates comments and API calls throughout |
crates/lambda-rs/examples/reflective_room.rs |
Migrates from PushConstant to ImmediateData, renames helper function to immediate_data_to_words |
tools/obj_loader/src/main.rs |
Migrates from PushConstant to ImmediateData with updated comments and API calls |
docs/tutorials/textured-cube.md |
Comprehensive update: title, metadata, terminology change from push constants to immediates throughout, adds wgpu v28 feature notes |
docs/tutorials/reflective-room.md |
Updates metadata, terminology, and all code examples to use immediates instead of push constants |
docs/tutorials/immediates-multiple-triangles.md |
Renames from push-constants tutorial, updates all content to use immediates terminology with wgpu v28 notes |
docs/tutorials/basic-triangle.md |
Updates exercise references from push constants to immediates |
docs/tutorials/uniform-buffers.md |
Updates exercise references to point to immediates example |
docs/tutorials/README.md |
Updates tutorial index entry from "Push Constants" to "Immediates" |
README.md |
Updates example documentation from "Push Constants" to "Immediates", formatting improvements throughout |
Comments suppressed due to low confidence (1)
docs/tutorials/immediates-multiple-triangles.md:6
- The last_updated date is set to 2026-01-05, which is in the future. The current date according to the system context is January 6, 2026, so this date should be updated to reflect the actual update date or set to today's date (2026-01-06).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Calculate the total immediate size from immediate data ranges. | ||
| // The immediate_size is the maximum end offset across all ranges. | ||
| let immediate_size = self | ||
| .immediate_data_ranges | ||
| .iter() | ||
| .map(|pcr| wgpu::PushConstantRange { | ||
| stages: pcr.stages.to_wgpu(), | ||
| range: pcr.range.clone(), | ||
| }) | ||
| .collect(); | ||
| .map(|r| r.range.end) | ||
| .max() | ||
| .unwrap_or(0); |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calculation of immediate_size only considers the maximum end offset, but does not verify that ranges start at 0 or are contiguous. In wgpu v28, immediate_size represents the total size of immediate data that must be allocated. If there are gaps in the ranges or if ranges don't start at 0, this calculation may produce an incorrect size. The implementation should either ensure ranges are validated to be contiguous starting from 0, or calculate the size differently to handle non-contiguous ranges.
| RenderCommand::Immediates { | ||
| pipeline: _, | ||
| stage: _, | ||
| offset, | ||
| bytes, | ||
| } => { | ||
| let _ = render_pipelines.get(pipeline).ok_or_else(|| { | ||
| RenderPassError::Validation(format!("Unknown pipeline {pipeline}")) | ||
| })?; | ||
| let slice = unsafe { | ||
| // Convert the u32 words to a byte slice for set_immediates. | ||
| let byte_slice = unsafe { | ||
| std::slice::from_raw_parts( | ||
| bytes.as_ptr() as *const u8, | ||
| bytes.len() * std::mem::size_of::<u32>(), | ||
| ) | ||
| }; | ||
| rp_encoder.set_push_constants(stage, offset, slice); | ||
| rp_encoder.set_immediates(offset, byte_slice); |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pipeline and stage fields in the RenderCommand::Immediates variant are ignored (marked with underscore). While the wgpu v28 set_immediates API no longer requires stage information at the call site, the pipeline field should still be validated to ensure it exists before attempting to set immediate data. Consider adding validation similar to the BindVertexBuffer command which validates the pipeline exists.
Summary
Update wgpu and naga dependencies from v26 to v28. This PR addresses breaking API changes and fully migrates from "push constants" to the new "immediates" API introduced in wgpu v28, including renaming all public APIs, types, and documentation to use the new terminology.
In wgpu v28, push constants were renamed to "immediates" and gated behind the
Features::IMMEDIATESfeature flag. This PR updates all engine code, public APIs, examples, tools, and tutorials to use the new API and consistent terminology.Related Issues
Changes
wgpu v28 API Migration
PipelineLayoutDescriptor::push_constant_ranges→immediate_size: u32RenderPipelineDescriptor::multiview→multiview_maskDeviceDescriptornow requiresexperimental_featuresfieldSamplerDescriptor::mipmap_filteruses separateMipmapFilterModeenumImmediates Feature Enablement
Features::IMMEDIATESby default in GPU builderset_immediates(offset, data)method to platformRenderPassset_immediates()to high-levelRenderPassEncoderPublic API Renames (Breaking)
Platform layer (
lambda-rs-platform):PushConstantRange→ImmediateDataRangePipelineLayoutBuilder::push_constant_rangesfield →immediate_data_rangesPipelineLayoutBuilder::with_push_constants()→with_immediate_data_ranges()High-level API (
lambda-rs):PushConstantUploadtype alias →ImmediateDataUploadRenderPipelineBuilder::push_constantsfield →immediate_dataRenderPipelineBuilder::with_push_constant()→with_immediate_data()RenderCommand::PushConstantsvariant removed (useRenderCommand::Immediates)Updated Examples
push_constants.rs→immediates.rsreflective_room.rs- migrated toImmediateData,with_immediate_data(),RenderCommand::Immediatestextured_cube.rs- migrated toImmediateData,with_immediate_data(),RenderCommand::Immediatestriangles.rs- migrated toImmediateData,with_immediate_data(),RenderCommand::ImmediatesUpdated Tools
obj_loader- migrated toImmediateData,with_immediate_data(),RenderCommand::ImmediatesUpdated Documentation
README.md- updated example name from "Push Constants" to "Immediates"Updated Tutorials
push-constants-multiple-triangles.md→immediates-multiple-triangles.mdtextured-cube.md- updated wgpu version, allwith_push_constant()→with_immediate_data()reflective-room.md- updated wgpu version, tags, terminology, all API callsbasic-triangle.md- updated exercise to reference "immediates" instead of "push constants"uniform-buffers.md- updated exercise referencesType of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-logginglambda-obj-loadertoolChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
Manual verification steps (if applicable):
immediatesexample - window opens showing a rotating colored triangletrianglesexample - multiple triangles render with keyboard controltextured_cubeexample - textured cube rotates on screenreflective_roomexample - cube reflects on floor surfaceScreenshots/Recordings
The examples render correctly, demonstrating per-draw immediate data updates.
Platform Testing
Additional Notes
Breaking Changes
RenderCommand::PushConstantsremoved - All code must useRenderCommand::Immediateswith_push_constant()renamed - All code must usewith_immediate_data()PushConstantUploadrenamed - UseImmediateDataUploadtype aliasPushConstantRange→ImmediateDataRange,with_push_constants()→with_immediate_data_ranges()Migration Guide
1. Update pipeline builders:
2. Update render commands:
3. Rename data structs and helpers: