From d18e63e6e22a0b7df7a10086663b0f26b984d358 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sun, 16 Feb 2020 18:09:22 +0300 Subject: [PATCH] [D3D12] Always write original shader source in DXBC if PIX is attached --- src/xenia/gpu/d3d12/pipeline_cache.cc | 3 ++- src/xenia/gpu/dxbc_shader_translator.cc | 16 +++++++++------- src/xenia/gpu/dxbc_shader_translator.h | 7 ++++++- src/xenia/gpu/dxbc_shader_translator_alu.cc | 2 +- src/xenia/gpu/dxbc_shader_translator_fetch.cc | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/xenia/gpu/d3d12/pipeline_cache.cc b/src/xenia/gpu/d3d12/pipeline_cache.cc index f4f374e7c..98d488f4c 100644 --- a/src/xenia/gpu/d3d12/pipeline_cache.cc +++ b/src/xenia/gpu/d3d12/pipeline_cache.cc @@ -72,7 +72,8 @@ PipelineCache::PipelineCache(D3D12CommandProcessor* command_processor, auto provider = command_processor_->GetD3D12Context()->GetD3D12Provider(); shader_translator_ = std::make_unique( - provider->GetAdapterVendorID(), edram_rov_used_); + provider->GetAdapterVendorID(), edram_rov_used_, + provider->GetGraphicsAnalysis() != nullptr); if (edram_rov_used_) { depth_only_pixel_shader_ = diff --git a/src/xenia/gpu/dxbc_shader_translator.cc b/src/xenia/gpu/dxbc_shader_translator.cc index f221243a0..e8b27e9ce 100644 --- a/src/xenia/gpu/dxbc_shader_translator.cc +++ b/src/xenia/gpu/dxbc_shader_translator.cc @@ -81,8 +81,10 @@ constexpr uint32_t DxbcShaderTranslator::kCbufferIndexUnallocated; constexpr uint32_t DxbcShaderTranslator::kCfExecBoolConstantNone; DxbcShaderTranslator::DxbcShaderTranslator(uint32_t vendor_id, - bool edram_rov_used) + bool edram_rov_used, + bool force_emit_source_map) : vendor_id_(vendor_id), edram_rov_used_(edram_rov_used) { + emit_source_map_ = force_emit_source_map || cvars::dxbc_source_map; // Don't allocate again and again for the first shader. shader_code_.reserve(8192); shader_object_.reserve(16384); @@ -1963,7 +1965,7 @@ std::vector DxbcShaderTranslator::CompleteTranslation() { } void DxbcShaderTranslator::EmitInstructionDisassembly() { - if (!cvars::dxbc_source_map) { + if (!emit_source_map_) { return; } @@ -2955,7 +2957,7 @@ void DxbcShaderTranslator::ProcessLabel(uint32_t cf_index) { void DxbcShaderTranslator::ProcessExecInstructionBegin( const ParsedExecInstruction& instr) { - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); // Will be emitted by UpdateExecConditionals. @@ -3006,7 +3008,7 @@ void DxbcShaderTranslator::ProcessLoopStartInstruction( // Loop control is outside execs - actually close the last exec. CloseExecConditionals(); - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); EmitInstructionDisassembly(); @@ -3118,7 +3120,7 @@ void DxbcShaderTranslator::ProcessLoopEndInstruction( // Loop control is outside execs - actually close the last exec. CloseExecConditionals(); - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); EmitInstructionDisassembly(); @@ -3276,7 +3278,7 @@ void DxbcShaderTranslator::ProcessLoopEndInstruction( void DxbcShaderTranslator::ProcessJumpInstruction( const ParsedJumpInstruction& instr) { - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); // Will be emitted by UpdateExecConditionals. @@ -3305,7 +3307,7 @@ void DxbcShaderTranslator::ProcessJumpInstruction( void DxbcShaderTranslator::ProcessAllocInstruction( const ParsedAllocInstruction& instr) { - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); EmitInstructionDisassembly(); diff --git a/src/xenia/gpu/dxbc_shader_translator.h b/src/xenia/gpu/dxbc_shader_translator.h index 1bac1ccd7..87891fdd0 100644 --- a/src/xenia/gpu/dxbc_shader_translator.h +++ b/src/xenia/gpu/dxbc_shader_translator.h @@ -55,7 +55,8 @@ namespace gpu { // 0 for NaN. class DxbcShaderTranslator : public ShaderTranslator { public: - DxbcShaderTranslator(uint32_t vendor_id, bool edram_rov_used); + DxbcShaderTranslator(uint32_t vendor_id, bool edram_rov_used, + bool force_emit_source_map = false); ~DxbcShaderTranslator() override; // Constant buffer bindings in space 0. @@ -1874,6 +1875,10 @@ class DxbcShaderTranslator : public ShaderTranslator { // Buffer for instruction disassembly comments. StringBuffer instruction_disassembly_buffer_; + // Whether to write comments with the original Xenos instructions to the + // output. + bool emit_source_map_; + // Vendor ID of the GPU manufacturer, for toggling unsupported features. uint32_t vendor_id_; diff --git a/src/xenia/gpu/dxbc_shader_translator_alu.cc b/src/xenia/gpu/dxbc_shader_translator_alu.cc index bd3a35d96..beef57293 100644 --- a/src/xenia/gpu/dxbc_shader_translator_alu.cc +++ b/src/xenia/gpu/dxbc_shader_translator_alu.cc @@ -2425,7 +2425,7 @@ void DxbcShaderTranslator::ProcessAluInstruction( return; } - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); // Will be emitted by UpdateInstructionPredication. diff --git a/src/xenia/gpu/dxbc_shader_translator_fetch.cc b/src/xenia/gpu/dxbc_shader_translator_fetch.cc index 78d9eb762..c2478424b 100644 --- a/src/xenia/gpu/dxbc_shader_translator_fetch.cc +++ b/src/xenia/gpu/dxbc_shader_translator_fetch.cc @@ -322,7 +322,7 @@ void DxbcShaderTranslator::ProcessVertexFetchInstruction( } uint32_t result_write_mask = (1 << result_component_count) - 1; - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); // Will be emitted by UpdateInstructionPredication. @@ -1162,7 +1162,7 @@ void DxbcShaderTranslator::ArrayCoordToCubeDirection(uint32_t reg) { void DxbcShaderTranslator::ProcessTextureFetchInstruction( const ParsedTextureFetchInstruction& instr) { - if (cvars::dxbc_source_map) { + if (emit_source_map_) { instruction_disassembly_buffer_.Reset(); instr.Disassemble(&instruction_disassembly_buffer_); // Will be emitted later explicitly or by UpdateInstructionPredication.