st/mesa: Let NIR lower UBO and SSBO access when we have it
authorJason Ekstrand <jason.ekstrand@intel.com>
Sun, 10 Mar 2019 13:57:51 +0000 (08:57 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Fri, 15 Mar 2019 01:02:19 +0000 (01:02 +0000)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 528e6b74a541649404106f5f854b38159b860c0c..c953bfd9f7a6b0ed50768518ab84333f27ee5679 100644 (file)
@@ -329,7 +329,13 @@ void st_init_limits(struct pipe_screen *screen,
       if (!screen->get_param(screen, PIPE_CAP_NIR_COMPACT_ARRAYS))
          options->LowerCombinedClipCullDistance = true;
 
-      options->LowerBufferInterfaceBlocks = true;
+      bool prefer_nir = PIPE_SHADER_IR_NIR ==
+         screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_PREFERRED_IR);
+
+      /* NIR can do the lowering on our behalf and we'll get better results
+       * because it can actually optimize SSBO access.
+       */
+      options->LowerBufferInterfaceBlocks = !prefer_nir;
    }
 
    c->MaxUserAssignableUniformLocations =
index 03637299ca4a1e4b762337dea54465537f834479..e5d5fe21e2772b801a0498316064686cc1715b12 100644 (file)
@@ -415,6 +415,10 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
 
    st_nir_opts(nir, is_scalar);
 
+   NIR_PASS_V(nir, gl_nir_lower_buffers, shader_program);
+   /* Do a round of constant folding to clean up address calculations */
+   NIR_PASS_V(nir, nir_opt_constant_folding);
+
    if (lower_64bit) {
       bool lowered_64bit_ops = false;
       bool progress = false;