<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 27, 2016 at 11:24 AM, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">v2:<br>
 * Move lower flag to context constants. (Ken)<br>
<br>
Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
Reviewed-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> (v1)<br>
---<br>
 src/compiler/glsl/builtin_variables.cpp  | 29 ++++++++++++++++++-----------<br>
 src/compiler/glsl/glsl_parser_extras.cpp |  2 +-<br>
 src/compiler/glsl/ir.h                   |  3 ++-<br>
 src/mesa/drivers/dri/i965/brw_context.c  |  1 +<br>
 src/mesa/main/mtypes.h                   |  3 +++<br>
 src/mesa/state_tracker/st_extensions.c   |  4 +++-<br>
 6 files changed, 28 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp<br>
index d8b6f6e..22d16de 100644<br>
--- a/src/compiler/glsl/builtin_variables.cpp<br>
+++ b/src/compiler/glsl/builtin_variables.cpp<br>
@@ -1201,8 +1201,15 @@ builtin_variable_generator::generate_cs_special_vars()<br>
                     "gl_LocalInvocationID");<br>
    add_system_value(SYSTEM_VALUE_WORK_GROUP_ID, uvec3_t, "gl_WorkGroupID");<br>
    add_system_value(SYSTEM_VALUE_NUM_WORK_GROUPS, uvec3_t, "gl_NumWorkGroups");<br>
-   add_variable("gl_GlobalInvocationID", uvec3_t, ir_var_auto, 0);<br>
-   add_variable("gl_LocalInvocationIndex", uint_t, ir_var_auto, 0);<br>
+   if (state->ctx->Const.LowerCsDerivedVariables) {<br>
+      add_variable("gl_GlobalInvocationID", uvec3_t, ir_var_auto, 0);<br>
+      add_variable("gl_LocalInvocationIndex", uint_t, ir_var_auto, 0);<br>
+   } else {<br>
+      add_system_value(SYSTEM_VALUE_GLOBAL_INVOCATION_ID,<br>
+                       uvec3_t, "gl_GlobalInvocationID");<br>
+      add_system_value(SYSTEM_VALUE_LOCAL_INVOCATION_INDEX,<br>
+                       uint_t, "gl_LocalInvocationIndex");<br>
+   }<br>
 }<br>
<br>
<br>
@@ -1431,16 +1438,16 @@ initialize_cs_derived_variables(gl_shader *shader,<br>
  * These are initialized in the main function.<br>
  */<br>
 void<br>
-_mesa_glsl_initialize_derived_variables(gl_shader *shader)<br>
+_mesa_glsl_initialize_derived_variables(struct gl_context *ctx,<br>
+                                        gl_shader *shader)<br>
 {<br>
    /* We only need to set CS variables currently. */<br>
-   if (shader->Stage != MESA_SHADER_COMPUTE)<br>
-      return;<br>
+   if (shader->Stage == MESA_SHADER_COMPUTE &&<br>
+       ctx->Const.LowerCsDerivedVariables) {<br>
+      ir_function_signature *const main_sig =<br>
+         _mesa_get_main_function_signature(shader);<br>
<br>
-   ir_function_signature *const main_sig =<br>
-      _mesa_get_main_function_signature(shader);<br>
-   if (main_sig == NULL)<br>
-      return;<br>
-<br>
-   initialize_cs_derived_variables(shader, main_sig);<br>
+      if (main_sig != NULL)<br>
+         initialize_cs_derived_variables(shader, main_sig);<br>
+   }<br>
 }<br>
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp<br>
index 843998d..3d08508 100644<br>
--- a/src/compiler/glsl/glsl_parser_extras.cpp<br>
+++ b/src/compiler/glsl/glsl_parser_extras.cpp<br>
@@ -1907,7 +1907,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,<br>
       }<br>
    }<br>
<br>
-   _mesa_glsl_initialize_derived_variables(shader);<br>
+   _mesa_glsl_initialize_derived_variables(ctx, shader);<br>
<br>
    delete state->symbols;<br>
    ralloc_free(state);<br>
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h<br>
index e8efd27..93716c4 100644<br>
--- a/src/compiler/glsl/ir.h<br>
+++ b/src/compiler/glsl/ir.h<br>
@@ -2562,7 +2562,8 @@ _mesa_glsl_initialize_variables(exec_list *instructions,<br>
                                struct _mesa_glsl_parse_state *state);<br>
<br>
 extern void<br>
-_mesa_glsl_initialize_derived_variables(gl_shader *shader);<br>
+_mesa_glsl_initialize_derived_variables(struct gl_context *ctx,<br>
+                                        gl_shader *shader);<br>
<br>
 extern void<br>
 _mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c<br>
index 552e5ec..1477c8b 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.c<br>
@@ -565,6 +565,7 @@ brw_initialize_context_constants(struct brw_context *brw)<br>
       ctx->Const.MaxClipPlanes = 8;<br>
<br>
    ctx->Const.LowerTessLevel = true;<br>
+   ctx->Const.LowerCsDerivedVariables = true;<br>
    ctx->Const.PrimitiveRestartForPatches = true;<br>
<br>
    ctx->Const.Program[MESA_SHADER_VERTEX].MaxNativeInstructions = 16 * 1024;<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index 2233526..d0f3760 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -3763,6 +3763,9 @@ struct gl_constants<br>
    GLuint MaxTessControlTotalOutputComponents;<br>
    bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */<br>
    bool PrimitiveRestartForPatches;<br>
+   bool LowerCsDerivedVariables;    /**< Lower gl_GlobalInvocationID and<br>
+                                     *   gl_LocalInvocationIndex based on<br>
+                                     *   other builtin variables. */<br>
 };<br>
<br>
<br>
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c<br>
index 68e6601..8f249bb 100644<br>
--- a/src/mesa/state_tracker/st_extensions.c<br>
+++ b/src/mesa/state_tracker/st_extensions.c<br>
@@ -309,11 +309,13 @@ void st_init_limits(struct pipe_screen *screen,<br>
       options->LowerCombinedClipCullDistance = true;<br>
       options->LowerBufferInterfaceBlocks = true;<br>
<br>
-      if (sh == PIPE_SHADER_COMPUTE)<br>
+      if (sh == PIPE_SHADER_COMPUTE) {<br>
          options->LowerShaderSharedVariables = true;<br>
+      }<br>
    }<br>
<br>
    c->LowerTessLevel = true;<br>
+   c->LowerCsDerivedVariables = true;<br></blockquote><div><br></div><div>This looks a bit odd.  Did you initially put this in the condition above?  (Hence the added braces).  If you really want it here, it's probably best to drop the braces above.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    c->PrimitiveRestartForPatches =<br>
       screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.8.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>