st/nir: Pull sampler lowering into a helper function.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 6 Feb 2019 08:03:49 +0000 (00:03 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 12 Feb 2019 05:34:35 +0000 (21:34 -0800)
This will make it easier to reuse across GLSL / ARB / built-ins.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_nir.h

index 686c243e508b92e5c7551478aeb371d844d1c243..b904060528ba403dfa0f84ac24a9e1c925ddef89 100644 (file)
@@ -846,6 +846,16 @@ st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir)
    }
 }
 
+void
+st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir,
+                      struct gl_shader_program *shader_program)
+{
+   if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
+      NIR_PASS_V(nir, gl_nir_lower_samplers_as_deref, shader_program);
+   else
+      NIR_PASS_V(nir, gl_nir_lower_samplers, shader_program);
+}
+
 /* Last third of preparing nir from glsl, which happens after shader
  * variant lowering.
  */
@@ -881,10 +891,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
       NIR_PASS_V(nir, st_nir_lower_uniforms_to_ubo);
    }
 
-   if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
-      NIR_PASS_V(nir, gl_nir_lower_samplers_as_deref, shader_program);
-   else
-      NIR_PASS_V(nir, gl_nir_lower_samplers, shader_program);
+   st_nir_lower_samplers(screen, nir, shader_program);
 }
 
 } /* extern "C" */
index fcd67e32d4434aa42d241270b14898b41cd90cd0..42a04a4676bb461b5b196237e509c0b7e777662c 100644 (file)
@@ -55,6 +55,9 @@ st_link_nir(struct gl_context *ctx,
 void st_nir_assign_varying_locations(struct st_context *st,
                                      struct nir_shader *nir);
 
+void st_nir_lower_samplers(struct pipe_screen *screen, struct nir_shader *nir,
+                           struct gl_shader_program *shader_program);
+
 struct pipe_shader_state *
 st_nir_finish_builtin_shader(struct st_context *st,
                              struct nir_shader *nir,