r300: enable R400 cos and sin hardware vertex shader opcodes

The R400 has working hardware opcodes for cos and sin at
the vertex shader level. This change enables these features.

This change was tested on an ATI R430 (0x554d).

Here is the shader-db summary:
total instructions in shared programs: 103863 -> 103552 (-0.30%)
instructions in affected programs: 5610 -> 5299 (-5.54%)
helped: 38
HURT: 24
total temps in shared programs: 16836 -> 16830 (-0.04%)
temps in affected programs: 42 -> 36 (-14.29%)
helped: 6
HURT: 0
total cycles in shared programs: 162448 -> 162139 (-0.19%)
cycles in affected programs: 5760 -> 5451 (-5.36%)
helped: 38
HURT: 24

LOST:   0
GAINED: 3

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10504
Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27970>
This commit is contained in:
Patrick Lerda 2024-03-04 14:20:24 +01:00 committed by Marge Bot
parent 158e5882e9
commit 11ce5b1a9f
2 changed files with 20 additions and 4 deletions

View file

@ -538,6 +538,14 @@ static const nir_shader_compiler_options r300_vs_compiler_options = {
.max_unroll_iterations = 32,
};
static const nir_shader_compiler_options r400_vs_compiler_options = {
COMMON_NIR_OPTIONS,
.lower_fsat = true, /* No fsat in pre-r500 VS */
/* Note: has HW loops support, but only 256 ALU instructions. */
.max_unroll_iterations = 32,
};
static const nir_shader_compiler_options r300_fs_compiler_options = {
COMMON_NIR_OPTIONS,
.lower_fpow = true, /* POW is only in the VS */
@ -563,10 +571,14 @@ r300_get_compiler_options(struct pipe_screen *pscreen,
else
return &r500_fs_compiler_options;
} else {
if (shader == PIPE_SHADER_VERTEX)
if (shader == PIPE_SHADER_VERTEX) {
if (r300screen->caps.is_r400)
return &r400_vs_compiler_options;
return &r300_vs_compiler_options;
else
} else {
return &r300_fs_compiler_options;
}
}
}

View file

@ -1965,9 +1965,13 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
!(info->name && !strcmp("TTN", info->name))) {
NIR_PASS_V(shader->ir.nir, r300_transform_vs_trig_input);
}
}
else
} else {
ntr_options = &hwtcl_r300_options;
if (r300->screen->caps.is_r400) {
NIR_PASS_V(shader->ir.nir, r300_transform_vs_trig_input);
}
}
} else {
ntr_options = &swtcl_options;
}