summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2010-02-27 17:00:03 +0100
committerMarek Olšák <maraeo@gmail.com>2010-02-28 00:46:35 +0100
commitd36e3952c21240cde19dac7f16cc37aac7174673 (patch)
tree9ea969b2aa995a3e02a51d62166678edf090e0fb /src
parent4ed97f0a73db37f6105b6282d92646c3f66c2645 (diff)
r300g: put validating buffers after flushing
Also cleaning up the nasty validation process.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/r300_emit.c32
-rw-r--r--src/gallium/drivers/r300/r300_emit.h4
-rw-r--r--src/gallium/drivers/r300/r300_render.c54
3 files changed, 37 insertions, 53 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 013611018b..d66fa0dbdb 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -1010,11 +1010,16 @@ void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, voi
END_CS;
}
-void r300_emit_buffer_validate(struct r300_context *r300)
+void r300_emit_buffer_validate(struct r300_context *r300,
+ boolean do_validate_vertex_buffers,
+ struct pipe_buffer *index_buffer)
{
struct pipe_framebuffer_state* fb =
(struct pipe_framebuffer_state*)r300->fb_state.state;
struct r300_texture* tex;
+ struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
+ struct pipe_vertex_element *velem = r300->vertex_element;
+ struct pipe_buffer *pbuf;
unsigned i;
boolean invalid = FALSE;
@@ -1061,16 +1066,35 @@ validate:
goto validate;
}
}
- /* ...and vertex buffer. */
+ /* ...vertex buffer for SWTCL path... */
if (r300->vbo) {
if (!r300->winsys->add_buffer(r300->winsys, r300->vbo,
RADEON_GEM_DOMAIN_GTT, 0)) {
r300->context.flush(&r300->context, 0, NULL);
goto validate;
}
- } else {
- /* debug_printf("No VBO while emitting dirty state!\n"); */
}
+ /* ...vertex buffers for HWTCL path... */
+ if (do_validate_vertex_buffers) {
+ for (i = 0; i < r300->vertex_element_count; i++) {
+ pbuf = vbuf[velem[i].vertex_buffer_index].buffer;
+
+ if (!r300->winsys->add_buffer(r300->winsys, pbuf,
+ RADEON_GEM_DOMAIN_GTT, 0)) {
+ r300->context.flush(&r300->context, 0, NULL);
+ goto validate;
+ }
+ }
+ }
+ /* ...and index buffer for HWTCL path. */
+ if (index_buffer) {
+ if (!r300->winsys->add_buffer(r300->winsys, index_buffer,
+ RADEON_GEM_DOMAIN_GTT, 0)) {
+ r300->context.flush(&r300->context, 0, NULL);
+ goto validate;
+ }
+ }
+
if (!r300->winsys->validate(r300->winsys)) {
r300->context.flush(&r300->context, 0, NULL);
if (invalid) {
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index c73b016b76..4a3f94087b 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -105,6 +105,8 @@ unsigned r300_get_num_dirty_dwords(struct r300_context *r300);
/* Emit all dirty state. */
void r300_emit_dirty_state(struct r300_context* r300);
-void r300_emit_buffer_validate(struct r300_context *r300);
+void r300_emit_buffer_validate(struct r300_context *r300,
+ boolean do_validate_vertex_buffers,
+ struct pipe_buffer *index_buffer);
#endif /* R300_EMIT_H */
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index e4f7615368..c5baf5508e 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -186,6 +186,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300,
dwords = 10 + count * vertex_size;
r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords);
+ r300_emit_buffer_validate(r300, FALSE, 0);
r300_emit_dirty_state(r300);
BEGIN_CS(dwords);
@@ -313,31 +314,6 @@ static void r300_emit_draw_elements(struct r300_context *r300,
END_CS;
}
-static boolean r300_setup_vertex_buffers(struct r300_context *r300)
-{
- struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
- struct pipe_vertex_element *velem = r300->vertex_element;
- struct pipe_buffer *pbuf;
-
-validate:
- for (int i = 0; i < r300->vertex_element_count; i++) {
- pbuf = vbuf[velem[i].vertex_buffer_index].buffer;
-
- if (!r300->winsys->add_buffer(r300->winsys, pbuf,
- RADEON_GEM_DOMAIN_GTT, 0)) {
- r300->context.flush(&r300->context, 0, NULL);
- goto validate;
- }
- }
-
- if (!r300->winsys->validate(r300->winsys)) {
- r300->context.flush(&r300->context, 0, NULL);
- return r300->winsys->validate(r300->winsys);
- }
-
- return TRUE;
-}
-
static void r300_shorten_ubyte_elts(struct r300_context* r300,
struct pipe_buffer** elts,
unsigned count)
@@ -393,30 +369,16 @@ void r300_draw_range_elements(struct pipe_context* pipe,
return;
}
- r300_update_derived_state(r300);
-
- r300_emit_buffer_validate(r300);
-
- if (!r300_setup_vertex_buffers(r300)) {
- return;
- }
-
if (indexSize == 1) {
r300_shorten_ubyte_elts(r300, &indexBuffer, count);
indexSize = 2;
}
- if (!r300->winsys->add_buffer(r300->winsys, indexBuffer,
- RADEON_GEM_DOMAIN_GTT, 0)) {
- goto cleanup;
- }
-
- if (!r300->winsys->validate(r300->winsys)) {
- goto cleanup;
- }
+ r300_update_derived_state(r300);
/* 128 dwords for emit_aos and emit_draw_elements */
r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128);
+ r300_emit_buffer_validate(r300, TRUE, indexBuffer);
r300_emit_dirty_state(r300);
r300_emit_aos(r300, 0);
@@ -434,13 +396,13 @@ void r300_draw_range_elements(struct pipe_context* pipe,
/* 16 spare dwords are enough for emit_draw_elements. */
if (count && r300_reserve_cs_space(r300, 16)) {
+ r300_emit_buffer_validate(r300, TRUE, indexBuffer);
r300_emit_dirty_state(r300);
r300_emit_aos(r300, 0);
}
} while (count);
}
-cleanup:
if (indexBuffer != orgIndexBuffer) {
pipe->screen->buffer_destroy(indexBuffer);
}
@@ -477,18 +439,13 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
r300_update_derived_state(r300);
- r300_emit_buffer_validate(r300);
-
if (immd_is_good_idea(r300, count)) {
r300_emit_draw_arrays_immediate(r300, mode, start, count);
} else {
- if (!r300_setup_vertex_buffers(r300)) {
- return;
- }
-
/* Make sure there are at least 128 spare dwords in the command buffer.
* (most of it being consumed by emit_aos) */
r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128);
+ r300_emit_buffer_validate(r300, TRUE, 0);
r300_emit_dirty_state(r300);
if (alt_num_verts || count <= 65535) {
@@ -506,6 +463,7 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
/* Again, we emit both AOS and draw_arrays so there should be
* at least 128 spare dwords. */
if (count && r300_reserve_cs_space(r300, 128)) {
+ r300_emit_buffer_validate(r300, TRUE, 0);
r300_emit_dirty_state(r300);
}
} while (count);