Skip to content

Commit 2cbdb28

Browse files
authored
Make specialization constants work (#780)
* Add new template parameters for GraphicsPipelineBuilder * Add support for the specialization constants in build() * Fix SpecializationConstants fields being private * Fix lifetime problem in SpecializationConstants::descriptors() * Run rustfmt on builder.rs
1 parent a54281f commit 2cbdb28

File tree

3 files changed

+338
-236
lines changed

3 files changed

+338
-236
lines changed

Diff for: vulkano-shaders/src/spec_consts.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,19 @@ impl Default for SpecializationConstants {{
122122
123123
unsafe impl SpecConstsTrait for SpecializationConstants {{
124124
fn descriptors() -> &'static [SpecializationMapEntry] {{
125-
&[
125+
static DESCRIPTORS: [SpecializationMapEntry; {num_map_entries}] = [
126126
{map_entries}
127-
]
127+
];
128+
&DESCRIPTORS
128129
}}
129130
}}
130131
131132
"#,
132-
struct_def = spec_consts.iter().map(|c| format!("{}: {}", c.name, c.rust_ty))
133+
struct_def = spec_consts.iter().map(|c| format!("pub {}: {}", c.name, c.rust_ty))
133134
.collect::<Vec<_>>().join(", "),
134135
def_vals = spec_consts.iter().map(|c| format!("{}: {}", c.name, c.default_value))
135136
.collect::<Vec<_>>().join(", "),
137+
num_map_entries = map_entries.len(),
136138
map_entries = map_entries.join(", ")
137139
)
138140
}

0 commit comments

Comments
 (0)