diff options
author | Marek Olšák <[email protected]> | 2009-12-02 17:15:27 +0100 |
---|---|---|
committer | Corbin Simpson <[email protected]> | 2009-12-04 09:23:59 -0800 |
commit | 7679447b5835fd73ab44b3d77b12a034c95af5c5 (patch) | |
tree | b057715b502d4df1c52da20719cd85535b7cc1b8 /src | |
parent | 3da8265cd3233e2b22ab0f8a28fbba892984e399 (diff) |
r300g, radeong: fix the CS overflow
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/r300/r300_cs.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 9 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_r300.c | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 8b100375fdf..9fcf3ab538c 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -55,7 +55,7 @@ int cs_count = 0; #define CHECK_CS(size) \ - cs_winsys->check_cs(cs_winsys, (size)) + assert(cs_winsys->check_cs(cs_winsys, (size))) #define BEGIN_CS(size) do { \ CHECK_CS(size); \ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a479842f9eb..3bb42f9e434 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -871,10 +871,17 @@ void r300_emit_dirty_state(struct r300_context* r300) return; } + /* Check size of CS. */ + /* Make sure we have at least 8*1024 spare dwords. */ + /* XXX It would be nice to know the number of dwords we really need to + * XXX emit. */ + if (!r300->winsys->check_cs(r300->winsys, 8*1024)) { + r300->context.flush(&r300->context, 0, NULL); + } + /* Clean out BOs. */ r300->winsys->reset_bos(r300->winsys); - /* XXX check size */ validate: /* Color buffers... */ for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 7362279b77a..ba0596c30dc 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -52,8 +52,9 @@ static boolean radeon_validate(struct radeon_winsys* winsys) static boolean radeon_check_cs(struct radeon_winsys* winsys, int size) { - /* XXX check size here, lazy ass! */ - return radeon_validate(winsys); + struct radeon_cs* cs = winsys->priv->cs; + + return radeon_validate(winsys) && cs->cdw + size <= cs->ndw; } static void radeon_begin_cs(struct radeon_winsys* winsys, |