From c24a03d0359affaa360aaa55a3e8fd136ada6834 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 24 Jan 2021 15:13:04 -0500 Subject: [PATCH] mesa: inline check_valid_to_render MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit because it has only one use. Reviewed-by: Zoltán Böszörményi Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/draw_validate.c | 56 ++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index 022385a..615adaa 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -236,40 +236,6 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) /** - * Check if OK to draw arrays/elements. - */ -static bool -check_valid_to_render(struct gl_context *ctx, bool uses_vao, - const char *function) -{ - if (!_mesa_valid_to_render(ctx, function)) { - return false; - } - - /* Section 6.3.2 from the GL 4.5: - * "Any GL command which attempts to read from, write to, or change - * the state of a buffer object may generate an INVALID_OPERATION error if - * all or part of the buffer object is mapped ... However, only commands - * which explicitly describe this error are required to do so. If an error - * is not generated, such commands will have undefined results and may - * result in GL interruption or termination." - * - * Only some buffer API functions require INVALID_OPERATION with mapped - * buffers. No other functions list such an error, thus it's not required - * to report INVALID_OPERATION for draw calls with mapped buffers. - */ - if (uses_vao && - !ctx->Const.AllowMappedBuffersDuringExecution && - !_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(vertex buffers are mapped)", function); - return false; - } - - return true; -} - -/** * Compute the bitmask of allowed primitive types (ValidPrimMask) depending * on shaders and current states. This is used by draw validation. * @@ -573,10 +539,30 @@ GLboolean _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, bool uses_vao, const char *name) { + /* Section 6.3.2 from the GL 4.5: + * "Any GL command which attempts to read from, write to, or change + * the state of a buffer object may generate an INVALID_OPERATION error if + * all or part of the buffer object is mapped ... However, only commands + * which explicitly describe this error are required to do so. If an error + * is not generated, such commands will have undefined results and may + * result in GL interruption or termination." + * + * Only some buffer API functions require INVALID_OPERATION with mapped + * buffers. No other functions list such an error, thus it's not required + * to report INVALID_OPERATION for draw calls with mapped buffers. + */ + if (uses_vao && + !ctx->Const.AllowMappedBuffersDuringExecution && + !_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(vertex buffers are mapped)", name); + return false; + } + /* This might update ValidPrimMask, so it must be done before ValidPrimMask * is checked. */ - if (!check_valid_to_render(ctx, uses_vao, name)) + if (!_mesa_valid_to_render(ctx, name)) return false; /* All primitive type enums are less than 32, so we can use the shift. */ -- 2.7.4