<div dir="ltr">HI Ilia<br><div class="gmail_extra"><br><div class="gmail_quote">2015-08-14 1:31 GMT-03:00 Ilia Mirkin <span dir="ltr"><<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Aug 14, 2015 at 12:25 AM, Marcos Souza<br>
<span class=""><<a href="mailto:marcos.souza.org@gmail.com">marcos.souza.org@gmail.com</a>> wrote:<br>
> Hi Ilia,<br>
><br>
> 2015-08-14 1:02 GMT-03:00 Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>>:<br>
>><br>
>> On Thu, Aug 13, 2015 at 11:55 PM, Marcos Souza<br>
>> <<a href="mailto:marcos.souza.org@gmail.com">marcos.souza.org@gmail.com</a>> wrote:<br>
>> > Hi Ilia,<br>
>> ><br>
>> > So i found the point here it addrs that double brackets, and the<br>
>> > following<br>
>> > patch solves it, but this is a right solution? If someone could guide me<br>
>> > here, I could fix it :)<br>
>> ><br>
>> > diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c<br>
>> > b/src/gallium/auxiliary/tgsi/tgsi_dump.c<br>
>> > index 8ceb5b4..046471e 100644<br>
>> > --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c<br>
>> > +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c<br>
>> > @@ -302,10 +302,14 @@ iter_declaration(<br>
>> >        TXT("[]");<br>
>> >     }<br>
>> ><br>
>> > -   if (decl->Declaration.Dimension) {<br>
>><br>
>> The issue is that the declaration is getting a dimension set by the<br>
>> parser, which in turn is causing it to print funny. It shouldn't be<br>
>> getting a dimension in the first place for those.<br>
><br>
><br>
> The following patch fix the problem, is it the right place to put it?<br>
<br>
</span>I don't think so. Just glanced at the code, look at<br>
<br>
parse_register_dcl<br>
<br>
      /* for geometry shader we don't really care about<br>
       * the first brackets it's always the size of the<br>
       * input primitive. so we want to declare just<br>
       * the index relevant to the semantics which is in<br>
       * the second bracket */<br>
      if (ctx->processor == TGSI_PROCESSOR_GEOMETRY && *file ==<br>
TGSI_FILE_INPUT) {<br>
         brackets[0] = brackets[1];<br>
         *num_brackets = 1;<br>
      }<br>
<br>
Basically you need to extend this logic to similarly exclude<br>
<br>
(a) tess ctrl inputs and outputs<br>
(b) tess eval inputs<br>
<br>
Technically you need to exclude patch/tessinner/tessouter from that,<br>
but in practice they won't have an extra set of brackets either.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>Sorry for flooding the list, but I'm relaly excited about it :)<br><br></div><div>So, this is the change you asked. It also solved the problem:<br>diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c<br>index 8647e4e..95c1daf 100644<br>--- a/src/gallium/auxiliary/tgsi/tgsi_text.c<br>+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c<br>@@ -684,7 +684,12 @@ parse_register_dcl(<br>        * input primitive. so we want to declare just<br>        * the index relevant to the semantics which is in<br>        * the second bracket */<br>-      if (ctx->processor == TGSI_PROCESSOR_GEOMETRY && *file == TGSI_FILE_INPUT) {<br>+<br>+      /* similarly from tessalation */<br>+      int exclude = (ctx->processor == TGSI_PROCESSOR_TESS_EVAL && *file == TGSI_FILE_INPUT) ||<br>+          (ctx->processor == TGSI_PROCESSOR_TESS_CTRL && (*file == TGSI_FILE_INPUT ||<br>+             *file == TGSI_FILE_OUTPUT));<br>+      if ((ctx->processor == TGSI_PROCESSOR_GEOMETRY && *file == TGSI_FILE_INPUT) || exclude) {<br>          brackets[0] = brackets[1];<br>          *num_brackets = 1;<br>       } else {<br><br></div><div>What do you think Ilia?<br><br></div><div>Thanks!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
><br>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
> b/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
> index 8647e4e..f734d58 100644<br>
> --- a/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
> +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
> @@ -1185,7 +1185,10 @@ static boolean parse_declaration( struct<br>
> translate_ctx *ctx )<br>
>        decl.Range.First = brackets[1].first;<br>
>        decl.Range.Last = brackets[1].last;<br>
><br>
> -      decl.Declaration.Dimension = 1;<br>
> +      if (!(ctx->processor == TGSI_PROCESSOR_TESS_CTRL ||<br>
> +         ctx->processor == TGSI_PROCESSOR_TESS_EVAL))<br>
> +         decl.Declaration.Dimension = 1;<br>
> +<br>
>        decl.Dim.Index2D = brackets[0].first;<br>
>     }<br>
><br>
><br>
><br>
>><br>
>><br>
>> > -      CHR('[');<br>
>> > -      SID(decl->Dim.Index2D);<br>
>> > -      CHR(']');<br>
>> > +   /* FIXME: patched version could have tree dimensions?? */<br>
>> > +   if (patch && (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL<br>
>> > ||<br>
>> > +      iter->processor.Processor == TGSI_PROCESSOR_TESS_EVAL)) {<br>
>> > +      if (decl->Declaration.Dimension) {<br>
>> > +         CHR('[');<br>
>> > +         SID(decl->Dim.Index2D);<br>
>> > +         CHR(']');<br>
>> > +      }<br>
>> >     }<br>
>> ><br>
>> > After this patch, tess_eval output is the same before and after, but<br>
>> > tess_ctrl is a little different:<br>
>> > [marcos@x mesa]$ diff tess_ctrl tess_ctrl_new<br>
>> > 29c29<br>
>> > <  15: LRP OUT[ADDR[1].x][3], TEMP[1].xxxx, TEMP[3], TEMP[2]<br>
>> > ---<br>
>> >>  15: LRP OUT[0][3], TEMP[1].xxxx, TEMP[3], TEMP[2]<br>
>> > 40c40<br>
>> > <  26: MOV OUT[ADDR[1].x][2], TEMP[0]<br>
>> > ---<br>
>> >>  26: MOV OUT[0][2], TEMP[0]<br>
>> ><br>
>> > I'll try to investigate and send a new patch in the weekend.<br>
>> ><br>
>> > Thanks for all help Ilia and others!<br>
>> ><br>
>> > 2015-08-13 18:43 GMT-03:00 Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>>:<br>
>> >><br>
>> >> [mesa-dev readded, please don't drop CC's]<br>
>> >><br>
>> >> I found it by feeding the shader to nouveau_compiler with<br>
>> >> NV50_PROG_DEBUG=1 set, which dumps the input tgsi. Those two should<br>
>> >> match up.<br>
>> >><br>
>> >> On Thu, Aug 13, 2015 at 5:39 PM, Marcos Paulo de souza<br>
>> >> <<a href="mailto:marcos.souza.org@gmail.com">marcos.souza.org@gmail.com</a>> wrote:<br>
>> >> > Hi Ilia,<br>
>> >> ><br>
>> >> > So, how can I test it? Do I need to especify some patameter to verify<br>
>> >> > this<br>
>> >> > type of problem?<br>
>> >> ><br>
>> >> > Thanks for the quick revision!<br>
>> >> ><br>
>> >> ><br>
>> >> > Em 13-08-2015 16:03, Ilia Mirkin escreveu:<br>
>> >> >><br>
>> >> >> Hi Macros,<br>
>> >> >><br>
>> >> >> Looks like it's not parsed in exactly right. It will parse something<br>
>> >> >> like<br>
>> >> >><br>
>> >> >> TESS_EVAL<br>
>> >> >> PROPERTY TES_PRIM_MODE 7<br>
>> >> >> PROPERTY TES_SPACING 2<br>
>> >> >> PROPERTY TES_VERTEX_ORDER_CW 0<br>
>> >> >> PROPERTY TES_POINT_MODE 0<br>
>> >> >> DCL IN[][0], GENERIC[0]<br>
>> >> >> DCL IN[][1], GENERIC[1]<br>
>> >> >><br>
>> >> >> as<br>
>> >> >><br>
>> >> >> TESS_EVAL<br>
>> >> >> PROPERTY TES_PRIM_MODE 7<br>
>> >> >> PROPERTY TES_SPACING 2<br>
>> >> >> PROPERTY TES_VERTEX_ORDER_CW 0<br>
>> >> >> PROPERTY TES_POINT_MODE 0<br>
>> >> >> DCL IN[][0][0], GENERIC[0]<br>
>> >> >> DCL IN[][0][1], GENERIC[1]<br>
>> >> >><br>
>> >> >> Perhaps the same issue happens for geometry shaders, but that<br>
>> >> >> doesn't<br>
>> >> >> make it right :) You might have to look at the printing logic to get<br>
>> >> >> a<br>
>> >> >> better understanding of what's going wrong.<br>
>> >> >><br>
>> >> >> Also you should send patches to nouveau separately from patches to<br>
>> >> >> the<br>
>> >> >> rest of the infra. Ideally this would have been 2 patches, e.g.<br>
>> >> >><br>
>> >> >> tgsi: set implicit array size for tess stages<br>
>> >> >> nouveau: recognize tess stages in nouveau_compiler<br>
>> >> >><br>
>> >> >> or something like that.<br>
>> >> >><br>
>> >> >> On Wed, Aug 12, 2015 at 9:25 PM, Marcos Paulo de Souza<br>
>> >> >> <<a href="mailto:marcos.souza.org@gmail.com">marcos.souza.org@gmail.com</a>> wrote:<br>
>> >> >>><br>
>> >> >>> From: Marcos Paulo de Souza <<a href="mailto:marcos.souza.org@gmail.com">marcos.souza.org@gmail.com</a>><br>
>> >> >>><br>
>> >> >>> Signed-off-by: Marcos Paulo de Souza <<a href="http://marcos.souza.org" rel="noreferrer" target="_blank">marcos.souza.org</a>><br>
>> >> >>> Suggested-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>><br>
>> >> >>> ---<br>
>> >> >>>   src/gallium/auxiliary/tgsi/tgsi_text.c         | 6 +++++-<br>
>> >> >>>   src/gallium/drivers/nouveau/nouveau_compiler.c | 4 ++++<br>
>> >> >>>   2 files changed, 9 insertions(+), 1 deletion(-)<br>
>> >> >>><br>
>> >> >>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
>> >> >>> b/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
>> >> >>> index a6675c5..8647e4e 100644<br>
>> >> >>> --- a/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
>> >> >>> +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c<br>
>> >> >>> @@ -259,7 +259,7 @@ struct translate_ctx<br>
>> >> >>>      struct tgsi_token *tokens_end;<br>
>> >> >>>      struct tgsi_header *header;<br>
>> >> >>>      unsigned processor : 4;<br>
>> >> >>> -   int implied_array_size : 5;<br>
>> >> >>> +   int implied_array_size : 6;<br>
>> >> >>>      unsigned num_immediates;<br>
>> >> >>>   };<br>
>> >> >>><br>
>> >> >>> @@ -1623,6 +1623,10 @@ static boolean translate( struct<br>
>> >> >>> translate_ctx<br>
>> >> >>> *ctx )<br>
>> >> >>>      if (!parse_header( ctx ))<br>
>> >> >>>         return FALSE;<br>
>> >> >>><br>
>> >> >>> +   if (ctx->processor == TGSI_PROCESSOR_TESS_CTRL ||<br>
>> >> >>> +       ctx->processor == TGSI_PROCESSOR_TESS_EVAL)<br>
>> >> >>> +       ctx->implied_array_size = 32 ;<br>
>> >> >>> +<br>
>> >> >>>      while (*ctx->cur != '\0') {<br>
>> >> >>>         uint label_val = 0;<br>
>> >> >>>         if (!eat_white( &ctx->cur )) {<br>
>> >> >>> diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c<br>
>> >> >>> b/src/gallium/drivers/nouveau/nouveau_compiler.c<br>
>> >> >>> index 8660498..495450b 100644<br>
>> >> >>> --- a/src/gallium/drivers/nouveau/nouveau_compiler.c<br>
>> >> >>> +++ b/src/gallium/drivers/nouveau/nouveau_compiler.c<br>
>> >> >>> @@ -190,6 +190,10 @@ main(int argc, char *argv[])<br>
>> >> >>>         type = PIPE_SHADER_GEOMETRY;<br>
>> >> >>>      else if (!strncmp(text, "COMP", 4))<br>
>> >> >>>         type = PIPE_SHADER_COMPUTE;<br>
>> >> >>> +   else if (!strncmp(text, "TESS_CTRL", 9))<br>
>> >> >>> +      type = PIPE_SHADER_TESS_CTRL;<br>
>> >> >>> +   else if (!strncmp(text, "TESS_EVAL", 9))<br>
>> >> >>> +      type = PIPE_SHADER_TESS_EVAL;<br>
>> >> >>>      else {<br>
>> >> >>>         _debug_printf("Unrecognized TGSI header\n");<br>
>> >> >>>         return 1;<br>
>> >> >>> --<br>
>> >> >>> 2.4.3<br>
>> >> >>><br>
>> >> >>> _______________________________________________<br>
>> >> >>> mesa-dev mailing list<br>
>> >> >>> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
>> >> >>> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
>> >> ><br>
>> >> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > Att,<br>
>> ><br>
>> > Marcos Paulo de Souza<br>
>> > Github: <a href="https://github.com/marcosps/" rel="noreferrer" target="_blank">https://github.com/marcosps/</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Att,<br>
><br>
> Marcos Paulo de Souza<br>
> Github: <a href="https://github.com/marcosps/" rel="noreferrer" target="_blank">https://github.com/marcosps/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Att,<br><br>Marcos Paulo de Souza<br>Github: <a href="https://github.com/marcosps/" target="_blank">https://github.com/marcosps/</a><br></div></div>
</div></div>