[Mesa-dev] [PATCH 09/12] mesa: Drop bitfield "enums" from the enum-to-string table.
Eric Anholt
eric at anholt.net
Wed Nov 25 19:10:52 PST 2015
Asking the table for bitfield names doesn't make any sense. For 0x10, do
you want GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV or
GL_COLOR_BUFFER_BIT4_QCOM or GL_POLYGON_STIPPLE_BIT or
GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV? Giving a useful answer would
depend on a whole lot of context.
This also fixes a bad enum table entry, where we chose GL_HINT_BIT instead
of GL_ABGR_EXT for 0x8000, so we can now fix its entry in the enum_strings
test.
---
src/mapi/glapi/gen/gl_enums.py | 19 +++++++++++--------
src/mesa/main/tests/enum_strings.cpp | 25 ++++++++++++-------------
2 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
index c8199e2..5f4ad0b 100644
--- a/src/mapi/glapi/gen/gl_enums.py
+++ b/src/mapi/glapi/gen/gl_enums.py
@@ -272,8 +272,17 @@ _mesa_lookup_prim_by_nr(GLuint nr)
if value > 0xffffffff:
return
- if name.endswith('_BIT'):
- priority += 100
+ # We don't want bitfields in the enum-to-string table --
+ # individual bits have so many names, it's pointless. Note
+ # that we check for power-of-two, since some getters have
+ # "_BITS" in their name, but none have a power-of-two enum
+ # number.
+ if not (value & (value - 1)) and '_BIT' in name:
+ return
+
+ # Also drop the GL_*_ATTRIB_BITS bitmasks.
+ if value == 0xffffffff:
+ return
if value in self.enum_table:
(n, p) = self.enum_table[value]
@@ -489,12 +498,6 @@ _mesa_lookup_prim_by_nr(GLuint nr)
name = enum.get('name')
value = int(enum.get('value'), base=16)
- if name == 'GL_ALL_ATTRIB_BITS':
- # Khronos XML defines this one as 0xffffffff, but Mesa
- # has always had the original definition of
- # 0x000fffff.
- value = 0x000fffff
-
# If the same name ever maps to multiple values, that can
# confuse us. GL_ACTIVE_PROGRAM_EXT is OK to lose because
# we choose GL_ACTIVE PROGRAM instead.
diff --git a/src/mesa/main/tests/enum_strings.cpp b/src/mesa/main/tests/enum_strings.cpp
index 8b92026..bff425a 100644
--- a/src/mesa/main/tests/enum_strings.cpp
+++ b/src/mesa/main/tests/enum_strings.cpp
@@ -58,6 +58,11 @@ const struct enum_info everything[] = {
/* A core enum, that should take precedence over a _BIT. */
{ 0x0100, "GL_ACCUM" },
+ /* An enum with "_BIT" that shouldn't get stripped out when we drop most
+ * "*_BIT" enums.
+ */
+ { 0x0d55, "GL_ALPHA_BITS" },
+
/* An EXT-only extension that we never expect to see show up in ARB/core.
*/
{ 0x8062, "GL_REPLACE_EXT" },
@@ -78,23 +83,17 @@ const struct enum_info everything[] = {
*/
{ 0x850a, "GL_MODELVIEW1_ARB" },
- /* This should be included, but it's value collides with GL_HINT_BIT. The
- * generator script picks GL_HINT_BIT because it prefers names that lack an
- * extension suffix.
- */
-/* { 0x8000, "GL_ABGR_EXT" }, */
- { 0x8000, "GL_HINT_BIT" },
+ /* An EXT-only enum that should take precedence over a _BIT. */
+ { 0x8000, "GL_ABGR_EXT" },
/* An unusually-large enum */
{ 0x19262, "GL_RASTER_POSITION_UNCLIPPED_IBM" },
- /* A bitmask masquerading as an enum */
- { 0x00080000, "GL_SCISSOR_BIT" },
-
- /* A bitfield where Mesa uses a different value from Khronos. */
- { 0x000fffff, "GL_ALL_ATTRIB_BITS" },
-
- /* A bitfield in the table, where we fail to return its string anyway! */
+ /* Bitfields like GL_SCISSOR_BIT and GL_ALL_ATTRIB_BITS should not appear
+ * in the table.
+ */
+ { 0x00080000, "0x80000" },
+ { 0x000fffff, "0xfffff" },
{ (int)0xffffffff, "0xffffffff" },
{ 0, NULL }
--
2.6.2
More information about the mesa-dev
mailing list