r600g,radeonsi: Assert that there's enough space after flushing
authorMichel Dänzer <michel.daenzer@amd.com>
Wed, 19 Nov 2014 06:31:24 +0000 (15:31 +0900)
committerMichel Dänzer <michel@daenzer.net>
Mon, 8 Jun 2015 09:10:35 +0000 (18:10 +0900)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/radeon/r600_pipe_common.c

index 42e681dc7d218ec9b11fd463ccc72ee530b5413c..3def44468823557cea70140ec50c9e7da037fe2a 100644 (file)
@@ -107,11 +107,10 @@ void r600_draw_rectangle(struct blitter_context *blitter,
 
 void r600_need_dma_space(struct r600_common_context *ctx, unsigned num_dw)
 {
-       /* The number of dwords we already used in the DMA so far. */
-       num_dw += ctx->rings.dma.cs->cdw;
        /* Flush if there's not enough space. */
-       if (num_dw > RADEON_MAX_CMDBUF_DWORDS) {
+       if ((num_dw + ctx->rings.dma.cs->cdw) > RADEON_MAX_CMDBUF_DWORDS) {
                ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC, NULL);
+               assert((num_dw + ctx->rings.dma.cs->cdw) <= RADEON_MAX_CMDBUF_DWORDS);
        }
 }