freedreno: Only call nir_lower_io on shader_in/out
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 10 Jun 2020 22:42:15 +0000 (17:42 -0500)
committerMarge Bot <eric+marge@anholt.net>
Mon, 6 Jul 2020 19:54:30 +0000 (19:54 +0000)
Gallium drivers should never see nir_var_uniform because gallium lowers
regular uniforms to a UBO.  No GL driver should ever see either
nir_var_mem_shared because that's lowered in GLSL IR.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5418>

src/freedreno/ir3/ir3_nir.c
src/gallium/drivers/freedreno/a2xx/fd2_program.c
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c

index 5c15f5b8dfca616370d2288543c99da8ff68feab..5707cbcb66fa71ccd00bb1bf2c3f321fa4b32cdb 100644 (file)
@@ -278,8 +278,8 @@ ir3_finalize_nir(struct ir3_compiler *compiler, nir_shader *s)
 void
 ir3_nir_post_finalize(struct ir3_compiler *compiler, nir_shader *s)
 {
-       NIR_PASS_V(s, nir_lower_io, nir_var_all, ir3_glsl_type_size,
-                          (nir_lower_io_options)0);
+       NIR_PASS_V(s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
+                          ir3_glsl_type_size, (nir_lower_io_options)0);
 
        if (s->info.stage == MESA_SHADER_FRAGMENT) {
                /* NOTE: lower load_barycentric_at_sample first, since it
index 958b1f784b2a4c6ccdfcac5ded4e34a64ac1ef9b..7d40e8c99b348149a52be78c5e244d8955db3309 100644 (file)
@@ -100,8 +100,9 @@ fd2_fp_state_create(struct pipe_context *pctx,
        so->nir = (cso->type == PIPE_SHADER_IR_NIR) ? cso->ir.nir :
                tgsi_to_nir(cso->tokens, pctx->screen, false);
 
-       NIR_PASS_V(so->nir, nir_lower_io, nir_var_all, ir2_glsl_type_size,
-                          (nir_lower_io_options)0);
+       NIR_PASS_V(so->nir, nir_lower_io,
+                  nir_var_shader_in | nir_var_shader_out,
+                  ir2_glsl_type_size, (nir_lower_io_options)0);
 
        if (ir2_optimize_nir(so->nir, true))
                goto fail;
@@ -137,8 +138,9 @@ fd2_vp_state_create(struct pipe_context *pctx,
        so->nir = (cso->type == PIPE_SHADER_IR_NIR) ? cso->ir.nir :
                tgsi_to_nir(cso->tokens, pctx->screen, false);
 
-       NIR_PASS_V(so->nir, nir_lower_io, nir_var_all, ir2_glsl_type_size,
-                          (nir_lower_io_options)0);
+       NIR_PASS_V(so->nir, nir_lower_io,
+                  nir_var_shader_in | nir_var_shader_out,
+                  ir2_glsl_type_size, (nir_lower_io_options)0);
 
        if (ir2_optimize_nir(so->nir, true))
                goto fail;
index 0498c5828ad31ebeec1c2c3dc6b06f42eeec1648..81895a7aebe2551c2936543a2d08d2095b494378 100644 (file)
@@ -183,7 +183,9 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 
        NIR_PASS_V(nir, nir_lower_system_values);
        NIR_PASS_V(nir, nir_lower_frexp);
-       NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size, 0);
+       NIR_PASS_V(nir, nir_lower_io,
+                  nir_var_shader_in | nir_var_shader_out,
+                  ir3_glsl_type_size, (nir_lower_io_options)0);
        NIR_PASS_V(nir, gl_nir_lower_samplers, prog);
 
        return nir;
@@ -475,8 +477,9 @@ int main(int argc, char **argv)
        } else if (from_spirv) {
                nir = load_spirv(filenames[0], entry, stage);
 
-               NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size,
-                               (nir_lower_io_options)0);
+               NIR_PASS_V(nir, nir_lower_io,
+                          nir_var_shader_in | nir_var_shader_out,
+                          ir3_glsl_type_size, (nir_lower_io_options)0);
 
                /* TODO do this somewhere else */
                nir_lower_int64(nir, ~0);