mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_COUNT constant.
authorPaul Berry <stereotype441@gmail.com>
Wed, 8 Jan 2014 09:42:58 +0000 (01:42 -0800)
committerPaul Berry <stereotype441@gmail.com>
Wed, 5 Feb 2014 17:03:08 +0000 (09:03 -0800)
v2: Document that the 3-element array MaxComputeWorkGroupCount is
indexed by dimension.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/builtin_variables.cpp
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/glsl/main.cpp
src/glsl/standalone_scaffolding.cpp
src/mesa/main/context.c
src/mesa/main/get.c
src/mesa/main/mtypes.h

index f96d4895d5fa26593ab320de9584664a95191b67..3e7a84521e932ea95c6f33684afd7982f2a2c993 100644 (file)
@@ -682,6 +682,10 @@ builtin_variable_generator::generate_constants()
    }
 
    if (state->is_version(430, 0) || state->ARB_compute_shader_enable) {
+      add_const_ivec3("gl_MaxComputeWorkGroupCount",
+                      state->Const.MaxComputeWorkGroupCount[0],
+                      state->Const.MaxComputeWorkGroupCount[1],
+                      state->Const.MaxComputeWorkGroupCount[2]);
       add_const_ivec3("gl_MaxComputeWorkGroupSize",
                       state->Const.MaxComputeWorkGroupSize[0],
                       state->Const.MaxComputeWorkGroupSize[1],
index d256680e8ea2e6f198018561892d501c9321603b..d45e63f9d2ff7ef6a210cf3b64ed6294483b3ada 100644 (file)
@@ -124,6 +124,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
    this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings;
 
    /* Compute shader constants */
+   for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupCount); i++)
+      this->Const.MaxComputeWorkGroupCount[i] = ctx->Const.MaxComputeWorkGroupCount[i];
    for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupSize); i++)
       this->Const.MaxComputeWorkGroupSize[i] = ctx->Const.MaxComputeWorkGroupSize[i];
 
index 802e0f0e6357a6b612aa2f71bc8080d34424ba13..20ed2cfddc65e02b2602772072fc0c1578f60e86 100644 (file)
@@ -252,6 +252,7 @@ struct _mesa_glsl_parse_state {
       unsigned MaxAtomicBufferBindings;
 
       /* ARB_compute_shader */
+      unsigned MaxComputeWorkGroupCount[3];
       unsigned MaxComputeWorkGroupSize[3];
    } Const;
 
index 94bc1cc5e915a5cbdaa4ec669361b60ed4357976..5ea57d53a88c70de0bb434fa4e107586099c7a4d 100644 (file)
@@ -50,6 +50,9 @@ initialize_context(struct gl_context *ctx, gl_api api)
     */
    ctx->Const.GLSLVersion = glsl_version;
    ctx->Extensions.ARB_ES3_compatibility = true;
+   ctx->Const.MaxComputeWorkGroupCount[0] = 65535;
+   ctx->Const.MaxComputeWorkGroupCount[1] = 65535;
+   ctx->Const.MaxComputeWorkGroupCount[2] = 65535;
    ctx->Const.MaxComputeWorkGroupSize[0] = 1024;
    ctx->Const.MaxComputeWorkGroupSize[1] = 1024;
    ctx->Const.MaxComputeWorkGroupSize[2] = 64;
index 475fbd8edc84cf9140752a821ecf2846ff3aa5d8..6c25010b7d9a8da3f63198c87081869710ba2559 100644 (file)
@@ -141,6 +141,9 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
    ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32;
 
    ctx->Const.MaxDrawBuffers = 1;
+   ctx->Const.MaxComputeWorkGroupCount[0] = 65535;
+   ctx->Const.MaxComputeWorkGroupCount[1] = 65535;
+   ctx->Const.MaxComputeWorkGroupCount[2] = 65535;
    ctx->Const.MaxComputeWorkGroupSize[0] = 1024;
    ctx->Const.MaxComputeWorkGroupSize[1] = 1024;
    ctx->Const.MaxComputeWorkGroupSize[2] = 64;
index 4cf86bc5150411d1c0530523e36db5008ccf5e2d..f2f9bb3ed5cb1fee9346b92271d6d982762e258f 100644 (file)
@@ -702,6 +702,9 @@ _mesa_init_constants(struct gl_context *ctx)
    ctx->Const.MaxVertexAttribBindings = MAX_VERTEX_GENERIC_ATTRIBS;
 
    /* GL_ARB_compute_shader */
+   ctx->Const.MaxComputeWorkGroupCount[0] = 65535;
+   ctx->Const.MaxComputeWorkGroupCount[1] = 65535;
+   ctx->Const.MaxComputeWorkGroupCount[2] = 65535;
    ctx->Const.MaxComputeWorkGroupSize[0] = 1024;
    ctx->Const.MaxComputeWorkGroupSize[1] = 1024;
    ctx->Const.MaxComputeWorkGroupSize[2] = 64;
index 2833a15a43397e14f489ec80a3a663910f697f4c..32aa7364a919fd3af53ba3853c1180b58122d157 100644 (file)
@@ -1929,6 +1929,14 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
       v->value_int = ctx->ImageUnits[index].Format;
       return TYPE_INT;
 
+   case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
+      if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_compute_shader)
+         goto invalid_enum;
+      if (index >= 3)
+         goto invalid_value;
+      v->value_int = ctx->Const.MaxComputeWorkGroupCount[index];
+      return TYPE_INT;
+
    case GL_MAX_COMPUTE_WORK_GROUP_SIZE:
       if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_compute_shader)
          goto invalid_enum;
index 40e2e68f2d7b082e966f953ee0e92db992d7bb21..bd22d5003fd16fcaa4b00bbf4fb9201572955e1e 100644 (file)
@@ -3380,6 +3380,7 @@ struct gl_constants
    GLuint MaxCombinedImageUniforms;
 
    /** GL_ARB_compute_shader */
+   GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
    GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
    GLuint MaxComputeWorkGroupInvocations;
 };