summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2009-05-20 11:46:26 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2009-05-20 11:46:26 -0700
commit65946ef0813e00944763ae959698e281871ee642 (patch)
tree2209e46f911f92d1e68ba46161539b0f62743e1d
parent4550423211063010a2fa482037d8233bb80e3773 (diff)
r300-gallium: Make surface_copy work, and refactor buffer validation.
-rw-r--r--src/gallium/drivers/r300/r300_emit.c13
-rw-r--r--src/gallium/drivers/r300/r300_surface.c50
2 files changed, 47 insertions, 16 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 0cb0507fc8..5e4b179505 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -452,8 +452,8 @@ void r300_emit_dirty_state(struct r300_context* r300)
{
struct r300_screen* r300screen = r300_screen(r300->context.screen);
struct r300_texture* tex;
- int i;
- int dirty_tex = 0;
+ int i, dirty_tex = 0;
+ boolean invalid = FALSE;
if (!(r300->dirty_state)) {
return;
@@ -462,6 +462,7 @@ void r300_emit_dirty_state(struct r300_context* r300)
r300_update_derived_state(r300);
/* XXX check size */
+validate:
/* Color buffers... */
for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) {
tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture;
@@ -490,10 +491,14 @@ void r300_emit_dirty_state(struct r300_context* r300)
} else {
debug_printf("No VBO while emitting dirty state!\n");
}
-
if (r300->winsys->validate(r300->winsys)) {
- /* XXX */
r300->context.flush(&r300->context, 0, NULL);
+ if (invalid) {
+ /* Well, hell. */
+ exit(1);
+ }
+ invalid = TRUE;
+ goto validate;
}
if (r300->dirty_state & R300_NEW_BLEND) {
diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
index acb6192492..7711e8f569 100644
--- a/src/gallium/drivers/r300/r300_surface.c
+++ b/src/gallium/drivers/r300/r300_surface.c
@@ -32,13 +32,6 @@ static void r300_surface_setup(struct r300_context* r300,
unsigned pixpitch = dest->stride / dest->tex.block.size;
CS_LOCALS(r300);
- /* Make sure our target BO is okay. */
- r300->winsys->add_buffer(r300->winsys, dest->buffer,
- 0, RADEON_GEM_DOMAIN_VRAM);
- if (r300->winsys->validate(r300->winsys)) {
- r300->context.flush(&r300->context, 0, NULL);
- }
-
r300_emit_blend_state(r300, &blend_clear_state);
r300_emit_blend_color_state(r300, &blend_color_clear_state);
r300_emit_dsa_state(r300, &dsa_clear_state);
@@ -106,6 +99,7 @@ static void r300_surface_fill(struct pipe_context* pipe,
struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
struct r300_texture* tex = (struct r300_texture*)dest->texture;
unsigned pixpitch = tex->stride / tex->tex.block.size;
+ boolean invalid = FALSE;
CS_LOCALS(r300);
a = (float)((color >> 24) & 0xff) / 255.0f;
@@ -118,11 +112,25 @@ static void r300_surface_fill(struct pipe_context* pipe,
/* Fallback? */
if (FALSE) {
+fallback:
debug_printf("r300: Falling back on surface clear...");
util_surface_fill(pipe, dest, x, y, w, h, color);
return;
}
+ /* Make sure our target BO is okay. */
+validate:
+ r300->winsys->add_buffer(r300->winsys, tex->buffer,
+ 0, RADEON_GEM_DOMAIN_VRAM);
+ if (r300->winsys->validate(r300->winsys)) {
+ r300->context.flush(&r300->context, 0, NULL);
+ if (invalid) {
+ goto fallback;
+ }
+ invalid = TRUE;
+ goto validate;
+ }
+
r300_surface_setup(r300, tex, x, y, w, h);
/* Vertex shader setup */
@@ -216,6 +224,7 @@ static void r300_surface_copy(struct pipe_context* pipe,
struct r300_texture* srctex = (struct r300_texture*)src->texture;
struct r300_texture* desttex = (struct r300_texture*)dest->texture;
unsigned pixpitch = srctex->stride / srctex->tex.block.size;
+ boolean invalid = FALSE;
CS_LOCALS(r300);
debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d),"
@@ -225,21 +234,38 @@ static void r300_surface_copy(struct pipe_context* pipe,
if ((srctex == desttex) &&
((destx < srcx + w) || (srcx < destx + w)) &&
((desty < srcy + h) || (srcy < desty + h))) {
+fallback:
debug_printf("r300: Falling back on surface_copy\n");
util_surface_copy(pipe, FALSE, dest, destx, desty, src,
srcx, srcy, w, h);
}
- /* Add our source texture to the BO list before emitting anything.
- * r300_surface_setup will flush if needed for us. */
+ /* Add our target BOs to the list. */
+validate:
r300->winsys->add_buffer(r300->winsys, srctex->buffer,
RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ r300->winsys->add_buffer(r300->winsys, desttex->buffer,
+ 0, RADEON_GEM_DOMAIN_VRAM);
+ if (r300->winsys->validate(r300->winsys)) {
+ r300->context.flush(&r300->context, 0, NULL);
+ if (invalid) {
+ goto fallback;
+ }
+ invalid = TRUE;
+ goto validate;
+ }
r300_surface_setup(r300, desttex, destx, desty, w, h);
+ /* Setup the texture. */
r300_emit_sampler(r300, &r300_sampler_copy_state, 0);
r300_emit_texture(r300, srctex, 0);
- r300_flush_textures(r300);
+
+ /* Flush and enable. */
+ BEGIN_CS(4);
+ OUT_CS_REG(R300_TX_INVALTAGS, 0);
+ OUT_CS_REG(R300_TX_ENABLE, 0x1);
+ END_CS;
/* Vertex shader setup */
if (caps->has_tcl) {
@@ -263,7 +289,7 @@ static void r300_surface_copy(struct pipe_context* pipe,
r300_emit_rs_block_state(r300, &r300_rs_block_copy_state);
}
- BEGIN_CS(28);
+ BEGIN_CS(30);
/* VAP stream control, mapping from input memory to PVS/RS memory */
if (caps->has_tcl) {
OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
@@ -287,7 +313,7 @@ static void r300_surface_copy(struct pipe_context* pipe,
OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2);
/* Vertex size. */
- OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
+ OUT_CS_REG(R300_VAP_VTX_SIZE, 0x4);
/* Packet3 with our texcoords */
OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 16);