[Mesa-dev] [PATCH] glsl: expose accurate gl_MaxCompute* constants rather than cooked values

Timothy Arceri t_arceri at yahoo.com.au
Wed Jan 20 00:48:07 PST 2016


On Wed, 2016-01-20 at 03:06 -0500, Ilia Mirkin wrote:
> Looks like the various max's were never plumbed through. This fixes
> dEQP
> test failures which checked for gl_MaxCompute* to match up to the
> relevant GL queries.
> 
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/glsl/builtin_variables.cpp  | 15 ++++++++++-----
>  src/glsl/glsl_parser_extras.cpp |  7 +++++++
>  src/glsl/glsl_parser_extras.h   |  5 +++++
>  src/glsl/main.cpp               |  4 ++++
>  src/mesa/main/config.h          | 10 ----------
>  5 files changed, 26 insertions(+), 15 deletions(-)
> 
> diff --git a/src/glsl/builtin_variables.cpp
> b/src/glsl/builtin_variables.cpp
> index cc7fca2..a8bcdff 100644
> --- a/src/glsl/builtin_variables.cpp
> +++ b/src/glsl/builtin_variables.cpp
> @@ -772,11 +772,16 @@
> builtin_variable_generator::generate_constants()
>     }
>  
>     if (state->is_version(430, 310) || state
> ->ARB_compute_shader_enable) {
> -      add_const("gl_MaxComputeAtomicCounterBuffers",
> MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS);
> -      add_const("gl_MaxComputeAtomicCounters",
> MAX_COMPUTE_ATOMIC_COUNTERS);
> -      add_const("gl_MaxComputeImageUniforms",
> MAX_COMPUTE_IMAGE_UNIFORMS);
> -      add_const("gl_MaxComputeTextureImageUnits",
> MAX_COMPUTE_TEXTURE_IMAGE_UNITS);
> -      add_const("gl_MaxComputeUniformComponents",
> MAX_COMPUTE_UNIFORM_COMPONENTS);
> +      add_const("gl_MaxComputeAtomicCounterBuffers",
> +                state->Const.MaxComputeAtomicCounterBuffers);
> +      add_const("gl_MaxComputeAtomicCounters",
> +                state->Const.MaxComputeAtomicCounters);
> +      add_const("gl_MaxComputeImageUniforms",
> +                state->Const.MaxComputeImageUniforms);
> +      add_const("gl_MaxComputeTextureImageUnits",
> +                state->Const.MaxComputeTextureImageUnits);
> +      add_const("gl_MaxComputeUniformComponents",
> +                state->Const.MaxComputeUniformComponents);
>  
>        add_const_ivec3("gl_MaxComputeWorkGroupCount",
>                        state->Const.MaxComputeWorkGroupCount[0],
> diff --git a/src/glsl/glsl_parser_extras.cpp
> b/src/glsl/glsl_parser_extras.cpp
> index 1d74db5..8765eb8 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -119,6 +119,7 @@
> _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context
> *_ctx,
>     this->Const.MaxTessEvaluationAtomicCounters = ctx
> ->Const.Program[MESA_SHADER_TESS_EVAL].MaxAtomicCounters;
>     this->Const.MaxGeometryAtomicCounters = ctx
> ->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters;
>     this->Const.MaxFragmentAtomicCounters = ctx
> ->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters;
> +   this->Const.MaxComputeAtomicCounters = ctx
> ->Const.Program[MESA_SHADER_COMPUTE].MaxAtomicCounters;
>     this->Const.MaxCombinedAtomicCounters = ctx
> ->Const.MaxCombinedAtomicCounters;
>     this->Const.MaxAtomicBufferBindings = ctx
> ->Const.MaxAtomicBufferBindings;
>     this->Const.MaxVertexAtomicCounterBuffers =
> @@ -131,6 +132,8 @@
> _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context
> *_ctx,
>        ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers;
>     this->Const.MaxFragmentAtomicCounterBuffers =
>        ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
> +   this->Const.MaxComputeAtomicCounterBuffers =
> +      ctx->Const.Program[MESA_SHADER_COMPUTE].MaxAtomicBuffers;
>     this->Const.MaxCombinedAtomicCounterBuffers =
>        ctx->Const.MaxCombinedAtomicBuffers;
>     this->Const.MaxAtomicCounterBufferSize =
> @@ -142,6 +145,9 @@
> _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context
> *_ctx,
>     for (unsigned i = 0; i < ARRAY_SIZE(this
> ->Const.MaxComputeWorkGroupSize); i++)
>        this->Const.MaxComputeWorkGroupSize[i] = ctx
> ->Const.MaxComputeWorkGroupSize[i];
>  
> +   this->Const.MaxComputeTextureImageUnits = ctx
> ->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits;
> +   this->Const.MaxComputeUniformComponents = ctx
> ->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents;
> +
>     this->Const.MaxImageUnits = ctx->Const.MaxImageUnits;
>     this->Const.MaxCombinedShaderOutputResources = ctx
> ->Const.MaxCombinedShaderOutputResources;
>     this->Const.MaxImageSamples = ctx->Const.MaxImageSamples;
> @@ -150,6 +156,7 @@
> _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context
> *_ctx,
>     this->Const.MaxTessEvaluationImageUniforms = ctx
> ->Const.Program[MESA_SHADER_TESS_EVAL].MaxImageUniforms;
>     this->Const.MaxGeometryImageUniforms = ctx
> ->Const.Program[MESA_SHADER_GEOMETRY].MaxImageUniforms;
>     this->Const.MaxFragmentImageUniforms = ctx
> ->Const.Program[MESA_SHADER_FRAGMENT].MaxImageUniforms;
> +   this->Const.MaxComputeImageUniforms = ctx
> ->Const.Program[MESA_SHADER_COMPUTE].MaxImageUniforms;
>     this->Const.MaxCombinedImageUniforms = ctx
> ->Const.MaxCombinedImageUniforms;
>  
>     /* ARB_viewport_array */
> diff --git a/src/glsl/glsl_parser_extras.h
> b/src/glsl/glsl_parser_extras.h
> index ecc2992..43a99ad 100644
> --- a/src/glsl/glsl_parser_extras.h
> +++ b/src/glsl/glsl_parser_extras.h
> @@ -424,6 +424,11 @@ struct _mesa_glsl_parse_state {
>        unsigned MaxAtomicCounterBufferSize;
>  
>        /* ARB_compute_shader */
> +      unsigned MaxComputeAtomicCounterBuffers;
> +      unsigned MaxComputeAtomicCounters;
> +      unsigned MaxComputeImageUniforms;
> +      unsigned MaxComputeTextureImageUnits;
> +      unsigned MaxComputeUniformComponents;
>        unsigned MaxComputeWorkGroupCount[3];
>        unsigned MaxComputeWorkGroupSize[3];
>  
> diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
> index c9432f1..bdf2f07 100644
> --- a/src/glsl/main.cpp
> +++ b/src/glsl/main.cpp
> @@ -63,6 +63,10 @@ initialize_context(struct gl_context *ctx, gl_api
> api)
>     ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents =
> 1024;

I think the above default is wrong too, it should be 512.

>     ctx->Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0;
> /* not used */
>     ctx->Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0;
> /* not used */
> +   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxAtomicBuffers = 8;
> +   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxAtomicCounters = 8;
> +   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxImageUniforms = 8;
> +   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformBlocks = 12;
>  
>     switch (ctx->Const.GLSLVersion) {
>     case 100:
> diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
> index a769e51..820ae07 100644
> --- a/src/mesa/main/config.h
> +++ b/src/mesa/main/config.h
> @@ -288,16 +288,6 @@
>  #define PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS 0
>  /*@}*/
>  
> -/** For GL_ARB_compute_shader */
> -/*@{*/
> -#define MAX_COMPUTE_UNIFORM_BLOCKS          12
> -#define MAX_COMPUTE_TEXTURE_IMAGE_UNITS     16
> -#define MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS  8
> -#define MAX_COMPUTE_ATOMIC_COUNTERS         8
> -#define MAX_COMPUTE_UNIFORM_COMPONENTS      512
> -#define MAX_COMPUTE_IMAGE_UNIFORMS          8
> -/*@}*/
> -
>  /** For GL_ARB_pipeline_statistics_query */
>  #define MAX_PIPELINE_STATISTICS             11
>  


More information about the mesa-dev mailing list