diff options
author | Nicolai Hähnle <[email protected]> | 2017-10-10 13:58:43 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-10-10 13:58:43 +0200 |
commit | a2c8812f919c59933605c5942d6613e14ec8b3d1 (patch) | |
tree | d26a5a609334f319ec2ce4b9f14d7ab36a705ec5 /src/compiler/glsl/lower_shared_reference.cpp | |
parent | ca949e00d803abd7500192cc4804e77763c0aff3 (diff) |
glsl/linker: add check for compute shared memory size
Unlike uniforms, the limit on shared memory size is not called out
explicitly in the list of things that cause linker errors, but presumably
that's just an oversight in the spec.
Fixes dEQP-GLES31.functional.debug.negative_coverage.{callbacks,get_error,log}.compute.exceed_shared_memory_size_limit
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl/lower_shared_reference.cpp')
-rw-r--r-- | src/compiler/glsl/lower_shared_reference.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/compiler/glsl/lower_shared_reference.cpp b/src/compiler/glsl/lower_shared_reference.cpp index b9098913af8..a1b3f7df47e 100644 --- a/src/compiler/glsl/lower_shared_reference.cpp +++ b/src/compiler/glsl/lower_shared_reference.cpp @@ -33,6 +33,7 @@ #include "lower_buffer_access.h" #include "ir_builder.h" +#include "linker.h" #include "main/macros.h" #include "util/list.h" #include "glsl_parser_extras.h" @@ -478,7 +479,9 @@ lower_shared_reference_visitor::visit_enter(ir_call *ir) } /* unnamed namespace */ void -lower_shared_reference(struct gl_linked_shader *shader, unsigned *shared_size) +lower_shared_reference(struct gl_context *ctx, + struct gl_shader_program *prog, + struct gl_linked_shader *shader) { if (shader->Stage != MESA_SHADER_COMPUTE) return; @@ -495,5 +498,19 @@ lower_shared_reference(struct gl_linked_shader *shader, unsigned *shared_size) visit_list_elements(&v, shader->ir); } while (v.progress); - *shared_size = v.shared_size; + prog->Comp.SharedSize = v.shared_size; + + /* Section 19.1 (Compute Shader Variables) of the OpenGL 4.5 (Core Profile) + * specification says: + * + * "There is a limit to the total size of all variables declared as + * shared in a single program object. This limit, expressed in units of + * basic machine units, may be queried as the value of + * MAX_COMPUTE_SHARED_MEMORY_SIZE." + */ + if (prog->Comp.SharedSize > ctx->Const.MaxComputeSharedMemorySize) { + linker_error(prog, "Too much shared memory used (%u/%u)\n", + prog->Comp.SharedSize, + ctx->Const.MaxComputeSharedMemorySize); + } } |