st,nir: Use nir_shader::xfb_info in nir_lower_io_passes
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16750>
This commit is contained in:

committed by
Marge Bot

parent
16b0719441
commit
2a22885a45
@@ -4594,7 +4594,7 @@ bool nir_lower_io(nir_shader *shader,
|
||||
bool nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes);
|
||||
|
||||
void
|
||||
nir_lower_io_passes(nir_shader *nir, struct nir_xfb_info *xfb);
|
||||
nir_lower_io_passes(nir_shader *nir);
|
||||
|
||||
bool
|
||||
nir_lower_vars_to_explicit_types(nir_shader *shader,
|
||||
|
@@ -2944,13 +2944,13 @@ nir_lower_color_inputs(nir_shader *nir)
|
||||
}
|
||||
|
||||
static bool
|
||||
nir_add_xfb_info(nir_shader *nir, nir_xfb_info *info)
|
||||
nir_add_xfb_info(nir_shader *nir)
|
||||
{
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
bool progress = false;
|
||||
|
||||
for (unsigned i = 0; i < NIR_MAX_XFB_BUFFERS; i++)
|
||||
nir->info.xfb_stride[i] = info->buffers[i].stride;
|
||||
nir->info.xfb_stride[i] = nir->xfb_info->buffers[i].stride;
|
||||
|
||||
nir_foreach_block (block, impl) {
|
||||
nir_foreach_instr_safe (instr, block) {
|
||||
@@ -2980,9 +2980,9 @@ nir_add_xfb_info(nir_shader *nir, nir_xfb_info *info)
|
||||
nir_io_xfb xfb[2];
|
||||
memset(xfb, 0, sizeof(xfb));
|
||||
|
||||
for (unsigned i = 0; i < info->output_count; i++) {
|
||||
if (info->outputs[i].location == sem.location) {
|
||||
nir_xfb_output_info *out = &info->outputs[i];
|
||||
for (unsigned i = 0; i < nir->xfb_info->output_count; i++) {
|
||||
nir_xfb_output_info *out = &nir->xfb_info->outputs[i];
|
||||
if (out->location == sem.location) {
|
||||
unsigned xfb_mask = writemask & out->component_mask;
|
||||
|
||||
/*fprintf(stdout, "output%u: buffer=%u, offset=%u, location=%u, "
|
||||
@@ -3026,23 +3026,18 @@ type_size_vec4(const struct glsl_type *type, bool bindless)
|
||||
}
|
||||
|
||||
void
|
||||
nir_lower_io_passes(nir_shader *nir, nir_xfb_info *xfb)
|
||||
nir_lower_io_passes(nir_shader *nir)
|
||||
{
|
||||
if (!nir->options->lower_io_variables)
|
||||
return;
|
||||
|
||||
/* Ignore transform feedback for stages that can't have it. */
|
||||
if (nir->info.stage != MESA_SHADER_VERTEX &&
|
||||
nir->info.stage != MESA_SHADER_TESS_EVAL &&
|
||||
nir->info.stage != MESA_SHADER_GEOMETRY)
|
||||
xfb = NULL;
|
||||
|
||||
bool has_indirect_inputs =
|
||||
(nir->options->support_indirect_inputs >> nir->info.stage) & 0x1;
|
||||
|
||||
/* Transform feedback requires that indirect outputs are lowered. */
|
||||
bool has_indirect_outputs =
|
||||
(nir->options->support_indirect_outputs >> nir->info.stage) & 0x1 && !xfb;
|
||||
(nir->options->support_indirect_outputs >> nir->info.stage) & 0x1 &&
|
||||
nir->xfb_info == NULL;
|
||||
|
||||
if (!has_indirect_inputs || !has_indirect_outputs) {
|
||||
NIR_PASS_V(nir, nir_lower_io_to_temporaries,
|
||||
@@ -3075,8 +3070,8 @@ nir_lower_io_passes(nir_shader *nir, nir_xfb_info *xfb)
|
||||
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp |
|
||||
nir_var_shader_in | nir_var_shader_out, NULL);
|
||||
|
||||
if (xfb)
|
||||
NIR_PASS_V(nir, nir_add_xfb_info, xfb);
|
||||
if (nir->xfb_info)
|
||||
NIR_PASS_V(nir, nir_add_xfb_info);
|
||||
|
||||
nir->info.io_lowered = true;
|
||||
}
|
||||
|
@@ -319,7 +319,7 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr)
|
||||
struct si_screen *sscreen = (struct si_screen *)screen;
|
||||
struct nir_shader *nir = (struct nir_shader *)nirptr;
|
||||
|
||||
nir_lower_io_passes(nir, NULL);
|
||||
nir_lower_io_passes(nir);
|
||||
|
||||
/* Remove dead derefs, so that we can remove uniforms. */
|
||||
NIR_PASS_V(nir, nir_opt_dce);
|
||||
|
@@ -1074,12 +1074,8 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
|
||||
/* Lower load_deref/store_deref of inputs and outputs.
|
||||
* This depends on st_nir_assign_varying_locations.
|
||||
*/
|
||||
if (nir->options->lower_io_variables) {
|
||||
nir_xfb_info *xfb = shader_program ?
|
||||
gl_to_nir_xfb_info(prog->sh.LinkedTransformFeedback, NULL) : NULL;
|
||||
nir_lower_io_passes(nir, xfb);
|
||||
ralloc_free(xfb);
|
||||
}
|
||||
if (nir->options->lower_io_variables)
|
||||
nir_lower_io_passes(nir);
|
||||
|
||||
/* Set num_uniforms in number of attribute slots (vec4s) */
|
||||
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
|
||||
|
Reference in New Issue
Block a user