<div dir="ltr">ping for push. it's not pushed yet.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 20, 2018 at 5:55 PM, Robert Tarasov <span dir="ltr"><<a href="mailto:tutankhamen@chromium.org" target="_blank">tutankhamen@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: "Joe M. Kniss" <<a href="mailto:djmk@chromium.org">djmk@chromium.org</a>><br>
<span class=""><br>
Add support for glsl 'invariant' modifier for output data declarations.<br>
Gallium drivers that use TGSI serialization currently loose invariant<br>
modifiers in glsl shaders.<br>
<br>
</span>v2: use boolean for invariant instead of unsigned.<br>
<br>
Change-Id: Ieac8639116def45233513b6867a84<wbr>7cf7fda2f55<br>
<span class="">Tested: chromiumos on qemu with virglrenderer.<br>
</span><span class="">---<br>
 src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.c  |  2 ++<br>
 src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.h  |  2 ++<br>
</span> src/gallium/auxiliary/tgsi/<wbr>tgsi_text.c     | 18 ++++++++++----<br>
 src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c     | 28 +++++++++++++++-------<br>
<span class=""> src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h     |  4 +++-<br>
 src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp |  8 +++++--<br>
</span> 6 files changed, 46 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.c b/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.c<br>
index 4f28b49ce8a..434871273f2 100644<br>
<span class="">--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.c<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.c<br>
@@ -185,6 +185,8 @@ const char *tgsi_interpolate_locations[<wbr>TGSI_INTERPOLATE_LOC_COUNT] =<br>
    "SAMPLE",<br>
 };<br>
<br>
+const char *tgsi_invariant_name = "INVARIANT";<br>
+<br>
 const char *tgsi_primitive_names[PIPE_<wbr>PRIM_MAX] =<br>
 {<br>
    "POINTS",<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.h b/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.h<br>
</span>index bb2d3458dde..20e3f7127f6 100644<br>
<span class="">--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.h<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_strings.h<br>
@@ -52,6 +52,8 @@ extern const char *tgsi_interpolate_names[TGSI_<wbr>INTERPOLATE_COUNT];<br>
<br>
 extern const char *tgsi_interpolate_locations[<wbr>TGSI_INTERPOLATE_LOC_COUNT];<br>
<br>
+extern const char *tgsi_invariant_name;<br>
+<br>
 extern const char *tgsi_primitive_names[PIPE_<wbr>PRIM_MAX];<br>
<br>
 extern const char *tgsi_fs_coord_origin_names[2]<wbr>;<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_text.c b/src/gallium/auxiliary/tgsi/<wbr>tgsi_text.c<br>
</span>index 02241a66bfe..815b1ee65db 100644<br>
<div><div class="h5">--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_text.c<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_text.c<br>
@@ -1586,10 +1586,6 @@ static boolean parse_declaration( struct translate_ctx *ctx )<br>
             break;<br>
          }<br>
       }<br>
-      if (i == TGSI_INTERPOLATE_COUNT) {<br>
-         report_error( ctx, "Expected semantic or interpolate attribute" );<br>
-         return FALSE;<br>
-      }<br>
    }<br>
<br>
    cur = ctx->cur;<br>
@@ -1609,6 +1605,20 @@ static boolean parse_declaration( struct translate_ctx *ctx )<br>
       }<br>
    }<br>
<br>
+   cur = ctx->cur;<br>
+   eat_opt_white( &cur );<br>
+   if (*cur == ',' && !is_vs_input) {<br>
+      cur++;<br>
+      eat_opt_white( &cur );<br>
+      if (str_match_nocase_whole( &cur, tgsi_invariant_name )) {<br>
+         decl.Declaration.Invariant = 1;<br>
+         ctx->cur = cur;<br>
+      } else {<br>
+         report_error( ctx, "Expected semantic, interpolate attribute, or invariant ");<br>
+         return FALSE;<br>
+      }<br>
+   }<br>
+   <br>
    advance = tgsi_build_full_declaration(<br>
       &decl,<br>
       ctx->tokens_cur,<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c<br>
</div></div>index 7d2b9af140d..f1bebe1e155 100644<br>
<span class="">--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c<br>
@@ -140,6 +140,7 @@ struct ureg_program<br>
       unsigned first;<br>
       unsigned last;<br>
       unsigned array_id;<br>
</span>+      boolean invariant;<br>
<span class="">    } output[UREG_MAX_OUTPUT];<br>
    unsigned nr_outputs, nr_output_regs;<br>
<br>
@@ -427,7 +428,8 @@ ureg_DECL_output_layout(struct ureg_program *ureg,<br>
                         unsigned index,<br>
                         unsigned usage_mask,<br>
                         unsigned array_id,<br>
-                        unsigned array_size)<br>
+                        unsigned array_size,<br>
</span>+                        boolean invariant)<br>
<span class=""> {<br>
    unsigned i;<br>
<br>
@@ -455,6 +457,7 @@ ureg_DECL_output_layout(struct ureg_program *ureg,<br>
       ureg->output[i].first = index;<br>
       ureg->output[i].last = index + array_size - 1;<br>
       ureg->output[i].array_id = array_id;<br>
+      ureg->output[i].invariant = invariant;<br>
       ureg->nr_output_regs = MAX2(ureg->nr_output_regs, index + array_size);<br>
       ureg->nr_outputs++;<br>
    }<br>
</span>@@ -480,7 +483,8 @@ ureg_DECL_output_masked(struct ureg_program *ureg,<br>
<span class="">                         unsigned array_size)<br>
 {<br>
    return ureg_DECL_output_layout(ureg, name, index, 0,<br>
-                                  ureg->nr_output_regs, usage_mask, array_id, array_size);<br>
+                                  ureg->nr_output_regs, usage_mask, array_id,<br>
</span>+                                  array_size, FALSE);<br>
 }<br>
<br>
<br>
@@ -1512,7 +1516,8 @@ emit_decl_semantic(struct ureg_program *ureg,<br>
<span class="">                    unsigned semantic_index,<br>
                    unsigned streams,<br>
                    unsigned usage_mask,<br>
-                   unsigned array_id)<br>
+                   unsigned array_id,<br>
</span>+                   boolean invariant)<br>
<span class=""> {<br>
    union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, array_id ? 4 : 3);<br>
<br>
</span>@@ -1523,7 +1528,8 @@ emit_decl_semantic(struct ureg_program *ureg,<br>
<span class="">    out[0].decl.UsageMask = usage_mask;<br>
    out[0].decl.Semantic = 1;<br>
    out[0].decl.Array = array_id != 0;<br>
-<br>
+   out[0].decl.Invariant = invariant;<br>
+   <br>
    out[1].value = 0;<br>
    out[1].decl_range.First = first;<br>
    out[1].decl_range.Last = last;<br>
</span>@@ -1870,7 +1876,8 @@ static void emit_decls( struct ureg_program *ureg )<br>
<span class="">                                ureg->input[i].semantic_index,<br>
                                0,<br>
                                TGSI_WRITEMASK_XYZW,<br>
-                               ureg->input[i].array_id);<br>
+                               ureg->input[i].array_id,<br>
</span>+                               FALSE);<br>
          }<br>
       }<br>
       else {<br>
@@ -1883,7 +1890,7 @@ static void emit_decls( struct ureg_program *ureg )<br>
<span class="">                                   ureg->input[i].semantic_index +<br>
                                   (j - ureg->input[i].first),<br>
                                   0,<br>
-                                  TGSI_WRITEMASK_XYZW, 0);<br>
</span>+                                  TGSI_WRITEMASK_XYZW, 0, FALSE);<br>
             }<br>
          }<br>
       }<br>
@@ -1897,7 +1904,7 @@ static void emit_decls( struct ureg_program *ureg )<br>
<span class="">                          ureg->system_value[i].<wbr>semantic_name,<br>
                          ureg->system_value[i].<wbr>semantic_index,<br>
                          0,<br>
-                         TGSI_WRITEMASK_XYZW, 0);<br>
</span>+                         TGSI_WRITEMASK_XYZW, 0, FALSE);<br>
    }<br>
<br>
    if (ureg->supports_any_inout_<wbr>decl_range) {<br>
@@ -1910,7 +1917,8 @@ static void emit_decls( struct ureg_program *ureg )<br>
<span class="">                             ureg->output[i].semantic_<wbr>index,<br>
                             ureg->output[i].streams,<br>
                             ureg->output[i].usage_mask,<br>
-                            ureg->output[i].array_id);<br>
+                            ureg->output[i].array_id,<br>
+                            ureg->output[i].invariant);<br>
       }<br>
    }<br>
    else {<br>
</span>@@ -1923,7 +1931,9 @@ static void emit_decls( struct ureg_program *ureg )<br>
<span class="">                                ureg->output[i].semantic_index +<br>
                                (j - ureg->output[i].first),<br>
                                ureg->output[i].streams,<br>
-                               ureg->output[i].usage_mask, 0);<br>
+                               ureg->output[i].usage_mask,<br>
+                               0,<br>
+                               ureg->output[i].invariant);<br>
          }<br>
       }<br>
    }<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h<br>
</span>index ac46da55080..4d4a954529b 100644<br>
<span class="">--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h<br>
@@ -79,6 +79,7 @@ struct ureg_dst<br>
    unsigned DimIndirect     : 1;  /* BOOL */<br>
    unsigned Dimension       : 1;  /* BOOL */<br>
    unsigned Saturate        : 1;  /* BOOL */<br>
+   unsigned Invariant       : 1;  /* BOOL */<br>
    int      Index           : 16; /* SINT */<br>
    int      IndirectIndex   : 16; /* SINT */<br>
    unsigned IndirectFile    : 4;  /* TGSI_FILE_ */<br>
@@ -250,7 +251,8 @@ ureg_DECL_output_layout(struct ureg_program *,<br>
                         unsigned index,<br>
                         unsigned usage_mask,<br>
                         unsigned array_id,<br>
-                        unsigned array_size);<br>
+                        unsigned array_size,<br>
</span>+                        boolean invariant);<br>
<span class=""> <br>
 struct ureg_dst<br>
 ureg_DECL_output_masked(struct ureg_program *,<br>
diff --git a/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp<br>
</span>index b321112cf88..c5d7f79f0bc 100644<br>
<span class="">--- a/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp<br>
+++ b/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp<br>
@@ -123,6 +123,7 @@ struct inout_decl {<br>
    enum glsl_interp_mode interp;<br>
    enum glsl_base_type base_type;<br>
    ubyte usage_mask; /* GLSL-style usage-mask,  i.e. single bit per double */<br>
</span>+   bool invariant;<br>
<span class=""> };<br>
<br>
 static struct inout_decl *<br>
@@ -2508,6 +2509,8 @@ glsl_to_tgsi_visitor::visit(<wbr>ir_dereference_variable *ir)<br>
          unsigned num_components;<br>
          num_outputs++;<br>
<br>
+         decl->invariant = var->data.invariant;<br>
+<br>
          if (type_without_array->is_64bit(<wbr>))<br>
             component = component / 2;<br>
          if (type_without_array->vector_<wbr>elements)<br>
</span>@@ -6441,14 +6444,15 @@ st_translate_program(<br>
<span class="">                      (enum tgsi_semantic) outputSemanticName[slot],<br>
                      outputSemanticIndex[slot],<br>
                      decl->gs_out_streams,<br>
-                     slot, tgsi_usage_mask, decl->array_id, decl->size);<br>
-<br>
+                     slot, tgsi_usage_mask, decl->array_id, decl->size, decl->invariant);<br>
+         dst.Invariant = decl->invariant;<br>
          for (unsigned j = 0; j < decl->size; ++j) {<br>
             if (t->outputs[slot + j].File != TGSI_FILE_OUTPUT) {<br>
                /* The ArrayID is set up in dst_register */<br>
                t->outputs[slot + j] = dst;<br>
                t->outputs[slot + j].ArrayID = 0;<br>
                t->outputs[slot + j].Index += j;<br>
+               t->outputs[slot + j].Invariant = decl->invariant;<br>
             }<br>
          }<br>
       }<br>
-- <br>
</span>2.18.0.rc1.244.gcf134e6275-<wbr>goog<br>
<br>
</blockquote></div><br></div>