[Piglit] [PATCH 1/3] util: add infrastructure to look-up glMemoryBarrier() enums via names
Timothy Arceri
timothy.arceri at collabora.com
Wed Dec 9 15:36:50 PST 2015
---
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
More information about the Piglit
mailing list