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 <ian.d.romanick@intel.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user