summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2016-09-06 22:46:42 +0200
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>2016-10-07 00:18:57 +0200
commitdee627a16ee46ffd9d049217cbb394d4ad5c6043 (patch)
treeb167180773688e164749b0c331753c6c43b44aa0
parent008e785f742078e17221ebea727a5a5ea7ee95ff (diff)
downloadexternal_mesa3d-dee627a16ee46ffd9d049217cbb394d4ad5c6043.zip
external_mesa3d-dee627a16ee46ffd9d049217cbb394d4ad5c6043.tar.gz
external_mesa3d-dee627a16ee46ffd9d049217cbb394d4ad5c6043.tar.bz2
glsl/linker: handle errors when a variable local size is used
Compute shaders can now include a fixed local size as defined by ARB_compute_shader or a variable size as defined by ARB_compute_variable_group_size. v2: - update formatting spec quotations (Ian) - various cosmetic changes (Ian) Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
-rw-r--r--src/compiler/glsl/linker.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index e6b2231..8599590 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -1988,6 +1988,8 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
for (int i = 0; i < 3; i++)
linked_shader->info.Comp.LocalSize[i] = 0;
+ linked_shader->info.Comp.LocalSizeVariable = false;
+
/* This function is called for all shader stages, but it only has an effect
* for compute shaders.
*/
@@ -2022,6 +2024,20 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
linked_shader->info.Comp.LocalSize[i] =
shader->info.Comp.LocalSize[i];
}
+ } else if (shader->info.Comp.LocalSizeVariable) {
+ if (linked_shader->info.Comp.LocalSize[0] != 0) {
+ /* The ARB_compute_variable_group_size spec says:
+ *
+ * If one compute shader attached to a program declares a
+ * variable local group size and a second compute shader
+ * attached to the same program declares a fixed local group
+ * size, a link-time error results.
+ */
+ linker_error(prog, "compute shader defined with both fixed and "
+ "variable local group size\n");
+ return;
+ }
+ linked_shader->info.Comp.LocalSizeVariable = true;
}
}
@@ -2029,12 +2045,17 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
* since we already know we're in the right type of shader program
* for doing it.
*/
- if (linked_shader->info.Comp.LocalSize[0] == 0) {
- linker_error(prog, "compute shader didn't declare local size\n");
+ if (linked_shader->info.Comp.LocalSize[0] == 0 &&
+ !linked_shader->info.Comp.LocalSizeVariable) {
+ linker_error(prog, "compute shader must contain a fixed or a variable "
+ "local group size\n");
return;
}
for (int i = 0; i < 3; i++)
prog->Comp.LocalSize[i] = linked_shader->info.Comp.LocalSize[i];
+
+ prog->Comp.LocalSizeVariable =
+ linked_shader->info.Comp.LocalSizeVariable;
}