On Wed, Jun 5, 2013 at 10:11 PM, Roland Scheidegger <span dir="ltr"><<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 06.06.2013 04:16, schrieb Roland Scheidegger:<br>
<div><div class="h5">> Am 06.06.2013 02:52, schrieb Brian Paul:<br>
>> On 06/05/2013 05:44 PM, <a href="mailto:sroland@vmware.com">sroland@vmware.com</a> wrote:<br>
>>> From: Roland Scheidegger <<a href="mailto:sroland@vmware.com">sroland@vmware.com</a>><br>
>>><br>
>>> Also report if a shader writes the layer semantic<br>
>>> ---<br>
>>>   src/gallium/auxiliary/draw/draw_context.c |    2 +-<br>
>>>   src/gallium/auxiliary/tgsi/tgsi_scan.c    |    5 +++++<br>
>>>   src/gallium/auxiliary/tgsi/tgsi_scan.h    |    1 +<br>
>>>   src/gallium/auxiliary/tgsi/tgsi_strings.c |    1 +<br>
>>>   4 files changed, 8 insertions(+), 1 deletion(-)<br>
>>><br>
>>> diff --git a/src/gallium/auxiliary/draw/draw_context.c<br>
>>> b/src/gallium/auxiliary/draw/draw_context.c<br>
>>> index 58ce270..35063b9 100644<br>
>>> --- a/src/gallium/auxiliary/draw/draw_context.c<br>
>>> +++ b/src/gallium/auxiliary/draw/draw_context.c<br>
>>> @@ -548,7 +548,7 @@ draw_get_shader_info(const struct draw_context *draw)<br>
>>>    * function to find those attributes.<br>
>>>    *<br>
>>>    * -1 is returned if the attribute is not found since this is<br>
>>> - * an undefined situtation. Note, that zero is valid and can<br>
>>> + * an undefined situation. Note, that zero is valid and can<br>
>>>    * be used by any of the attributes, because position is not<br>
>>>    * required to be attribute 0 or even at all present.<br>
>>>    */<br>
>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c<br>
>>> b/src/gallium/auxiliary/tgsi/tgsi_scan.c<br>
>>> index 0230267..d331257 100644<br>
>>> --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c<br>
>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c<br>
>>> @@ -217,6 +217,11 @@ tgsi_scan_shader(const struct tgsi_token *tokens,<br>
>>>                         TGSI_SEMANTIC_VIEWPORT_INDEX) {<br>
>>>                        info->writes_viewport_index = TRUE;<br>
>>>                     }<br>
>>> +                  if (procType == TGSI_PROCESSOR_GEOMETRY &&<br>
>>> +                      fulldecl->Semantic.Name ==<br>
>>> +                      TGSI_SEMANTIC_LAYER) {<br>
>>> +                     info->writes_layer = TRUE;<br>
>>> +                  }<br>
>>>                  }<br>
>>><br>
>>>                }<br>
>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h<br>
>>> b/src/gallium/auxiliary/tgsi/tgsi_scan.h<br>
>>> index 676abf0..a5b7024 100644<br>
>>> --- a/src/gallium/auxiliary/tgsi/tgsi_scan.h<br>
>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h<br>
>>> @@ -76,6 +76,7 @@ struct tgsi_shader_info<br>
>>>      boolean pixel_center_integer;<br>
>>>      boolean color0_writes_all_cbufs;<br>
>>>      boolean writes_viewport_index;<br>
>>> +   boolean writes_layer;<br>
>>><br>
>>>      unsigned num_written_clipdistance;<br>
>>>      /**<br>
>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c<br>
>>> b/src/gallium/auxiliary/tgsi/tgsi_strings.c<br>
>>> index 6abf927..625107c 100644<br>
>>> --- a/src/gallium/auxiliary/tgsi/tgsi_strings.c<br>
>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c<br>
>>> @@ -80,6 +80,7 @@ const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =<br>
>>>      "TEXCOORD",<br>
>>>      "PCOORD",<br>
>>>      "VIEWPORT_INDEX"<br>
>>> +   "LAYER"<br>
>>>   };<br>
>>><br>
>>>   const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =<br>
>>><br>
>><br>
>> Hmm, there's a STATIC_ASSERT later in the file which should have<br>
>> detected a missing string in the array.  I bet we need to remove the<br>
>> TGSI_SEMANTIC_COUNT from the array size declaration to make that work.<br>
>> Can you check into that.<br>
> That is odd indeed. The patch was actually buggy (no comma). All of<br>
> these name arrays there are indeed fixed size which looks like defeating<br>
> the purpose of the STATIC_ASSERT. Even if I change this though it never<br>
> triggers no matter what's in there. Hmm.<br>
><br>
<br>
</div></div>So this can't work. The size of these arrays is declared elsewhere, what<br>
we put in in this file here doesn't really matter for the Elements used<br>
in STATIC_ASSERT at all. And we can't just make the size dynamic in<br>
there in tgsi_string.h as sizeof() used for Elements can't work with<br>
that. So I've no idea how to make this actually work.<br></blockquote><div><br>OK, I see the problem now.  I'm going to post a patch which replaces the tgsi_file_names[] array with a function.  I think this is nicer and it gives us a working static assertions.<br>
<br>If you like it, I could create a bugzilla entry/task for someone to give the same treatment to the other tgsi string arrays.<br><br>-Brian<br> <br></div></div>