{"record":{"id":"119007e9ef1ae29b","repo":"gfx-rs/wgpu","slug":"immediates-feature-must-be-enabled-to-call-set-imm","errorCode":null,"errorMessage":"IMMEDIATES feature must be enabled to call set_immediates","messagePattern":"IMMEDIATES feature must be enabled to call set_immediates","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/backend/webgpu.rs","lineNumber":3650,"sourceCode":"        let bind_group = bind_group.map(|bind_group| &bind_group.as_webgpu().inner);\n\n        if offsets.is_empty() {\n            self.inner.set_bind_group(index, bind_group);\n        } else {\n            self.inner\n                .set_bind_group_with_u32_slice_and_f64_and_dynamic_offsets_data_length(\n                    index,\n                    bind_group,\n                    offsets,\n                    0f64,\n                    offsets.len() as u32,\n                )\n                .unwrap();\n        }\n    }\n\n    fn set_immediates(&mut self, _offset: u32, _data: &[u8]) {\n        panic!(\"IMMEDIATES feature must be enabled to call set_immediates\")\n    }\n\n    fn insert_debug_marker(&mut self, label: &str) {\n        self.inner.insert_debug_marker(label);\n    }\n\n    fn push_debug_group(&mut self, group_label: &str) {\n        self.inner.push_debug_group(group_label);\n    }\n\n    fn pop_debug_group(&mut self) {\n        self.inner.pop_debug_group();\n    }\n\n    fn write_timestamp(&mut self, _query_set: &dispatch::DispatchQuerySet, _query_index: u32) {\n        panic!(\"TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass.\")\n    }\n","sourceCodeStart":3632,"sourceCodeEnd":3668,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/backend/webgpu.rs#L3632-L3668","documentation":"The WebGPU backend does not support immediates (push-constants-style inline data), so ComputePassEncoder::set_immediates is unimplemented there and wgpu panics. Callers must not invoke it when running on WebGPU.","triggerScenarios":"Calling set_immediates(offset, data) on a compute pass encoder while running on the webgpu backend, even if the pipeline layout declares immediate data ranges.","commonSituations":"Pipelines ported from native (Vulkan push constants / DX12 root constants) to wasm; shared per-dispatch uniform updates relying on immediates; missing runtime or cfg gating for the web backend.","solutions":["Do not call set_immediates on the WebGPU backend; gate the call on backend detection.","Use a bind group with a dynamic uniform buffer instead of immediates.","Restrict immediates-dependent pipelines to native backends and check capabilities at startup.","Route per-dispatch data through uniform/storage buffers."],"exampleFix":"// before\ncompute_pass.set_immediates(0, bytemuck::bytes_of(&data));\n// after\nif !is_webgpu {\n    compute_pass.set_immediates(0, bytemuck::bytes_of(&data));\n} else {\n    compute_pass.set_bind_group(0, &uniform_bg, &[offset]);\n}","handlingStrategy":"validation","validationCode":"if !is_webgpu_backend(device) { pass.set_immediates(0, &data); } else { /* bind-group path */ }","typeGuard":"fn supports_immediates(b: Backend) -> bool { b != Backend::Browser }","tryCatchPattern":null,"preventionTips":["Never rely on immediates for pipelines shared with wasm targets.","Prefer dynamic uniform buffers for portable per-dispatch data.","Gate immediate usage behind a backend capability flag resolved at device creation.","Test both native and web targets in CI when using backend-specific APIs."],"tags":["panic","webgpu","immediates","compute-pass","unsupported-feature"],"backgroundTag":"unsupported-feature-panic","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}