glsl: just use NIR to lower outputs when driver can't read outputs
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 30 Oct 2019 00:24:37 +0000 (11:24 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 1 Nov 2019 00:33:33 +0000 (11:33 +1100)
This will allow us to stop lowering gl_FragData in GLSL IR for NIR
drivers which means we won't need the special GLSL IR type
handling for building the resource list in a NIR based linker.

i965 has been doing this since b828f7a27b2b.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 0e249377ce6106aa8af56b8ec7a17bc5bbf633d3..d0ca8b0877b270f746ebe50d61f8df2d0bb0eeb1 100644 (file)
@@ -340,6 +340,7 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
                   struct gl_shader_program *shader_program,
                   gl_shader_stage stage)
 {
+   struct pipe_screen *screen = st->pipe->screen;
    const nir_shader_compiler_options *options =
       st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
    assert(options);
@@ -376,7 +377,8 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
       NIR_PASS_V(nir, nir_lower_io_to_temporaries,
                  nir_shader_get_entrypoint(nir),
                  true, true);
-   } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+   } else if (nir->info.stage == MESA_SHADER_FRAGMENT ||
+              !screen->get_param(screen, PIPE_CAP_TGSI_CAN_READ_OUTPUTS)) {
       NIR_PASS_V(nir, nir_lower_io_to_temporaries,
                  nir_shader_get_entrypoint(nir),
                  true, false);
@@ -660,7 +662,6 @@ st_link_nir(struct gl_context *ctx,
             struct gl_shader_program *shader_program)
 {
    struct st_context *st = st_context(ctx);
-   struct pipe_screen *screen = st->pipe->screen;
    unsigned num_linked_shaders = 0;
 
    unsigned last_stage = 0;
@@ -691,10 +692,6 @@ st_link_nir(struct gl_context *ctx,
          _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
                                                      prog->Parameters);
 
-         /* Remove reads from output registers. */
-         if (!screen->get_param(screen, PIPE_CAP_TGSI_CAN_READ_OUTPUTS))
-            lower_output_reads(shader->Stage, shader->ir);
-
          if (ctx->_Shader->Flags & GLSL_DUMP) {
             _mesa_log("\n");
             _mesa_log("GLSL IR for linked %s program %d:\n",