summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Fröhlich <mathias.froehlich@web.de>2019-04-03 12:33:37 +0200
committerMathias Fröhlich <mathias.froehlich@web.de>2019-05-04 07:39:18 +0200
commit60076a6171931b92dcdda53c2962666cc27fda2d (patch)
treeea203933c95925791f4e0a2ad36f7e19a09efcac /src
parent91899495a14568e9f23fa64d4bf4f5ef3f017fb9 (diff)
mesa: Factor out index function that will have multiple use.
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. v2: Use vertex_format_to_index instead of NORM_IDX. Reviewed-by: Brian Paul <brianp@vmware.com> Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/api_arrayelt.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 1c086bbcda4..0fe9311adae 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
+vertex_format_to_index(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 =
&vao->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
- GLint intOrNorm;
at->array = attribArray;
at->binding = &vao->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[vertex_format_to_index(&at->array->Format)]
[at->array->Format.Size-1]
[TYPE_IDX(at->array->Format.Type)];