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:
@@ -2170,9 +2170,9 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
|
||||
|
||||
|
||||
/**
|
||||
* Perform cross-validation of compute shader local_size_{x,y,z} layout
|
||||
* qualifiers for the attached compute shaders, and propagate them to the
|
||||
* linked CS and linked shader program.
|
||||
* Perform cross-validation of compute shader local_size_{x,y,z} layout and
|
||||
* derivative arrangement qualifiers for the attached compute shaders, and
|
||||
* propagate them to the linked CS and linked shader program.
|
||||
*/
|
||||
static void
|
||||
link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
|
||||
@@ -2191,6 +2191,8 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
|
||||
|
||||
gl_prog->info.cs.local_size_variable = false;
|
||||
|
||||
gl_prog->info.cs.derivative_group = DERIVATIVE_GROUP_NONE;
|
||||
|
||||
/* From the ARB_compute_shader spec, in the section describing local size
|
||||
* declarations:
|
||||
*
|
||||
@@ -2234,6 +2236,17 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
|
||||
}
|
||||
gl_prog->info.cs.local_size_variable = true;
|
||||
}
|
||||
|
||||
enum gl_derivative_group group = shader->info.Comp.DerivativeGroup;
|
||||
if (group != DERIVATIVE_GROUP_NONE) {
|
||||
if (gl_prog->info.cs.derivative_group != DERIVATIVE_GROUP_NONE &&
|
||||
gl_prog->info.cs.derivative_group != group) {
|
||||
linker_error(prog, "compute shader defined with conflicting "
|
||||
"derivative groups\n");
|
||||
return;
|
||||
}
|
||||
gl_prog->info.cs.derivative_group = group;
|
||||
}
|
||||
}
|
||||
|
||||
/* Just do the intrastage -> interstage propagation right now,
|
||||
@@ -2246,6 +2259,30 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
|
||||
"local group size\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (gl_prog->info.cs.derivative_group == DERIVATIVE_GROUP_QUADS) {
|
||||
if (gl_prog->info.cs.local_size[0] % 2 != 0) {
|
||||
linker_error(prog, "derivative_group_quadsNV must be used with a "
|
||||
"local group size whose first dimension "
|
||||
"is a multiple of 2\n");
|
||||
return;
|
||||
}
|
||||
if (gl_prog->info.cs.local_size[1] % 2 != 0) {
|
||||
linker_error(prog, "derivative_group_quadsNV must be used with a local"
|
||||
"group size whose second dimension "
|
||||
"is a multiple of 2\n");
|
||||
return;
|
||||
}
|
||||
} else if (gl_prog->info.cs.derivative_group == DERIVATIVE_GROUP_LINEAR) {
|
||||
if ((gl_prog->info.cs.local_size[0] *
|
||||
gl_prog->info.cs.local_size[1] *
|
||||
gl_prog->info.cs.local_size[2]) % 4 != 0) {
|
||||
linker_error(prog, "derivative_group_linearNV must be used with a "
|
||||
"local group size whose total number of invocations "
|
||||
"is a multiple of 4\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user