diff options
| author | Yong He <yonghe@outlook.com> | 2024-04-02 16:30:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-02 16:30:06 -0700 |
| commit | c0482ec12d683e53aca56543b620a4ec02082e29 (patch) | |
| tree | 3fb3b33a96da15e7a1378680d03b69a934f9f604 /source/slang/slang-emit-spirv.cpp | |
| parent | 539d368a32ec0afa44c195615baf50dafe602563 (diff) | |
Fix the erroneous logic of determining whether or not to emit DepthReplacing. (#3885)
* Fix the erroneous logic of determining whether or not to emit DepthReplacing.
Closes #3884.
* Fix.
* More cleanup.
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 36c9aa5f8..d32530b90 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -2894,7 +2894,7 @@ struct SPIRVEmitContext } - SpvExecutionMode isDepthOutput(IRInst* builtinVar) + SpvExecutionMode getDepthOutputExecutionMode(IRInst* builtinVar) { SpvExecutionMode result = SpvExecutionModeMax; bool isDepthVar = false; @@ -2943,6 +2943,7 @@ struct SPIRVEmitContext { case kIROp_SwizzledStore: case kIROp_Store: + case kIROp_Call: return result; } } @@ -2956,34 +2957,25 @@ struct SPIRVEmitContext // Check if the entrypoint uses any depth output builtin variables, // if so, we need to emit a DepthReplacing execution mode for the // fragment entrypoint. - bool needDepthReplacingMode = false; SpvExecutionMode mode = SpvExecutionModeMax; for (auto globalInst : referencedBuiltinIRVars) { - if (auto thisMode = isDepthOutput(globalInst)) + auto thisMode = getDepthOutputExecutionMode(globalInst); + if (mode == SpvExecutionModeMax) + mode = thisMode; + else if (mode != thisMode) { - needDepthReplacingMode = true; - if (mode == SpvExecutionModeMax) - mode = thisMode; - else if (mode != thisMode) - mode = SpvExecutionModeDepthReplacing; + mode = SpvExecutionModeDepthReplacing; break; } } - if (!needDepthReplacingMode) + if (mode == SpvExecutionModeMax) return; + emitOpExecutionMode(getSection(SpvLogicalSectionID::ExecutionModes), nullptr, entryPoint, - SpvExecutionModeDepthReplacing); - if (mode != SpvExecutionModeDepthReplacing && - mode != SpvExecutionModeMax) - { - emitOpExecutionMode(getSection(SpvLogicalSectionID::ExecutionModes), - nullptr, - entryPoint, - mode); - } + mode); } // Make user type name conform to `SPV_GOOGLE_user_type` spec. |
