[Mesa-dev,10/10] i965/fs: Allow brw_fs_vector_splitting on shader outputs.

Submitted by Eric Anholt on March 26, 2014, 9:23 p.m.

Details

Message ID 1395869028-22187-11-git-send-email-eric@anholt.net
State New
Headers show

Not browsing as part of any series.

Commit Message

Eric Anholt March 26, 2014, 9:23 p.m.
Now, a single output vec4 can be referenced by multiple ir_variables
(gl_Fragcolor_x, gl_FragColor_y, etc.).  This gives a couple of chances
for tree grafting to work.

total instructions in shared programs: 1644020 -> 1643948 (-0.00%)
instructions in affected programs:     7446 -> 7374 (-0.97%)
GAINED:                                0
LOST:                                  0
---
 src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
index a9125ca..bf940c4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
@@ -107,7 +107,6 @@  ir_vector_reference_visitor::get_variable_entry(ir_variable *var)
    switch (var->data.mode) {
    case ir_var_uniform:
    case ir_var_shader_in:
-   case ir_var_shader_out:
    case ir_var_system_value:
    case ir_var_function_in:
    case ir_var_function_out:
@@ -372,8 +371,19 @@  brw_do_vector_splitting(exec_list *instructions)
 					    entry->var->name,
 					    "xyzw"[i]);
 
-	 entry->components[i] = new(entry->mem_ctx) ir_variable(type, name,
-								ir_var_temporary);
+         ir_variable *new_var;
+
+         if (entry->var->data.mode == ir_var_shader_out) {
+            new_var = entry->var->clone(entry->mem_ctx, NULL);
+            new_var->type = type;
+            new_var->name = ralloc_strdup(new_var, name);
+            new_var->data.location_frac = i;
+         } else {
+            new_var = new(entry->mem_ctx) ir_variable(type, name,
+                                                      ir_var_temporary);
+         }
+
+	 entry->components[i] = new_var;
 	 entry->var->insert_before(entry->components[i]);
       }