gallium/ttn: mark location specially in nir for color0-writes-all
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 27 Jun 2015 21:38:57 +0000 (17:38 -0400)
committerRob Clark <robclark@freedesktop.org>
Fri, 3 Jul 2015 12:56:09 +0000 (08:56 -0400)
We need to distinguish a shader that has separate writes to each MRT
from one which is supposed to write the data from MRT 0 to all the MRTs.
In TGSI this is done with a property. NIR doesn't have that, so encode
it as a funny location and decode on the other end.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/vc4/vc4_program.c

index bf7eb2fde022022964e0af037e72ae96444e0596..4130697e2a7db300d8d632f5a8e42fe641e67249 100644 (file)
@@ -253,7 +253,12 @@ ttn_emit_declaration(struct ttn_compile *c)
             var->name = ralloc_asprintf(var, "out_%d", idx);
 
             var->data.location = decl->Semantic.Name;
-            var->data.index = decl->Semantic.Index;
+            if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+                decl->Semantic.Index == 0 &&
+                c->scan->properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
+               var->data.index = -1;
+            else
+               var->data.index = decl->Semantic.Index;
 
             if (is_array) {
                unsigned j;
index 3b36114a5baaf8eb694a80934d7210fb5244aef8..fa13c4076dcc0c803d6fa007db236b36bae09340 100644 (file)
@@ -2110,6 +2110,10 @@ setup_output(struct ir3_compile *ctx, nir_variable *out)
                        so->writes_pos = true;
                        break;
                case TGSI_SEMANTIC_COLOR:
+                       if (semantic_index == -1) {
+                               semantic_index = 0;
+                               so->color0_mrt = 1;
+                       }
                        break;
                default:
                        compile_error(ctx, "unknown FS semantic name: %s\n",
index 7b39a03f01a7102ff480faf945717a637dbb07db..a7aa3172a755d147828f5ef7a88d6af10dec6b23 100644 (file)
@@ -1783,6 +1783,12 @@ ntq_setup_outputs(struct vc4_compile *c)
 
                 assert(array_len == 1);
 
+                /* NIR hack to pass through
+                 * TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS */
+                if (semantic_name == TGSI_SEMANTIC_COLOR &&
+                    semantic_index == -1)
+                        semantic_index = 0;
+
                 for (int i = 0; i < 4; i++) {
                         add_output(c,
                                    loc + i,