struct si_descriptors *descs,
unsigned num_buffers,
short shader_userdata_rel_index,
- enum radeon_bo_usage shader_usage,
- enum radeon_bo_usage shader_usage_constbuf,
enum radeon_bo_priority priority,
enum radeon_bo_priority priority_constbuf)
{
- buffers->shader_usage = shader_usage;
- buffers->shader_usage_constbuf = shader_usage_constbuf;
buffers->priority = priority;
buffers->priority_constbuf = priority_constbuf;
buffers->buffers = CALLOC(num_buffers, sizeof(struct pipe_resource*));
radeon_add_to_buffer_list(sctx, sctx->gfx_cs,
si_resource(buffers->buffers[i]),
- i < SI_NUM_SHADER_BUFFERS ? buffers->shader_usage :
- buffers->shader_usage_constbuf,
+ buffers->writable_mask & (1u << i) ? RADEON_USAGE_READWRITE :
+ RADEON_USAGE_READ,
i < SI_NUM_SHADER_BUFFERS ? buffers->priority :
buffers->priority_constbuf);
}
buffers->buffers[slot] = buffer;
radeon_add_to_gfx_buffer_list_check_mem(sctx,
si_resource(buffer),
- buffers->shader_usage_constbuf,
+ RADEON_USAGE_READ,
buffers->priority_constbuf, true);
buffers->enabled_mask |= 1u << slot;
} else {
struct si_buffer_resources *buffers,
unsigned descriptors_idx,
uint slot, const struct pipe_shader_buffer *sbuffer,
- enum radeon_bo_priority priority)
+ bool writable, enum radeon_bo_priority priority)
{
struct si_descriptors *descs = &sctx->descriptors[descriptors_idx];
uint32_t *desc = descs->list + slot * 4;
pipe_resource_reference(&buffers->buffers[slot], NULL);
memset(desc, 0, sizeof(uint32_t) * 4);
buffers->enabled_mask &= ~(1u << slot);
+ buffers->writable_mask &= ~(1u << slot);
sctx->descriptors_dirty |= 1u << descriptors_idx;
return;
}
pipe_resource_reference(&buffers->buffers[slot], &buf->b.b);
radeon_add_to_gfx_buffer_list_check_mem(sctx, buf,
- buffers->shader_usage,
+ writable ? RADEON_USAGE_READWRITE :
+ RADEON_USAGE_READ,
priority, true);
+ if (writable)
+ buffers->writable_mask |= 1u << slot;
+ else
+ buffers->writable_mask &= ~(1u << slot);
buffers->enabled_mask |= 1u << slot;
sctx->descriptors_dirty |= 1u << descriptors_idx;
si_resource(sbuffer->buffer)->bind_history |= PIPE_BIND_SHADER_BUFFER;
si_set_shader_buffer(sctx, buffers, descriptors_idx, slot, sbuffer,
+ !!(writable_bitmask & (1u << i)),
buffers->priority);
}
}
const struct pipe_shader_buffer *sbuffer)
{
si_set_shader_buffer(sctx, &sctx->rw_buffers, SI_DESCS_RW_BUFFERS,
- slot, sbuffer, RADEON_PRIO_SHADER_RW_BUFFER);
+ slot, sbuffer, true, RADEON_PRIO_SHADER_RW_BUFFER);
}
void si_set_ring_buffer(struct si_context *sctx, uint slot,
pipe_resource_reference(&buffers->buffers[slot], buffer);
radeon_add_to_buffer_list(sctx, sctx->gfx_cs,
si_resource(buffer),
- buffers->shader_usage, buffers->priority);
+ RADEON_USAGE_READWRITE, buffers->priority);
buffers->enabled_mask |= 1u << slot;
} else {
/* Clear the descriptor. */
unsigned slot_mask,
struct pipe_resource *buf,
uint64_t old_va,
- enum radeon_bo_usage usage,
enum radeon_bo_priority priority)
{
struct si_descriptors *descs = &sctx->descriptors[descriptors_idx];
radeon_add_to_gfx_buffer_list_check_mem(sctx,
si_resource(buf),
- usage, priority, true);
+ buffers->writable_mask & (1u << i) ?
+ RADEON_USAGE_READWRITE :
+ RADEON_USAGE_READ,
+ priority, true);
}
}
}
sctx->descriptors_dirty |= 1u << SI_DESCS_RW_BUFFERS;
radeon_add_to_gfx_buffer_list_check_mem(sctx,
- buffer, buffers->shader_usage,
+ buffer, RADEON_USAGE_WRITE,
RADEON_PRIO_SHADER_RW_BUFFER,
true);
si_const_and_shader_buffer_descriptors_idx(shader),
u_bit_consecutive(SI_NUM_SHADER_BUFFERS, SI_NUM_CONST_BUFFERS),
buf, old_va,
- sctx->const_and_shader_buffers[shader].shader_usage_constbuf,
sctx->const_and_shader_buffers[shader].priority_constbuf);
}
si_const_and_shader_buffer_descriptors_idx(shader),
u_bit_consecutive(0, SI_NUM_SHADER_BUFFERS),
buf, old_va,
- sctx->const_and_shader_buffers[shader].shader_usage,
sctx->const_and_shader_buffers[shader].priority);
}
desc = si_const_and_shader_buffer_descriptors(sctx, i);
si_init_buffer_resources(&sctx->const_and_shader_buffers[i], desc,
num_buffer_slots, rel_dw_offset,
- RADEON_USAGE_READWRITE,
- RADEON_USAGE_READ,
RADEON_PRIO_SHADER_RW_BUFFER,
RADEON_PRIO_CONST_BUFFER);
desc->slot_index_to_bind_directly = si_get_constbuf_slot(0);
si_init_buffer_resources(&sctx->rw_buffers,
&sctx->descriptors[SI_DESCS_RW_BUFFERS],
SI_NUM_RW_BUFFERS, SI_SGPR_RW_BUFFERS,
- /* The second set of usage/priority is used by
+ /* The second priority is used by
* const buffers in RW buffer slots. */
- RADEON_USAGE_READWRITE, RADEON_USAGE_READ,
RADEON_PRIO_SHADER_RINGS, RADEON_PRIO_CONST_BUFFER);
sctx->descriptors[SI_DESCS_RW_BUFFERS].num_active_slots = SI_NUM_RW_BUFFERS;