[Piglit] [PATCH 1/3] util: add infrastructure to look-up glMemoryBarrier() enums via names

Francisco Jerez currojerez at riseup.net
Fri Dec 11 05:59:35 PST 2015


Jordan Justen <jordan.l.justen at intel.com> writes:

> Thanks for looking at this! I wanted to add the memory barrier command
> to shader_runner to, but I also found that
> piglit_get_gl_enum_from_name would not handle those strings.
>
> My question is, why not just make piglit_get_gl_enum_from_name handle
> more strings?
>

Because the barrier set is not an enum but a bitfield.  They're
different index spaces and are allowed to overlap, and they're even
different data types in the GL API -- piglit_get_gl_enum_from_name has
the wrong type signature.

> I think the enum=>string translation is ambiguous, but string=>enum
> should not be, right?

The enum->string translation being ambiguous sounds like a deal-breaker
to me.  What should piglit_get_gl_enum_name() do now if you pass one of
the ambiguous "enums"?

v1 of patches 1-2 are:

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

>
> -Jordan
>
> On 2015-12-09 15:36:50, Timothy Arceri wrote:
>> ---
>>  tests/util/gen_dispatch.py                | 14 +++++++++++++-
>>  tests/util/piglit-util-gl-enum-gen.c.mako | 24 ++++++++++++++++++++++++
>>  tests/util/piglit-util-gl.h               |  3 +++
>>  3 files changed, 40 insertions(+), 1 deletion(-)
>> 
>> diff --git a/tests/util/gen_dispatch.py b/tests/util/gen_dispatch.py
>> index 80099ad..dd05687 100644
>> --- a/tests/util/gen_dispatch.py
>> +++ b/tests/util/gen_dispatch.py
>> @@ -144,12 +144,14 @@ class EnumCode(object):
>>          enums = cls.get_enums_in_default_namespace(gl_registry)
>>          unique_enums = cls.get_unique_enums(enums)
>>          enums_by_name = cls.get_enums_by_name(enums)
>> +        memory_barrier = cls.get_enums_in_memory_barrier_group(gl_registry)
>>          render_template(
>>              cls.C_TEMPLATE,
>>              out_dir,
>>              gl_registry=gl_registry,
>>              sorted_unique_enums_in_default_namespace=unique_enums,
>> -            sorted_enums_by_name=enums_by_name)
>> +            sorted_enums_by_name=enums_by_name,
>> +            sorted_by_name_memory_barrier_enums=memory_barrier)
>>  
>>      @classmethod
>>      def get_enums_in_default_namespace(cls, gl_registry):
>> @@ -161,6 +163,16 @@ class EnumCode(object):
>>          return enums
>>  
>>      @classmethod
>> +    def get_enums_in_memory_barrier_group(cls, gl_registry):
>> +        enums = []
>> +        for enum_group in gl_registry.enum_groups:
>> +            if enum_group.name == 'MemoryBarrierMask':
>> +               if enum_group.type == 'bitmask':
>> +                    for enum in enum_group.enums:
>> +                        enums.append(enum)
>> +        return cls.get_enums_by_name(enums)
>> +
>> +    @classmethod
>>      def get_unique_enums(cls, enums):
>>          def append_enum_if_new_value(enum_list, enum):
>>              if enum_list[-1].num_value < enum.num_value:
>> diff --git a/tests/util/piglit-util-gl-enum-gen.c.mako b/tests/util/piglit-util-gl-enum-gen.c.mako
>> index 9a0fff8..04b79b8 100644
>> --- a/tests/util/piglit-util-gl-enum-gen.c.mako
>> +++ b/tests/util/piglit-util-gl-enum-gen.c.mako
>> @@ -64,6 +64,30 @@ compare_enum_name(const void *a, const void *b)
>>  }
>>  
>>  GLenum
>> +piglit_get_gl_memory_barrier_enum_from_name(const char *name)
>> +{
>> +>-------static const struct gl_name_to_enum names[] = {
>> +% for enum in sorted_by_name_memory_barrier_enums:
>> +>------->-------{ "${enum.name}", ${enum.c_num_literal} },
>> +% endfor
>> +>-------};
>> +>-------struct gl_name_to_enum key = { name, 0 };
>> +>-------struct gl_name_to_enum *result;
>> +
>> +>-------result = (struct gl_name_to_enum*)
>> +>------->-------bsearch(&key,
>> +>------->-------        names, ARRAY_SIZE(names), sizeof names[0],
>> +>------->-------        compare_enum_name);
>> +
>> +>-------if (result == NULL) {
>> +>------->-------fprintf(stderr, "No known enum named %s!\n", name);
>> +>------->-------abort();
>> +>-------}
>> +
>> +>-------return result->_enum;
>> +}
>> +
>> +GLenum
>>  piglit_get_gl_enum_from_name(const char *name)
>>  {
>>  >-------static const struct gl_name_to_enum names[] = {
>> diff --git a/tests/util/piglit-util-gl.h b/tests/util/piglit-util-gl.h
>> index 5a8c82b..4ba0aa3 100644
>> --- a/tests/util/piglit-util-gl.h
>> +++ b/tests/util/piglit-util-gl.h
>> @@ -95,6 +95,9 @@ const char *piglit_get_gl_enum_name(GLenum param);
>>   */
>>  GLenum piglit_get_gl_enum_from_name(const char *name);
>>  
>> +GLenum
>> +piglit_get_gl_memory_barrier_enum_from_name(const char *name);
>> +
>>  /**
>>   * \brief Convert a GL primitive type enum value to a string.
>>   *
>> -- 
>> 2.4.3
>> 
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/piglit
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20151211/6c80db63/attachment-0001.sig>


More information about the Piglit mailing list