summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_parser_extras.cpp
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-03-26 00:04:57 -0700
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-04-08 19:29:32 -0700
commit3c5ddaeacd2c52bc11f9cda451fe640cff629bdd (patch)
tree47586c1451345101c711cae5d72e270b025727a6 /src/compiler/glsl/glsl_parser_extras.cpp
parentca60f0b7baeb95caf5d6e0ab4d83c6bb1d3e0eaa (diff)
glsl: Parse and propagate derivative_group to shader_info
NV_compute_shader_derivatives allow selecting between two possible arrangements (quads and linear) when calculating derivatives and certain subgroup operations in case of Vulkan. So parse and propagate those up to shader_info.h. v2: Do not fail when ARB_compute_variable_group_size is being used, since we are still clarifying what is the right thing to do here. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glsl_parser_extras.cpp')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index ec196299b6a..c1c3c9649fe 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1717,7 +1717,8 @@ set_shader_inout_layout(struct gl_shader *shader,
{
/* Should have been prevented by the parser. */
if (shader->Stage != MESA_SHADER_GEOMETRY &&
- shader->Stage != MESA_SHADER_TESS_EVAL) {
+ shader->Stage != MESA_SHADER_TESS_EVAL &&
+ shader->Stage != MESA_SHADER_COMPUTE) {
assert(!state->in_qualifier->flags.i);
}
@@ -1725,6 +1726,7 @@ set_shader_inout_layout(struct gl_shader *shader,
/* Should have been prevented by the parser. */
assert(!state->cs_input_local_size_specified);
assert(!state->cs_input_local_size_variable_specified);
+ assert(state->cs_derivative_group == DERIVATIVE_GROUP_NONE);
}
if (shader->Stage != MESA_SHADER_FRAGMENT) {
@@ -1849,6 +1851,36 @@ set_shader_inout_layout(struct gl_shader *shader,
shader->info.Comp.LocalSizeVariable =
state->cs_input_local_size_variable_specified;
+
+ shader->info.Comp.DerivativeGroup = state->cs_derivative_group;
+
+ if (state->NV_compute_shader_derivatives_enable) {
+ /* We allow multiple cs_input_layout nodes, but do not store them in
+ * a convenient place, so for now live with an empty location error.
+ */
+ YYLTYPE loc = {0};
+ if (shader->info.Comp.DerivativeGroup == DERIVATIVE_GROUP_QUADS) {
+ if (shader->info.Comp.LocalSize[0] % 2 != 0) {
+ _mesa_glsl_error(&loc, state, "derivative_group_quadsNV must be used with a "
+ "local group size whose first dimension "
+ "is a multiple of 2\n");
+ }
+ if (shader->info.Comp.LocalSize[1] % 2 != 0) {
+ _mesa_glsl_error(&loc, state, "derivative_group_quadsNV must be used with a "
+ "local group size whose second dimension "
+ "is a multiple of 2\n");
+ }
+ } else if (shader->info.Comp.DerivativeGroup == DERIVATIVE_GROUP_LINEAR) {
+ if ((shader->info.Comp.LocalSize[0] *
+ shader->info.Comp.LocalSize[1] *
+ shader->info.Comp.LocalSize[2]) % 4 != 0) {
+ _mesa_glsl_error(&loc, state, "derivative_group_linearNV must be used with a "
+ "local group size whose total number of invocations "
+ "is a multiple of 4\n");
+ }
+ }
+ }
+
break;
case MESA_SHADER_FRAGMENT: