[Mesa-dev] [PATCH 07/20] mesa: don't assign numbers to vertex attrib enums manually
Ian Romanick
idr at freedesktop.org
Wed Nov 22 22:05:10 UTC 2017
Patches 7, 8, and 9 are
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
On 11/21/2017 10:01 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> I plan to remove one of them.
> ---
> src/compiler/shader_enums.h | 68 ++++++++++++++--------------
> src/mesa/tnl/t_context.h | 106 ++++++++++++++++++++++----------------------
> src/mesa/vbo/vbo_attrib.h | 92 +++++++++++++++++++-------------------
> 3 files changed, 133 insertions(+), 133 deletions(-)
>
> diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
> index 9d229d4..17b236e 100644
> --- a/src/compiler/shader_enums.h
> +++ b/src/compiler/shader_enums.h
> @@ -67,54 +67,54 @@ const char *_mesa_shader_stage_to_abbrev(unsigned stage);
>
> /**
> * Indexes for vertex program attributes.
> * GL_NV_vertex_program aliases generic attributes over the conventional
> * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
> * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
> * generic attributes are distinct/separate).
> */
> typedef enum
> {
> - VERT_ATTRIB_POS = 0,
> - VERT_ATTRIB_WEIGHT = 1,
> - VERT_ATTRIB_NORMAL = 2,
> - VERT_ATTRIB_COLOR0 = 3,
> - VERT_ATTRIB_COLOR1 = 4,
> - VERT_ATTRIB_FOG = 5,
> - VERT_ATTRIB_COLOR_INDEX = 6,
> - VERT_ATTRIB_EDGEFLAG = 7,
> - VERT_ATTRIB_TEX0 = 8,
> - VERT_ATTRIB_TEX1 = 9,
> - VERT_ATTRIB_TEX2 = 10,
> - VERT_ATTRIB_TEX3 = 11,
> - VERT_ATTRIB_TEX4 = 12,
> - VERT_ATTRIB_TEX5 = 13,
> - VERT_ATTRIB_TEX6 = 14,
> - VERT_ATTRIB_TEX7 = 15,
> - VERT_ATTRIB_POINT_SIZE = 16,
> - VERT_ATTRIB_GENERIC0 = 17,
> - VERT_ATTRIB_GENERIC1 = 18,
> - VERT_ATTRIB_GENERIC2 = 19,
> - VERT_ATTRIB_GENERIC3 = 20,
> - VERT_ATTRIB_GENERIC4 = 21,
> - VERT_ATTRIB_GENERIC5 = 22,
> - VERT_ATTRIB_GENERIC6 = 23,
> - VERT_ATTRIB_GENERIC7 = 24,
> - VERT_ATTRIB_GENERIC8 = 25,
> - VERT_ATTRIB_GENERIC9 = 26,
> - VERT_ATTRIB_GENERIC10 = 27,
> - VERT_ATTRIB_GENERIC11 = 28,
> - VERT_ATTRIB_GENERIC12 = 29,
> - VERT_ATTRIB_GENERIC13 = 30,
> - VERT_ATTRIB_GENERIC14 = 31,
> - VERT_ATTRIB_GENERIC15 = 32,
> - VERT_ATTRIB_MAX = 33
> + VERT_ATTRIB_POS,
> + VERT_ATTRIB_WEIGHT,
> + VERT_ATTRIB_NORMAL,
> + VERT_ATTRIB_COLOR0,
> + VERT_ATTRIB_COLOR1,
> + VERT_ATTRIB_FOG,
> + VERT_ATTRIB_COLOR_INDEX,
> + VERT_ATTRIB_EDGEFLAG,
> + VERT_ATTRIB_TEX0,
> + VERT_ATTRIB_TEX1,
> + VERT_ATTRIB_TEX2,
> + VERT_ATTRIB_TEX3,
> + VERT_ATTRIB_TEX4,
> + VERT_ATTRIB_TEX5,
> + VERT_ATTRIB_TEX6,
> + VERT_ATTRIB_TEX7,
> + VERT_ATTRIB_POINT_SIZE,
> + VERT_ATTRIB_GENERIC0,
> + VERT_ATTRIB_GENERIC1,
> + VERT_ATTRIB_GENERIC2,
> + VERT_ATTRIB_GENERIC3,
> + VERT_ATTRIB_GENERIC4,
> + VERT_ATTRIB_GENERIC5,
> + VERT_ATTRIB_GENERIC6,
> + VERT_ATTRIB_GENERIC7,
> + VERT_ATTRIB_GENERIC8,
> + VERT_ATTRIB_GENERIC9,
> + VERT_ATTRIB_GENERIC10,
> + VERT_ATTRIB_GENERIC11,
> + VERT_ATTRIB_GENERIC12,
> + VERT_ATTRIB_GENERIC13,
> + VERT_ATTRIB_GENERIC14,
> + VERT_ATTRIB_GENERIC15,
> + VERT_ATTRIB_MAX
> } gl_vert_attrib;
>
> const char *gl_vert_attrib_name(gl_vert_attrib attrib);
>
> /**
> * Symbolic constats to help iterating over
> * specific blocks of vertex attributes.
> *
> * VERT_ATTRIB_FF
> * includes all fixed function attributes as well as
> diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
> index e7adb5f..67a87f2 100644
> --- a/src/mesa/tnl/t_context.h
> +++ b/src/mesa/tnl/t_context.h
> @@ -69,84 +69,84 @@
> * number of bits allocated for these numbers in places like vertex
> * program instruction formats and register layouts.
> */
> /* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for
> * GLSL vertex shader which cannot be aliased with conventional vertex attribs.
> * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give
> * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE*
> * attribs want (16).
> */
> enum {
> - _TNL_ATTRIB_POS = 0,
> - _TNL_ATTRIB_WEIGHT = 1,
> - _TNL_ATTRIB_NORMAL = 2,
> - _TNL_ATTRIB_COLOR0 = 3,
> - _TNL_ATTRIB_COLOR1 = 4,
> - _TNL_ATTRIB_FOG = 5,
> - _TNL_ATTRIB_COLOR_INDEX = 6,
> - _TNL_ATTRIB_EDGEFLAG = 7,
> - _TNL_ATTRIB_TEX0 = 8,
> - _TNL_ATTRIB_TEX1 = 9,
> - _TNL_ATTRIB_TEX2 = 10,
> - _TNL_ATTRIB_TEX3 = 11,
> - _TNL_ATTRIB_TEX4 = 12,
> - _TNL_ATTRIB_TEX5 = 13,
> - _TNL_ATTRIB_TEX6 = 14,
> - _TNL_ATTRIB_TEX7 = 15,
> -
> - _TNL_ATTRIB_GENERIC0 = 17, /* doesn't really exist! */
> - _TNL_ATTRIB_GENERIC1 = 18,
> - _TNL_ATTRIB_GENERIC2 = 19,
> - _TNL_ATTRIB_GENERIC3 = 20,
> - _TNL_ATTRIB_GENERIC4 = 21,
> - _TNL_ATTRIB_GENERIC5 = 22,
> - _TNL_ATTRIB_GENERIC6 = 23,
> - _TNL_ATTRIB_GENERIC7 = 24,
> - _TNL_ATTRIB_GENERIC8 = 25,
> - _TNL_ATTRIB_GENERIC9 = 26,
> - _TNL_ATTRIB_GENERIC10 = 27,
> - _TNL_ATTRIB_GENERIC11 = 28,
> - _TNL_ATTRIB_GENERIC12 = 29,
> - _TNL_ATTRIB_GENERIC13 = 30,
> - _TNL_ATTRIB_GENERIC14 = 31,
> - _TNL_ATTRIB_GENERIC15 = 32,
> + _TNL_ATTRIB_POS,
> + _TNL_ATTRIB_WEIGHT,
> + _TNL_ATTRIB_NORMAL,
> + _TNL_ATTRIB_COLOR0,
> + _TNL_ATTRIB_COLOR1,
> + _TNL_ATTRIB_FOG,
> + _TNL_ATTRIB_COLOR_INDEX,
> + _TNL_ATTRIB_EDGEFLAG,
> + _TNL_ATTRIB_TEX0,
> + _TNL_ATTRIB_TEX1,
> + _TNL_ATTRIB_TEX2,
> + _TNL_ATTRIB_TEX3,
> + _TNL_ATTRIB_TEX4,
> + _TNL_ATTRIB_TEX5,
> + _TNL_ATTRIB_TEX6,
> + _TNL_ATTRIB_TEX7,
> +
> + /* This is really a VARYING_SLOT, not an attrib. Need to fix
> + * tnl to understand the difference.
> + */
> + _TNL_ATTRIB_POINTSIZE,
> +
> + _TNL_ATTRIB_GENERIC0, /* doesn't really exist! */
> + _TNL_ATTRIB_GENERIC1,
> + _TNL_ATTRIB_GENERIC2,
> + _TNL_ATTRIB_GENERIC3,
> + _TNL_ATTRIB_GENERIC4,
> + _TNL_ATTRIB_GENERIC5,
> + _TNL_ATTRIB_GENERIC6,
> + _TNL_ATTRIB_GENERIC7,
> + _TNL_ATTRIB_GENERIC8,
> + _TNL_ATTRIB_GENERIC9,
> + _TNL_ATTRIB_GENERIC10,
> + _TNL_ATTRIB_GENERIC11,
> + _TNL_ATTRIB_GENERIC12,
> + _TNL_ATTRIB_GENERIC13,
> + _TNL_ATTRIB_GENERIC14,
> + _TNL_ATTRIB_GENERIC15,
> +
> + _TNL_ATTRIB_MAX,
>
> /* These alias with the generics, but they are not active
> * concurrently, so it's not a problem. The TNL module
> * doesn't have to do anything about this as this is how they
> * are passed into the _draw_prims callback.
> *
> * When we generate fixed-function replacement programs (in
> * t_vp_build.c currently), they refer to the appropriate
> * generic attribute in order to pick up per-vertex material
> * data.
> */
> - _TNL_ATTRIB_MAT_FRONT_AMBIENT = 17,
> - _TNL_ATTRIB_MAT_BACK_AMBIENT = 18,
> - _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 19,
> - _TNL_ATTRIB_MAT_BACK_DIFFUSE = 20,
> - _TNL_ATTRIB_MAT_FRONT_SPECULAR = 21,
> - _TNL_ATTRIB_MAT_BACK_SPECULAR = 22,
> - _TNL_ATTRIB_MAT_FRONT_EMISSION = 23,
> - _TNL_ATTRIB_MAT_BACK_EMISSION = 24,
> - _TNL_ATTRIB_MAT_FRONT_SHININESS = 25,
> - _TNL_ATTRIB_MAT_BACK_SHININESS = 26,
> - _TNL_ATTRIB_MAT_FRONT_INDEXES = 27,
> - _TNL_ATTRIB_MAT_BACK_INDEXES = 28,
> -
> - /* This is really a VARYING_SLOT, not an attrib. Need to fix
> - * tnl to understand the difference.
> - */
> - _TNL_ATTRIB_POINTSIZE = 16,
> -
> - _TNL_ATTRIB_MAX = 33
> -} ;
> + _TNL_ATTRIB_MAT_FRONT_AMBIENT = _TNL_ATTRIB_GENERIC0,
> + _TNL_ATTRIB_MAT_BACK_AMBIENT,
> + _TNL_ATTRIB_MAT_FRONT_DIFFUSE,
> + _TNL_ATTRIB_MAT_BACK_DIFFUSE,
> + _TNL_ATTRIB_MAT_FRONT_SPECULAR,
> + _TNL_ATTRIB_MAT_BACK_SPECULAR,
> + _TNL_ATTRIB_MAT_FRONT_EMISSION,
> + _TNL_ATTRIB_MAT_BACK_EMISSION,
> + _TNL_ATTRIB_MAT_FRONT_SHININESS,
> + _TNL_ATTRIB_MAT_BACK_SHININESS,
> + _TNL_ATTRIB_MAT_FRONT_INDEXES,
> + _TNL_ATTRIB_MAT_BACK_INDEXES,
> +};
>
> #define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u))
> #define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n))
>
> /* special index used for handing invalid glVertexAttribute() indices */
> #define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_GENERIC15 + 1)
>
> /**
> * Handy attribute ranges:
> */
> diff --git a/src/mesa/vbo/vbo_attrib.h b/src/mesa/vbo/vbo_attrib.h
> index 5ee77fe..560c826 100644
> --- a/src/mesa/vbo/vbo_attrib.h
> +++ b/src/mesa/vbo/vbo_attrib.h
> @@ -37,72 +37,72 @@
> * Note: The first attributes match the VERT_ATTRIB_* definitions
> * in mtypes.h. However, the tnl module has additional attributes
> * for materials, color indexes, edge flags, etc.
> */
> /* Although it's nice to use these as bit indexes in a DWORD flag, we
> * could manage without if necessary. Another limit currently is the
> * number of bits allocated for these numbers in places like vertex
> * program instruction formats and register layouts.
> */
> enum {
> - VBO_ATTRIB_POS = 0,
> - VBO_ATTRIB_WEIGHT = 1,
> - VBO_ATTRIB_NORMAL = 2,
> - VBO_ATTRIB_COLOR0 = 3,
> - VBO_ATTRIB_COLOR1 = 4,
> - VBO_ATTRIB_FOG = 5,
> - VBO_ATTRIB_INDEX = 6,
> - VBO_ATTRIB_EDGEFLAG = 7,
> - VBO_ATTRIB_TEX0 = 8,
> - VBO_ATTRIB_TEX1 = 9,
> - VBO_ATTRIB_TEX2 = 10,
> - VBO_ATTRIB_TEX3 = 11,
> - VBO_ATTRIB_TEX4 = 12,
> - VBO_ATTRIB_TEX5 = 13,
> - VBO_ATTRIB_TEX6 = 14,
> - VBO_ATTRIB_TEX7 = 15,
> - VBO_ATTRIB_POINT_SIZE = 16,
> + VBO_ATTRIB_POS,
> + VBO_ATTRIB_WEIGHT,
> + VBO_ATTRIB_NORMAL,
> + VBO_ATTRIB_COLOR0,
> + VBO_ATTRIB_COLOR1,
> + VBO_ATTRIB_FOG,
> + VBO_ATTRIB_INDEX,
> + VBO_ATTRIB_EDGEFLAG,
> + VBO_ATTRIB_TEX0,
> + VBO_ATTRIB_TEX1,
> + VBO_ATTRIB_TEX2,
> + VBO_ATTRIB_TEX3,
> + VBO_ATTRIB_TEX4,
> + VBO_ATTRIB_TEX5,
> + VBO_ATTRIB_TEX6,
> + VBO_ATTRIB_TEX7,
> + VBO_ATTRIB_POINT_SIZE,
>
> - VBO_ATTRIB_GENERIC0 = 17, /* Not used? */
> - VBO_ATTRIB_GENERIC1 = 18,
> - VBO_ATTRIB_GENERIC2 = 19,
> - VBO_ATTRIB_GENERIC3 = 20,
> - VBO_ATTRIB_GENERIC4 = 21,
> - VBO_ATTRIB_GENERIC5 = 22,
> - VBO_ATTRIB_GENERIC6 = 23,
> - VBO_ATTRIB_GENERIC7 = 24,
> - VBO_ATTRIB_GENERIC8 = 25,
> - VBO_ATTRIB_GENERIC9 = 26,
> - VBO_ATTRIB_GENERIC10 = 27,
> - VBO_ATTRIB_GENERIC11 = 28,
> - VBO_ATTRIB_GENERIC12 = 29,
> - VBO_ATTRIB_GENERIC13 = 30,
> - VBO_ATTRIB_GENERIC14 = 31,
> - VBO_ATTRIB_GENERIC15 = 32,
> + VBO_ATTRIB_GENERIC0, /* Not used? */
> + VBO_ATTRIB_GENERIC1,
> + VBO_ATTRIB_GENERIC2,
> + VBO_ATTRIB_GENERIC3,
> + VBO_ATTRIB_GENERIC4,
> + VBO_ATTRIB_GENERIC5,
> + VBO_ATTRIB_GENERIC6,
> + VBO_ATTRIB_GENERIC7,
> + VBO_ATTRIB_GENERIC8,
> + VBO_ATTRIB_GENERIC9,
> + VBO_ATTRIB_GENERIC10,
> + VBO_ATTRIB_GENERIC11,
> + VBO_ATTRIB_GENERIC12,
> + VBO_ATTRIB_GENERIC13,
> + VBO_ATTRIB_GENERIC14,
> + VBO_ATTRIB_GENERIC15,
>
> /* XXX: in the vertex program inputs_read flag, we alias
> * materials and generics and use knowledge about the program
> * (whether it is a fixed-function emulation) to
> * differentiate. Here we must keep them apart instead.
> */
> - VBO_ATTRIB_MAT_FRONT_AMBIENT = 33,
> - VBO_ATTRIB_MAT_BACK_AMBIENT = 34,
> - VBO_ATTRIB_MAT_FRONT_DIFFUSE = 35,
> - VBO_ATTRIB_MAT_BACK_DIFFUSE = 36,
> - VBO_ATTRIB_MAT_FRONT_SPECULAR = 37,
> - VBO_ATTRIB_MAT_BACK_SPECULAR = 38,
> - VBO_ATTRIB_MAT_FRONT_EMISSION = 39,
> - VBO_ATTRIB_MAT_BACK_EMISSION = 40,
> - VBO_ATTRIB_MAT_FRONT_SHININESS = 41,
> - VBO_ATTRIB_MAT_BACK_SHININESS = 42,
> - VBO_ATTRIB_MAT_FRONT_INDEXES = 43,
> - VBO_ATTRIB_MAT_BACK_INDEXES = 44,
> + VBO_ATTRIB_MAT_FRONT_AMBIENT,
> + VBO_ATTRIB_MAT_BACK_AMBIENT,
> + VBO_ATTRIB_MAT_FRONT_DIFFUSE,
> + VBO_ATTRIB_MAT_BACK_DIFFUSE,
> + VBO_ATTRIB_MAT_FRONT_SPECULAR,
> + VBO_ATTRIB_MAT_BACK_SPECULAR,
> + VBO_ATTRIB_MAT_FRONT_EMISSION,
> + VBO_ATTRIB_MAT_BACK_EMISSION,
> + VBO_ATTRIB_MAT_FRONT_SHININESS,
> + VBO_ATTRIB_MAT_BACK_SHININESS,
> + VBO_ATTRIB_MAT_FRONT_INDEXES,
> + VBO_ATTRIB_MAT_BACK_INDEXES,
>
> - VBO_ATTRIB_MAX = 45
> + VBO_ATTRIB_MAX
> };
>
> #define VBO_ATTRIB_FIRST_MATERIAL VBO_ATTRIB_MAT_FRONT_AMBIENT
> #define VBO_ATTRIB_LAST_MATERIAL VBO_ATTRIB_MAT_BACK_INDEXES
>
> #define VBO_MAX_COPIED_VERTS 3
>
> #endif
>
More information about the mesa-dev
mailing list