ALU predicated discard
This commit is contained in:
parent
08a173e5ec
commit
ca01bb2311
|
@ -599,8 +599,20 @@ void SpirvShaderTranslator::ProcessVectorAluInstruction(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest) {
|
if (dest) {
|
||||||
|
// If predicated, discard the result from the instruction.
|
||||||
|
Id pred_cond = 0;
|
||||||
|
Id pv_dest = dest;
|
||||||
|
if (instr.is_predicated) {
|
||||||
|
pred_cond =
|
||||||
|
b.createBinOp(spv::Op::OpLogicalEqual, bool_type_, b.createLoad(p0_),
|
||||||
|
b.makeBoolConstant(instr.predicate_condition));
|
||||||
|
|
||||||
|
pv_dest = b.createTriOp(spv::Op::OpSelect, vec4_float_type_, pred_cond,
|
||||||
|
dest, b.createLoad(pv_));
|
||||||
|
}
|
||||||
|
|
||||||
b.createStore(dest, pv_);
|
b.createStore(dest, pv_);
|
||||||
StoreToResult(dest, instr.result);
|
StoreToResult(dest, instr.result, pred_cond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,8 +851,20 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest) {
|
if (dest) {
|
||||||
|
// If predicated, discard the result from the instruction.
|
||||||
|
Id pred_cond = 0;
|
||||||
|
Id ps_dest = dest;
|
||||||
|
if (instr.is_predicated) {
|
||||||
|
pred_cond =
|
||||||
|
b.createBinOp(spv::Op::OpLogicalEqual, bool_type_, b.createLoad(p0_),
|
||||||
|
b.makeBoolConstant(instr.predicate_condition));
|
||||||
|
|
||||||
|
ps_dest = b.createTriOp(spv::Op::OpSelect, float_type_, pred_cond, dest,
|
||||||
|
b.createLoad(ps_));
|
||||||
|
}
|
||||||
|
|
||||||
b.createStore(dest, ps_);
|
b.createStore(dest, ps_);
|
||||||
StoreToResult(dest, instr.result);
|
StoreToResult(dest, instr.result, pred_cond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,7 +1002,8 @@ Id SpirvShaderTranslator::LoadFromOperand(const InstructionOperand& op) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
||||||
const InstructionResult& result) {
|
const InstructionResult& result,
|
||||||
|
Id predicate_cond) {
|
||||||
auto& b = *builder_;
|
auto& b = *builder_;
|
||||||
|
|
||||||
if (result.storage_target == InstructionStorageTarget::kNone) {
|
if (result.storage_target == InstructionStorageTarget::kNone) {
|
||||||
|
@ -1153,6 +1178,14 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
||||||
// Perform store into the pointer.
|
// Perform store into the pointer.
|
||||||
assert_true(b.getNumComponents(source_value_id) ==
|
assert_true(b.getNumComponents(source_value_id) ==
|
||||||
b.getNumTypeComponents(storage_type));
|
b.getNumTypeComponents(storage_type));
|
||||||
|
|
||||||
|
// Discard if predicate condition is false.
|
||||||
|
if (predicate_cond) {
|
||||||
|
source_value_id =
|
||||||
|
b.createTriOp(spv::Op::OpSelect, storage_type, predicate_cond,
|
||||||
|
source_value_id, storage_value);
|
||||||
|
}
|
||||||
|
|
||||||
b.createStore(source_value_id, storage_pointer);
|
b.createStore(source_value_id, storage_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ class SpirvShaderTranslator : public ShaderTranslator {
|
||||||
// Stores a value based on the specified result information.
|
// Stores a value based on the specified result information.
|
||||||
// The value will be transformed into the appropriate form for the result and
|
// The value will be transformed into the appropriate form for the result and
|
||||||
// the proper components will be selected.
|
// the proper components will be selected.
|
||||||
void StoreToResult(spv::Id source_value_id, const InstructionResult& result);
|
void StoreToResult(spv::Id source_value_id, const InstructionResult& result,
|
||||||
|
spv::Id predicate_cond = 0);
|
||||||
|
|
||||||
xe::ui::spirv::SpirvDisassembler disassembler_;
|
xe::ui::spirv::SpirvDisassembler disassembler_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue