r300: don't lower sin/cos in finalize_nir
finalize_nir requires that calling it multiple times on the same shader doesn't break it. RV530 shader-db: total instructions in shared programs: 132915 -> 132851 (-0.05%) instructions in affected programs: 2016 -> 1952 (-3.17%) helped: 16 HURT: 0 total temps in shared programs: 18238 -> 18232 (-0.03%) temps in affected programs: 42 -> 36 (-14.29%) helped: 6 HURT: 0 total cycles in shared programs: 197510 -> 197446 (-0.03%) cycles in affected programs: 2102 -> 2038 (-3.04%) helped: 16 HURT: 0 Reviewed-by: Pavel Ondračka <pavel.ondracka@gmail.com> Reviewed-by: Filip Gawin <filip@gawin.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32160>
This commit is contained in:
@@ -2257,6 +2257,26 @@ nir_to_rc(struct nir_shader *s, struct pipe_screen *screen)
|
||||
c->screen = screen;
|
||||
c->lower_fabs = !is_r500 && s->info.stage == MESA_SHADER_VERTEX;
|
||||
|
||||
if (s->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
if (is_r500) {
|
||||
NIR_PASS_V(s, r300_transform_fs_trig_input);
|
||||
}
|
||||
} else if (r300_screen(screen)->caps.has_tcl) {
|
||||
if (is_r500) {
|
||||
/* Only nine should set both NTT shader name and
|
||||
* use_legacy_math_rules and D3D9 already mandates
|
||||
* the proper range for the trigonometric inputs.
|
||||
*/
|
||||
if (!s->info.use_legacy_math_rules || !(s->info.name && !strcmp("TTN", s->info.name))) {
|
||||
NIR_PASS_V(s, r300_transform_vs_trig_input);
|
||||
}
|
||||
} else {
|
||||
if (r300_screen(screen)->caps.is_r400) {
|
||||
NIR_PASS_V(s, r300_transform_vs_trig_input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Lower array indexing on FS inputs. Since we don't set
|
||||
* ureg->supports_any_inout_decl_range, the TGSI input decls will be split to
|
||||
* elements by ureg, and so dynamically indexing them would be invalid.
|
||||
|
||||
@@ -143,44 +143,24 @@ r300_optimize_nir(struct nir_shader *s, struct pipe_screen *screen)
|
||||
bool is_r500 = r300_screen(screen)->caps.is_r500;
|
||||
|
||||
bool progress;
|
||||
if (s->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
if (is_r500) {
|
||||
NIR_PASS_V(s, r300_transform_fs_trig_input);
|
||||
}
|
||||
} else {
|
||||
if (r300_screen(screen)->caps.has_tcl) {
|
||||
if (r300_screen(screen)->caps.is_r500) {
|
||||
/* Only nine should set both NTT shader name and
|
||||
* use_legacy_math_rules and D3D9 already mandates
|
||||
* the proper range for the trigonometric inputs.
|
||||
*/
|
||||
if (!s->info.use_legacy_math_rules || !(s->info.name && !strcmp("TTN", s->info.name))) {
|
||||
NIR_PASS_V(s, r300_transform_vs_trig_input);
|
||||
}
|
||||
} else {
|
||||
if (r300_screen(screen)->caps.is_r400) {
|
||||
NIR_PASS_V(s, r300_transform_vs_trig_input);
|
||||
if (s->info.stage == MESA_SHADER_VERTEX && r300_screen(screen)->caps.has_tcl) {
|
||||
/* There is no HW support for gl_ClipVertex, so we just remove it early. */
|
||||
if (nir_shader_instructions_pass(s, remove_clip_vertex,
|
||||
nir_metadata_control_flow, NULL)) {
|
||||
unsigned clip_vertex_location = 0;
|
||||
nir_foreach_variable_with_modes(var, s, nir_var_shader_out) {
|
||||
if (var->data.location == VARYING_SLOT_CLIP_VERTEX) {
|
||||
clip_vertex_location = var->data.driver_location;
|
||||
}
|
||||
}
|
||||
|
||||
/* There is no HW support for gl_ClipVertex, so we just remove it early. */
|
||||
if (nir_shader_instructions_pass(s, remove_clip_vertex,
|
||||
nir_metadata_control_flow, NULL)) {
|
||||
unsigned clip_vertex_location = 0;
|
||||
nir_foreach_variable_with_modes(var, s, nir_var_shader_out) {
|
||||
if (var->data.location == VARYING_SLOT_CLIP_VERTEX) {
|
||||
clip_vertex_location = var->data.driver_location;
|
||||
}
|
||||
nir_foreach_variable_with_modes(var, s, nir_var_shader_out) {
|
||||
if (var->data.driver_location > clip_vertex_location) {
|
||||
var->data.driver_location--;
|
||||
}
|
||||
nir_foreach_variable_with_modes(var, s, nir_var_shader_out) {
|
||||
if (var->data.driver_location > clip_vertex_location) {
|
||||
var->data.driver_location--;
|
||||
}
|
||||
}
|
||||
NIR_PASS_V(s, nir_remove_dead_variables, nir_var_shader_out, NULL);
|
||||
fprintf(stderr, "r300: no HW support for clip vertex, expect misrendering.\n");
|
||||
fprintf(stderr, "r300: software emulation can be enabled with RADEON_DEBUG=notcl.\n");
|
||||
}
|
||||
NIR_PASS_V(s, nir_remove_dead_variables, nir_var_shader_out, NULL);
|
||||
fprintf(stderr, "r300: no HW support for clip vertex, expect misrendering.\n");
|
||||
fprintf(stderr, "r300: software emulation can be enabled with RADEON_DEBUG=notcl.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user