summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-03-31 22:17:19 +0200
committerMarek Olšák <[email protected]>2012-04-04 04:28:40 +0200
commitda2123051c3923a2953cdd96f05ad684e7d3c8c3 (patch)
treeebd9cfa49f4a8b2cc8131e0c0afd6fbdfeffa235 /src
parent5ce0598a034179eaacff96f39eaebf0ba0f30d4c (diff)
r300g/swtcl: don't enter u_vbuf_mgr
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/r300_blit.c9
-rw-r--r--src/gallium/drivers/r300/r300_context.c12
-rw-r--r--src/gallium/drivers/r300/r300_context.h3
-rw-r--r--src/gallium/drivers/r300/r300_render.c14
-rw-r--r--src/gallium/drivers/r300/r300_state.c44
5 files changed, 48 insertions, 34 deletions
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index d1326380f3d..920612b8de5 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -63,8 +63,13 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o
util_blitter_save_vertex_shader(r300->blitter, r300->vs_state.state);
util_blitter_save_viewport(r300->blitter, &r300->viewport);
util_blitter_save_vertex_elements(r300->blitter, r300->velems);
- util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers,
- r300->vbuf_mgr->vertex_buffer);
+ if (r300->vbuf_mgr) {
+ util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers,
+ r300->vbuf_mgr->vertex_buffer);
+ } else {
+ util_blitter_save_vertex_buffers(r300->blitter, r300->swtcl_nr_vertex_buffers,
+ r300->swtcl_vertex_buffer);
+ }
if (op & R300_SAVE_FRAMEBUFFER) {
util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state);
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 158dbc07c7f..505c6ccf99e 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -418,17 +418,19 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300_init_query_functions(r300);
r300_init_state_functions(r300);
r300_init_resource_functions(r300);
-
+
r300->context.create_video_decoder = vl_create_decoder;
r300->context.create_video_buffer = vl_video_buffer_create;
- r300->vbuf_mgr = u_vbuf_create(&r300->context, 1024 * 1024, 16,
+ if (r300->screen->caps.has_tcl) {
+ r300->vbuf_mgr = u_vbuf_create(&r300->context, 1024 * 1024, 16,
PIPE_BIND_VERTEX_BUFFER |
PIPE_BIND_INDEX_BUFFER,
U_VERTEX_FETCH_DWORD_ALIGNED);
- if (!r300->vbuf_mgr)
- goto fail;
- r300->vbuf_mgr->caps.format_fixed32 = 0;
+ if (!r300->vbuf_mgr)
+ goto fail;
+ r300->vbuf_mgr->caps.format_fixed32 = 0;
+ }
r300->blitter = util_blitter_create(&r300->context);
if (r300->blitter == NULL)
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index f32504c530a..0802e79add7 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -579,6 +579,9 @@ struct r300_context {
void *dsa_decompress_zmask;
struct u_vbuf *vbuf_mgr;
+ struct pipe_index_buffer swtcl_index_buffer;
+ struct pipe_vertex_buffer swtcl_vertex_buffer[PIPE_MAX_ATTRIBS];
+ unsigned swtcl_nr_vertex_buffers;
struct util_slab_mempool pool_transfers;
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index b9ce857d43c..91c528ec512 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -818,7 +818,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
struct pipe_transfer *ib_transfer = NULL;
int i;
void *indices = NULL;
- boolean indexed = info->indexed && r300->vbuf_mgr->index_buffer.buffer;
+ boolean indexed = info->indexed && r300->swtcl_index_buffer.buffer;
if (r300->skip_rendering) {
return;
@@ -831,10 +831,10 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
(indexed ? PREP_INDEXED : 0),
indexed ? 256 : 6);
- for (i = 0; i < r300->vbuf_mgr->nr_vertex_buffers; i++) {
- if (r300->vbuf_mgr->vertex_buffer[i].buffer) {
+ for (i = 0; i < r300->swtcl_nr_vertex_buffers; i++) {
+ if (r300->swtcl_vertex_buffer[i].buffer) {
void *buf = pipe_buffer_map(pipe,
- r300->vbuf_mgr->vertex_buffer[i].buffer,
+ r300->swtcl_vertex_buffer[i].buffer,
PIPE_TRANSFER_READ |
PIPE_TRANSFER_UNSYNCHRONIZED,
&vb_transfer[i]);
@@ -843,7 +843,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
}
if (indexed) {
- indices = pipe_buffer_map(pipe, r300->vbuf_mgr->index_buffer.buffer,
+ indices = pipe_buffer_map(pipe, r300->swtcl_index_buffer.buffer,
PIPE_TRANSFER_READ |
PIPE_TRANSFER_UNSYNCHRONIZED, &ib_transfer);
}
@@ -856,8 +856,8 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
draw_flush(r300->draw);
r300->draw_vbo_locked = FALSE;
- for (i = 0; i < r300->vbuf_mgr->nr_vertex_buffers; i++) {
- if (r300->vbuf_mgr->vertex_buffer[i].buffer) {
+ for (i = 0; i < r300->swtcl_nr_vertex_buffers; i++) {
+ if (r300->swtcl_vertex_buffer[i].buffer) {
pipe_buffer_unmap(pipe, vb_transfer[i]);
draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
}
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index a623ff898a7..05ed81b2b9d 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1589,7 +1589,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
const struct pipe_vertex_buffer* buffers)
{
struct r300_context* r300 = r300_context(pipe);
- unsigned i;
struct pipe_vertex_buffer dummy_vb = {0};
/* There must be at least one vertex buffer set, otherwise it locks up. */
@@ -1599,18 +1598,13 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
count = 1;
}
- u_vbuf_set_vertex_buffers(r300->vbuf_mgr, count, buffers);
-
if (r300->screen->caps.has_tcl) {
- /* HW TCL. */
- for (i = 0; i < count; i++) {
- if (buffers[i].buffer &&
- !r300_resource(buffers[i].buffer)->b.user_ptr) {
- }
- }
+ u_vbuf_set_vertex_buffers(r300->vbuf_mgr, count, buffers);
r300->vertex_arrays_dirty = TRUE;
} else {
- /* SW TCL. */
+ util_copy_vertex_buffers(r300->swtcl_vertex_buffer,
+ &r300->swtcl_nr_vertex_buffers,
+ buffers, count);
draw_set_vertex_buffers(r300->draw, count, buffers);
}
}
@@ -1620,9 +1614,15 @@ static void r300_set_index_buffer(struct pipe_context* pipe,
{
struct r300_context* r300 = r300_context(pipe);
- u_vbuf_set_index_buffer(r300->vbuf_mgr, ib);
-
- if (!r300->screen->caps.has_tcl) {
+ if (r300->screen->caps.has_tcl) {
+ u_vbuf_set_index_buffer(r300->vbuf_mgr, ib);
+ } else {
+ if (ib) {
+ pipe_resource_reference(&r300->swtcl_index_buffer.buffer, ib->buffer);
+ memcpy(&r300->swtcl_index_buffer, ib, sizeof(*ib));
+ } else {
+ pipe_resource_reference(&r300->swtcl_index_buffer.buffer, NULL);
+ }
draw_set_index_buffer(r300->draw, ib);
}
}
@@ -1696,11 +1696,11 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
return NULL;
velems->count = count;
- velems->vmgr_elements =
- u_vbuf_create_vertex_elements(r300->vbuf_mgr, count, attribs,
- velems->velem);
if (r300_screen(pipe->screen)->caps.has_tcl) {
+ velems->vmgr_elements =
+ u_vbuf_create_vertex_elements(r300->vbuf_mgr, count, attribs,
+ velems->velem);
/* Setup PSC.
* The unused components will be replaced by (..., 0, 1). */
r300_vertex_psc(velems);
@@ -1710,6 +1710,8 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
align(util_format_get_blocksize(velems->velem[i].src_format), 4);
velems->vertex_size_dwords += velems->format_size[i] / 4;
}
+ } else {
+ memcpy(velems->velem, attribs, count * sizeof(struct pipe_vertex_element));
}
return velems;
@@ -1727,9 +1729,9 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe,
r300->velems = velems;
- u_vbuf_bind_vertex_elements(r300->vbuf_mgr, state, velems->vmgr_elements);
-
- if (r300->draw) {
+ if (r300->screen->caps.has_tcl) {
+ u_vbuf_bind_vertex_elements(r300->vbuf_mgr, state, velems->vmgr_elements);
+ } else {
draw_set_vertex_elements(r300->draw, velems->count, velems->velem);
return;
}
@@ -1744,7 +1746,9 @@ static void r300_delete_vertex_elements_state(struct pipe_context *pipe, void *s
struct r300_context *r300 = r300_context(pipe);
struct r300_vertex_element_state *velems = state;
- u_vbuf_destroy_vertex_elements(r300->vbuf_mgr, velems->vmgr_elements);
+ if (r300->screen->caps.has_tcl) {
+ u_vbuf_destroy_vertex_elements(r300->vbuf_mgr, velems->vmgr_elements);
+ }
FREE(state);
}