draw: add NIR support to draw_create_vertex_shader

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7826>
This commit is contained in:
Marek Olšák 2020-11-28 02:38:16 -05:00 committed by Marge Bot
parent 8bb4a76add
commit df11ceaaaf

View file

@ -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;