From 6135146ea3b4a6d29a8c417f4c6d7dea7e51a4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= Date: Thu, 31 May 2018 08:35:16 +0200 Subject: [PATCH] mesa: Make sure that imm draws have landed before array draws get executed. --- src/mesa/main/context.h | 16 +++++++++ src/mesa/main/draw_validate.c | 26 --------------- src/mesa/vbo/vbo_exec_array.c | 75 +++++++++++++++++++++---------------------- src/mesa/vbo/vbo_save_draw.c | 4 +-- 4 files changed, 55 insertions(+), 66 deletions(-) diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 77520f678f..d50438fd7f 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -232,6 +232,22 @@ do { \ ctx->NewState |= newstate; \ } 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 bcb2d91306..352263c5c7 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(endArray.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -568,10 +568,9 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count, _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n", _mesa_enum_to_string(mode), start, count, numInstances); + FLUSH_FOR_DRAW(ctx); if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); - _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -610,9 +609,9 @@ vbo_exec_DrawArraysInstancedBaseInstance(GLenum mode, GLint first, _mesa_enum_to_string(mode), first, count, numInstances, baseInstance); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -650,9 +649,9 @@ vbo_exec_MultiDrawArrays(GLenum mode, const GLint *first, "glMultiDrawArrays(%s, %p, %p, %d)\n", _mesa_enum_to_string(mode), first, count, primcount); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -873,9 +872,9 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, _mesa_enum_to_string(mode), start, end, count, _mesa_enum_to_string(type), indices, basevertex); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -984,9 +983,9 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, _mesa_enum_to_string(mode), count, _mesa_enum_to_string(type), indices); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1017,9 +1016,9 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, _mesa_enum_to_string(mode), count, _mesa_enum_to_string(type), indices); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1050,9 +1049,9 @@ vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, _mesa_enum_to_string(mode), count, _mesa_enum_to_string(type), indices); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1089,9 +1088,9 @@ vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, _mesa_enum_to_string(type), indices, numInstances, basevertex); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1130,9 +1129,9 @@ vbo_exec_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, _mesa_enum_to_string(type), indices, numInstances, baseInstance); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1173,9 +1172,9 @@ vbo_exec_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, _mesa_enum_to_string(type), indices, numInstances, basevertex, baseInstance); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1360,9 +1359,9 @@ vbo_exec_MultiDrawElementsBaseVertex(GLenum mode, { GET_CURRENT_CONTEXT(ctx); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1398,9 +1397,9 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode, { struct _mesa_prim prim; - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1615,9 +1614,9 @@ vbo_exec_DrawArraysIndirect(GLenum mode, const GLvoid *indirect) _mesa_debug(ctx, "glDrawArraysIndirect(%s, %p)\n", _mesa_enum_to_string(mode), indirect); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1646,9 +1645,9 @@ vbo_exec_DrawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect) _mesa_enum_to_string(mode), _mesa_enum_to_string(type), indirect); - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1681,9 +1680,9 @@ vbo_exec_MultiDrawArraysIndirect(GLenum mode, const GLvoid *indirect, if (stride == 0) stride = 4 * sizeof(GLuint); /* sizeof(DrawArraysIndirectCommand) */ - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1720,9 +1719,9 @@ vbo_exec_MultiDrawElementsIndirect(GLenum mode, GLenum type, if (stride == 0) stride = 5 * sizeof(GLuint); /* sizeof(DrawElementsIndirectCommand) */ - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1815,9 +1814,9 @@ vbo_exec_MultiDrawArraysIndirectCount(GLenum mode, GLintptr indirect, if (stride == 0) stride = 4 * sizeof(GLuint); /* sizeof(DrawArraysIndirectCommand) */ - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) @@ -1860,9 +1859,9 @@ vbo_exec_MultiDrawElementsIndirectCount(GLenum mode, GLenum type, if (stride == 0) stride = 5 * sizeof(GLuint); /* sizeof(DrawElementsIndirectCommand) */ - if (_mesa_is_no_error_enabled(ctx)) { - FLUSH_CURRENT(ctx, 0); + FLUSH_FOR_DRAW(ctx); + if (_mesa_is_no_error_enabled(ctx)) { _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx)); if (ctx->NewState) diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index f4b2c80748..19e4769c99 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -168,8 +168,6 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) remap_vertex_store = GL_TRUE; } - FLUSH_CURRENT(ctx, 0); - if (node->prim_count > 0) { if (_mesa_inside_begin_end(ctx) && node->prims[0].begin) { @@ -189,6 +187,8 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) goto end; } + FLUSH_FOR_DRAW(ctx); + bind_vertex_list(ctx, node); /* Need that at least one time. */ -- 2.14.3