mesa: inline check_valid_to_render

because it has only one use.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8798>
This commit is contained in:
Marek Olšák 2021-01-24 15:13:04 -05:00 committed by Marge Bot
parent dfd1080f9d
commit c24a03d035

View file

@ -235,40 +235,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. */