mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
glsl: use the nir based lower_named_interface_blocks()
Because we are now doing the lowering in NIR we need to move the code that sets the compact flag on some builtin vars out of the glsl to nir pass. Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26001>
This commit is contained in:
parent
bedf504d38
commit
cdf0ed8960
4 changed files with 56 additions and 42 deletions
|
|
@ -1344,6 +1344,8 @@ gl_nir_link_glsl(const struct gl_constants *consts,
|
|||
last = i;
|
||||
}
|
||||
|
||||
gl_nir_lower_named_interface_blocks(prog);
|
||||
|
||||
/* Validate the inputs of each stage with the output of the preceding
|
||||
* stage.
|
||||
*/
|
||||
|
|
@ -1454,9 +1456,28 @@ gl_nir_link_glsl(const struct gl_constants *consts,
|
|||
nir_var_mem_ubo | nir_var_mem_ssbo |
|
||||
nir_var_system_value,
|
||||
&opts);
|
||||
|
||||
if (shader->Program->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
nir_shader *nir = shader->Program->nir;
|
||||
nir_foreach_variable_in_shader(var, nir) {
|
||||
if (var->data.mode == nir_var_system_value &&
|
||||
(var->data.location == SYSTEM_VALUE_SAMPLE_ID ||
|
||||
var->data.location == SYSTEM_VALUE_SAMPLE_POS))
|
||||
nir->info.fs.uses_sample_shading = true;
|
||||
|
||||
if (var->data.mode == nir_var_shader_in && var->data.sample)
|
||||
nir->info.fs.uses_sample_shading = true;
|
||||
|
||||
if (var->data.mode == nir_var_shader_out &&
|
||||
var->data.fb_fetch_output)
|
||||
nir->info.fs.uses_sample_shading = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!gl_nir_link_uniforms(consts, prog, true))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -309,10 +309,44 @@ lower_named_interface_blocks(struct gl_linked_shader *sh)
|
|||
nir_metadata_dominance, &state);
|
||||
|
||||
/* Third pass: Mark now lowered blks as ordinary globals to be dead code
|
||||
* eliminated.
|
||||
* eliminated. Also use this oppotunity to set the compact flag where
|
||||
* needed now that the default interface block has been lowered away.
|
||||
*/
|
||||
nir_foreach_variable_with_modes(var, sh->Program->nir,
|
||||
nir_var_shader_in | nir_var_shader_out) {
|
||||
|
||||
if (var->data.mode == nir_var_shader_in) {
|
||||
if (sh->Program->nir->info.stage == MESA_SHADER_TESS_EVAL &&
|
||||
(var->data.location == VARYING_SLOT_TESS_LEVEL_INNER ||
|
||||
var->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) {
|
||||
var->data.compact =
|
||||
glsl_type_is_scalar(glsl_without_array(var->type));
|
||||
}
|
||||
|
||||
if (sh->Program->nir->info.stage > MESA_SHADER_VERTEX &&
|
||||
var->data.location >= VARYING_SLOT_CLIP_DIST0 &&
|
||||
var->data.location <= VARYING_SLOT_CULL_DIST1) {
|
||||
var->data.compact =
|
||||
glsl_type_is_scalar(glsl_without_array(var->type));
|
||||
}
|
||||
} else {
|
||||
assert(var->data.mode == nir_var_shader_out);
|
||||
|
||||
if (sh->Program->nir->info.stage == MESA_SHADER_TESS_CTRL &&
|
||||
(var->data.location == VARYING_SLOT_TESS_LEVEL_INNER ||
|
||||
var->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) {
|
||||
var->data.compact =
|
||||
glsl_type_is_scalar(glsl_without_array(var->type));
|
||||
}
|
||||
|
||||
if (sh->Program->nir->info.stage <= MESA_SHADER_GEOMETRY &&
|
||||
var->data.location >= VARYING_SLOT_CLIP_DIST0 &&
|
||||
var->data.location <= VARYING_SLOT_CULL_DIST1) {
|
||||
var->data.compact =
|
||||
glsl_type_is_scalar(glsl_without_array(var->type));
|
||||
}
|
||||
}
|
||||
|
||||
const struct glsl_type * iface_t = glsl_without_array(var->type);
|
||||
if (!(iface_t == var->interface_type))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -303,19 +303,6 @@ glsl_to_nir(const struct gl_constants *consts,
|
|||
shader->info.fs.pixel_center_integer = sh->Program->info.fs.pixel_center_integer;
|
||||
shader->info.fs.origin_upper_left = sh->Program->info.fs.origin_upper_left;
|
||||
shader->info.fs.advanced_blend_modes = sh->Program->info.fs.advanced_blend_modes;
|
||||
|
||||
nir_foreach_variable_in_shader(var, shader) {
|
||||
if (var->data.mode == nir_var_system_value &&
|
||||
(var->data.location == SYSTEM_VALUE_SAMPLE_ID ||
|
||||
var->data.location == SYSTEM_VALUE_SAMPLE_POS))
|
||||
shader->info.fs.uses_sample_shading = true;
|
||||
|
||||
if (var->data.mode == nir_var_shader_in && var->data.sample)
|
||||
shader->info.fs.uses_sample_shading = true;
|
||||
|
||||
if (var->data.mode == nir_var_shader_out && var->data.fb_fetch_output)
|
||||
shader->info.fs.uses_sample_shading = true;
|
||||
}
|
||||
}
|
||||
|
||||
return shader;
|
||||
|
|
@ -585,34 +572,11 @@ nir_visitor::visit(ir_variable *ir)
|
|||
var->data.mode = nir_var_system_value;
|
||||
} else {
|
||||
var->data.mode = nir_var_shader_in;
|
||||
|
||||
if (shader->info.stage == MESA_SHADER_TESS_EVAL &&
|
||||
(ir->data.location == VARYING_SLOT_TESS_LEVEL_INNER ||
|
||||
ir->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) {
|
||||
var->data.compact = ir->type->without_array()->is_scalar();
|
||||
}
|
||||
|
||||
if (shader->info.stage > MESA_SHADER_VERTEX &&
|
||||
ir->data.location >= VARYING_SLOT_CLIP_DIST0 &&
|
||||
ir->data.location <= VARYING_SLOT_CULL_DIST1) {
|
||||
var->data.compact = ir->type->without_array()->is_scalar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ir_var_shader_out:
|
||||
var->data.mode = nir_var_shader_out;
|
||||
if (shader->info.stage == MESA_SHADER_TESS_CTRL &&
|
||||
(ir->data.location == VARYING_SLOT_TESS_LEVEL_INNER ||
|
||||
ir->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) {
|
||||
var->data.compact = ir->type->without_array()->is_scalar();
|
||||
}
|
||||
|
||||
if (shader->info.stage <= MESA_SHADER_GEOMETRY &&
|
||||
ir->data.location >= VARYING_SLOT_CLIP_DIST0 &&
|
||||
ir->data.location <= VARYING_SLOT_CULL_DIST1) {
|
||||
var->data.compact = ir->type->without_array()->is_scalar();
|
||||
}
|
||||
break;
|
||||
|
||||
case ir_var_uniform:
|
||||
|
|
|
|||
|
|
@ -3116,11 +3116,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
if (!prog->data->LinkStatus)
|
||||
goto done;
|
||||
|
||||
for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||
if (prog->_LinkedShaders[i] != NULL)
|
||||
lower_named_interface_blocks(mem_ctx, prog->_LinkedShaders[i]);
|
||||
}
|
||||
|
||||
if (prog->IsES && prog->GLSL_Version == 100)
|
||||
if (!validate_invariant_builtins(prog,
|
||||
prog->_LinkedShaders[MESA_SHADER_VERTEX],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue