From 1124bee4baba49466d84b2bf274017dbba6360a7 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 2 May 2022 18:19:30 -0500 Subject: [PATCH] glsl/nir: Set sample_shading if a FS output ever shows up as an rvalue If framebuffer fetch is used, we have to enable sample shading because the fetched framebuffer value is per-sample. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/glsl/glsl_to_nir.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 7dff79114c4..0a8c33aa00a 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -81,6 +81,9 @@ public: void create_function(ir_function_signature *ir); + /* True if we have any output rvalues */ + bool has_output_rvalue; + private: void add_instr(nir_instr *instr, unsigned num_components, unsigned bit_size); nir_ssa_def *evaluate_rvalue(ir_rvalue *ir); @@ -271,6 +274,9 @@ glsl_to_nir(const struct gl_constants *consts, if (var->data.mode == nir_var_shader_in && var->data.sample) shader->info.fs.uses_sample_shading = true; } + + if (v1.has_output_rvalue) + shader->info.fs.uses_sample_shading = true; } return shader; @@ -281,6 +287,7 @@ nir_visitor::nir_visitor(const struct gl_constants *consts, nir_shader *shader) this->supports_std430 = consts->UseSTD430AsDefaultPacking; this->shader = shader; this->is_global = true; + this->has_output_rvalue = false; this->var_table = _mesa_pointer_hash_table_create(NULL); this->overload_table = _mesa_pointer_hash_table_create(NULL); this->sparse_variable_set = _mesa_pointer_set_create(NULL); @@ -1838,6 +1845,9 @@ nir_visitor::evaluate_rvalue(ir_rvalue* ir) enum gl_access_qualifier access = deref_get_qualifier(this->deref); this->result = nir_load_deref_with_access(&b, this->deref, access); + + if (nir_deref_mode_is(this->deref, nir_var_shader_out)) + this->has_output_rvalue = true; } return this->result;