[GPU] Shader translator: More memexport validation

This commit is contained in:
Triang3l 2018-12-21 22:24:09 +03:00
parent 73baaa8e89
commit 72e9ac5c28
2 changed files with 25 additions and 0 deletions

View File

@ -492,6 +492,22 @@ struct ParsedAluInstruction {
// Describes each source operand.
InstructionOperand operands[3];
// If this is a valid eA write (MAD with a stream constant), returns the index
// of the stream float constant, otherwise returns UINT32_MAX.
uint32_t GetMemExportStreamConstant() const {
if (result.storage_target == InstructionStorageTarget::kExportAddress &&
is_vector_type() && vector_opcode == ucode::AluVectorOpcode::kMad &&
result.has_all_writes() &&
operands[2].storage_source ==
InstructionStorageSource::kConstantFloat &&
operands[2].storage_addressing_mode ==
InstructionStorageAddressingMode::kStatic &&
operands[2].is_standard_swizzle()) {
return operands[2].storage_index;
}
return UINT32_MAX;
}
// Disassembles the instruction into ucode assembly text.
void Disassemble(StringBuffer* out) const;
};

View File

@ -145,6 +145,15 @@ bool ShaderTranslator::TranslateInternal(Shader* shader) {
GatherInstructionInformation(cf_a);
GatherInstructionInformation(cf_b);
}
// Cleanup invalid/unneeded memexport allocs.
for (uint32_t i = 0; i < kMaxMemExports; ++i) {
if (!memexport_eM_written_[i]) {
memexport_eA_written_ &= ~(1u << i);
}
}
if (memexport_eA_written_ == 0) {
memexport_stream_constants_.clear();
}
StartTranslation();