mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 11:30:11 +01:00
glsl: lower IO in the linker if enabled, don't lower it later
This removes the useless codepath that kept IO derefs until st_finalize_nir. It was used before nir_opt_varyings existed. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31968>
This commit is contained in:
parent
32a537b25b
commit
adc40aee25
4 changed files with 11 additions and 32 deletions
|
|
@ -1497,6 +1497,7 @@ gl_nir_lower_optimize_varyings(const struct gl_constants *consts,
|
||||||
unsigned num_shaders = 0;
|
unsigned num_shaders = 0;
|
||||||
unsigned max_ubos = UINT_MAX;
|
unsigned max_ubos = UINT_MAX;
|
||||||
unsigned max_uniform_comps = UINT_MAX;
|
unsigned max_uniform_comps = UINT_MAX;
|
||||||
|
bool optimize_io = true;
|
||||||
|
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||||
struct gl_linked_shader *shader = prog->_LinkedShaders[i];
|
struct gl_linked_shader *shader = prog->_LinkedShaders[i];
|
||||||
|
|
@ -1506,11 +1507,8 @@ gl_nir_lower_optimize_varyings(const struct gl_constants *consts,
|
||||||
|
|
||||||
nir_shader *nir = shader->Program->nir;
|
nir_shader *nir = shader->Program->nir;
|
||||||
|
|
||||||
if (nir->info.stage == MESA_SHADER_COMPUTE)
|
if (nir->info.stage == MESA_SHADER_COMPUTE ||
|
||||||
return;
|
!(nir->options->io_options & nir_io_glsl_lower_derefs))
|
||||||
|
|
||||||
if (!(nir->options->io_options & nir_io_glsl_lower_derefs) ||
|
|
||||||
!(nir->options->io_options & nir_io_glsl_opt_varyings))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shaders[num_shaders] = nir;
|
shaders[num_shaders] = nir;
|
||||||
|
|
@ -1518,14 +1516,15 @@ gl_nir_lower_optimize_varyings(const struct gl_constants *consts,
|
||||||
consts->Program[i].MaxUniformComponents);
|
consts->Program[i].MaxUniformComponents);
|
||||||
max_ubos = MIN2(max_ubos, consts->Program[i].MaxUniformBlocks);
|
max_ubos = MIN2(max_ubos, consts->Program[i].MaxUniformBlocks);
|
||||||
num_shaders++;
|
num_shaders++;
|
||||||
|
optimize_io &= nir->options->io_options & nir_io_glsl_opt_varyings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lower IO derefs to load and store intrinsics. */
|
/* Lower IO derefs to load and store intrinsics. */
|
||||||
for (unsigned i = 0; i < num_shaders; i++) {
|
for (unsigned i = 0; i < num_shaders; i++)
|
||||||
nir_shader *nir = shaders[i];
|
nir_lower_io_passes(shaders[i], true);
|
||||||
|
|
||||||
nir_lower_io_passes(nir, true);
|
if (!optimize_io)
|
||||||
}
|
return;
|
||||||
|
|
||||||
/* There is nothing to optimize for only 1 shader. */
|
/* There is nothing to optimize for only 1 shader. */
|
||||||
if (num_shaders == 1) {
|
if (num_shaders == 1) {
|
||||||
|
|
|
||||||
|
|
@ -3843,13 +3843,7 @@ typedef enum {
|
||||||
nir_io_glsl_lower_derefs = BITFIELD_BIT(16),
|
nir_io_glsl_lower_derefs = BITFIELD_BIT(16),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run nir_opt_varyings in the GLSL linker. If false, optimize varyings
|
* Run nir_opt_varyings in the GLSL linker.
|
||||||
* the old way and lower IO later.
|
|
||||||
*
|
|
||||||
* nir_io_lower_to_intrinsics must be set for this to take effect.
|
|
||||||
*
|
|
||||||
* TODO: remove this and default to enabled once we are sure that this
|
|
||||||
* codepath is solid.
|
|
||||||
*/
|
*/
|
||||||
nir_io_glsl_opt_varyings = BITFIELD_BIT(17),
|
nir_io_glsl_opt_varyings = BITFIELD_BIT(17),
|
||||||
} nir_io_options;
|
} nir_io_options;
|
||||||
|
|
|
||||||
|
|
@ -335,8 +335,7 @@ _mesa_spirv_to_nir(struct gl_context *ctx,
|
||||||
NIR_PASS(_, nir, nir_split_per_member_structs);
|
NIR_PASS(_, nir, nir_split_per_member_structs);
|
||||||
|
|
||||||
if (nir->info.stage == MESA_SHADER_VERTEX &&
|
if (nir->info.stage == MESA_SHADER_VERTEX &&
|
||||||
(!(nir->options->io_options & nir_io_glsl_lower_derefs) ||
|
!(nir->options->io_options & nir_io_glsl_lower_derefs))
|
||||||
!(nir->options->io_options & nir_io_glsl_opt_varyings)))
|
|
||||||
nir_remap_dual_slot_attributes(nir, &linked_shader->Program->DualSlotInputs);
|
nir_remap_dual_slot_attributes(nir, &linked_shader->Program->DualSlotInputs);
|
||||||
|
|
||||||
NIR_PASS(_, nir, nir_lower_frexp);
|
NIR_PASS(_, nir, nir_lower_frexp);
|
||||||
|
|
|
||||||
|
|
@ -737,8 +737,7 @@ st_link_glsl_to_nir(struct gl_context *ctx,
|
||||||
prog->info.num_abos = old_info.num_abos;
|
prog->info.num_abos = old_info.num_abos;
|
||||||
|
|
||||||
if (prog->info.stage == MESA_SHADER_VERTEX) {
|
if (prog->info.stage == MESA_SHADER_VERTEX) {
|
||||||
if (prog->nir->info.io_lowered &&
|
if (prog->nir->info.io_lowered) {
|
||||||
prog->nir->options->io_options & nir_io_glsl_opt_varyings) {
|
|
||||||
prog->info.inputs_read = prog->nir->info.inputs_read;
|
prog->info.inputs_read = prog->nir->info.inputs_read;
|
||||||
prog->DualSlotInputs = prog->nir->info.dual_slot_inputs;
|
prog->DualSlotInputs = prog->nir->info.dual_slot_inputs;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -910,18 +909,6 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
|
||||||
st_nir_assign_varying_locations(st, nir);
|
st_nir_assign_varying_locations(st, nir);
|
||||||
st_nir_assign_uniform_locations(st->ctx, prog, nir);
|
st_nir_assign_uniform_locations(st->ctx, prog, nir);
|
||||||
|
|
||||||
/* Lower load_deref/store_deref of inputs and outputs.
|
|
||||||
* This depends on st_nir_assign_varying_locations.
|
|
||||||
*
|
|
||||||
* TODO: remove this once nir_io_glsl_opt_varyings is enabled by default.
|
|
||||||
*/
|
|
||||||
if (!is_draw_shader && nir->options->io_options & nir_io_glsl_lower_derefs &&
|
|
||||||
!(nir->options->io_options & nir_io_glsl_opt_varyings)) {
|
|
||||||
nir_lower_io_passes(nir, false);
|
|
||||||
NIR_PASS(_, nir, nir_remove_dead_variables,
|
|
||||||
nir_var_shader_in | nir_var_shader_out, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set num_uniforms in number of attribute slots (vec4s) */
|
/* Set num_uniforms in number of attribute slots (vec4s) */
|
||||||
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
|
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue