[Mesa-dev] [PATCH v2 08/73] st/glsl_to_nir: use nir_lower_samplers_as_deref when requested by the driver

Nicolai Hähnle nhaehnle at gmail.com
Wed Jul 5 10:47:52 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 5c4ae81..c8a7464 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -310,20 +310,22 @@ sort_varyings(struct exec_list *var_list)
    }
    exec_list_move_nodes_to(&new_list, var_list);
 }
 
 /* Second half of preparing nir from glsl, which happens after shader
  * variant lowering.
  */
 void
 st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
 {
+   struct pipe_screen *screen = st->pipe->screen;
+
    NIR_PASS_V(nir, nir_split_var_copies);
    NIR_PASS_V(nir, nir_lower_var_copies);
    NIR_PASS_V(nir, nir_lower_io_types);
 
    if (nir->stage == MESA_SHADER_VERTEX) {
       /* Needs special handling so drvloc matches the vbo state: */
       st_nir_assign_vs_in_locations(prog, nir);
       /* Re-lower global vars, to deal with any dead VS inputs. */
       NIR_PASS_V(nir, nir_lower_global_vars_to_local);
 
@@ -365,21 +367,24 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
 
    NIR_PASS_V(nir, nir_lower_atomics_to_ssbo,
          st->ctx->Const.Program[nir->stage].MaxAtomicBuffers);
 
    st_nir_assign_uniform_locations(prog, shader_program,
                                    &nir->uniforms, &nir->num_uniforms);
 
    NIR_PASS_V(nir, nir_lower_system_values);
    NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size,
               (nir_lower_io_options)0);
-   NIR_PASS_V(nir, nir_lower_samplers, shader_program);
+   if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
+      NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
+   else
+      NIR_PASS_V(nir, nir_lower_samplers, shader_program);
 }
 
 struct gl_program *
 st_nir_get_mesa_program(struct gl_context *ctx,
                         struct gl_shader_program *shader_program,
                         struct gl_linked_shader *shader)
 {
    struct gl_program *prog;
 
    validate_ir_tree(shader->ir);
-- 
2.9.3



More information about the mesa-dev mailing list