summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authordavli-nv <davli@nvidia.com>2025-08-06 12:29:28 -0700
committerGitHub <noreply@github.com>2025-08-06 19:29:28 +0000
commit5074c4948d73b451c74bd21ac139d69eaeb390f3 (patch)
treeb87d103868d14f1cfed946984a079164c38c5d26 /source/slang/slang-emit-spirv.cpp
parentd107327422b69777d41f1077c58d46c6bcf579c4 (diff)
Fix noperspective modifier for SV_Barycentrics in SPIRV and GLSL (#8067)
* Fix noperspective modifier for SV_Barycentrics in SPIRV and GLSL - Added test case with both regular and noperspective SV_Barycentrics inputs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: davli-nv <davli-nv@users.noreply.github.com> * fixup format * address review https://github.com/shader-slang/slang/pull/8067#pullrequestreview-3090037501 * address review https://github.com/shader-slang/slang/pull/8067#discussion_r2255818595 * add test case from review --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: davli-nv <davli-nv@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index a5a77e148..0a755cd6d 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -6211,11 +6211,24 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
requireSPIRVCapability(SpvCapabilityFragmentBarycentricKHR);
ensureExtensionDeclaration(
UnownedStringSlice("SPV_KHR_fragment_shader_barycentric"));
- return getBuiltinGlobalVar(inst->getFullType(), SpvBuiltInBaryCoordKHR, inst);
- // TODO: There is also the `gl_BaryCoordNoPerspNV` builtin, which
- // we ought to use if the `noperspective` modifier has been
- // applied to this varying input.
+ auto interpolationModeDecor =
+ inst->findDecoration<IRInterpolationModeDecoration>();
+ if (interpolationModeDecor &&
+ interpolationModeDecor->getMode() == IRInterpolationMode::NoPerspective)
+ {
+ return getBuiltinGlobalVar(
+ inst->getFullType(),
+ SpvBuiltInBaryCoordNoPerspKHR,
+ inst);
+ }
+ else
+ {
+ return getBuiltinGlobalVar(
+ inst->getFullType(),
+ SpvBuiltInBaryCoordKHR,
+ inst);
+ }
}
else if (semanticName == "sv_cullprimitive")
{