summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/ir3
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2018-11-09 14:46:28 -0500
committerRob Clark <[email protected]>2018-11-27 15:44:02 -0500
commitea4cbf601d3e854fbe4bfa9d90544c4b2d002bbd (patch)
tree9d62b3af13960fd35dfd6e9023a990671627ffe8 /src/gallium/drivers/freedreno/ir3
parent030e98630d82c658c1f03894f4c74e233a30fd73 (diff)
freedreno/ir3: remove pipe_stream_output_info dependency
A bit annoying to have to copy into our own struct. But this is something the compiler really needs to know, at least on earlier generations where streamout is implemented in shader. Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3')
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_cmdline.c2
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c3
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_shader.c28
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_shader.h32
4 files changed, 58 insertions, 7 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
index 77fba9f4445..a06eb89b9c6 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
@@ -350,7 +350,7 @@ int main(int argc, char **argv)
}
if (!strcmp(argv[n], "--stream-out")) {
- struct pipe_stream_output_info *so = &s.stream_output;
+ struct ir3_stream_output_info *so = &s.stream_output;
debug_printf(" %s", argv[n]);
/* TODO more dynamic config based on number of outputs, etc
* rather than just hard-code for first output:
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
index 75c00a02224..5d647a6d8a2 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
@@ -26,7 +26,6 @@
#include <stdarg.h>
-#include "pipe/p_state.h"
#include "util/u_string.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
@@ -3106,7 +3105,7 @@ emit_stream_out(struct ir3_context *ctx)
{
struct ir3_shader_variant *v = ctx->so;
struct ir3 *ir = ctx->ir;
- struct pipe_stream_output_info *strmout =
+ struct ir3_stream_output_info *strmout =
&ctx->so->shader->stream_output;
struct ir3_block *orig_end_block, *stream_out_block, *new_end_block;
struct ir3_instruction *vtxcnt, *maxvtxcnt, *cond;
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
index 14605902458..3becd757833 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
@@ -311,6 +311,27 @@ ir3_shader_destroy(struct ir3_shader *shader)
free(shader);
}
+static void
+copy_stream_out(struct ir3_stream_output_info *i,
+ const struct pipe_stream_output_info *p)
+{
+ STATIC_ASSERT(ARRAY_SIZE(i->stride) == ARRAY_SIZE(p->stride));
+ STATIC_ASSERT(ARRAY_SIZE(i->output) == ARRAY_SIZE(p->output));
+
+ i->num_outputs = p->num_outputs;
+ for (int n = 0; n < ARRAY_SIZE(i->stride); n++)
+ i->stride[n] = p->stride[n];
+
+ for (int n = 0; n < ARRAY_SIZE(i->output); n++) {
+ i->output[n].register_index = p->output[n].register_index;
+ i->output[n].start_component = p->output[n].start_component;
+ i->output[n].num_components = p->output[n].num_components;
+ i->output[n].output_buffer = p->output[n].output_buffer;
+ i->output[n].dst_offset = p->output[n].dst_offset;
+ i->output[n].stream = p->output[n].stream;
+ }
+}
+
struct ir3_shader *
ir3_shader_create(struct ir3_compiler *compiler,
const struct pipe_shader_state *cso, gl_shader_stage type,
@@ -342,7 +363,8 @@ ir3_shader_create(struct ir3_compiler *compiler,
nir_print_shader(shader->nir, stdout);
}
- shader->stream_output = cso->stream_output;
+ copy_stream_out(&shader->stream_output, &cso->stream_output);
+
if (fd_mesa_debug & FD_DBG_SHADERDB) {
/* if shader-db run, create a standard variant immediately
* (as otherwise nothing will trigger the shader to be
@@ -758,7 +780,7 @@ emit_tfbos(struct fd_context *ctx, const struct ir3_shader_variant *v,
uint32_t offset = v->constbase.tfbo;
if (v->constlen > offset) {
struct fd_streamout_stateobj *so = &ctx->streamout;
- struct pipe_stream_output_info *info = &v->shader->stream_output;
+ struct ir3_stream_output_info *info = &v->shader->stream_output;
uint32_t params = 4;
uint32_t offsets[params];
struct pipe_resource *prscs[params];
@@ -785,7 +807,7 @@ static uint32_t
max_tf_vtx(struct fd_context *ctx, const struct ir3_shader_variant *v)
{
struct fd_streamout_stateobj *so = &ctx->streamout;
- struct pipe_stream_output_info *info = &v->shader->stream_output;
+ struct ir3_stream_output_info *info = &v->shader->stream_output;
uint32_t maxvtxcnt = 0x7fffffff;
if (ctx->screen->gpu_id >= 500)
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index d32ef10a160..f6ad49a50ae 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -63,6 +63,9 @@ enum ir3_driver_param {
IR3_DP_VS_COUNT = 36 /* must be aligned to vec4 */
};
+#define IR3_MAX_SO_BUFFERS 4
+#define IR3_MAX_SO_OUTPUTS 64
+
/**
* For consts needed to pass internal values to shader which may or may not
* be required, rather than allocating worst-case const space, we scan the
@@ -97,6 +100,33 @@ struct ir3_driver_const_layout {
} image_dims;
};
+/**
+ * A single output for vertex transform feedback.
+ */
+struct ir3_stream_output {
+ unsigned register_index:6; /**< 0 to 63 (OUT index) */
+ unsigned start_component:2; /** 0 to 3 */
+ unsigned num_components:3; /** 1 to 4 */
+ unsigned output_buffer:3; /**< 0 to PIPE_MAX_SO_BUFFERS */
+ unsigned dst_offset:16; /**< offset into the buffer in dwords */
+ unsigned stream:2; /**< 0 to 3 */
+};
+
+/**
+ * Stream output for vertex transform feedback.
+ */
+struct ir3_stream_output_info {
+ unsigned num_outputs;
+ /** stride for an entire vertex for each buffer in dwords */
+ uint16_t stride[IR3_MAX_SO_BUFFERS];
+
+ /**
+ * Array of stream outputs, in the order they are to be written in.
+ * Selected components are tightly packed into the output buffer.
+ */
+ struct ir3_stream_output output[IR3_MAX_SO_OUTPUTS];
+};
+
/* Configuration key used to identify a shader variant.. different
* shader variants can be used to implement features not supported
* in hw (two sided color), binning-pass vertex shader, etc.
@@ -363,7 +393,7 @@ struct ir3_shader {
struct ir3_compiler *compiler;
struct nir_shader *nir;
- struct pipe_stream_output_info stream_output;
+ struct ir3_stream_output_info stream_output;
struct ir3_shader_variant *variants;
};