summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-11-03 23:46:29 -0700
committerKenneth Graunke <[email protected]>2019-02-05 13:43:36 -0800
commit2d45f9fa250cfb2ed0694f0819c984edaf1ca151 (patch)
tree96534394439f49144c5ad3713ee75318eb6f1239 /src/mesa
parentcdc53fa81cbeb80373eac33ef7695d9025caf14b (diff)
st/mesa: Add a NIR version of the drawpixels/bitmap VS copy shader.
This provides a native NIR version of the DrawPixels/Bitmap passthrough vertex shader. Reviewed-by: Marek Olšák <[email protected]> Tested-by: Rob Clark <[email protected]> Tested-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 672b665310b..e5d5035c63d 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -65,6 +65,7 @@
#include "st_sampler_view.h"
#include "st_scissor.h"
#include "st_texture.h"
+#include "st_nir.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -76,6 +77,7 @@
#include "util/u_tile.h"
#include "cso_cache/cso_context.h"
+#include "compiler/nir/nir_builder.h"
/**
* We have a simple glDrawPixels cache to try to optimize the case where the
@@ -197,18 +199,37 @@ get_drawpix_z_stencil_program(struct st_context *st,
void
st_make_passthrough_vertex_shader(struct st_context *st)
{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_screen *screen = pipe->screen;
+
if (st->passthrough_vs)
return;
- const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
- TGSI_SEMANTIC_COLOR,
- st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD :
- TGSI_SEMANTIC_GENERIC };
- const uint semantic_indexes[] = { 0, 0, 0 };
+ enum pipe_shader_ir preferred_ir =
+ screen->get_shader_param(screen, MESA_SHADER_VERTEX,
+ PIPE_SHADER_CAP_PREFERRED_IR);
- st->passthrough_vs =
- util_make_vertex_passthrough_shader(st->pipe, 3, semantic_names,
- semantic_indexes, false);
+ if (preferred_ir == PIPE_SHADER_IR_NIR) {
+ unsigned inputs[] =
+ { VERT_ATTRIB_POS, VERT_ATTRIB_COLOR0, VERT_ATTRIB_GENERIC0 };
+ unsigned outputs[] =
+ { VARYING_SLOT_POS, VARYING_SLOT_COL0, VARYING_SLOT_TEX0 };
+
+ st->passthrough_vs =
+ st_nir_make_passthrough_shader(st, "drawpixels VS",
+ MESA_SHADER_VERTEX, 3,
+ inputs, outputs, NULL, 0);
+ } else {
+ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+ TGSI_SEMANTIC_COLOR,
+ st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD :
+ TGSI_SEMANTIC_GENERIC };
+ const uint semantic_indexes[] = { 0, 0, 0 };
+
+ st->passthrough_vs =
+ util_make_vertex_passthrough_shader(st->pipe, 3, semantic_names,
+ semantic_indexes, false);
+ }
}