glsl: Support gl_TessLevelInner/Outer[] as TES input variables.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 6 Dec 2016 09:50:03 +0000 (01:50 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 6 Jan 2017 23:55:41 +0000 (15:55 -0800)
Upcoming reworks in i965 are going to make it easy to handle this
like any other input.  Having it as a system value will just require
additional code for no benefit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
src/compiler/glsl/builtin_variables.cpp
src/mesa/main/mtypes.h

index ca266a4c37ca0ae5c126c01fa92f8b8695b893f6..d6dac6d7de5696eacc70492fbdf1d6ec8865c0fe 100644 (file)
@@ -1075,10 +1075,17 @@ builtin_variable_generator::generate_tes_special_vars()
    add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
    add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
    add_system_value(SYSTEM_VALUE_TESS_COORD, vec3_t, "gl_TessCoord");
-   add_system_value(SYSTEM_VALUE_TESS_LEVEL_OUTER, array(float_t, 4),
-                    "gl_TessLevelOuter");
-   add_system_value(SYSTEM_VALUE_TESS_LEVEL_INNER, array(float_t, 2),
-                    "gl_TessLevelInner");
+   if (this->state->ctx->Const.GLSLTessLevelsAsInputs) {
+      add_input(VARYING_SLOT_TESS_LEVEL_OUTER, array(float_t, 4),
+                "gl_TessLevelOuter")->data.patch = 1;
+      add_input(VARYING_SLOT_TESS_LEVEL_INNER, array(float_t, 2),
+                "gl_TessLevelInner")->data.patch = 1;
+   } else {
+      add_system_value(SYSTEM_VALUE_TESS_LEVEL_OUTER, array(float_t, 4),
+                       "gl_TessLevelOuter");
+      add_system_value(SYSTEM_VALUE_TESS_LEVEL_INNER, array(float_t, 2),
+                       "gl_TessLevelInner");
+   }
    if (state->ARB_shader_viewport_layer_array_enable) {
       var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
       var->data.interpolation = INTERP_MODE_FLAT;
index 243c76ded14ef1257e8b5dde7b8a81d5e75ab9ae..dadedb145adda219780022ff5848f8ca2c71ae07 100644 (file)
@@ -3640,6 +3640,12 @@ struct gl_constants
     */
    bool GLSLOptimizeConservatively;
 
+   /**
+    * True if gl_TessLevelInner/Outer[] in the TES should be inputs
+    * (otherwise, they're system values).
+    */
+   bool GLSLTessLevelsAsInputs;
+
    /**
     * Always use the GetTransformFeedbackVertexCount() driver hook, rather
     * than passing the transform feedback object to the drawing function.