mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-13 06:38:31 +09:00
[Feat] (MG_Util/ShaderTranspiler): patch op OpFOrdNotEqual/OpFUnordNotEqual
This commit is contained in:
@@ -42,12 +42,25 @@ namespace MobileGL {
|
|||||||
for (auto itInst = bb.begin(); itInst != bb.end(); ++itInst) {
|
for (auto itInst = bb.begin(); itInst != bb.end(); ++itInst) {
|
||||||
auto& inst = *itInst;
|
auto& inst = *itInst;
|
||||||
|
|
||||||
// Check if opcode is `OpFOrdEqual` or `OpFUnordEqual`
|
bool shouldSkip = true;
|
||||||
if (inst.opcode() != spv::Op::OpFOrdEqual &&
|
|
||||||
inst.opcode() != spv::Op::OpFUnordEqual) {
|
// Check if opcode is `OpFOrdEqual`, `OpFUnordEqual`,
|
||||||
continue;
|
// `OpFOrdNotEqual` or `OpFUnordNotEqual`,
|
||||||
|
// simply skip if irrelevant
|
||||||
|
switch (inst.opcode()) {
|
||||||
|
case spv::Op::OpFOrdEqual:
|
||||||
|
case spv::Op::OpFUnordEqual:
|
||||||
|
case spv::Op::OpFOrdNotEqual:
|
||||||
|
case spv::Op::OpFUnordNotEqual:
|
||||||
|
shouldSkip = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldSkip)
|
||||||
|
continue;
|
||||||
|
|
||||||
// check if operand is "float 0.0"
|
// check if operand is "float 0.0"
|
||||||
// OpFOrdEqual ResultType ResultID Operand1 Operand2
|
// OpFOrdEqual ResultType ResultID Operand1 Operand2
|
||||||
uint32_t op1_id = inst.GetSingleWordInOperand(0);
|
uint32_t op1_id = inst.GetSingleWordInOperand(0);
|
||||||
@@ -114,9 +127,10 @@ namespace MobileGL {
|
|||||||
less_operands.push_back({spv_operand_type_t::SPV_OPERAND_TYPE_ID, {abs_inst->result_id()}});
|
less_operands.push_back({spv_operand_type_t::SPV_OPERAND_TYPE_ID, {abs_inst->result_id()}});
|
||||||
less_operands.push_back({spv_operand_type_t::SPV_OPERAND_TYPE_ID, {eps_id}});
|
less_operands.push_back({spv_operand_type_t::SPV_OPERAND_TYPE_ID, {eps_id}});
|
||||||
|
|
||||||
|
bool isEqualOp = (inst.opcode() == spv::Op::OpFOrdEqual || inst.opcode() == spv::Op::OpFUnordEqual);
|
||||||
Instruction* less_than_inst = builder.AddInstruction(MakeUnique<Instruction>(
|
Instruction* less_than_inst = builder.AddInstruction(MakeUnique<Instruction>(
|
||||||
context(),
|
context(),
|
||||||
spv::Op::OpFOrdLessThan,
|
isEqualOp ? spv::Op::OpFOrdLessThan : spv::Op::OpFOrdGreaterThanEqual,
|
||||||
bool_type_id,
|
bool_type_id,
|
||||||
context()->TakeNextId(),
|
context()->TakeNextId(),
|
||||||
less_operands
|
less_operands
|
||||||
|
|||||||
Reference in New Issue
Block a user