mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
Scalar kill ops
This commit is contained in:
parent
e78537571f
commit
9b805b929e
|
|
@ -831,6 +831,10 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id pred_cond =
|
||||||
|
b.createBinOp(spv::Op::OpLogicalEqual, bool_type_, b.createLoad(p0_),
|
||||||
|
b.makeBoolConstant(instr.predicate_condition));
|
||||||
|
|
||||||
switch (instr.scalar_opcode) {
|
switch (instr.scalar_opcode) {
|
||||||
case AluScalarOpcode::kAdds:
|
case AluScalarOpcode::kAdds:
|
||||||
case AluScalarOpcode::kAddsc0:
|
case AluScalarOpcode::kAddsc0:
|
||||||
|
|
@ -852,6 +856,81 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
|
||||||
{sources[0]});
|
{sources[0]});
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case AluScalarOpcode::kKillsEq: {
|
||||||
|
auto continue_block = &b.makeNewBlock();
|
||||||
|
auto kill_block = &b.makeNewBlock();
|
||||||
|
auto cond = b.createBinOp(spv::Op::OpFOrdEqual, bool_type_, sources[0],
|
||||||
|
b.makeFloatConstant(0.f));
|
||||||
|
cond = b.createBinOp(spv::Op::OpLogicalAnd, bool_type_, cond, pred_cond);
|
||||||
|
b.createConditionalBranch(cond, kill_block, continue_block);
|
||||||
|
|
||||||
|
b.setBuildPoint(kill_block);
|
||||||
|
b.createNoResultOp(spv::Op::OpKill);
|
||||||
|
|
||||||
|
b.setBuildPoint(continue_block);
|
||||||
|
dest = b.makeFloatConstant(0.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case AluScalarOpcode::kKillsGe: {
|
||||||
|
auto continue_block = &b.makeNewBlock();
|
||||||
|
auto kill_block = &b.makeNewBlock();
|
||||||
|
auto cond = b.createBinOp(spv::Op::OpFOrdGreaterThanEqual, bool_type_,
|
||||||
|
sources[0], b.makeFloatConstant(0.f));
|
||||||
|
cond = b.createBinOp(spv::Op::OpLogicalAnd, bool_type_, cond, pred_cond);
|
||||||
|
b.createConditionalBranch(cond, kill_block, continue_block);
|
||||||
|
|
||||||
|
b.setBuildPoint(kill_block);
|
||||||
|
b.createNoResultOp(spv::Op::OpKill);
|
||||||
|
|
||||||
|
b.setBuildPoint(continue_block);
|
||||||
|
dest = b.makeFloatConstant(0.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case AluScalarOpcode::kKillsGt: {
|
||||||
|
auto continue_block = &b.makeNewBlock();
|
||||||
|
auto kill_block = &b.makeNewBlock();
|
||||||
|
auto cond = b.createBinOp(spv::Op::OpFOrdGreaterThan, bool_type_,
|
||||||
|
sources[0], b.makeFloatConstant(0.f));
|
||||||
|
cond = b.createBinOp(spv::Op::OpLogicalAnd, bool_type_, cond, pred_cond);
|
||||||
|
b.createConditionalBranch(cond, kill_block, continue_block);
|
||||||
|
|
||||||
|
b.setBuildPoint(kill_block);
|
||||||
|
b.createNoResultOp(spv::Op::OpKill);
|
||||||
|
|
||||||
|
b.setBuildPoint(continue_block);
|
||||||
|
dest = b.makeFloatConstant(0.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case AluScalarOpcode::kKillsNe: {
|
||||||
|
auto continue_block = &b.makeNewBlock();
|
||||||
|
auto kill_block = &b.makeNewBlock();
|
||||||
|
auto cond = b.createBinOp(spv::Op::OpFOrdNotEqual, bool_type_, sources[0],
|
||||||
|
b.makeFloatConstant(0.f));
|
||||||
|
cond = b.createBinOp(spv::Op::OpLogicalAnd, bool_type_, cond, pred_cond);
|
||||||
|
b.createConditionalBranch(cond, kill_block, continue_block);
|
||||||
|
|
||||||
|
b.setBuildPoint(kill_block);
|
||||||
|
b.createNoResultOp(spv::Op::OpKill);
|
||||||
|
|
||||||
|
b.setBuildPoint(continue_block);
|
||||||
|
dest = b.makeFloatConstant(0.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case AluScalarOpcode::kKillsOne: {
|
||||||
|
auto continue_block = &b.makeNewBlock();
|
||||||
|
auto kill_block = &b.makeNewBlock();
|
||||||
|
auto cond = b.createBinOp(spv::Op::OpFOrdEqual, bool_type_, sources[0],
|
||||||
|
b.makeFloatConstant(1.f));
|
||||||
|
cond = b.createBinOp(spv::Op::OpLogicalAnd, bool_type_, cond, pred_cond);
|
||||||
|
b.createConditionalBranch(cond, kill_block, continue_block);
|
||||||
|
|
||||||
|
b.setBuildPoint(kill_block);
|
||||||
|
b.createNoResultOp(spv::Op::OpKill);
|
||||||
|
|
||||||
|
b.setBuildPoint(continue_block);
|
||||||
|
dest = b.makeFloatConstant(0.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
case AluScalarOpcode::kMaxs: {
|
case AluScalarOpcode::kMaxs: {
|
||||||
// dest = max(src0, src1)
|
// dest = max(src0, src1)
|
||||||
dest = CreateGlslStd450InstructionCall(
|
dest = CreateGlslStd450InstructionCall(
|
||||||
|
|
@ -1026,13 +1105,8 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
|
||||||
|
|
||||||
if (dest) {
|
if (dest) {
|
||||||
// If predicated, discard the result from the instruction.
|
// If predicated, discard the result from the instruction.
|
||||||
Id pred_cond = 0;
|
|
||||||
Id ps_dest = dest;
|
Id ps_dest = dest;
|
||||||
if (instr.is_predicated) {
|
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,
|
ps_dest = b.createTriOp(spv::Op::OpSelect, float_type_, pred_cond, dest,
|
||||||
b.createLoad(ps_));
|
b.createLoad(ps_));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue