Mesa (master): st/glsl_to_nir: move some calls out of st_glsl_to_nir_post_opts()

Timothy Arceri tarceri at kemper.freedesktop.org
Sun Dec 3 22:14:57 UTC 2017


Module: Mesa
Branch: master
Commit: c3a5d74377bd90f78b9af55db598b03d264d0c02
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3a5d74377bd90f78b9af55db598b03d264d0c02

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Nov 17 17:45:32 2017 +1100

st/glsl_to_nir: move some calls out of st_glsl_to_nir_post_opts()

NIR component packing will be inserted between these calls and the
calling of st_glsl_to_nir_post_opts().

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/mesa/state_tracker/st_glsl_to_nir.cpp | 67 +++++++++++++++++--------------
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 5f92bcef00..fdb6b8be04 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -347,36 +347,6 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
     */
    _mesa_associate_uniform_storage(st->ctx, shader_program, prog, true);
 
-   /* fragment shaders may need : */
-   if (prog->info.stage == MESA_SHADER_FRAGMENT) {
-      static const gl_state_index wposTransformState[STATE_LENGTH] = {
-         STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
-      };
-      nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
-      struct pipe_screen *pscreen = st->pipe->screen;
-
-      memcpy(wpos_options.state_tokens, wposTransformState,
-             sizeof(wpos_options.state_tokens));
-      wpos_options.fs_coord_origin_upper_left =
-         pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT);
-      wpos_options.fs_coord_origin_lower_left =
-         pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
-      wpos_options.fs_coord_pixel_center_integer =
-         pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
-      wpos_options.fs_coord_pixel_center_half_integer =
-         pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER);
-
-      if (nir_lower_wpos_ytransform(nir, &wpos_options)) {
-         nir_validate_shader(nir);
-         _mesa_add_state_reference(prog->Parameters, wposTransformState);
-      }
-   }
-
-   NIR_PASS_V(nir, nir_lower_system_values);
-
-   nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
-   prog->info = nir->info;
-
    st_set_prog_affected_state_flags(prog);
 
    NIR_PASS_V(nir, st_nir_lower_builtin);
@@ -524,6 +494,43 @@ st_link_nir(struct gl_context *ctx,
       if (shader == NULL)
          continue;
 
+      nir_shader *nir = shader->Program->nir;
+
+      /* fragment shaders may need : */
+      if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+         static const gl_state_index wposTransformState[STATE_LENGTH] = {
+            STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
+         };
+         nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
+         struct pipe_screen *pscreen = st->pipe->screen;
+
+         memcpy(wpos_options.state_tokens, wposTransformState,
+                sizeof(wpos_options.state_tokens));
+         wpos_options.fs_coord_origin_upper_left =
+            pscreen->get_param(pscreen,
+                               PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT);
+         wpos_options.fs_coord_origin_lower_left =
+            pscreen->get_param(pscreen,
+                               PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+         wpos_options.fs_coord_pixel_center_integer =
+            pscreen->get_param(pscreen,
+                               PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+         wpos_options.fs_coord_pixel_center_half_integer =
+            pscreen->get_param(pscreen,
+                               PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER);
+
+         if (nir_lower_wpos_ytransform(nir, &wpos_options)) {
+            nir_validate_shader(nir);
+            _mesa_add_state_reference(shader->Program->Parameters,
+                                      wposTransformState);
+         }
+      }
+
+      NIR_PASS_V(nir, nir_lower_system_values);
+
+      nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
+      shader->Program->info = nir->info;
+
       st_glsl_to_nir_post_opts(st, shader->Program, shader_program);
 
       assert(shader->Program);




More information about the mesa-commit mailing list