From e6524aa497703cf002e17849660f201dda3b9b06 Mon Sep 17 00:00:00 2001 From: DrChat Date: Sun, 8 Apr 2018 18:02:39 -0500 Subject: [PATCH] [GPU] Disassemble memexport exports --- src/xenia/gpu/shader.h | 4 +++ src/xenia/gpu/shader_translator.cc | 36 +++++++++++++++++++---- src/xenia/gpu/shader_translator_disasm.cc | 7 +++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/xenia/gpu/shader.h b/src/xenia/gpu/shader.h index 7e0cd3ab2..252ee3078 100644 --- a/src/xenia/gpu/shader.h +++ b/src/xenia/gpu/shader.h @@ -31,6 +31,10 @@ enum class InstructionStorageTarget { kPosition, // Result is stored to the point size export (gl_PointSize). kPointSize, + // Result is stored as memexport destination address. + kExportAddress, + // Result is stored to memexport destination data. + kExportData, // Result is stored to a color target export indexed by storage_index [0-3]. kColorTarget, // Result is stored to the depth export (gl_FragDepth). diff --git a/src/xenia/gpu/shader_translator.cc b/src/xenia/gpu/shader_translator.cc index 4634ef34d..1f3e13dbc 100644 --- a/src/xenia/gpu/shader_translator.cc +++ b/src/xenia/gpu/shader_translator.cc @@ -1147,14 +1147,15 @@ void ShaderTranslator::ParseAluVectorInstruction( } else if (is_vertex_shader()) { switch (dest_num) { case 32: + i.result.storage_target = InstructionStorageTarget::kExportAddress; + break; case 33: case 34: case 35: case 36: case 37: - // TODO: Memexport registers - i.result.storage_target = InstructionStorageTarget::kNone; - i.result.storage_index = 0; + i.result.storage_index = dest_num - 33; + i.result.storage_target = InstructionStorageTarget::kExportData; break; case 62: i.result.storage_target = InstructionStorageTarget::kPosition; @@ -1198,14 +1199,15 @@ void ShaderTranslator::ParseAluVectorInstruction( i.result.storage_index = 3; break; case 32: + i.result.storage_target = InstructionStorageTarget::kExportAddress; + break; case 33: case 34: case 35: case 36: case 37: - // TODO: Memexport registers - i.result.storage_target = InstructionStorageTarget::kNone; - i.result.storage_index = 0; + i.result.storage_index = dest_num - 33; + i.result.storage_target = InstructionStorageTarget::kExportData; break; case 61: i.result.storage_target = InstructionStorageTarget::kDepth; @@ -1303,6 +1305,17 @@ void ShaderTranslator::ParseAluScalarInstruction( : InstructionStorageAddressingMode::kStatic; } else if (is_vertex_shader()) { switch (dest_num) { + case 32: + i.result.storage_target = InstructionStorageTarget::kExportAddress; + break; + case 33: + case 34: + case 35: + case 36: + case 37: + i.result.storage_index = dest_num - 33; + i.result.storage_target = InstructionStorageTarget::kExportData; + break; case 62: i.result.storage_target = InstructionStorageTarget::kPosition; break; @@ -1344,6 +1357,17 @@ void ShaderTranslator::ParseAluScalarInstruction( i.result.storage_target = InstructionStorageTarget::kColorTarget; i.result.storage_index = 3; break; + case 32: + i.result.storage_target = InstructionStorageTarget::kExportAddress; + break; + case 33: + case 34: + case 35: + case 36: + case 37: + i.result.storage_index = dest_num - 33; + i.result.storage_target = InstructionStorageTarget::kExportData; + break; case 61: i.result.storage_target = InstructionStorageTarget::kDepth; break; diff --git a/src/xenia/gpu/shader_translator_disasm.cc b/src/xenia/gpu/shader_translator_disasm.cc index b36267fb4..6a2007eaa 100644 --- a/src/xenia/gpu/shader_translator_disasm.cc +++ b/src/xenia/gpu/shader_translator_disasm.cc @@ -38,6 +38,13 @@ void DisassembleResultOperand(const InstructionResult& result, case InstructionStorageTarget::kPointSize: out->Append("oPts"); break; + case InstructionStorageTarget::kExportAddress: + out->Append("eA"); + break; + case InstructionStorageTarget::kExportData: + out->Append("eM"); + uses_storage_index = true; + break; case InstructionStorageTarget::kColorTarget: out->AppendFormat("oC"); uses_storage_index = true;