[SPIR-V] Declare DepthReplacing if we replace depth

This commit is contained in:
Dr. Chat 2018-04-29 18:43:31 -05:00
parent 87bfad1f74
commit 62bee78edd
2 changed files with 7 additions and 2 deletions

View File

@ -483,8 +483,10 @@ std::vector<uint8_t> 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:

View File

@ -163,6 +163,8 @@ class SpirvShaderTranslator : public ShaderTranslator {
spv::Id vtx_ = 0; // Vertex buffer array (32 runtime arrays)
std::unordered_map<uint32_t, uint32_t> vtx_binding_map_;
bool writes_depth_ = false;
// SPIR-V IDs that are part of the in/out interface.
std::vector<spv::Id> interface_ids_;