glsl: pass shader stage to lower_output_reads and handle tess control
authorIlia Mirkin <imirkin@alum.mit.edu>
Tue, 22 Jul 2014 01:59:37 +0000 (21:59 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 22 Jul 2015 22:59:28 +0000 (00:59 +0200)
Tessellation control outputs can be read in directly without first
having been written. Accessing these will require some special logic
anyways, so just let them through.

V2: Never lower tess control output reads, whether patch or not -- both
can be read back by other threads.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ir_optimization.h
src/glsl/lower_output_reads.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index a174c9683a16955b5ac464703343d84367cb76d1..766b723df0b94db0ea639bbc63619372a75af477 100644 (file)
@@ -120,7 +120,7 @@ bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
 bool lower_const_arrays_to_uniforms(exec_list *instructions);
 bool lower_clip_distance(gl_shader *shader);
-void lower_output_reads(exec_list *instructions);
+void lower_output_reads(unsigned stage, exec_list *instructions);
 bool lower_packing_builtins(exec_list *instructions, int op_mask);
 void lower_ubo_reference(struct gl_shader *shader, exec_list *instructions);
 void lower_packed_varyings(void *mem_ctx,
index 1ee815d5eceb35d21e32b9f392044b7453f15fa3..79488df2932da251db0baae0bbfcf8b2683da955 100644 (file)
@@ -48,8 +48,10 @@ protected:
    hash_table *replacements;
 
    void *mem_ctx;
+
+   unsigned stage;
 public:
-   output_read_remover();
+   output_read_remover(unsigned stage);
    ~output_read_remover();
    virtual ir_visitor_status visit(class ir_dereference_variable *);
    virtual ir_visitor_status visit_leave(class ir_emit_vertex *);
@@ -75,8 +77,9 @@ hash_table_var_hash(const void *key)
    return hash_table_string_hash(var->name);
 }
 
-output_read_remover::output_read_remover()
+output_read_remover::output_read_remover(unsigned stage)
 {
+   this->stage = stage;
    mem_ctx = ralloc_context(NULL);
    replacements =
       hash_table_ctor(0, hash_table_var_hash, hash_table_pointer_compare);
@@ -93,6 +96,8 @@ output_read_remover::visit(ir_dereference_variable *ir)
 {
    if (ir->var->data.mode != ir_var_shader_out)
       return visit_continue;
+   if (stage == MESA_SHADER_TESS_CTRL)
+      return visit_continue;
 
    ir_variable *temp = (ir_variable *) hash_table_find(replacements, ir->var);
 
@@ -166,8 +171,8 @@ output_read_remover::visit_leave(ir_function_signature *sig)
 }
 
 void
-lower_output_reads(exec_list *instructions)
+lower_output_reads(unsigned stage, exec_list *instructions)
 {
-   output_read_remover v;
+   output_read_remover v(stage);
    visit_list_elements(&v, instructions);
 }
index 379ff4a3a1aca54100962e83c1795238ef324891..9d60543c1674f76d401b168cd87021a2dcffeaca 100644 (file)
@@ -316,7 +316,7 @@ process_glsl_ir(gl_shader_stage stage,
    } while (progress);
 
    if (options->NirOptions != NULL)
-      lower_output_reads(shader->ir);
+      lower_output_reads(stage, shader->ir);
 
    validate_ir_tree(shader->ir);
 
index b727c5e9c93f081ee086faf14f9e512df8110475..0ed16aeab8754a9ae1d4d1e0a2898cc45498892e 100644 (file)
@@ -5674,7 +5674,7 @@ get_mesa_program(struct gl_context *ctx,
                                                prog->Parameters);
 
    /* Remove reads from output registers. */
-   lower_output_reads(shader->ir);
+   lower_output_reads(shader->Stage, shader->ir);
 
    /* Emit intermediate IR for main(). */
    visit_exec_list(shader->ir, v);