Anonymous specialization constants support (#1338)

This commit is contained in:
Ilya Lakhin 2020-05-09 17:59:10 +07:00 committed by GitHub
parent c74ac31f27
commit f211a3af2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View File

@ -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)

View File

@ -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 = {