freedreno/ir3: Switch emit_const_ptrs() to take BOs instead of prscs.
authorEric Anholt <eric@anholt.net>
Wed, 11 Nov 2020 20:18:51 +0000 (12:18 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 16 Nov 2020 21:54:22 +0000 (13:54 -0800)
Just indirect in the caller, which means that I'll be able to pass a
non-resource BO in the large-constants case.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5810>

src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/a5xx/fd5_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_const.c
src/gallium/drivers/freedreno/ir3/ir3_const.h

index a689a79..e62bcb8 100644 (file)
@@ -101,7 +101,7 @@ fd3_emit_const_bo(struct fd_ringbuffer *ring, const struct ir3_shader_variant *v
 
 static void
 fd3_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type,
-               uint32_t regid, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t regid, uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        uint32_t anum = align(num, 4);
        uint32_t i;
@@ -117,8 +117,8 @@ fd3_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type,
                        CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS));
 
        for (i = 0; i < num; i++) {
-               if (prscs[i]) {
-                       OUT_RELOC(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0);
+               if (bos[i]) {
+                       OUT_RELOC(ring, bos[i], offsets[i], 0, 0);
                } else {
                        OUT_RING(ring, 0xbad00000 | (i << 16));
                }
@@ -137,11 +137,11 @@ is_stateobj(struct fd_ringbuffer *ring)
 static void
 emit_const_ptrs(struct fd_ringbuffer *ring,
                const struct ir3_shader_variant *v, uint32_t dst_offset,
-               uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        /* TODO inline this */
        assert(dst_offset + num <= v->constlen * 4);
-       fd3_emit_const_ptrs(ring, v->type, dst_offset, num, prscs, offsets);
+       fd3_emit_const_ptrs(ring, v->type, dst_offset, num, bos, offsets);
 }
 
 #define VERT_TEX_OFF    0
index 9c9e2a1..809822f 100644 (file)
@@ -92,7 +92,7 @@ fd4_emit_const_bo(struct fd_ringbuffer *ring, const struct ir3_shader_variant *v
 
 static void
 fd4_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type,
-               uint32_t regid, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t regid, uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        uint32_t anum = align(num, 4);
        uint32_t i;
@@ -108,8 +108,8 @@ fd4_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type,
                        CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS));
 
        for (i = 0; i < num; i++) {
-               if (prscs[i]) {
-                       OUT_RELOC(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0);
+               if (bos[i]) {
+                       OUT_RELOC(ring, bos[i], offsets[i], 0, 0);
                } else {
                        OUT_RING(ring, 0xbad00000 | (i << 16));
                }
@@ -128,11 +128,11 @@ is_stateobj(struct fd_ringbuffer *ring)
 static void
 emit_const_ptrs(struct fd_ringbuffer *ring,
                const struct ir3_shader_variant *v, uint32_t dst_offset,
-               uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        /* TODO inline this */
        assert(dst_offset + num <= v->constlen * 4);
-       fd4_emit_const_ptrs(ring, v->type, dst_offset, num, prscs, offsets);
+       fd4_emit_const_ptrs(ring, v->type, dst_offset, num, bos, offsets);
 }
 
 static void
index 1711fd6..0a6db47 100644 (file)
@@ -95,7 +95,7 @@ fd5_emit_const_bo(struct fd_ringbuffer *ring, const struct ir3_shader_variant *v
 
 static void
 fd5_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type,
-               uint32_t regid, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t regid, uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        uint32_t anum = align(num, 2);
        uint32_t i;
@@ -112,8 +112,8 @@ fd5_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type,
        OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
 
        for (i = 0; i < num; i++) {
-               if (prscs[i]) {
-                       OUT_RELOC(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0);
+               if (bos[i]) {
+                       OUT_RELOC(ring, bos[i], offsets[i], 0, 0);
                } else {
                        OUT_RING(ring, 0xbad00000 | (i << 16));
                        OUT_RING(ring, 0xbad00000 | (i << 16));
@@ -135,11 +135,11 @@ is_stateobj(struct fd_ringbuffer *ring)
 static void
 emit_const_ptrs(struct fd_ringbuffer *ring,
                const struct ir3_shader_variant *v, uint32_t dst_offset,
-               uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        /* TODO inline this */
        assert(dst_offset + num <= v->constlen * 4);
-       fd5_emit_const_ptrs(ring, v->type, dst_offset, num, prscs, offsets);
+       fd5_emit_const_ptrs(ring, v->type, dst_offset, num, bos, offsets);
 }
 
 void
index 68a2487..020fbf5 100644 (file)
@@ -124,7 +124,7 @@ is_stateobj(struct fd_ringbuffer *ring)
 static void
 emit_const_ptrs(struct fd_ringbuffer *ring,
                const struct ir3_shader_variant *v, uint32_t dst_offset,
-               uint32_t num, struct pipe_resource **prscs, uint32_t *offsets)
+               uint32_t num, struct fd_bo **bos, uint32_t *offsets)
 {
        unreachable("shouldn't be called on a6xx");
 }
index 4784ac6..2c9c560 100644 (file)
@@ -59,7 +59,7 @@ static void emit_const_prsc(struct fd_ringbuffer *ring,
 
 static void emit_const_ptrs(struct fd_ringbuffer *ring,
                const struct ir3_shader_variant *v, uint32_t dst_offset,
-               uint32_t num, struct pipe_resource **prscs, uint32_t *offsets);
+               uint32_t num, struct fd_bo **bos, uint32_t *offsets);
 
 static void
 emit_const_asserts(struct fd_ringbuffer *ring,
@@ -173,7 +173,7 @@ ir3_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
        if (v->constlen > offset) {
                uint32_t params = const_state->num_ubos;
                uint32_t offsets[params];
-               struct pipe_resource *prscs[params];
+               struct fd_bo *bos[params];
 
                for (uint32_t i = 0; i < params; i++) {
                        struct pipe_constant_buffer *cb = &constbuf->cb[i];
@@ -194,16 +194,16 @@ ir3_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
 
                        if ((constbuf->enabled_mask & (1 << i)) && cb->buffer) {
                                offsets[i] = cb->buffer_offset;
-                               prscs[i] = cb->buffer;
+                               bos[i] = fd_resource(cb->buffer)->bo;
                        } else {
                                offsets[i] = 0;
-                               prscs[i] = NULL;
+                               bos[i] = NULL;
                        }
                }
 
                assert(offset * 4 + params <= v->constlen * 4);
 
-               emit_const_ptrs(ring, v, offset * 4, params, prscs, offsets);
+               emit_const_ptrs(ring, v, offset * 4, params, bos, offsets);
        }
 }
 
@@ -336,7 +336,7 @@ emit_tfbos(struct fd_context *ctx, const struct ir3_shader_variant *v,
                struct ir3_stream_output_info *info = &v->shader->stream_output;
                uint32_t params = 4;
                uint32_t offsets[params];
-               struct pipe_resource *prscs[params];
+               struct fd_bo *bos[params];
 
                for (uint32_t i = 0; i < params; i++) {
                        struct pipe_stream_output_target *target = so->targets[i];
@@ -344,16 +344,16 @@ emit_tfbos(struct fd_context *ctx, const struct ir3_shader_variant *v,
                        if (target) {
                                offsets[i] = (so->offsets[i] * info->stride[i] * 4) +
                                                target->buffer_offset;
-                               prscs[i] = target->buffer;
+                               bos[i] = fd_resource(target->buffer)->bo;
                        } else {
                                offsets[i] = 0;
-                               prscs[i] = NULL;
+                               bos[i] = NULL;
                        }
                }
 
                assert(offset * 4 + params <= v->constlen * 4);
 
-               emit_const_ptrs(ring, v, offset * 4, params, prscs, offsets);
+               emit_const_ptrs(ring, v, offset * 4, params, bos, offsets);
        }
 }