summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_exec_array.c
diff options
context:
space:
mode:
authorFabian Bieler <[email protected]>2013-05-25 13:33:42 +0200
committerPaul Berry <[email protected]>2013-08-27 15:11:52 -0700
commitcd18269705c948f5141478a48cf82a1fddd06b83 (patch)
treef7c6f2b21de6839aaf9252172c63267b2e0571bd /src/mesa/vbo/vbo_exec_array.c
parentac74de37109b62ca092827ca263de1935e2d1c08 (diff)
mesa/main: Check for 0 size draws after validation.
When validating draw parameters move check for 0 draw count last (drawing with count 0 is not an error), so that other parameters (e.g.: the primitive type) are validated and the correct errors (if applicable) are generated. >From the OpenGL 3.3 spec page 33 (page 48 of the PDF): "[Regarding DrawArraysOneInstance, in terms of which other draw operations are defined:] If count is negative, an INVALID_VALUE error is generated." This patch also changes the bahavior of MultiDrawElements to perform the draw operation if some primitive's index counts are zero. Signed-off-by: Fabian Bieler <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_exec_array.c')
-rw-r--r--src/mesa/vbo/vbo_exec_array.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index bd05cd0c369..1670409d48b 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -1334,6 +1334,16 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
}
}
+ /* Draw primitives individually if one count is zero, so we can easily skip
+ * that primitive.
+ */
+ for (i = 0; i < primcount; i++) {
+ if (count[i] == 0) {
+ fallback = GL_TRUE;
+ break;
+ }
+ }
+
/* If the index buffer isn't in a VBO, then treating the application's
* subranges of the index buffer as one large index buffer may lead to
* us reading unmapped memory.
@@ -1370,6 +1380,8 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
} else {
/* render one prim at a time */
for (i = 0; i < primcount; i++) {
+ if (count[i] == 0)
+ continue;
ib.count = count[i];
ib.type = type;
ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;