diff options
author | Mathias Fröhlich <[email protected]> | 2018-06-01 19:10:08 +0200 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-06-05 07:05:24 +0200 |
commit | 1ac4439d6278e6c5f9da5499bbc50362f0c6759b (patch) | |
tree | 036f347b512becd479d16164b5b4100e20e7ef9a /src/mesa/main | |
parent | a7b74a77fa63efe6d6462ff4f201bea03fa23a33 (diff) |
mesa: Make sure that imm draws are flushed before other draws execute.
The recent patch
mesa: Remove FLUSH_VERTICES from VAO state changes.
Pending draw calls on immediate mode or display list calls do
not depend on changes of the VAO state. So, remove calls to
FLUSH_VERTICES and flag _NEW_ARRAY as appropriate.
uncovered a problem that non immediate mode draw calls do only
flush outstanding immediate mode draws if FLUSH_UPDATE_CURRENT
is set in ctx->Driver.NeedFlush.
In that case, due to the sequence of _mesa_set_draw_vao commands
we could end up with the VAO from the FLUSH_VERTICES call set
into gl_context::Array._DrawVAO when the array draw is executed.
So the change pulls FLUSH_CURRENT out of _mesa_validate_* calls
into the array draw calls being validated.
The change introduces a new macro FLUSH_FOR_DRAW beside FLUSH_VERTICES
and FLUSH_CURRENT that flushes on changed current attributes as well
as on outstanding immediate mode draw calls. Use FLUSH_FOR_DRAW
in the non immediate mode draw code paths.
Reviewed-by: Marek Olšák <[email protected]>
Tested-by: Kai Wasserbäch <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106594
Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.h | 16 | ||||
-rw-r--r-- | src/mesa/main/draw_validate.c | 26 |
2 files changed, 16 insertions, 26 deletions
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 77520f678ff..d50438fd7f9 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -233,6 +233,22 @@ do { \ } while (0) /** + * Flush vertices. + * + * \param ctx GL context. + * + * Checks if dd_function_table::NeedFlush is marked to flush stored vertices + * or current state and calls dd_function_table::FlushVertices if so. + */ +#define FLUSH_FOR_DRAW(ctx) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_FOR_DRAW in %s\n", __func__); \ + if (ctx->Driver.NeedFlush) \ + vbo_exec_FlushVertices(ctx, ctx->Driver.NeedFlush); \ +} while (0) + +/** * Macro to assert that the API call was made outside the * glBegin()/glEnd() pair, with return value. * diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index bcb2d91306e..352263c5c78 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -696,8 +696,6 @@ _mesa_validate_DrawElements(struct gl_context *ctx, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { - FLUSH_CURRENT(ctx, 0); - return validate_DrawElements_common(ctx, mode, count, type, indices, "glDrawElements"); } @@ -716,8 +714,6 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx, { GLsizei i; - FLUSH_CURRENT(ctx, 0); - /* * Section 2.3.1 (Errors) of the OpenGL 4.5 (Core Profile) spec says: * @@ -780,8 +776,6 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { - FLUSH_CURRENT(ctx, 0); - if (end < start) { _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)"); return GL_FALSE; @@ -895,8 +889,6 @@ static bool validate_draw_arrays(struct gl_context *ctx, const char *func, GLenum mode, GLsizei count, GLsizei numInstances) { - FLUSH_CURRENT(ctx, 0); - if (count < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(count)", func); return false; @@ -971,8 +963,6 @@ _mesa_validate_MultiDrawArrays(struct gl_context *ctx, GLenum mode, { int i; - FLUSH_CURRENT(ctx, 0); - if (!_mesa_valid_prim_mode(ctx, mode, "glMultiDrawArrays")) return false; @@ -1018,8 +1008,6 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei numInstances) { - FLUSH_CURRENT(ctx, 0); - if (numInstances < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElementsInstanced(numInstances=%d)", numInstances); @@ -1039,8 +1027,6 @@ _mesa_validate_DrawTransformFeedback(struct gl_context *ctx, GLuint stream, GLsizei numInstances) { - FLUSH_CURRENT(ctx, 0); - if (!_mesa_valid_prim_mode(ctx, mode, "glDrawTransformFeedback*(mode)")) { return GL_FALSE; } @@ -1244,8 +1230,6 @@ _mesa_validate_DrawArraysIndirect(struct gl_context *ctx, { const unsigned drawArraysNumParams = 4; - FLUSH_CURRENT(ctx, 0); - return valid_draw_indirect(ctx, mode, indirect, drawArraysNumParams * sizeof(GLuint), "glDrawArraysIndirect"); @@ -1258,8 +1242,6 @@ _mesa_validate_DrawElementsIndirect(struct gl_context *ctx, { const unsigned drawElementsNumParams = 5; - FLUSH_CURRENT(ctx, 0); - return valid_draw_indirect_elements(ctx, mode, type, indirect, drawElementsNumParams * sizeof(GLuint), "glDrawElementsIndirect"); @@ -1274,8 +1256,6 @@ _mesa_validate_MultiDrawArraysIndirect(struct gl_context *ctx, GLsizeiptr size = 0; const unsigned drawArraysNumParams = 4; - FLUSH_CURRENT(ctx, 0); - /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */ assert(stride != 0); @@ -1304,8 +1284,6 @@ _mesa_validate_MultiDrawElementsIndirect(struct gl_context *ctx, GLsizeiptr size = 0; const unsigned drawElementsNumParams = 5; - FLUSH_CURRENT(ctx, 0); - /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */ assert(stride != 0); @@ -1385,8 +1363,6 @@ _mesa_validate_MultiDrawArraysIndirectCount(struct gl_context *ctx, GLsizeiptr size = 0; const unsigned drawArraysNumParams = 4; - FLUSH_CURRENT(ctx, 0); - /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */ assert(stride != 0); @@ -1418,8 +1394,6 @@ _mesa_validate_MultiDrawElementsIndirectCount(struct gl_context *ctx, GLsizeiptr size = 0; const unsigned drawElementsNumParams = 5; - FLUSH_CURRENT(ctx, 0); - /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */ assert(stride != 0); |