Re: [Mesa-dev] [PATCH 01/10] mesa: Factor out index function that will have multiple use.

2019-05-02 Thread Mathias Fröhlich
Good Morning,

On Friday, 3 May 2019 00:17:38 CEST Brian Paul wrote:
> On 05/02/2019 03:27 AM, mathias.froehl...@gmx.net wrote:
> > From: Mathias Fröhlich 
> > 
> > For access to glArrayElement methods factor out a function to
> > get the table lookup index for normalized/integer/double access.
> > The function will be used in the next patch at least twice.
> > 
> > Signed-off-by: Mathias Fröhlich 
> > ---
> >   src/mesa/main/api_arrayelt.c | 29 ++---
> >   1 file changed, 18 insertions(+), 11 deletions(-)
> > 
> > diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
> > index 1c086bbcda4..3f16e18b44d 100644
> > --- a/src/mesa/main/api_arrayelt.c
> > +++ b/src/mesa/main/api_arrayelt.c
> > @@ -90,6 +90,23 @@ TYPE_IDX(GLenum t)
> >   }
> > 
> > 
> > +/*
> > + * Convert normalized/integer/double to the range [0, 3].
> > + */
> > +static inline int
> > +NORM_IDX(const struct gl_vertex_format *vformat)
> 
> Maybe we could find a better name.  How about vertex_format_to_index()?

Sure! Changed that to your suggestion!
Thanks!

best

Mathias

> 
> -Brian
> 
> 
> > +{
> > +   if (vformat->Doubles)
> > +  return 3;
> > +   else if (vformat->Integer)
> > +  return 2;
> > +   else if (vformat->Normalized)
> > +  return 1;
> > +   else
> > +  return 0;
> > +}
> > +
> > +
> >   bool
> >   _ae_is_state_dirty(struct gl_context *ctx)
> >   {
> > @@ -1610,7 +1627,6 @@ _ae_update_state(struct gl_context *ctx)
> > if (vao->Enabled & VERT_BIT_GENERIC(i)) {
> >struct gl_array_attributes *attribArray =
> >   >VertexAttrib[VERT_ATTRIB_GENERIC(i)];
> > - GLint intOrNorm;
> >at->array = attribArray;
> >at->binding = 
> > >BufferBinding[attribArray->BufferBindingIndex];
> >/* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
> > @@ -1618,16 +1634,7 @@ _ae_update_state(struct gl_context *ctx)
> > * change from one execution of _ae_ArrayElement() to
> > * the next.  Doing so caused UT to break.
> > */
> > - if (at->array->Format.Doubles)
> > -intOrNorm = 3;
> > - else if (at->array->Format.Integer)
> > -intOrNorm = 2;
> > - else if (at->array->Format.Normalized)
> > -intOrNorm = 1;
> > - else
> > -intOrNorm = 0;
> > -
> > - at->func = AttribFuncsARB[intOrNorm]
> > + at->func = AttribFuncsARB[NORM_IDX(>array->Format)]
> >   [at->array->Format.Size-1]
> >   [TYPE_IDX(at->array->Format.Type)];
> > 
> > --
> > 2.20.1
> > 
> 
> 




___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 01/10] mesa: Factor out index function that will have multiple use.

2019-05-02 Thread Brian Paul

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

From: Mathias Fröhlich 

For access to glArrayElement methods factor out a function to
get the table lookup index for normalized/integer/double access.
The function will be used in the next patch at least twice.

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

diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 1c086bbcda4..3f16e18b44d 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -90,6 +90,23 @@ TYPE_IDX(GLenum t)
  }


+/*
+ * Convert normalized/integer/double to the range [0, 3].
+ */
+static inline int
+NORM_IDX(const struct gl_vertex_format *vformat)


Maybe we could find a better name.  How about vertex_format_to_index()?

-Brian



+{
+   if (vformat->Doubles)
+  return 3;
+   else if (vformat->Integer)
+  return 2;
+   else if (vformat->Normalized)
+  return 1;
+   else
+  return 0;
+}
+
+
  bool
  _ae_is_state_dirty(struct gl_context *ctx)
  {
@@ -1610,7 +1627,6 @@ _ae_update_state(struct gl_context *ctx)
if (vao->Enabled & VERT_BIT_GENERIC(i)) {
   struct gl_array_attributes *attribArray =
  >VertexAttrib[VERT_ATTRIB_GENERIC(i)];
- GLint intOrNorm;
   at->array = attribArray;
   at->binding = >BufferBinding[attribArray->BufferBindingIndex];
   /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
@@ -1618,16 +1634,7 @@ _ae_update_state(struct gl_context *ctx)
* change from one execution of _ae_ArrayElement() to
* the next.  Doing so caused UT to break.
*/
- if (at->array->Format.Doubles)
-intOrNorm = 3;
- else if (at->array->Format.Integer)
-intOrNorm = 2;
- else if (at->array->Format.Normalized)
-intOrNorm = 1;
- else
-intOrNorm = 0;
-
- at->func = AttribFuncsARB[intOrNorm]
+ at->func = AttribFuncsARB[NORM_IDX(>array->Format)]
  [at->array->Format.Size-1]
  [TYPE_IDX(at->array->Format.Type)];

--
2.20.1



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 01/10] mesa: Factor out index function that will have multiple use.

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

For access to glArrayElement methods factor out a function to
get the table lookup index for normalized/integer/double access.
The function will be used in the next patch at least twice.

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

diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 1c086bbcda4..3f16e18b44d 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -90,6 +90,23 @@ TYPE_IDX(GLenum t)
 }


+/*
+ * Convert normalized/integer/double to the range [0, 3].
+ */
+static inline int
+NORM_IDX(const struct gl_vertex_format *vformat)
+{
+   if (vformat->Doubles)
+  return 3;
+   else if (vformat->Integer)
+  return 2;
+   else if (vformat->Normalized)
+  return 1;
+   else
+  return 0;
+}
+
+
 bool
 _ae_is_state_dirty(struct gl_context *ctx)
 {
@@ -1610,7 +1627,6 @@ _ae_update_state(struct gl_context *ctx)
   if (vao->Enabled & VERT_BIT_GENERIC(i)) {
  struct gl_array_attributes *attribArray =
 >VertexAttrib[VERT_ATTRIB_GENERIC(i)];
- GLint intOrNorm;
  at->array = attribArray;
  at->binding = >BufferBinding[attribArray->BufferBindingIndex];
  /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
@@ -1618,16 +1634,7 @@ _ae_update_state(struct gl_context *ctx)
   * change from one execution of _ae_ArrayElement() to
   * the next.  Doing so caused UT to break.
   */
- if (at->array->Format.Doubles)
-intOrNorm = 3;
- else if (at->array->Format.Integer)
-intOrNorm = 2;
- else if (at->array->Format.Normalized)
-intOrNorm = 1;
- else
-intOrNorm = 0;
-
- at->func = AttribFuncsARB[intOrNorm]
+ at->func = AttribFuncsARB[NORM_IDX(>array->Format)]
 [at->array->Format.Size-1]
 [TYPE_IDX(at->array->Format.Type)];

--
2.20.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev