mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 16:25:31 +00:00
parent
34736a675a
commit
df302d8f7b
@ -845,28 +845,43 @@ fn descriptor_binding_requirements_of(spirv: &Spirv, variable_id: Id) -> Descrip
|
|||||||
fn push_constant_requirements(spirv: &Spirv, stage: ShaderStage) -> Option<PushConstantRange> {
|
fn push_constant_requirements(spirv: &Spirv, stage: ShaderStage) -> Option<PushConstantRange> {
|
||||||
spirv
|
spirv
|
||||||
.iter_global()
|
.iter_global()
|
||||||
|
// TODO: doesn't work with more than one entry point in the shader.
|
||||||
|
// We should really use the interface variables in Instruction::EntryPoint,
|
||||||
|
// but before SPIR-V 1.4 these do not contain push constants.
|
||||||
.find_map(|instruction| match *instruction {
|
.find_map(|instruction| match *instruction {
|
||||||
|
Instruction::Variable {
|
||||||
|
result_type_id,
|
||||||
|
storage_class: StorageClass::PushConstant,
|
||||||
|
..
|
||||||
|
} => Some(result_type_id),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.map(|pointer_type_id| {
|
||||||
|
let struct_type_id = match *spirv.id(pointer_type_id).instruction() {
|
||||||
Instruction::TypePointer {
|
Instruction::TypePointer {
|
||||||
ty,
|
ty,
|
||||||
storage_class: StorageClass::PushConstant,
|
storage_class: StorageClass::PushConstant,
|
||||||
..
|
..
|
||||||
} => {
|
} => ty,
|
||||||
let id_info = spirv.id(ty);
|
_ => unreachable!(),
|
||||||
assert!(matches!(
|
};
|
||||||
id_info.instruction(),
|
|
||||||
Instruction::TypeStruct { .. }
|
|
||||||
));
|
|
||||||
let start = offset_of_struct(spirv, ty);
|
|
||||||
let end =
|
|
||||||
size_of_type(spirv, ty).expect("Found runtime-sized push constants") as u32;
|
|
||||||
|
|
||||||
Some(PushConstantRange {
|
assert!(
|
||||||
|
matches!(
|
||||||
|
spirv.id(struct_type_id).instruction(),
|
||||||
|
Instruction::TypeStruct { .. }
|
||||||
|
),
|
||||||
|
"VUID-StandaloneSpirv-PushConstant-06808"
|
||||||
|
);
|
||||||
|
let start = offset_of_struct(spirv, struct_type_id);
|
||||||
|
let end = size_of_type(spirv, struct_type_id)
|
||||||
|
.expect("Found runtime-sized push constants") as u32;
|
||||||
|
|
||||||
|
PushConstantRange {
|
||||||
stages: stage.into(),
|
stages: stage.into(),
|
||||||
offset: start,
|
offset: start,
|
||||||
size: end - start,
|
size: end - start,
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user