summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300/r300_state.c
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2021-12-06 12:11:43 -0800
committerMarge Bot <emma+marge@anholt.net>2021-12-09 22:15:53 +0000
commit7d2ea9b0edef2176140629ac3dee6a6809c4abe2 (patch)
tree7857a0a27a8ab41487e41efe46b33888e4594b05 /src/gallium/drivers/r300/r300_state.c
parente68a9b033997c9de485c2914717d25e55fbb053e (diff)
r300: Request NIR shaders from mesa/st and use NIR-to-TGSI.
This brings us into parity on state tracker paths with most other supported drivers, and a lot of additional optimization on our shaders. Results on a subset of shader-db that doesn't crash: instructions in affected programs: 59502 -> 47991 (-19.35%) vinst in affected programs: 17633 -> 15197 (-13.82%) sinst in affected programs: 9296 -> 7319 (-21.27%) flowcontrol in affected programs: 627 -> 310 (-50.56%) presub in affected programs: 4220 -> 1554 (-63.18%) temps in affected programs: 5775 -> 8570 (48.40%) lits in affected programs: 215 -> 37 (-82.79%) The temps (register usage) increase is unfortunate, but it seems that instruction counts tend to be our limit before reg counts are. Fixes: #3354 Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14096>
Diffstat (limited to 'src/gallium/drivers/r300/r300_state.c')
-rw-r--r--src/gallium/drivers/r300/r300_state.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 39c442802af..4c9df7588bb 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -46,6 +46,7 @@
#include "r300_fs.h"
#include "r300_texture.h"
#include "r300_vs.h"
+#include "nir/nir_to_tgsi.h"
/* r300_state: Functions used to initialize state context by translating
* Gallium state objects into semi-native r300 state objects. */
@@ -1041,7 +1042,14 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
/* Copy state directly into shader. */
fs->state = *shader;
- fs->state.tokens = tgsi_dup_tokens(shader->tokens);
+
+ if (fs->state.type == PIPE_SHADER_IR_NIR) {
+ fs->state.tokens = nir_to_tgsi(shader->ir.nir, pipe->screen);
+ } else {
+ assert(fs->state.type == PIPE_SHADER_IR_TGSI);
+ /* we need to keep a local copy of the tokens */
+ fs->state.tokens = tgsi_dup_tokens(fs->state.tokens);
+ }
/* Precompile the fragment shader at creation time to avoid jank at runtime.
* In most cases we won't have anything in the key at draw time.
@@ -1925,7 +1933,14 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
/* Copy state directly into shader. */
vs->state = *shader;
- vs->state.tokens = tgsi_dup_tokens(shader->tokens);
+
+ if (vs->state.type == PIPE_SHADER_IR_NIR) {
+ vs->state.tokens = nir_to_tgsi(shader->ir.nir, pipe->screen);
+ } else {
+ assert(vs->state.type == PIPE_SHADER_IR_TGSI);
+ /* we need to keep a local copy of the tokens */
+ vs->state.tokens = tgsi_dup_tokens(vs->state.tokens);
+ }
if (r300->screen->caps.has_tcl) {
r300_init_vs_outputs(r300, vs);