summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2010-12-03 02:48:11 +0100
committerMarek Olšák <maraeo@gmail.com>2010-12-03 04:40:22 +0100
commit3ba8843307a909f35f2a04e6be6dcadd760ad82b (patch)
tree4c69fda7f8962184259483b8b96a85243a84e159 /src/gallium/drivers
parent6299f241e9fdd86e705d144a42d9b1979c13f9ad (diff)
r300g: use internal BO handle for add_buffer and write_reloc
Small perf improvement in ipers. radeon_drm_get_cs_handle is exactly what this commit tries to avoid in every write_reloc.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r300/r300_context.h3
-rw-r--r--src/gallium/drivers/r300/r300_cs.h6
-rw-r--r--src/gallium/drivers/r300/r300_emit.c36
-rw-r--r--src/gallium/drivers/r300/r300_query.c1
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.c7
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.h7
-rw-r--r--src/gallium/drivers/r300/r300_state.c2
-rw-r--r--src/gallium/drivers/r300/r300_texture.c5
-rw-r--r--src/gallium/drivers/r300/r300_transfer.c4
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h13
10 files changed, 49 insertions, 35 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 2b97e4f8e2..93c20a0a6a 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -282,6 +282,7 @@ struct r300_query {
/* 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. */
@@ -313,6 +314,7 @@ struct r300_surface {
/* Winsys buffer backing the texture. */
struct r300_winsys_buffer *buffer;
+ struct r300_winsys_cs_buffer *cs_buffer;
enum r300_buffer_domain domain;
@@ -396,6 +398,7 @@ struct r300_texture {
/* 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. */
diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h
index c194d6a1b0..ea29fc565b 100644
--- a/src/gallium/drivers/r300/r300_cs.h
+++ b/src/gallium/drivers/r300/r300_cs.h
@@ -115,17 +115,17 @@
#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)
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 3e6852b779..31c7b38adf 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -353,10 +353,10 @@ void r300_emit_aa_state(struct r300_context *r300, unsigned size, void *state)
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);
@@ -387,10 +387,10 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
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. */
@@ -400,10 +400,10 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
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,
@@ -416,10 +416,10 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
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;
@@ -559,7 +559,7 @@ static void r300_emit_query_end_frag_pipes(struct r300_context *r300,
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);
@@ -615,7 +615,7 @@ static void r300_emit_query_end_frag_pipes(struct r300_context *r300,
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);
@@ -629,7 +629,7 @@ static void rv530_emit_query_end_single_z(struct r300_context *r300,
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);
@@ -1188,14 +1188,14 @@ boolean r300_emit_buffer_validate(struct r300_context *r300,
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... */
@@ -1205,28 +1205,28 @@ boolean r300_emit_buffer_validate(struct r300_context *r300,
}
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)) {
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index 5f34fcb274..59cd1e7f79 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -60,6 +60,7 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe,
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;
}
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 98d36ad272..9b1ee9e068 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -43,7 +43,7 @@ unsigned r300_buffer_is_referenced(struct pipe_context *context,
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;
@@ -206,6 +206,9 @@ r300_buffer_transfer_map( struct pipe_context *pipe,
rbuf->b.b.bind,
rbuf->b.b.usage,
rbuf->domain);
+ rbuf->cs_buf =
+ r300screen->rws->buffer_get_cs_handle(r300screen->rws,
+ rbuf->buf);
break;
}
}
@@ -310,6 +313,8 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
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);
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h
index cafa9f96f2..a184ead3a3 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.h
+++ b/src/gallium/drivers/r300/r300_screen_buffer.h
@@ -51,6 +51,7 @@ struct r300_buffer
uint32_t magic;
struct r300_winsys_buffer *buf;
+ struct r300_winsys_cs_buffer *cs_buf;
enum r300_buffer_domain domain;
@@ -86,11 +87,7 @@ unsigned r300_buffer_is_referenced(struct pipe_context *context,
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)
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 0f563703c0..d4e2063558 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -626,7 +626,7 @@ static void r300_tex_set_tiling_flags(struct r300_context *r300,
/* 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,
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 4b7b3e0356..70fc5d96d8 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -675,7 +675,7 @@ static unsigned r300_texture_is_referenced(struct pipe_context *context,
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;
@@ -777,6 +777,8 @@ r300_texture_create_object(struct r300_screen *rscreen,
}
}
+ 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]);
@@ -876,6 +878,7 @@ struct pipe_surface* r300_create_surface(struct pipe_context * ctx,
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;
diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c
index 755aff8380..3b95af79bc 100644
--- a/src/gallium/drivers/r300/r300_transfer.c
+++ b/src/gallium/drivers/r300/r300_transfer.c
@@ -90,13 +90,13 @@ r300_texture_get_transfer(struct pipe_context *ctx,
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(
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 4597332399..c45888dbf3 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -36,7 +36,8 @@
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. */
@@ -102,6 +103,10 @@ struct r300_winsys_screen {
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).
*
@@ -242,7 +247,7 @@ struct r300_winsys_screen {
* 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);
@@ -263,7 +268,7 @@ struct r300_winsys_screen {
* \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);
@@ -303,7 +308,7 @@ struct r300_winsys_screen {
* \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);
};