[Mesa-dev] [PATCH v2] glsl: add packed varyings to program resource list
Ilia Mirkin
imirkin at alum.mit.edu
Thu Sep 10 23:32:38 PDT 2015
On Fri, Sep 11, 2015 at 2:18 AM, Tapani Pälli <tapani.palli at intel.com> wrote:
> On 09/11/2015 09:15 AM, Ilia Mirkin wrote:
>>
>> On Fri, Sep 11, 2015 at 2:12 AM, Tapani Pälli <tapani.palli at intel.com>
>> wrote:
>>>
>>> This makes sure that user is still able to query properties about
>>> variables that have gotten packed by lower_packed_varyings pass.
>>>
>>> Fixes following OpenGL ES 3.1 test:
>>> ES31-CTS.program_interface_query.separate-programs-vertex
>>>
>>> v2: fix 'name included in packed list' check (Ilia Mirkin)
>>>
>>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>>> ---
>>> src/glsl/linker.cpp | 74
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++---
>>> 1 file changed, 70 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
>>> index 94f847e..d8afb26 100644
>>> --- a/src/glsl/linker.cpp
>>> +++ b/src/glsl/linker.cpp
>>> @@ -3114,6 +3114,29 @@ add_program_resource(struct gl_shader_program
>>> *prog, GLenum type,
>>> return true;
>>> }
>>>
>>> +/* Function checks if a variable var is a packed varying and
>>> + * if given name is part of packed varying's list.
>>> + *
>>> + * If a variable is a packed varying, it has a name like
>>> + * 'packed:a,b,c' where a, b and c are separate variables.
>>> + */
>>> +static bool
>>> +included_in_packed_varying(ir_variable *var, const char *name)
>>> +{
>>> + if (strncmp(var->name, "packed:", 7) != 0)
>>> + return false;
>>> +
>>> + const char *name_in_list = strstr(var->name, name);
>>> + const char *head = name_in_list - 1;
>>> + const char *tail = name_in_list + strlen(name);
>>> +
>>> + if (name_in_list &&
>>> + (*head == ':' || *head == ',') &&
>>> + (*tail == '\0' || *tail == ','))
>>
>>
>> So... in the case "ab,b" and you search for 'b', it'll find 'ab' and
>> reject it.
>
>
> Huh, this seems more complex that I thought .. almost a case for proper
> parser rather than a helper function.
FWIW there's strtok_r(). BTW, make sure to skip the "packed:" bit of
var->name. And be thankful that variable names can't contain commas in
them :)
More information about the mesa-dev
mailing list