[Mesa-dev] [PATCH v7 01/35] st/glsl_to_nir: run lower_output_reads on !PIPE_CAP_TGSI_CAN_READ_OUTPUTS

Karol Herbst kherbst at redhat.com
Mon Apr 16 13:25:41 UTC 2018


this is required for Drivers which don't allow reading from outputs.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index bcf6a7ceb6a..6502aec370f 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -44,6 +44,7 @@
 #include "compiler/glsl_types.h"
 #include "compiler/glsl/glsl_to_nir.h"
 #include "compiler/glsl/ir.h"
+#include "compiler/glsl/ir_optimization.h"
 #include "compiler/glsl/string_to_uint_map.h"
 
 
@@ -553,6 +554,7 @@ st_nir_get_mesa_program(struct gl_context *ctx,
                         struct gl_linked_shader *shader)
 {
    struct st_context *st = st_context(ctx);
+   struct pipe_screen *pscreen = ctx->st->pipe->screen;
    struct gl_program *prog;
 
    validate_ir_tree(shader->ir);
@@ -565,6 +567,10 @@ st_nir_get_mesa_program(struct gl_context *ctx,
    _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
                                                prog->Parameters);
 
+   /* Remove reads from output registers. */
+   if (!pscreen->get_param(pscreen, 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",
-- 
2.14.3



More information about the mesa-dev mailing list