mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-12-01 03:03:26 +00:00
[spv-in] support boolean constants
This commit is contained in:
parent
2507794bc6
commit
49eb93cf7d
@ -1554,6 +1554,8 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
Op::Constant | Op::SpecConstant => self.parse_constant(inst, &mut module),
|
||||
Op::ConstantComposite => self.parse_composite_constant(inst, &mut module),
|
||||
Op::ConstantNull | Op::Undef => self.parse_null_constant(inst, &mut module),
|
||||
Op::ConstantTrue => self.parse_bool_constant(inst, true, &mut module),
|
||||
Op::ConstantFalse => self.parse_bool_constant(inst, false, &mut module),
|
||||
Op::Variable => self.parse_global_variable(inst, &mut module),
|
||||
Op::Function => {
|
||||
self.switch(ModuleState::Function, inst.op)?;
|
||||
@ -2398,6 +2400,34 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_bool_constant(
|
||||
&mut self,
|
||||
inst: Instruction,
|
||||
value: bool,
|
||||
module: &mut crate::Module,
|
||||
) -> Result<(), Error> {
|
||||
self.switch(ModuleState::Type, inst.op)?;
|
||||
inst.expect(3)?;
|
||||
let type_id = self.next()?;
|
||||
let id = self.next()?;
|
||||
|
||||
self.lookup_constant.insert(
|
||||
id,
|
||||
LookupConstant {
|
||||
handle: module.constants.append(crate::Constant {
|
||||
name: self.future_decor.remove(&id).and_then(|dec| dec.name),
|
||||
specialization: None, //TODO
|
||||
inner: crate::ConstantInner::Scalar {
|
||||
width: 1,
|
||||
value: crate::ScalarValue::Bool(value),
|
||||
},
|
||||
}),
|
||||
type_id,
|
||||
},
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_global_variable(
|
||||
&mut self,
|
||||
inst: Instruction,
|
||||
|
Loading…
Reference in New Issue
Block a user