summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-03-31 14:44:59 +1100
committerTimothy Arceri <[email protected]>2017-04-19 16:53:25 +1000
commit9e60742ddcce04bb218fda15f0b577f850668080 (patch)
treebd2fcd52a595da4a2f1f4bf3321994c78629ab9a /src/mesa/main
parentd0608c43c5160687faa285b86dec09ce8786d5b4 (diff)
mesa/varray: create get_array_format() helper
This will help us split array validation from array update. V2: add const to ctx param Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/varray.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 63aef84dec0..f4e4372d11d 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -258,6 +258,24 @@ get_legal_types_mask(const struct gl_context *ctx)
return legalTypesMask;
}
+static GLenum
+get_array_format(const struct gl_context *ctx, GLint sizeMax, GLint *size)
+{
+ GLenum format = GL_RGBA;
+
+ /* Do size parameter checking.
+ * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and
+ * must be handled specially.
+ */
+ if (ctx->Extensions.EXT_vertex_array_bgra && sizeMax == BGRA_OR_4 &&
+ *size == GL_BGRA) {
+ format = GL_BGRA;
+ *size = 4;
+ }
+
+ return format;
+}
+
/**
* \param attrib The index of the attribute array
@@ -329,7 +347,7 @@ update_array_format(struct gl_context *ctx,
GLuint relativeOffset)
{
GLbitfield typeBit;
- GLenum format = GL_RGBA;
+ GLenum format = get_array_format(ctx, sizeMax, &size);
/* at most, one of these bools can be true */
assert((int) normalized + (int) integer + (int) doubles <= 1);
@@ -359,13 +377,7 @@ update_array_format(struct gl_context *ctx,
return false;
}
- /* Do size parameter checking.
- * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and
- * must be handled specially.
- */
- if (ctx->Extensions.EXT_vertex_array_bgra &&
- sizeMax == BGRA_OR_4 &&
- size == GL_BGRA) {
+ if (format == GL_BGRA) {
/* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
*
* "An INVALID_OPERATION error is generated under any of the following
@@ -397,9 +409,6 @@ update_array_format(struct gl_context *ctx,
"%s(size=GL_BGRA and normalized=GL_FALSE)", func);
return false;
}
-
- format = GL_BGRA;
- size = 4;
}
else if (size < sizeMin || size > sizeMax || size > 4) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size);