[Mesa-dev] [PATCH 09/11] freedreno/ir3: upload shader buffer addresses after ubos
Ilia Mirkin
imirkin at alum.mit.edu
Sat Sep 26 23:33:25 PDT 2015
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
.../drivers/freedreno/ir3/ir3_compiler_nir.c | 3 +-
src/gallium/drivers/freedreno/ir3/ir3_shader.c | 42 ++++++++++++++++++++++
src/gallium/drivers/freedreno/ir3/ir3_shader.h | 4 ++-
3 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
index 2b9d200..84f1770 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
@@ -264,7 +264,8 @@ compile_init(struct ir3_compiler *compiler,
*/
/* reserve 4 (vec4) slots for ubo base addresses: */
- so->first_immediate += 4;
+ /* reserve 8 (vec4) slots for buffer base addresses: */
+ so->first_immediate += 12;
if (so->type == SHADER_VERTEX) {
/* driver params (see ir3_driver_param): */
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
index 7b56533..44a4d5e 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
@@ -528,6 +528,34 @@ emit_ubos(struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
}
static void
+emit_buffers(struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
+ struct pipe_shader_buffer *buffers)
+{
+ uint32_t offset = v->first_driver_param + IR3_BUFS_OFF;
+ if (v->constlen > offset) {
+ struct fd_context *ctx = fd_context(v->shader->pctx);
+ uint32_t params = MIN2(4, v->constlen - offset) * 4;
+ uint32_t offsets[params];
+ struct fd_bo *bos[params];
+
+ for (uint32_t i = 0; i < params; i++) {
+ struct pipe_shader_buffer *sb = &buffers[i];
+
+ if (sb->buffer) {
+ offsets[i] = sb->buffer_offset;
+ bos[i] = fd_resource(sb->buffer)->bo;
+ } else {
+ offsets[i] = 0;
+ bos[i] = NULL;
+ }
+ }
+
+ fd_wfi(ctx, ring);
+ ctx->emit_const_bo(ring, v->type, true, offset * 4, params, bos, offsets);
+ }
+}
+
+static void
emit_immediates(struct ir3_shader_variant *v, struct fd_ringbuffer *ring)
{
struct fd_context *ctx = fd_context(v->shader->pctx);
@@ -655,6 +683,20 @@ ir3_emit_consts(struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
emit_immediates(v, ring);
}
+ if (dirty & (FD_DIRTY_PROG | FD_DIRTY_BUFFERS)) {
+ struct pipe_shader_buffer *buffers;
+
+ if (v->type == SHADER_VERTEX) {
+ buffers = ctx->buffers[PIPE_SHADER_VERTEX];
+ } else if (v->type == SHADER_FRAGMENT) {
+ buffers = ctx->buffers[PIPE_SHADER_FRAGMENT];
+ } else {
+ unreachable("bad shader type");
+ }
+
+ emit_buffers(v, ring, buffers);
+ }
+
/* emit driver params every time: */
/* TODO skip emit if shader doesn't use driver params to avoid WFI.. */
if (info && (v->type == SHADER_VERTEX)) {
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index 6dc0ce1..25c1709 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -50,6 +50,7 @@ enum ir3_driver_param {
*
* num_uniform * vec4 - user consts
* 4 * vec4 - UBO addresses
+ * 8 * vec4 - Buffer addresses
* if (vertex shader) {
* N * vec4 - driver params (IR3_DP_*)
* 1 * vec4 - stream-out addresses
@@ -59,7 +60,8 @@ enum ir3_driver_param {
* that we don't need..
*/
#define IR3_UBOS_OFF 0 /* UBOs after user consts */
-#define IR3_DRIVER_PARAM_OFF 4 /* driver params after UBOs */
+#define IR3_BUFS_OFF 4 /* Buffers after UBOs */
+#define IR3_DRIVER_PARAM_OFF 12 /* driver params after buffers */
#define IR3_TFBOS_OFF (IR3_DRIVER_PARAM_OFF + IR3_DP_COUNT/4)
/* Configuration key used to identify a shader variant.. different
--
2.4.9
More information about the mesa-dev
mailing list