Expand description
WGSL push constants (immediates) helper for oxigdal-gpu.
In wgpu 29 the Vulkan “push constants” concept is exposed as immediate
data (var<immediate> in WGSL, wgpu::Features::IMMEDIATES on the
device, and wgpu::PipelineLayoutDescriptor::immediate_size). This
module provides ergonomic Rust wrappers around that API and remains
forward-compatible with the naming used in earlier wgpu versions.
§Quick start
use oxigdal_gpu::push_constants::{
PushConstantsLayout, PushConstantsBuffer, make_push_constants_shader_source,
build_push_constants_pipeline,
};
use oxigdal_gpu::GpuContext;
let ctx = GpuContext::new().await?;
let layout = PushConstantsLayout::compute_only(16);
let mut buf = PushConstantsBuffer::new(layout.clone());
buf.write_u32(0, 42)?;
buf.write_f32(4, 3.14)?;
let struct_wgsl = "struct PushConstantsBlock { value: u32, scale: f32, _pad0: u32, _pad1: u32, }";
let body_wgsl = "let v = pc.value;";
let src = make_push_constants_shader_source(struct_wgsl, body_wgsl);§Compatibility note
wgpu 29 renamed Vulkan push constants to “immediates”. The public API of
this module deliberately preserves the PushConstants* naming to keep the
call-site interface stable regardless of the underlying wgpu version.
Structs§
- Push
Constant Range - Describes one logical push-constant range within a pipeline layout.
- Push
Constant Range Desc - Descriptive wrapper returned by
PushConstantsLayout::to_wgpu_ranges. - Push
Constants Buffer - A typed byte buffer holding push-constant (immediate) data.
- Push
Constants Layout - Describes all push-constant data ranges used by a pipeline.
Constants§
- MAX_
PUSH_ CONSTANTS_ SIZE_ BYTES - Minimum guaranteed push-constants (immediates) size per the Vulkan spec
(128 bytes). Adapters may expose a larger limit via
max_push_constants_size. - PUSH_
CONSTANTS_ ALIGNMENT - Required alignment for the start and end of each push-constant range.
Functions§
- build_
push_ constants_ pipeline - Compile a compute pipeline that uses immediate data (push constants) with the given layout.
- dispatch_
with_ push_ constants - Upload immediate (push-constant) data and dispatch a compute pass.
- make_
push_ constants_ shader_ source - Generate a WGSL compute shader source that uses a
var<immediate>block. - max_
push_ constants_ size - Return the maximum immediate-data (push-constants) size in bytes supported by the current adapter’s device.
- supports_
push_ constants - Return
trueif the GPU context supports immediate data (push constants).