Small perf improvement in ipers.
radeon_drm_get_cs_handle is exactly what this commit tries to avoid
in every write_reloc.
/* The buffer where query results are stored. */
struct r300_winsys_buffer *buffer;
+ struct r300_winsys_cs_buffer *cs_buffer;
/* The size of the buffer. */
unsigned buffer_size;
/* The domain of the buffer. */
/* Winsys buffer backing the texture. */
struct r300_winsys_buffer *buffer;
+ struct r300_winsys_cs_buffer *cs_buffer;
enum r300_buffer_domain domain;
/* Pipe buffer backing this texture. */
struct r300_winsys_buffer *buffer;
+ struct r300_winsys_cs_buffer *cs_buffer;
/* Registers carrying texture format data. */
/* Only format-independent bits should be filled in. */
#define OUT_CS_BUF_RELOC(bo, offset, rd, wd) do { \
assert(bo); \
- OUT_CS_RELOC(r300_buffer(bo)->buf, offset, rd, wd); \
+ OUT_CS_RELOC(r300_buffer(bo)->cs_buf, offset, rd, wd); \
} while (0)
#define OUT_CS_TEX_RELOC(tex, offset, rd, wd) do { \
assert(tex); \
- OUT_CS_RELOC(tex->buffer, offset, rd, wd); \
+ OUT_CS_RELOC(tex->cs_buffer, offset, rd, wd); \
} while (0)
#define OUT_CS_BUF_RELOC_NO_OFFSET(bo, rd, wd) do { \
assert(bo); \
- cs_winsys->cs_write_reloc(cs_copy, r300_buffer(bo)->buf, rd, wd); \
+ cs_winsys->cs_write_reloc(cs_copy, r300_buffer(bo)->cs_buf, rd, wd); \
CS_DEBUG(cs_count -= 2;) \
} while (0)
if (aa->dest) {
OUT_CS_REG_SEQ(R300_RB3D_AARESOLVE_OFFSET, 1);
- OUT_CS_RELOC(aa->dest->buffer, aa->dest->offset, 0, aa->dest->domain);
+ OUT_CS_RELOC(aa->dest->cs_buffer, aa->dest->offset, 0, aa->dest->domain);
OUT_CS_REG_SEQ(R300_RB3D_AARESOLVE_PITCH, 1);
- OUT_CS_RELOC(aa->dest->buffer, aa->dest->pitch, 0, aa->dest->domain);
+ OUT_CS_RELOC(aa->dest->cs_buffer, aa->dest->pitch, 0, aa->dest->domain);
}
OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, aa->aaresolve_ctl);
surf = r300_surface(fb->cbufs[i]);
OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
- OUT_CS_RELOC(surf->buffer, surf->offset, 0, surf->domain);
+ OUT_CS_RELOC(surf->cs_buffer, surf->offset, 0, surf->domain);
OUT_CS_REG_SEQ(R300_RB3D_COLORPITCH0 + (4 * i), 1);
- OUT_CS_RELOC(surf->buffer, surf->pitch, 0, surf->domain);
+ OUT_CS_RELOC(surf->cs_buffer, surf->pitch, 0, surf->domain);
}
/* Set up the ZB part of the CBZB clear. */
OUT_CS_REG(R300_ZB_FORMAT, surf->cbzb_format);
OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
- OUT_CS_RELOC(surf->buffer, surf->cbzb_midpoint_offset, 0, surf->domain);
+ OUT_CS_RELOC(surf->cs_buffer, surf->cbzb_midpoint_offset, 0, surf->domain);
OUT_CS_REG_SEQ(R300_ZB_DEPTHPITCH, 1);
- OUT_CS_RELOC(surf->buffer, surf->cbzb_pitch, 0, surf->domain);
+ OUT_CS_RELOC(surf->cs_buffer, surf->cbzb_pitch, 0, surf->domain);
DBG(r300, DBG_CBZB,
"CBZB clearing cbuf %08x %08x\n", surf->cbzb_format,
OUT_CS_REG(R300_ZB_FORMAT, surf->format);
OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
- OUT_CS_RELOC(surf->buffer, surf->offset, 0, surf->domain);
+ OUT_CS_RELOC(surf->cs_buffer, surf->offset, 0, surf->domain);
OUT_CS_REG_SEQ(R300_ZB_DEPTHPITCH, 1);
- OUT_CS_RELOC(surf->buffer, surf->pitch, 0, surf->domain);
+ OUT_CS_RELOC(surf->cs_buffer, surf->pitch, 0, surf->domain);
if (can_hyperz) {
uint32_t surf_pitch;
struct r300_query *query)
{
struct r300_capabilities* caps = &r300->screen->caps;
- struct r300_winsys_buffer *buf = r300->query_current->buffer;
+ struct r300_winsys_cs_buffer *buf = r300->query_current->cs_buffer;
CS_LOCALS(r300);
assert(caps->num_frag_pipes);
static void rv530_emit_query_end_single_z(struct r300_context *r300,
struct r300_query *query)
{
- struct r300_winsys_buffer *buf = r300->query_current->buffer;
+ struct r300_winsys_cs_buffer *buf = r300->query_current->cs_buffer;
CS_LOCALS(r300);
BEGIN_CS(8);
static void rv530_emit_query_end_double_z(struct r300_context *r300,
struct r300_query *query)
{
- struct r300_winsys_buffer *buf = r300->query_current->buffer;
+ struct r300_winsys_cs_buffer *buf = r300->query_current->cs_buffer;
CS_LOCALS(r300);
BEGIN_CS(14);
for (i = 0; i < fb->nr_cbufs; i++) {
tex = r300_texture(fb->cbufs[i]->texture);
assert(tex && tex->buffer && "cbuf is marked, but NULL!");
- r300->rws->cs_add_buffer(r300->cs, tex->buffer, 0,
+ r300->rws->cs_add_buffer(r300->cs, tex->cs_buffer, 0,
r300_surface(fb->cbufs[i])->domain);
}
/* ...depth buffer... */
if (fb->zsbuf) {
tex = r300_texture(fb->zsbuf->texture);
assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
- r300->rws->cs_add_buffer(r300->cs, tex->buffer, 0,
+ r300->rws->cs_add_buffer(r300->cs, tex->cs_buffer, 0,
r300_surface(fb->zsbuf)->domain);
}
/* ...textures... */
}
tex = r300_texture(texstate->sampler_views[i]->base.texture);
- r300->rws->cs_add_buffer(r300->cs, tex->buffer, tex->domain, 0);
+ r300->rws->cs_add_buffer(r300->cs, tex->cs_buffer, tex->domain, 0);
}
/* ...occlusion query buffer... */
if (r300->query_current)
- r300->rws->cs_add_buffer(r300->cs, r300->query_current->buffer,
+ r300->rws->cs_add_buffer(r300->cs, r300->query_current->cs_buffer,
0, r300->query_current->domain);
/* ...vertex buffer for SWTCL path... */
if (r300->vbo)
- r300->rws->cs_add_buffer(r300->cs, r300_buffer(r300->vbo)->buf,
+ r300->rws->cs_add_buffer(r300->cs, r300_buffer(r300->vbo)->cs_buf,
r300_buffer(r300->vbo)->domain, 0);
/* ...vertex buffers for HWTCL path... */
if (do_validate_vertex_buffers) {
for (i = 0; i < r300->velems->count; i++) {
pbuf = vbuf[velem[i].vertex_buffer_index].buffer;
- r300->rws->cs_add_buffer(r300->cs, r300_buffer(pbuf)->buf,
+ r300->rws->cs_add_buffer(r300->cs, r300_buffer(pbuf)->cs_buf,
r300_buffer(pbuf)->domain, 0);
}
}
/* ...and index buffer for HWTCL path. */
if (index_buffer)
- r300->rws->cs_add_buffer(r300->cs, r300_buffer(index_buffer)->buf,
+ r300->rws->cs_add_buffer(r300->cs, r300_buffer(index_buffer)->cs_buf,
r300_buffer(index_buffer)->domain, 0);
if (!r300->rws->cs_validate(r300->cs)) {
q->buffer = r300->rws->buffer_create(r300->rws, q->buffer_size, 4096,
PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM,
q->domain);
+ q->cs_buffer = r300->rws->buffer_get_cs_handle(r300->rws, q->buffer);
return (struct pipe_query*)q;
}
if (r300_buffer_is_user_buffer(buf))
return PIPE_UNREFERENCED;
- if (r300->rws->cs_is_buffer_referenced(r300->cs, rbuf->buf, domain))
+ if (r300->rws->cs_is_buffer_referenced(r300->cs, rbuf->cs_buf, domain))
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
return PIPE_UNREFERENCED;
rbuf->b.b.bind,
rbuf->b.b.usage,
rbuf->domain);
+ rbuf->cs_buf =
+ r300screen->rws->buffer_get_cs_handle(r300screen->rws,
+ rbuf->buf);
break;
}
}
rbuf->b.b.width0, alignment,
rbuf->b.b.bind, rbuf->b.b.usage,
rbuf->domain);
+ rbuf->cs_buf =
+ r300screen->rws->buffer_get_cs_handle(r300screen->rws, rbuf->buf);
if (!rbuf->buf) {
util_slab_free(&r300screen->pool_buffers, rbuf);
uint32_t magic;
struct r300_winsys_buffer *buf;
+ struct r300_winsys_cs_buffer *cs_buf;
enum r300_buffer_domain domain;
static INLINE struct r300_buffer *r300_buffer(struct pipe_resource *buffer)
{
- if (buffer) {
- assert(((struct r300_buffer *)buffer)->magic == R300_BUFFER_MAGIC);
- return (struct r300_buffer *)buffer;
- }
- return NULL;
+ return (struct r300_buffer *)buffer;
}
static INLINE boolean r300_buffer_is_user_buffer(struct pipe_resource *buffer)
/* Tiling determines how DRM treats the buffer data.
* We must flush CS when changing it if the buffer is referenced. */
if (r300->rws->cs_is_buffer_referenced(r300->cs,
- tex->buffer, R300_REF_CS))
+ tex->cs_buffer, R300_REF_CS))
r300->context.flush(&r300->context, 0, NULL);
r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
struct r300_texture *rtex = (struct r300_texture *)texture;
if (r300->rws->cs_is_buffer_referenced(r300->cs,
- rtex->buffer, R300_REF_CS))
+ rtex->cs_buffer, R300_REF_CS))
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
return PIPE_UNREFERENCED;
}
}
+ tex->cs_buffer = rws->buffer_get_cs_handle(rws, tex->buffer);
+
rws->buffer_set_tiling(rws, tex->buffer,
tex->desc.microtile, tex->desc.macrotile[0],
tex->desc.stride_in_bytes[0]);
surface->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer;
surface->buffer = tex->buffer;
+ surface->cs_buffer = tex->cs_buffer;
/* Prefer VRAM if there are multiple domains to choose from. */
surface->domain = tex->domain;
referenced_cs =
r300->rws->cs_is_buffer_referenced(r300->cs,
- tex->buffer, R300_REF_CS);
+ tex->cs_buffer, R300_REF_CS);
if (referenced_cs) {
referenced_hw = TRUE;
} else {
referenced_hw =
r300->rws->cs_is_buffer_referenced(r300->cs,
- tex->buffer, R300_REF_HW);
+ tex->cs_buffer, R300_REF_HW);
}
blittable = ctx->screen->is_format_supported(
struct winsys_handle;
struct r300_winsys_screen;
-struct r300_winsys_buffer;
+struct r300_winsys_buffer; /* for map/unmap etc. */
+struct r300_winsys_cs_buffer; /* for write_reloc etc. */
struct r300_winsys_cs {
uint32_t *ptr; /* Pointer to the beginning of the CS. */
unsigned usage,
enum r300_buffer_domain domain);
+ struct r300_winsys_cs_buffer *(*buffer_get_cs_handle)(
+ struct r300_winsys_screen *ws,
+ struct r300_winsys_buffer *buf);
+
/**
* Reference a buffer object (assign with reference counting).
*
* of the R300_DOMAIN_* flags.
*/
void (*cs_add_buffer)(struct r300_winsys_cs *cs,
- struct r300_winsys_buffer *buf,
+ struct r300_winsys_cs_buffer *buf,
enum r300_buffer_domain rd,
enum r300_buffer_domain wd);
* \param wd A write domain containing a bitmask of the R300_DOMAIN_* flags.
*/
void (*cs_write_reloc)(struct r300_winsys_cs *cs,
- struct r300_winsys_buffer *buf,
+ struct r300_winsys_cs_buffer *buf,
enum r300_buffer_domain rd,
enum r300_buffer_domain wd);
* \param domain A bitmask of the R300_REF_* enums.
*/
boolean (*cs_is_buffer_referenced)(struct r300_winsys_cs *cs,
- struct r300_winsys_buffer *buf,
+ struct r300_winsys_cs_buffer *buf,
enum r300_reference_domain domain);
};
radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws);
void radeon_drm_bufmgr_add_buffer(struct r300_winsys_cs *cs,
- struct r300_winsys_buffer *buf,
+ struct r300_winsys_cs_buffer *buf,
enum r300_buffer_domain rd,
enum r300_buffer_domain wd);
void radeon_drm_bufmgr_write_reloc(struct r300_winsys_cs *cs,
- struct r300_winsys_buffer *buf,
+ struct r300_winsys_cs_buffer *buf,
enum r300_buffer_domain rd,
enum r300_buffer_domain wd);
struct winsys_handle *whandle);
boolean radeon_drm_bufmgr_is_buffer_referenced(struct r300_winsys_cs *cs,
- struct r300_winsys_buffer *buf,
+ struct r300_winsys_cs_buffer *buf,
enum r300_reference_domain domain);
void radeon_drm_bufmgr_wait(struct r300_winsys_screen *ws,
void radeon_drm_buffer_unmap(struct r300_winsys_screen *ws,
struct r300_winsys_buffer *buf);
+struct r300_winsys_cs_buffer *radeon_drm_get_cs_handle(
+ struct r300_winsys_screen *rws,
+ struct r300_winsys_buffer *_buf);
+
#endif
}
void radeon_drm_bufmgr_add_buffer(struct r300_winsys_cs *rcs,
- struct r300_winsys_buffer *_buf,
+ struct r300_winsys_cs_buffer *_buf,
enum r300_buffer_domain rd,
enum r300_buffer_domain wd)
{
struct radeon_libdrm_cs *cs = radeon_libdrm_cs(rcs);
- struct radeon_drm_buffer *buf = get_drm_buffer(radeon_pb_buffer(_buf));
+ struct radeon_bo *bo = (struct radeon_bo*)_buf;
uint32_t gem_rd = get_gem_domain(rd);
uint32_t gem_wd = get_gem_domain(wd);
- radeon_cs_space_add_persistent_bo(cs->cs, buf->bo, gem_rd, gem_wd);
+ radeon_cs_space_add_persistent_bo(cs->cs, bo, gem_rd, gem_wd);
}
void radeon_drm_bufmgr_write_reloc(struct r300_winsys_cs *rcs,
- struct r300_winsys_buffer *_buf,
+ struct r300_winsys_cs_buffer *_buf,
enum r300_buffer_domain rd,
enum r300_buffer_domain wd)
{
struct radeon_libdrm_cs *cs = radeon_libdrm_cs(rcs);
- struct radeon_drm_buffer *buf = get_drm_buffer(radeon_pb_buffer(_buf));
+ struct radeon_bo *bo = (struct radeon_bo*)_buf;
int retval;
uint32_t gem_rd = get_gem_domain(rd);
uint32_t gem_wd = get_gem_domain(wd);
cs->cs->cdw = cs->base.cdw;
- retval = radeon_cs_write_reloc(cs->cs, buf->bo, gem_rd, gem_wd, 0);
+ retval = radeon_cs_write_reloc(cs->cs, bo, gem_rd, gem_wd, 0);
cs->base.cdw = cs->cs->cdw;
if (retval) {
fprintf(stderr, "radeon: Relocation of %p (%d, %d, %d) failed!\n",
- buf, gem_rd, gem_wd, 0);
+ bo, gem_rd, gem_wd, 0);
}
}
+struct r300_winsys_cs_buffer *radeon_drm_get_cs_handle(
+ struct r300_winsys_screen *rws,
+ struct r300_winsys_buffer *_buf)
+{
+ /* return pure radeon_bo. */
+ return (struct r300_winsys_cs_buffer*)
+ get_drm_buffer(radeon_pb_buffer(_buf))->bo;
+}
+
boolean radeon_drm_bufmgr_is_buffer_referenced(struct r300_winsys_cs *rcs,
- struct r300_winsys_buffer *_buf,
+ struct r300_winsys_cs_buffer *_buf,
enum r300_reference_domain domain)
{
struct radeon_libdrm_cs *cs = radeon_libdrm_cs(rcs);
- struct radeon_drm_buffer *buf = get_drm_buffer(radeon_pb_buffer(_buf));
+ struct radeon_bo *bo = (struct radeon_bo*)_buf;
uint32_t tmp;
if (domain & R300_REF_CS) {
- if (radeon_bo_is_referenced_by_cs(buf->bo, cs->cs)) {
+ if (radeon_bo_is_referenced_by_cs(bo, cs->cs)) {
return TRUE;
}
}
if (domain & R300_REF_HW) {
- if (radeon_bo_is_busy(buf->bo, &tmp)) {
+ if (radeon_bo_is_busy(bo, &tmp)) {
return TRUE;
}
}
ws->base.get_value = radeon_get_value;
ws->base.buffer_create = radeon_r300_winsys_buffer_create;
+ ws->base.buffer_get_cs_handle = radeon_drm_get_cs_handle;
ws->base.buffer_set_tiling = radeon_drm_bufmgr_set_tiling;
ws->base.buffer_get_tiling = radeon_drm_bufmgr_get_tiling;
ws->base.buffer_map = radeon_drm_buffer_map;