mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-out] support select expressions
This commit is contained in:
committed by
Dzmitry Malyshau
parent
8183f4ff6f
commit
d0ef4e9dbe
@@ -709,6 +709,22 @@ impl super::Instruction {
|
||||
instruction
|
||||
}
|
||||
|
||||
pub(super) fn select(
|
||||
result_type_id: Word,
|
||||
id: Word,
|
||||
condition_id: Word,
|
||||
accept_id: Word,
|
||||
reject_id: Word,
|
||||
) -> Self {
|
||||
let mut instruction = Self::new(Op::Select);
|
||||
instruction.add_operand(result_type_id);
|
||||
instruction.add_operand(id);
|
||||
instruction.add_operand(condition_id);
|
||||
instruction.add_operand(accept_id);
|
||||
instruction.add_operand(reject_id);
|
||||
instruction
|
||||
}
|
||||
|
||||
pub(super) fn kill() -> Self {
|
||||
Self::new(Op::Kill)
|
||||
}
|
||||
|
||||
@@ -1734,6 +1734,29 @@ impl Writer {
|
||||
block.body.push(main_instruction);
|
||||
RawExpression::Value(id)
|
||||
}
|
||||
crate::Expression::Select {
|
||||
condition,
|
||||
accept,
|
||||
reject,
|
||||
} => {
|
||||
let id = self.generate_id();
|
||||
let condition_id =
|
||||
self.write_expression(ir_module, ir_function, condition, block, function)?;
|
||||
let accept_id =
|
||||
self.write_expression(ir_module, ir_function, accept, block, function)?;
|
||||
let reject_id =
|
||||
self.write_expression(ir_module, ir_function, reject, block, function)?;
|
||||
|
||||
let instruction = Instruction::select(
|
||||
result_type_id,
|
||||
id,
|
||||
condition_id,
|
||||
accept_id,
|
||||
reject_id,
|
||||
);
|
||||
block.body.push(instruction);
|
||||
RawExpression::Value(id)
|
||||
}
|
||||
ref other => {
|
||||
log::error!("unimplemented {:?}", other);
|
||||
return Err(Error::FeatureNotImplemented("expression"));
|
||||
|
||||
Reference in New Issue
Block a user