freedreno/ir3: Switch emit_const_ptrs() to take BOs instead of prscs.

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>
This commit is contained in:
Eric Anholt 2020-11-11 12:18:51 -08:00
parent a9b37e5dad
commit 386998cfbf
5 changed files with 25 additions and 25 deletions

View 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

View 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

View 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

View 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");
}

View 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);
}
}