diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc index 8375e51c6..834f4ae06 100644 --- a/src/xenia/gpu/spirv_shader_translator.cc +++ b/src/xenia/gpu/spirv_shader_translator.cc @@ -483,8 +483,10 @@ std::vector SpirvShaderTranslator::CompleteTranslation() { mainFn, "main"); b.addExecutionMode(mainFn, spv::ExecutionModeOriginUpperLeft); - // FIXME(DrChat): We need to declare the DepthReplacing execution mode if - // we write depth, and we must unconditionally write depth if declared! + // If we write a new depth value, we must declare this mode! + if (writes_depth_) { + b.addExecutionMode(mainFn, spv::ExecutionModeDepthReplacing); + } for (auto id : interface_ids_) { entry->addIdOperand(id); @@ -3298,6 +3300,7 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id, storage_type = float_type_; storage_offsets.push_back(0); storage_array = false; + writes_depth_ = true; break; default: case InstructionStorageTarget::kNone: diff --git a/src/xenia/gpu/spirv_shader_translator.h b/src/xenia/gpu/spirv_shader_translator.h index 3a7ead2f8..caa288353 100644 --- a/src/xenia/gpu/spirv_shader_translator.h +++ b/src/xenia/gpu/spirv_shader_translator.h @@ -163,6 +163,8 @@ class SpirvShaderTranslator : public ShaderTranslator { spv::Id vtx_ = 0; // Vertex buffer array (32 runtime arrays) std::unordered_map vtx_binding_map_; + bool writes_depth_ = false; + // SPIR-V IDs that are part of the in/out interface. std::vector interface_ids_;