[GPU] Store ALU result after both vector and scalar instructions
This commit is contained in:
@@ -820,18 +820,36 @@ void GlslShaderTranslator::ProcessTextureFetchInstruction(
|
||||
|
||||
void GlslShaderTranslator::ProcessAluInstruction(
|
||||
const ParsedAluInstruction& instr) {
|
||||
EmitSource("// ");
|
||||
EmitSource("/*\n");
|
||||
instr.Disassemble(&source_);
|
||||
EmitSource("*/\n");
|
||||
|
||||
switch (instr.type) {
|
||||
case ParsedAluInstruction::Type::kNop:
|
||||
break;
|
||||
case ParsedAluInstruction::Type::kVector:
|
||||
ProcessVectorAluInstruction(instr);
|
||||
break;
|
||||
case ParsedAluInstruction::Type::kScalar:
|
||||
ProcessScalarAluInstruction(instr);
|
||||
break;
|
||||
if (instr.is_nop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit if statement only if we have a different predicate condition than our
|
||||
// containing block.
|
||||
bool conditional = false;
|
||||
if (instr.is_predicated &&
|
||||
(!cf_exec_pred_ || (cf_exec_pred_cond_ != instr.predicate_condition))) {
|
||||
conditional = true;
|
||||
EmitSourceDepth("if (%cp0) {\n", instr.predicate_condition ? ' ' : '!');
|
||||
Indent();
|
||||
}
|
||||
|
||||
bool store_vector = ProcessVectorAluOperation(instr);
|
||||
bool store_scalar = ProcessScalarAluOperation(instr);
|
||||
if (store_vector) {
|
||||
EmitStoreVectorResult(instr.vector_result);
|
||||
}
|
||||
if (store_scalar) {
|
||||
EmitStoreScalarResult(instr.scalar_result);
|
||||
}
|
||||
|
||||
if (conditional) {
|
||||
Unindent();
|
||||
EmitSourceDepth("}\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1041,20 +1059,14 @@ void GlslShaderTranslator::EmitStoreResult(const InstructionResult& result,
|
||||
EmitSource(";\n");
|
||||
}
|
||||
|
||||
void GlslShaderTranslator::ProcessVectorAluInstruction(
|
||||
bool GlslShaderTranslator::ProcessVectorAluOperation(
|
||||
const ParsedAluInstruction& instr) {
|
||||
// Emit if statement only if we have a different predicate condition than our
|
||||
// containing block.
|
||||
bool conditional = false;
|
||||
if (instr.is_predicated &&
|
||||
(!cf_exec_pred_ || (cf_exec_pred_cond_ != instr.predicate_condition))) {
|
||||
conditional = true;
|
||||
EmitSourceDepth("if (%cp0) {\n", instr.predicate_condition ? ' ' : '!');
|
||||
Indent();
|
||||
if (!instr.has_vector_op) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < instr.operand_count; ++i) {
|
||||
EmitLoadOperand(i, instr.operands[i]);
|
||||
for (size_t i = 0; i < instr.vector_operand_count; ++i) {
|
||||
EmitLoadOperand(i, instr.vector_operands[i]);
|
||||
}
|
||||
|
||||
switch (instr.vector_opcode) {
|
||||
@@ -1251,26 +1263,17 @@ void GlslShaderTranslator::ProcessVectorAluInstruction(
|
||||
break;
|
||||
}
|
||||
|
||||
EmitStoreVectorResult(instr.result);
|
||||
|
||||
if (conditional) {
|
||||
Unindent();
|
||||
EmitSourceDepth("}\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GlslShaderTranslator::ProcessScalarAluInstruction(
|
||||
bool GlslShaderTranslator::ProcessScalarAluOperation(
|
||||
const ParsedAluInstruction& instr) {
|
||||
bool conditional = false;
|
||||
if (instr.is_predicated &&
|
||||
(!cf_exec_pred_ || (cf_exec_pred_cond_ != instr.predicate_condition))) {
|
||||
conditional = true;
|
||||
EmitSourceDepth("if (%cp0) {\n", instr.predicate_condition ? ' ' : '!');
|
||||
Indent();
|
||||
if (!instr.has_scalar_op) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < instr.operand_count; ++i) {
|
||||
EmitLoadOperand(i, instr.operands[i]);
|
||||
for (size_t i = 0; i < instr.scalar_operand_count; ++i) {
|
||||
EmitLoadOperand(i, instr.scalar_operands[i]);
|
||||
}
|
||||
|
||||
switch (instr.scalar_opcode) {
|
||||
@@ -1595,12 +1598,7 @@ void GlslShaderTranslator::ProcessScalarAluInstruction(
|
||||
break;
|
||||
}
|
||||
|
||||
EmitStoreScalarResult(instr.result);
|
||||
|
||||
if (conditional) {
|
||||
Unindent();
|
||||
EmitSourceDepth("}\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
Reference in New Issue
Block a user