From 83675103a1a4fefde11b314aed26f4d37860efe7 Mon Sep 17 00:00:00 2001 From: davli-nv Date: Tue, 5 Aug 2025 10:55:52 -0700 Subject: Implement SPV_EXT_fragment_invocation_density (SPV_NV_shading_rate) (#8037) * Implement SPV_EXT_fragment_invocation_density -Adds semantics SV_FragSize and SV_FragInvocationCount and implements them for SPIRV and GLSL using the appropriate target builtins from extensions. -Adds test case checking for expected target builtins from these semantics. -For future work, could implement SV_FragSize using pixel shader input SV_ShadingRate for HLSL, and SV_FragInvocationCount needs research. Fixes #7974 Generated with Claude Code * address review feedback https://github.com/shader-slang/slang/pull/8037#pullrequestreview-3084645845 * fixup format * review feedback https://github.com/shader-slang/slang/pull/8037#pullrequestreview-3086442819 --- source/slang/slang-emit-glsl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/slang/slang-emit-glsl.cpp') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index eb71286a2..eb6d4c694 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -1246,6 +1246,14 @@ void GLSLSourceEmitter::_maybeEmitGLSLBuiltin(IRGlobalParam* var, UnownedStringS { _requireGLSLExtension(toSlice("GL_EXT_fragment_shading_rate_primitive")); } + else if (name == "gl_FragSizeEXT") + { + _requireGLSLExtension(toSlice("GL_EXT_fragment_invocation_density")); + } + else if (name == "gl_FragInvocationCountEXT") + { + _requireGLSLExtension(toSlice("GL_EXT_fragment_invocation_density")); + } else if (name == "gl_DrawID") { _requireGLSLVersion(460); -- cgit v1.2.3