[Mesa-dev] [PATCH 15/17] mesa: move FLUSH_CURRENT() calls out of DispatchCompute*() validation

Timothy Arceri tarceri at itsqueeze.com
Mon May 15 06:19:24 UTC 2017


This is required to add KHR_no_error support.
---
 src/mesa/main/compute.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/compute.c b/src/mesa/main/compute.c
index e881d4f..f3cc6af 100644
--- a/src/mesa/main/compute.c
+++ b/src/mesa/main/compute.c
@@ -47,22 +47,20 @@ check_valid_to_compute(struct gl_context *ctx, const char *function)
                   function);
       return false;
    }
 
    return true;
 }
 
 static bool
 validate_DispatchCompute(struct gl_context *ctx, const GLuint *num_groups)
 {
-   FLUSH_CURRENT(ctx, 0);
-
    if (!check_valid_to_compute(ctx, "glDispatchCompute"))
       return GL_FALSE;
 
    for (int i = 0; i < 3; i++) {
       /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
        *
        * "An INVALID_VALUE error is generated if any of num_groups_x,
        *  num_groups_y and num_groups_z are greater than or equal to the
        *  maximum work group count for the corresponding dimension."
        *
@@ -100,22 +98,20 @@ validate_DispatchCompute(struct gl_context *ctx, const GLuint *num_groups)
    return GL_TRUE;
 }
 
 static bool
 validate_DispatchComputeGroupSizeARB(struct gl_context *ctx,
                                      const GLuint *num_groups,
                                      const GLuint *group_size)
 {
    GLuint total_invocations = 1;
 
-   FLUSH_CURRENT(ctx, 0);
-
    if (!check_valid_to_compute(ctx, "glDispatchComputeGroupSizeARB"))
       return GL_FALSE;
 
    /* The ARB_compute_variable_group_size spec says:
     *
     * "An INVALID_OPERATION error is generated by
     *  DispatchComputeGroupSizeARB if the active program for the compute
     *  shader stage has a fixed work group size."
     */
    struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
@@ -177,22 +173,20 @@ validate_DispatchComputeGroupSizeARB(struct gl_context *ctx,
                   ctx->Const.MaxComputeVariableGroupInvocations);
       return GL_FALSE;
    }
 
    return GL_TRUE;
 }
 
 static bool
 valid_dispatch_indirect(struct gl_context *ctx,  GLintptr indirect)
 {
-   FLUSH_CURRENT(ctx, 0);
-
    GLsizei size = 3 * sizeof(GLuint);
    const uint64_t end = (uint64_t) indirect + size;
    const char *name = "glDispatchComputeIndirect";
 
    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
@@ -250,56 +244,62 @@ valid_dispatch_indirect(struct gl_context *ctx,  GLintptr indirect)
 }
 
 void GLAPIENTRY
 _mesa_DispatchCompute(GLuint num_groups_x,
                       GLuint num_groups_y,
                       GLuint num_groups_z)
 {
    GET_CURRENT_CONTEXT(ctx);
    const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z };
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glDispatchCompute(%d, %d, %d)\n",
                   num_groups_x, num_groups_y, num_groups_z);
 
    if (!validate_DispatchCompute(ctx, num_groups))
       return;
 
    if (num_groups_x == 0u || num_groups_y == 0u || num_groups_z == 0u)
        return;
 
    ctx->Driver.DispatchCompute(ctx, num_groups);
 }
 
 extern void GLAPIENTRY
 _mesa_DispatchComputeIndirect(GLintptr indirect)
 {
    GET_CURRENT_CONTEXT(ctx);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glDispatchComputeIndirect(%ld)\n", (long) indirect);
 
    if (!valid_dispatch_indirect(ctx, indirect))
       return;
 
    ctx->Driver.DispatchComputeIndirect(ctx, indirect);
 }
 
 void GLAPIENTRY
 _mesa_DispatchComputeGroupSizeARB(GLuint num_groups_x, GLuint num_groups_y,
                                   GLuint num_groups_z, GLuint group_size_x,
                                   GLuint group_size_y, GLuint group_size_z)
 {
    GET_CURRENT_CONTEXT(ctx);
    const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z };
    const GLuint group_size[3] = { group_size_x, group_size_y, group_size_z };
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx,
                   "glDispatchComputeGroupSizeARB(%d, %d, %d, %d, %d, %d)\n",
                   num_groups_x, num_groups_y, num_groups_z,
                   group_size_x, group_size_y, group_size_z);
 
    if (!validate_DispatchComputeGroupSizeARB(ctx, num_groups, group_size))
       return;
 
    if (num_groups_x == 0u || num_groups_y == 0u || num_groups_z == 0u)
-- 
2.9.3



More information about the mesa-dev mailing list