summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-09-05 15:47:19 +1000
committerDave Airlie <[email protected]>2019-11-28 14:48:56 +1000
commitbf12bc2dd7a28844103bb30a07be0440e60c5864 (patch)
tree3651f292b005c09b06889a6e52ac3b1b9e587f7e /src/gallium
parent44a6b0107b37ad9644d3435cf6d2d29b6779654f (diff)
draw: add nir info gathering and building support
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/draw/draw_fs.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.c18
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c40
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_llvm.c24
5 files changed, 63 insertions, 26 deletions
diff --git a/src/gallium/auxiliary/draw/draw_fs.c b/src/gallium/auxiliary/draw/draw_fs.c
index 1543bd86f17..e3bd25193dc 100644
--- a/src/gallium/auxiliary/draw/draw_fs.c
+++ b/src/gallium/auxiliary/draw/draw_fs.c
@@ -32,6 +32,7 @@
#include "util/u_prim.h"
#include "tgsi/tgsi_parse.h"
+#include "nir/nir_to_tgsi_info.h"
#include "draw_fs.h"
#include "draw_private.h"
@@ -47,7 +48,10 @@ draw_create_fragment_shader(struct draw_context *draw,
dfs = CALLOC_STRUCT(draw_fragment_shader);
if (dfs) {
dfs->base = *shader;
- tgsi_scan_shader(shader->tokens, &dfs->info);
+ if (shader->type == PIPE_SHADER_IR_TGSI)
+ tgsi_scan_shader(shader->tokens, &dfs->info);
+ else
+ nir_tgsi_scan_shader(shader->ir.nir, &dfs->info, false);
}
return dfs;
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 94cfe860b6d..1e5d3a86ea0 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -35,7 +35,7 @@
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_exec.h"
-
+#include "nir/nir_to_tgsi_info.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
@@ -793,13 +793,17 @@ draw_create_geometry_shader(struct draw_context *draw,
gs->draw = draw;
gs->state = *state;
- gs->state.tokens = tgsi_dup_tokens(state->tokens);
- if (!gs->state.tokens) {
- FREE(gs);
- return NULL;
- }
- tgsi_scan_shader(state->tokens, &gs->info);
+ if (state->type == PIPE_SHADER_IR_TGSI) {
+ gs->state.tokens = tgsi_dup_tokens(state->tokens);
+ if (!gs->state.tokens) {
+ FREE(gs);
+ return NULL;
+ }
+
+ tgsi_scan_shader(state->tokens, &gs->info);
+ } else
+ nir_tgsi_scan_shader(state->ir.nir, &gs->info, false);
/* setup the defaults */
gs->max_out_prims = 0;
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 7c4d49e760e..ac3eaf11b27 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -43,6 +43,7 @@
#include "gallivm/lp_bld_flow.h"
#include "gallivm/lp_bld_debug.h"
#include "gallivm/lp_bld_tgsi.h"
+#include "gallivm/lp_bld_nir.h"
#include "gallivm/lp_bld_printf.h"
#include "gallivm/lp_bld_intr.h"
#include "gallivm/lp_bld_init.h"
@@ -646,7 +647,10 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
memcpy(&variant->key, key, shader->variant_key_size);
if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
- tgsi_dump(llvm->draw->vs.vertex_shader->state.tokens, 0);
+ if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI)
+ tgsi_dump(llvm->draw->vs.vertex_shader->state.tokens, 0);
+ else
+ nir_print_shader(llvm->draw->vs.vertex_shader->state.ir.nir, stderr);
draw_llvm_dump_variant_key(&variant->key);
}
@@ -712,10 +716,17 @@ generate_vs(struct draw_llvm_variant *variant,
params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = draw_image;
- lp_build_tgsi_soa(variant->gallivm,
- tokens,
- &params,
- outputs);
+ if (llvm->draw->vs.vertex_shader->state.ir.nir &&
+ llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_NIR)
+ lp_build_nir_soa(variant->gallivm,
+ llvm->draw->vs.vertex_shader->state.ir.nir,
+ &params,
+ outputs);
+ else
+ lp_build_tgsi_soa(variant->gallivm,
+ tokens,
+ &params,
+ outputs);
{
LLVMValueRef out;
@@ -2495,7 +2506,10 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
}
if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
- tgsi_dump(tokens, 0);
+ if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
+ tgsi_dump(tokens, 0);
+ else
+ nir_print_shader(llvm->draw->gs.geometry_shader->state.ir.nir, stderr);
draw_gs_llvm_dump_variant_key(&variant->key);
}
@@ -2515,10 +2529,16 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = image;
- lp_build_tgsi_soa(variant->gallivm,
- tokens,
- &params,
- outputs);
+ if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
+ lp_build_tgsi_soa(variant->gallivm,
+ tokens,
+ &params,
+ outputs);
+ else
+ lp_build_nir_soa(variant->gallivm,
+ llvm->draw->gs.geometry_shader->state.ir.nir,
+ &params,
+ outputs);
sampler->destroy(sampler);
image->destroy(image);
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 20aada25fa0..29b18d671ff 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -230,6 +230,7 @@ draw_create_vs_exec(struct draw_context *draw,
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;
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index 04484ff13b8..c8ebe04efe1 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -37,7 +37,7 @@
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_scan.h"
-
+#include "nir/nir_to_tgsi_info.h"
static void
vs_llvm_prepare(struct draw_vertex_shader *shader,
struct draw_context *draw)
@@ -90,15 +90,21 @@ draw_create_vs_llvm(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;
+ /* due to some bugs in the feedback state tracker we have to check
+ for ir.nir & PIPE_SHADER_IR_NIR here. */
+ if (state->ir.nir && state->type == PIPE_SHADER_IR_NIR)
+ nir_tgsi_scan_shader(state->ir.nir, &vs->base.info, false);
+ else {
+ /* 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;
+ }
+
+ tgsi_scan_shader(state->tokens, &vs->base.info);
}
- tgsi_scan_shader(state->tokens, &vs->base.info);
-
vs->variant_key_size =
draw_llvm_variant_key_size(
vs->base.info.file_max[TGSI_FILE_INPUT]+1,
@@ -106,6 +112,8 @@ draw_create_vs_llvm(struct draw_context *draw,
vs->base.info.file_max[TGSI_FILE_SAMPLER_VIEW]+1),
vs->base.info.file_max[TGSI_FILE_IMAGE]+1);
+ vs->base.state.type = state->type;
+ vs->base.state.ir.nir = state->ir.nir;
vs->base.state.stream_output = state->stream_output;
vs->base.draw = draw;
vs->base.prepare = vs_llvm_prepare;