summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2017-08-23 13:11:20 -0700
committerIan Romanick <ian.d.romanick@intel.com>2018-03-29 14:16:12 -0700
commitc32b68f7f49ede69583e6d446efb1f55ddba6855 (patch)
tree3d7c4b326dfc2a47238abb7ae9a86633613305d3
parent51eb6761dd0bfba4764e90cee10567bd0ca602f9 (diff)
glsl/spirv: Emit GLSL tessellation shader special output variables in SPIR-V
v2: Return 0 for unsupported cases instead of failing an assertion.
-rw-r--r--src/compiler/glsl/glsl_to_spirv.cpp19
-rw-r--r--src/compiler/glsl/tests/emit_spirv_variables_test.cpp20
2 files changed, 35 insertions, 4 deletions
diff --git a/src/compiler/glsl/glsl_to_spirv.cpp b/src/compiler/glsl/glsl_to_spirv.cpp
index b383b158e68..8c3ab18bf92 100644
--- a/src/compiler/glsl/glsl_to_spirv.cpp
+++ b/src/compiler/glsl/glsl_to_spirv.cpp
@@ -682,14 +682,25 @@ _mesa_spirv_program::emit_variable(const ir_variable *var,
builtin = SpvBuiltInViewportIndex;
break;
- case VARYING_SLOT_PRIMITIVE_ID:
- case VARYING_SLOT_FACE:
- case VARYING_SLOT_PNTC:
case VARYING_SLOT_TESS_LEVEL_OUTER:
+ assert(stage == MESA_SHADER_TESS_CTRL);
+ builtin = SpvBuiltInTessLevelOuter;
+ break;
+
case VARYING_SLOT_TESS_LEVEL_INNER:
- case VARYING_SLOT_EDGE:
+ assert(stage == MESA_SHADER_TESS_CTRL);
+ builtin = SpvBuiltInTessLevelInner;
+ break;
+
case VARYING_SLOT_BOUNDING_BOX0:
case VARYING_SLOT_BOUNDING_BOX1:
+ /* FINISHME: Handle gl_BoundingBox. */
+ break;
+
+ case VARYING_SLOT_PRIMITIVE_ID:
+ case VARYING_SLOT_FACE:
+ case VARYING_SLOT_PNTC:
+ case VARYING_SLOT_EDGE:
default:
unreachable("Invalid shader output.");
}
diff --git a/src/compiler/glsl/tests/emit_spirv_variables_test.cpp b/src/compiler/glsl/tests/emit_spirv_variables_test.cpp
index 9b360622683..446cf000dd4 100644
--- a/src/compiler/glsl/tests/emit_spirv_variables_test.cpp
+++ b/src/compiler/glsl/tests/emit_spirv_variables_test.cpp
@@ -1065,6 +1065,16 @@ TEST_F(validate_emit_fragment_variable, input_gl_ViewportIndex)
EXPECT_TRUE(spv->capabilities.is_enabled(SpvCapabilityMultiViewport));
}
+TEST_F(validate_emit_tess_ctrl_variable, output_gl_TessLevelOuter)
+{
+ check_builtin_output(shader_output(VARYING_SLOT_TESS_LEVEL_OUTER,
+ array4_float,
+ "gl_TessLevelOuter"),
+ 0x0000000b);
+
+ EXPECT_TRUE(spv->capabilities.is_enabled(SpvCapabilityTessellation));
+}
+
TEST_F(validate_emit_tess_eval_variable, input_gl_TessLevelOuter)
{
/* gl_TessLevelOuter is interesting because some drivers treat it as an
@@ -1089,6 +1099,16 @@ TEST_F(validate_emit_tess_eval_variable, sysval_gl_TessLevelOuter)
0x0000000b);
}
+TEST_F(validate_emit_tess_ctrl_variable, output_gl_TessLevelInner)
+{
+ check_builtin_output(shader_output(VARYING_SLOT_TESS_LEVEL_INNER,
+ array2_float,
+ "gl_TessLevelInner"),
+ 0x0000000c);
+
+ EXPECT_TRUE(spv->capabilities.is_enabled(SpvCapabilityTessellation));
+}
+
TEST_F(validate_emit_tess_eval_variable, input_gl_TessLevelInner)
{
/* gl_TessLevelInner is interesting because some drivers treat it as an