summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/slang/slang-ir-glsl-legalize.cpp11
-rw-r--r--tests/cross-compile/barycentrics.slang6
-rw-r--r--tests/cross-compile/barycentrics.slang.glsl12
3 files changed, 29 insertions, 0 deletions
diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp
index 5a14fe1aa..0a61d792d 100644
--- a/source/slang/slang-ir-glsl-legalize.cpp
+++ b/source/slang/slang-ir-glsl-legalize.cpp
@@ -575,6 +575,17 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// globalVarExpr = createGLSLBuiltinRef("gl_ViewportMaskPerViewNV",
// getUnsizedArrayType(getIntType()));
}
+ else if (semanticName == "sv_barycentrics")
+ {
+ context->requireGLSLVersion(ProfileVersion::GLSL_450);
+ context->requireGLSLExtension(UnownedStringSlice::fromLiteral("GL_NV_fragment_shader_barycentric"));
+
+ name = "gl_BaryCoordNV";
+
+ // TODO: There is also the `gl_BaryCoordNoPerspNV` builtin, which
+ // we ought to use if the `noperspective` modifier has been
+ // applied to this varying input.
+ }
if( name )
{
diff --git a/tests/cross-compile/barycentrics.slang b/tests/cross-compile/barycentrics.slang
new file mode 100644
index 000000000..1f2c27572
--- /dev/null
+++ b/tests/cross-compile/barycentrics.slang
@@ -0,0 +1,6 @@
+//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment
+
+float4 main(float3 bary : SV_Barycentrics) : SV_Target
+{
+ return float4(bary, 0);
+}
diff --git a/tests/cross-compile/barycentrics.slang.glsl b/tests/cross-compile/barycentrics.slang.glsl
new file mode 100644
index 000000000..ca37a14e8
--- /dev/null
+++ b/tests/cross-compile/barycentrics.slang.glsl
@@ -0,0 +1,12 @@
+#version 450
+
+#extension GL_NV_fragment_shader_barycentric : enable
+
+layout(location = 0)
+out vec4 _S1;
+
+void main()
+{
+ _S1 = vec4(gl_BaryCoordNV, float(0));
+ return;
+}