mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 15:23:33 +00:00
[spv-out] Use NotEqual for boolean casts
This commit is contained in:
parent
7c3cc904a0
commit
0bd78ef85e
@ -715,6 +715,23 @@ impl<'w> BlockContext<'w> {
|
||||
}
|
||||
};
|
||||
|
||||
let id = self.gen_id();
|
||||
|
||||
let instruction = match (src_kind, kind, convert) {
|
||||
(_, Sk::Bool, Some(_)) if src_kind != Sk::Bool => {
|
||||
let (op, value) = match src_kind {
|
||||
Sk::Sint => (spirv::Op::INotEqual, crate::ScalarValue::Sint(0)),
|
||||
Sk::Uint => (spirv::Op::INotEqual, crate::ScalarValue::Uint(0)),
|
||||
Sk::Float => {
|
||||
(spirv::Op::FUnordNotEqual, crate::ScalarValue::Float(0.0))
|
||||
}
|
||||
Sk::Bool => unreachable!(),
|
||||
};
|
||||
let zero_id = self.writer.get_constant_scalar(value, 4)?;
|
||||
|
||||
Instruction::binary(op, result_type_id, id, expr_id, zero_id)
|
||||
}
|
||||
_ => {
|
||||
let op = match (src_kind, kind, convert) {
|
||||
(_, _, None) => spirv::Op::Bitcast,
|
||||
(Sk::Float, Sk::Uint, Some(_)) => spirv::Op::ConvertFToU,
|
||||
@ -734,8 +751,10 @@ impl<'w> BlockContext<'w> {
|
||||
_ => spirv::Op::Bitcast,
|
||||
};
|
||||
|
||||
let id = self.gen_id();
|
||||
let instruction = Instruction::unary(op, result_type_id, id, expr_id);
|
||||
Instruction::unary(op, result_type_id, id, expr_id)
|
||||
}
|
||||
};
|
||||
|
||||
block.body.push(instruction);
|
||||
id
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user