From df11ceaaaf74e4715cde076eccadf84f2f8fd00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 28 Nov 2020 02:38:16 -0500 Subject: [PATCH] draw: add NIR support to draw_create_vertex_shader Reviewed-by: Eric Anholt Part-of: --- src/gallium/auxiliary/draw/draw_vs_exec.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 4fba01b5596..17800ad7eaa 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -33,7 +33,10 @@ #include "util/u_math.h" #include "util/u_memory.h" +#include "util/ralloc.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_context.h" +#include "nir/nir_to_tgsi.h" #include "draw_private.h" #include "draw_context.h" @@ -221,16 +224,24 @@ draw_create_vs_exec(struct draw_context *draw, if (!vs) return NULL; - /* we make a private copy of the tokens */ - vs->base.state.tokens = tgsi_dup_tokens(state->tokens); - if (!vs->base.state.tokens) { - FREE(vs); - return NULL; + if (state->type == PIPE_SHADER_IR_NIR) { + vs->base.state.type = PIPE_SHADER_IR_TGSI; + vs->base.state.tokens = nir_to_tgsi(state->ir.nir, draw->pipe->screen); + ralloc_free(state->ir.nir); + } else { + assert(state->type == PIPE_SHADER_IR_TGSI); + vs->base.state.type = state->type; + + /* we need to keep a local copy of the tokens */ + vs->base.state.tokens = tgsi_dup_tokens(state->tokens); + if (!vs->base.state.tokens) { + FREE(vs); + return NULL; + } } tgsi_scan_shader(state->tokens, &vs->base.info); - vs->base.state.type = state->type; vs->base.state.stream_output = state->stream_output; vs->base.draw = draw; vs->base.prepare = vs_exec_prepare;