From c32b68f7f49ede69583e6d446efb1f55ddba6855 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Aug 2017 13:11:20 -0700 Subject: glsl/spirv: Emit GLSL tessellation shader special output variables in SPIR-V v2: Return 0 for unsupported cases instead of failing an assertion. --- src/compiler/glsl/glsl_to_spirv.cpp | 19 +++++++++++++++---- .../glsl/tests/emit_spirv_variables_test.cpp | 20 ++++++++++++++++++++ 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 -- cgit v1.2.3