Re: [Mesa-dev] [PATCH 02/10] mesa: Use glVertexAttrib*NV functions for fixed function attribs.

2019-05-02 Thread Mathias Fröhlich
On Friday, 3 May 2019 00:17:45 CEST Brian Paul wrote:
> On 05/02/2019 03:27 AM, mathias.froehl...@gmx.net wrote:
> > From: Mathias Fröhlich 
> > 
> > In the glArrayElement implementation, use glVertexAttrib*NV type
> > functions for fixed function attributes. We do the same in display
> > execution when the list is replayed using immediate mode attribute
> > functions. By that use a loop to walk the attributes.
> 
> I'm not sure I understand that last sentence.

So, how about:

mesa: Use glVertexAttrib*NV functions for fixed function attribs.

In the glArrayElement implementation, use glVertexAttrib*NV type
functions for fixed function attributes. We do the same in display
execution when the list is replayed using immediate mode attribute
functions. Using a single set of function pointers enables to
use a unified loop to walk the vertex array attributes.

best and Thanks!

Mathias

> 
> The code looks fine.
> 
> Reviewed-by: Brian Paul 
> 
> 
> > 
> > Signed-off-by: Mathias Fröhlich 
> > ---
> >   src/mesa/main/api_arrayelt.c | 185 ++-
> >   1 file changed, 28 insertions(+), 157 deletions(-)
> > 
> > diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
> > index 3f16e18b44d..d46c8d14b68 100644
> > --- a/src/mesa/main/api_arrayelt.c
> > +++ b/src/mesa/main/api_arrayelt.c
> > @@ -117,89 +117,6 @@ _ae_is_state_dirty(struct gl_context *ctx)
> >   #define NUM_TYPES 8
> > 
> > 
> > -static const int ColorFuncs[2][NUM_TYPES] = {
> > -   {
> > -  _gloffset_Color3bv,
> > -  _gloffset_Color3ubv,
> > -  _gloffset_Color3sv,
> > -  _gloffset_Color3usv,
> > -  _gloffset_Color3iv,
> > -  _gloffset_Color3uiv,
> > -  _gloffset_Color3fv,
> > -  _gloffset_Color3dv,
> > -   },
> > -   {
> > -  _gloffset_Color4bv,
> > -  _gloffset_Color4ubv,
> > -  _gloffset_Color4sv,
> > -  _gloffset_Color4usv,
> > -  _gloffset_Color4iv,
> > -  _gloffset_Color4uiv,
> > -  _gloffset_Color4fv,
> > -  _gloffset_Color4dv,
> > -   },
> > -};
> > -
> > -static const int VertexFuncs[3][NUM_TYPES] = {
> > -   {
> > -  -1,
> > -  -1,
> > -  _gloffset_Vertex2sv,
> > -  -1,
> > -  _gloffset_Vertex2iv,
> > -  -1,
> > -  _gloffset_Vertex2fv,
> > -  _gloffset_Vertex2dv,
> > -   },
> > -   {
> > -  -1,
> > -  -1,
> > -  _gloffset_Vertex3sv,
> > -  -1,
> > -  _gloffset_Vertex3iv,
> > -  -1,
> > -  _gloffset_Vertex3fv,
> > -  _gloffset_Vertex3dv,
> > -   },
> > -   {
> > -  -1,
> > -  -1,
> > -  _gloffset_Vertex4sv,
> > -  -1,
> > -  _gloffset_Vertex4iv,
> > -  -1,
> > -  _gloffset_Vertex4fv,
> > -  _gloffset_Vertex4dv,
> > -   },
> > -};
> > -
> > -static const int IndexFuncs[NUM_TYPES] = {
> > -   -1,
> > -   _gloffset_Indexubv,
> > -   _gloffset_Indexsv,
> > -   -1,
> > -   _gloffset_Indexiv,
> > -   -1,
> > -   _gloffset_Indexfv,
> > -   _gloffset_Indexdv,
> > -};
> > -
> > -static const int NormalFuncs[NUM_TYPES] = {
> > -   _gloffset_Normal3bv,
> > -   -1,
> > -   _gloffset_Normal3sv,
> > -   -1,
> > -   _gloffset_Normal3iv,
> > -   -1,
> > -   _gloffset_Normal3fv,
> > -   _gloffset_Normal3dv,
> > -};
> > -
> > -/* Note: _gloffset_* for these may not be a compile-time constant. */
> > -static int SecondaryColorFuncs[NUM_TYPES];
> > -static int FogCoordFuncs[NUM_TYPES];
> > -
> > -
> >   /**
> >** GL_NV_vertex_program
> >**/
> > @@ -1508,25 +1425,6 @@ _ae_create_context(struct gl_context *ctx)
> >  if (ctx->aelt_context)
> > return GL_TRUE;
> > 
> > -   /* These _gloffset_* values may not be compile-time constants */
> > -   SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bv;
> > -   SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubv;
> > -   SecondaryColorFuncs[2] = _gloffset_SecondaryColor3sv;
> > -   SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usv;
> > -   SecondaryColorFuncs[4] = _gloffset_SecondaryColor3iv;
> > -   SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uiv;
> > -   SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
> > -   SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dv;
> > -
> > -   FogCoordFuncs[0] = -1;
> > -   FogCoordFuncs[1] = -1;
> > -   FogCoordFuncs[2] = -1;
> > -   FogCoordFuncs[3] = -1;
> > -   FogCoordFuncs[4] = -1;
> > -   FogCoordFuncs[5] = -1;
> > -   FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
> > -   FogCoordFuncs[7] = _gloffset_FogCoorddv;
> > -
> >  ctx->aelt_context = calloc(1, sizeof(AEcontext));
> >  if (!ctx->aelt_context)
> > return GL_FALSE;
> > @@ -1562,52 +1460,10 @@ _ae_update_state(struct gl_context *ctx)
> >  struct gl_vertex_array_object *vao = ctx->Array.VAO;
> > 
> >  /* conventional vertex arrays */
> > -   if (vao->Enabled & VERT_BIT_COLOR_INDEX) {
> > -  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
> > -  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
> > -  aa->offset = 

Re: [Mesa-dev] [PATCH 02/10] mesa: Use glVertexAttrib*NV functions for fixed function attribs.

2019-05-02 Thread Brian Paul

On 05/02/2019 03:27 AM, mathias.froehl...@gmx.net wrote:

From: Mathias Fröhlich 

In the glArrayElement implementation, use glVertexAttrib*NV type
functions for fixed function attributes. We do the same in display
execution when the list is replayed using immediate mode attribute
functions. By that use a loop to walk the attributes.


I'm not sure I understand that last sentence.

The code looks fine.

Reviewed-by: Brian Paul 




Signed-off-by: Mathias Fröhlich 
---
  src/mesa/main/api_arrayelt.c | 185 ++-
  1 file changed, 28 insertions(+), 157 deletions(-)

diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 3f16e18b44d..d46c8d14b68 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -117,89 +117,6 @@ _ae_is_state_dirty(struct gl_context *ctx)
  #define NUM_TYPES 8


-static const int ColorFuncs[2][NUM_TYPES] = {
-   {
-  _gloffset_Color3bv,
-  _gloffset_Color3ubv,
-  _gloffset_Color3sv,
-  _gloffset_Color3usv,
-  _gloffset_Color3iv,
-  _gloffset_Color3uiv,
-  _gloffset_Color3fv,
-  _gloffset_Color3dv,
-   },
-   {
-  _gloffset_Color4bv,
-  _gloffset_Color4ubv,
-  _gloffset_Color4sv,
-  _gloffset_Color4usv,
-  _gloffset_Color4iv,
-  _gloffset_Color4uiv,
-  _gloffset_Color4fv,
-  _gloffset_Color4dv,
-   },
-};
-
-static const int VertexFuncs[3][NUM_TYPES] = {
-   {
-  -1,
-  -1,
-  _gloffset_Vertex2sv,
-  -1,
-  _gloffset_Vertex2iv,
-  -1,
-  _gloffset_Vertex2fv,
-  _gloffset_Vertex2dv,
-   },
-   {
-  -1,
-  -1,
-  _gloffset_Vertex3sv,
-  -1,
-  _gloffset_Vertex3iv,
-  -1,
-  _gloffset_Vertex3fv,
-  _gloffset_Vertex3dv,
-   },
-   {
-  -1,
-  -1,
-  _gloffset_Vertex4sv,
-  -1,
-  _gloffset_Vertex4iv,
-  -1,
-  _gloffset_Vertex4fv,
-  _gloffset_Vertex4dv,
-   },
-};
-
-static const int IndexFuncs[NUM_TYPES] = {
-   -1,
-   _gloffset_Indexubv,
-   _gloffset_Indexsv,
-   -1,
-   _gloffset_Indexiv,
-   -1,
-   _gloffset_Indexfv,
-   _gloffset_Indexdv,
-};
-
-static const int NormalFuncs[NUM_TYPES] = {
-   _gloffset_Normal3bv,
-   -1,
-   _gloffset_Normal3sv,
-   -1,
-   _gloffset_Normal3iv,
-   -1,
-   _gloffset_Normal3fv,
-   _gloffset_Normal3dv,
-};
-
-/* Note: _gloffset_* for these may not be a compile-time constant. */
-static int SecondaryColorFuncs[NUM_TYPES];
-static int FogCoordFuncs[NUM_TYPES];
-
-
  /**
   ** GL_NV_vertex_program
   **/
@@ -1508,25 +1425,6 @@ _ae_create_context(struct gl_context *ctx)
 if (ctx->aelt_context)
return GL_TRUE;

-   /* These _gloffset_* values may not be compile-time constants */
-   SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bv;
-   SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubv;
-   SecondaryColorFuncs[2] = _gloffset_SecondaryColor3sv;
-   SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usv;
-   SecondaryColorFuncs[4] = _gloffset_SecondaryColor3iv;
-   SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uiv;
-   SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
-   SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dv;
-
-   FogCoordFuncs[0] = -1;
-   FogCoordFuncs[1] = -1;
-   FogCoordFuncs[2] = -1;
-   FogCoordFuncs[3] = -1;
-   FogCoordFuncs[4] = -1;
-   FogCoordFuncs[5] = -1;
-   FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
-   FogCoordFuncs[7] = _gloffset_FogCoorddv;
-
 ctx->aelt_context = calloc(1, sizeof(AEcontext));
 if (!ctx->aelt_context)
return GL_FALSE;
@@ -1562,52 +1460,10 @@ _ae_update_state(struct gl_context *ctx)
 struct gl_vertex_array_object *vao = ctx->Array.VAO;

 /* conventional vertex arrays */
-   if (vao->Enabled & VERT_BIT_COLOR_INDEX) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = IndexFuncs[TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_EDGEFLAG) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_EDGEFLAG];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = _gloffset_EdgeFlagv;
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_NORMAL) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_NORMAL];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = NormalFuncs[TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_COLOR0) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR0];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = 
ColorFuncs[aa->array->Format.Size-3][TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_COLOR1) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR1];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-  

[Mesa-dev] [PATCH 02/10] mesa: Use glVertexAttrib*NV functions for fixed function attribs.

2019-05-02 Thread Mathias . Froehlich
From: Mathias Fröhlich 

In the glArrayElement implementation, use glVertexAttrib*NV type
functions for fixed function attributes. We do the same in display
execution when the list is replayed using immediate mode attribute
functions. By that use a loop to walk the attributes.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/api_arrayelt.c | 185 ++-
 1 file changed, 28 insertions(+), 157 deletions(-)

diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 3f16e18b44d..d46c8d14b68 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -117,89 +117,6 @@ _ae_is_state_dirty(struct gl_context *ctx)
 #define NUM_TYPES 8


-static const int ColorFuncs[2][NUM_TYPES] = {
-   {
-  _gloffset_Color3bv,
-  _gloffset_Color3ubv,
-  _gloffset_Color3sv,
-  _gloffset_Color3usv,
-  _gloffset_Color3iv,
-  _gloffset_Color3uiv,
-  _gloffset_Color3fv,
-  _gloffset_Color3dv,
-   },
-   {
-  _gloffset_Color4bv,
-  _gloffset_Color4ubv,
-  _gloffset_Color4sv,
-  _gloffset_Color4usv,
-  _gloffset_Color4iv,
-  _gloffset_Color4uiv,
-  _gloffset_Color4fv,
-  _gloffset_Color4dv,
-   },
-};
-
-static const int VertexFuncs[3][NUM_TYPES] = {
-   {
-  -1,
-  -1,
-  _gloffset_Vertex2sv,
-  -1,
-  _gloffset_Vertex2iv,
-  -1,
-  _gloffset_Vertex2fv,
-  _gloffset_Vertex2dv,
-   },
-   {
-  -1,
-  -1,
-  _gloffset_Vertex3sv,
-  -1,
-  _gloffset_Vertex3iv,
-  -1,
-  _gloffset_Vertex3fv,
-  _gloffset_Vertex3dv,
-   },
-   {
-  -1,
-  -1,
-  _gloffset_Vertex4sv,
-  -1,
-  _gloffset_Vertex4iv,
-  -1,
-  _gloffset_Vertex4fv,
-  _gloffset_Vertex4dv,
-   },
-};
-
-static const int IndexFuncs[NUM_TYPES] = {
-   -1,
-   _gloffset_Indexubv,
-   _gloffset_Indexsv,
-   -1,
-   _gloffset_Indexiv,
-   -1,
-   _gloffset_Indexfv,
-   _gloffset_Indexdv,
-};
-
-static const int NormalFuncs[NUM_TYPES] = {
-   _gloffset_Normal3bv,
-   -1,
-   _gloffset_Normal3sv,
-   -1,
-   _gloffset_Normal3iv,
-   -1,
-   _gloffset_Normal3fv,
-   _gloffset_Normal3dv,
-};
-
-/* Note: _gloffset_* for these may not be a compile-time constant. */
-static int SecondaryColorFuncs[NUM_TYPES];
-static int FogCoordFuncs[NUM_TYPES];
-
-
 /**
  ** GL_NV_vertex_program
  **/
@@ -1508,25 +1425,6 @@ _ae_create_context(struct gl_context *ctx)
if (ctx->aelt_context)
   return GL_TRUE;

-   /* These _gloffset_* values may not be compile-time constants */
-   SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bv;
-   SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubv;
-   SecondaryColorFuncs[2] = _gloffset_SecondaryColor3sv;
-   SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usv;
-   SecondaryColorFuncs[4] = _gloffset_SecondaryColor3iv;
-   SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uiv;
-   SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
-   SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dv;
-
-   FogCoordFuncs[0] = -1;
-   FogCoordFuncs[1] = -1;
-   FogCoordFuncs[2] = -1;
-   FogCoordFuncs[3] = -1;
-   FogCoordFuncs[4] = -1;
-   FogCoordFuncs[5] = -1;
-   FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
-   FogCoordFuncs[7] = _gloffset_FogCoorddv;
-
ctx->aelt_context = calloc(1, sizeof(AEcontext));
if (!ctx->aelt_context)
   return GL_FALSE;
@@ -1562,52 +1460,10 @@ _ae_update_state(struct gl_context *ctx)
struct gl_vertex_array_object *vao = ctx->Array.VAO;

/* conventional vertex arrays */
-   if (vao->Enabled & VERT_BIT_COLOR_INDEX) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = IndexFuncs[TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_EDGEFLAG) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_EDGEFLAG];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = _gloffset_EdgeFlagv;
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_NORMAL) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_NORMAL];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = NormalFuncs[TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_COLOR0) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR0];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = 
ColorFuncs[aa->array->Format.Size-3][TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_COLOR1) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_COLOR1];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-  aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Format.Type)];
-  aa++;
-   }
-
-   if (vao->Enabled & VERT_BIT_FOG) {
-  aa->array = >VertexAttrib[VERT_ATTRIB_FOG];
-  aa->binding = >BufferBinding[aa->array->BufferBindingIndex];
-