[Mesa-dev] [PATCH 11/14] st/glsl_to_nir: move some calls out of st_glsl_to_nir_post_opts()

Timothy Arceri tarceri at itsqueeze.com
Tue Nov 21 03:37:32 UTC 2017


NIR component packing will be inserted between these calls and the
calling of st_glsl_to_nir_post_opts().
---
 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 746dfff396..27e36bd306 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -340,50 +340,20 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
     * This should be enough for Bitmap and DrawPixels constants.
     */
    _mesa_reserve_parameter_storage(prog->Parameters, 8);
 
    /* This has to be done last.  Any operation the can cause
     * prog->ParameterValues to get reallocated (e.g., anything that adds a
     * program constant) has to happen before creating this linkage.
     */
    _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);
    NIR_PASS_V(nir, nir_lower_atomics, shader_program);
 
    if (st->ctx->_Shader->Flags & GLSL_DUMP) {
       _mesa_log("\n");
       _mesa_log("NIR IR for linked %s program %d:\n",
              _mesa_shader_stage_to_string(prog->info.stage),
              shader_program->Name);
@@ -519,20 +489,57 @@ st_link_nir(struct gl_context *ctx,
          continue;
 
       nir_shader *nir = st_nir_get_mesa_program(ctx, shader_program, shader);
    }
 
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
       struct gl_linked_shader *shader = shader_program->_LinkedShaders[i];
       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);
       if (!ctx->Driver.ProgramStringNotify(ctx,
                                            _mesa_shader_stage_to_program(i),
                                            shader->Program)) {
          _mesa_reference_program(ctx, &shader->Program, NULL);
          return false;
       }
    }
-- 
2.14.3



More information about the mesa-dev mailing list