[Mesa-dev] [PATCH] mesa: validate the indirect param before the shader in DispatchComputeIndirect

Marek Olšák maraeo at gmail.com
Mon Aug 22 14:06:33 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

This is required by and fixes GL45-CTS.compute_shader.api-indirect.

I know it's silly, but it's the path of least resistence.
---
 src/mesa/main/api_validate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 384a8858..27c17fa 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -1102,40 +1102,40 @@ _mesa_validate_DispatchCompute(struct gl_context *ctx,
    return GL_TRUE;
 }
 
 static GLboolean
 valid_dispatch_indirect(struct gl_context *ctx,
                         GLintptr indirect,
                         GLsizei size, const char *name)
 {
    const uint64_t end = (uint64_t) indirect + size;
 
-   if (!check_valid_to_compute(ctx, name))
-      return GL_FALSE;
-
    /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
     *
     * "An INVALID_VALUE error is generated if indirect is negative or is not a
     *  multiple of four."
     */
    if (indirect & (sizeof(GLuint) - 1)) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                   "%s(indirect is not aligned)", name);
       return GL_FALSE;
    }
 
    if (indirect < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                   "%s(indirect is less than zero)", name);
       return GL_FALSE;
    }
 
+   if (!check_valid_to_compute(ctx, name))
+      return GL_FALSE;
+
    /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
     *
     * "An INVALID_OPERATION error is generated if no buffer is bound to the
     *  DRAW_INDIRECT_BUFFER binding, or if the command would source data
     *  beyond the end of the buffer object."
     */
    if (!_mesa_is_bufferobj(ctx->DispatchIndirectBuffer)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "%s: no buffer bound to DISPATCH_INDIRECT_BUFFER", name);
       return GL_FALSE;
-- 
2.7.4



More information about the mesa-dev mailing list