nv50,nvc0: Use ttn for tgsi shaders by default

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22537>
This commit is contained in:
M Henning 2023-04-04 01:54:40 -04:00 committed by Marge Bot
parent 44db89b937
commit 5889c13fcd
2 changed files with 36 additions and 6 deletions

View file

@ -29,6 +29,7 @@
#include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_parse.h"
#include "compiler/nir/nir.h" #include "compiler/nir/nir.h"
#include "nir/tgsi_to_nir.h"
#include "nv50/nv50_stateobj.h" #include "nv50/nv50_stateobj.h"
#include "nv50/nv50_context.h" #include "nv50/nv50_context.h"
@ -740,6 +741,7 @@ nv50_sp_state_create(struct pipe_context *pipe,
enum pipe_shader_type type) enum pipe_shader_type type)
{ {
struct nv50_program *prog; struct nv50_program *prog;
const struct nouveau_screen *screen = nouveau_screen(pipe->screen);
prog = CALLOC_STRUCT(nv50_program); prog = CALLOC_STRUCT(nv50_program);
if (!prog) if (!prog)
@ -750,7 +752,12 @@ nv50_sp_state_create(struct pipe_context *pipe,
switch (cso->type) { switch (cso->type) {
case PIPE_SHADER_IR_TGSI: case PIPE_SHADER_IR_TGSI:
prog->pipe.tokens = tgsi_dup_tokens(cso->tokens); if (screen->prefer_nir) {
prog->pipe.type = PIPE_SHADER_IR_NIR;
prog->pipe.ir.nir = tgsi_to_nir(cso->tokens, pipe->screen, false);
} else {
prog->pipe.tokens = tgsi_dup_tokens(cso->tokens);
}
break; break;
case PIPE_SHADER_IR_NIR: case PIPE_SHADER_IR_NIR:
prog->pipe.ir.nir = cso->ir.nir; prog->pipe.ir.nir = cso->ir.nir;
@ -841,6 +848,7 @@ nv50_cp_state_create(struct pipe_context *pipe,
const struct pipe_compute_state *cso) const struct pipe_compute_state *cso)
{ {
struct nv50_program *prog; struct nv50_program *prog;
const struct nouveau_screen *screen = nouveau_screen(pipe->screen);
prog = CALLOC_STRUCT(nv50_program); prog = CALLOC_STRUCT(nv50_program);
if (!prog) if (!prog)
@ -849,9 +857,16 @@ nv50_cp_state_create(struct pipe_context *pipe,
prog->pipe.type = cso->ir_type; prog->pipe.type = cso->ir_type;
switch(cso->ir_type) { switch(cso->ir_type) {
case PIPE_SHADER_IR_TGSI: case PIPE_SHADER_IR_TGSI: {
prog->pipe.tokens = tgsi_dup_tokens((const struct tgsi_token *)cso->prog); const struct tgsi_token *tokens = cso->prog;
if (screen->prefer_nir) {
prog->pipe.type = PIPE_SHADER_IR_NIR;
prog->pipe.ir.nir = tgsi_to_nir(tokens, pipe->screen, false);
} else {
prog->pipe.tokens = tgsi_dup_tokens(tokens);
}
break; break;
}
case PIPE_SHADER_IR_NIR: case PIPE_SHADER_IR_NIR:
prog->pipe.ir.nir = (nir_shader *)cso->prog; prog->pipe.ir.nir = (nir_shader *)cso->prog;
break; break;

View file

@ -29,6 +29,7 @@
#include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_parse.h"
#include "compiler/nir/nir.h" #include "compiler/nir/nir.h"
#include "compiler/nir/nir_serialize.h" #include "compiler/nir/nir_serialize.h"
#include "nir/tgsi_to_nir.h"
#include "nvc0/nvc0_stateobj.h" #include "nvc0/nvc0_stateobj.h"
#include "nvc0/nvc0_context.h" #include "nvc0/nvc0_context.h"
@ -600,6 +601,7 @@ nvc0_sp_state_create(struct pipe_context *pipe,
const struct pipe_shader_state *cso, unsigned type) const struct pipe_shader_state *cso, unsigned type)
{ {
struct nvc0_program *prog; struct nvc0_program *prog;
const struct nouveau_screen *screen = nouveau_screen(pipe->screen);
prog = CALLOC_STRUCT(nvc0_program); prog = CALLOC_STRUCT(nvc0_program);
if (!prog) if (!prog)
@ -610,7 +612,12 @@ nvc0_sp_state_create(struct pipe_context *pipe,
switch(cso->type) { switch(cso->type) {
case PIPE_SHADER_IR_TGSI: case PIPE_SHADER_IR_TGSI:
prog->pipe.tokens = tgsi_dup_tokens(cso->tokens); if (screen->prefer_nir) {
prog->pipe.type = PIPE_SHADER_IR_NIR;
prog->pipe.ir.nir = tgsi_to_nir(cso->tokens, pipe->screen, false);
} else {
prog->pipe.tokens = tgsi_dup_tokens(cso->tokens);
}
break; break;
case PIPE_SHADER_IR_NIR: case PIPE_SHADER_IR_NIR:
prog->pipe.ir.nir = cso->ir.nir; prog->pipe.ir.nir = cso->ir.nir;
@ -734,6 +741,7 @@ nvc0_cp_state_create(struct pipe_context *pipe,
const struct pipe_compute_state *cso) const struct pipe_compute_state *cso)
{ {
struct nvc0_program *prog; struct nvc0_program *prog;
const struct nouveau_screen *screen = nouveau_screen(pipe->screen);
prog = CALLOC_STRUCT(nvc0_program); prog = CALLOC_STRUCT(nvc0_program);
if (!prog) if (!prog)
@ -745,9 +753,16 @@ nvc0_cp_state_create(struct pipe_context *pipe,
prog->parm_size = cso->req_input_mem; prog->parm_size = cso->req_input_mem;
switch(cso->ir_type) { switch(cso->ir_type) {
case PIPE_SHADER_IR_TGSI: case PIPE_SHADER_IR_TGSI: {
prog->pipe.tokens = tgsi_dup_tokens((const struct tgsi_token *)cso->prog); const struct tgsi_token *tokens = cso->prog;
if (screen->prefer_nir) {
prog->pipe.type = PIPE_SHADER_IR_NIR;
prog->pipe.ir.nir = tgsi_to_nir(tokens, pipe->screen, false);
} else {
prog->pipe.tokens = tgsi_dup_tokens(tokens);
}
break; break;
}
case PIPE_SHADER_IR_NIR: case PIPE_SHADER_IR_NIR:
prog->pipe.ir.nir = (nir_shader *)cso->prog; prog->pipe.ir.nir = (nir_shader *)cso->prog;
break; break;