diff --git a/CHANGELOG_VULKANO.md b/CHANGELOG_VULKANO.md index ff196af9..40207ae1 100644 --- a/CHANGELOG_VULKANO.md +++ b/CHANGELOG_VULKANO.md @@ -1,5 +1,8 @@ # Unreleased +- Fixed Vulkano Shaders bug when compute shader local group layout values bound to specialization constants. + Now it is possible to define the layout in form of `layout(local_size_x_id = 12, local_size_y_id = 13, local_size_z = 1) in;` + and then set the values as `SpecializationConstants {constant_12: 8, constant_13: 4, ...}`. - Allow applications to access the instance and device pointers # Version 0.18.0 (2020-03-11) diff --git a/vulkano-shaders/src/spec_consts.rs b/vulkano-shaders/src/spec_consts.rs index 791ba933..805af255 100644 --- a/vulkano-shaders/src/spec_consts.rs +++ b/vulkano-shaders/src/spec_consts.rs @@ -72,17 +72,26 @@ pub fn write_specialization_constants(doc: &Spirv) -> TokenStream { let (rust_ty, rust_size, rust_alignment) = spec_const_type_from_id(doc, type_id); let rust_size = rust_size.expect("Found runtime-sized specialization constant"); - let constant_id = doc.get_decoration_params(result_id, Decoration::DecorationSpecId) - .unwrap()[0]; + let constant_id = doc.get_decoration_params(result_id, Decoration::DecorationSpecId); - spec_consts.push(SpecConst { - name: spirv_search::name_from_id(doc, result_id), - constant_id, - rust_ty, - rust_size, - rust_alignment: rust_alignment as u32, - default_value, - }); + if let Some(constant_id) = constant_id { + let constant_id = constant_id[0]; + + let mut name = spirv_search::name_from_id(doc, result_id); + + if name == "__unnamed".to_owned() { + name = String::from(format!("constant_{}", constant_id)); + } + + spec_consts.push(SpecConst { + name, + constant_id, + rust_ty, + rust_size, + rust_alignment: rust_alignment as u32, + default_value, + }); + } } let map_entries = {