diff options
| author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-17 00:20:51 +0000 | 
|---|---|---|
| committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-17 00:22:25 +0000 | 
| commit | b9f59b1099eeba3fb8b25693d4f37dd13267d8a3 (patch) | |
| tree | db714453a736df67d1077ad70b786e0b8ec78b5a | |
| parent | 6fc4cdafeba4517b94202ff292f05fdd90e52b2e (diff) | |
sna: correct adjust of a stolen 2d read buffer
If we steal a write buffer for creating a pixmap for read back, then we
need to be careful as we will have set the used amount to 0 and then try
to incorrectly decrease by the last row. Fortunately, we do not yet have
any code that attempts to create a 2d buffer for reading.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
| -rw-r--r-- | src/sna/kgem.c | 6 | 
1 files changed, 4 insertions, 2 deletions
| diff --git a/src/sna/kgem.c b/src/sna/kgem.c index f79f6603..48f8182a 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1289,7 +1289,7 @@ static void kgem_finish_partials(struct kgem *kgem)  			}  		} -		if (bo->need_io) { +		if (bo->used && bo->need_io) {  			DBG(("%s: handle=%d, uploading %d/%d\n",  			     __FUNCTION__, bo->base.handle, bo->used, bo->base.size));  			assert(!kgem_busy(kgem, bo->base.handle)); @@ -3176,6 +3176,7 @@ struct kgem_bo *kgem_create_buffer_2d(struct kgem *kgem,  	struct kgem_bo *bo;  	int stride; +	assert(width > 0 && height > 0);  	stride = ALIGN(width, 2) * bpp >> 3;  	stride = ALIGN(stride, kgem->min_alignment); @@ -3193,7 +3194,8 @@ struct kgem_bo *kgem_create_buffer_2d(struct kgem *kgem,  		 * the last pair of rows is valid, remove the padding so  		 * that it can be allocated to other pixmaps.  		 */ -		io->used -= stride; +		if (io->used) +			io->used -= stride;  		bo->size -= stride;  		bubble_sort_partial(kgem, io);  	} | 
