diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-05-02 23:54:42 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-05-03 00:13:36 +0100 |
commit | b84590994c4261d85485357263146d5e3d8827eb (patch) | |
tree | ca379bcc851305ced4904dec4fac5993cc3e1f8a /src | |
parent | 49e37469bdafe663fa08a5a446e44f3ede168a13 (diff) |
svga: Remove the screen private context.
All affected operations have already been moved to context.
More cleanup work can be done, in particular with the buffer transfers.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/svga/svga_context.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_pipe_query.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer_upload.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_texture.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_sampler_view.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_screen.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_screen.h | 12 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_surface.c | 43 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_surface.h | 1 |
11 files changed, 63 insertions, 106 deletions
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 3228a6d3d7..75d8afb2ea 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -194,6 +194,7 @@ void svga_context_flush( struct svga_context *svga, struct pipe_fence_handle **pfence ) { struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); + struct pipe_fence_handle *fence = NULL; svga->curr.nr_fbs = 0; @@ -202,21 +203,26 @@ void svga_context_flush( struct svga_context *svga, u_upload_flush(svga->upload_vb); u_upload_flush(svga->upload_ib); - /* Flush screen, to ensure that texture dma uploads are processed + /* Ensure that texture dma uploads are processed * before submitting commands. */ - svga_screen_flush(svgascreen, NULL); - svga_context_flush_buffers(svga); /* Flush pending commands to hardware: */ - svga->swc->flush(svga->swc, pfence); + svga->swc->flush(svga->swc, &fence); + + svga_screen_cache_flush(svgascreen, fence); if (SVGA_DEBUG & DEBUG_SYNC) { - if (pfence && *pfence) - svga->pipe.screen->fence_finish( svga->pipe.screen, *pfence, 0); + if (fence) + svga->pipe.screen->fence_finish( svga->pipe.screen, fence, 0); } + + if(pfence) + *pfence = fence; + else + svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL); } diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 9c6f5858ba..96fb4b8e53 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -68,6 +68,7 @@ static boolean svga_get_query_result(struct pipe_context *pipe, static struct pipe_query *svga_create_query( struct pipe_context *pipe, unsigned query_type ) { + struct svga_context *svga = svga_context( pipe ); struct svga_screen *svgascreen = svga_screen(pipe->screen); struct svga_winsys_screen *sws = svgascreen->sws; struct svga_query *sq; @@ -80,7 +81,7 @@ static struct pipe_query *svga_create_query( struct pipe_context *pipe, sq->type = SVGA3D_QUERYTYPE_OCCLUSION; - sq->hwbuf = svga_winsys_buffer_create(svgascreen, + sq->hwbuf = svga_winsys_buffer_create(svga, 1, SVGA_BUFFER_USAGE_PINNED, sizeof *sq->queryResult); diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c index 18eeff9c67..198d401332 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.c +++ b/src/gallium/drivers/svga/svga_resource_buffer.c @@ -125,8 +125,6 @@ svga_buffer_map_range( struct pipe_screen *screen, } if(map) { - pipe_mutex_lock(ss->swc_mutex); - ++sbuf->map.count; if (usage & PIPE_TRANSFER_WRITE) { @@ -135,8 +133,6 @@ svga_buffer_map_range( struct pipe_screen *screen, if (usage & PIPE_TRANSFER_FLUSH_EXPLICIT) sbuf->map.flush_explicit = TRUE; } - - pipe_mutex_unlock(ss->swc_mutex); } return map; diff --git a/src/gallium/drivers/svga/svga_resource_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h index 55e7321184..d3ec11bfd5 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.h +++ b/src/gallium/drivers/svga/svga_resource_buffer.h @@ -238,7 +238,7 @@ void svga_context_flush_buffers(struct svga_context *svga); struct svga_winsys_buffer * -svga_winsys_buffer_create(struct svga_screen *ss, +svga_winsys_buffer_create(struct svga_context *svga, unsigned alignment, unsigned usage, unsigned size); diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index acef60f464..3de5216a94 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -40,15 +40,21 @@ #include "svga_debug.h" -/* Allocate a winsys_buffer (ie. DMA, aka GMR memory). +/** + * Allocate a winsys_buffer (ie. DMA, aka GMR memory). + * + * It will flush and retry in case the first attempt to create a DMA buffer + * fails, so it should not be called from any function involved in flushing + * to avoid recursion. */ struct svga_winsys_buffer * -svga_winsys_buffer_create( struct svga_screen *ss, +svga_winsys_buffer_create( struct svga_context *svga, unsigned alignment, unsigned usage, unsigned size ) { - struct svga_winsys_screen *sws = ss->sws; + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); + struct svga_winsys_screen *sws = svgascreen->sws; struct svga_winsys_buffer *buf; /* Just try */ @@ -59,9 +65,8 @@ svga_winsys_buffer_create( struct svga_screen *ss, size); /* Try flushing all pending DMAs */ - svga_screen_flush(ss, NULL); + svga_context_flush(svga, NULL); buf = sws->buffer_create(sws, alignment, usage, size); - } return buf; @@ -95,11 +100,12 @@ svga_buffer_create_hw_storage(struct svga_screen *ss, assert(!sbuf->user); if(!sbuf->hwbuf) { + struct svga_winsys_screen *sws = ss->sws; unsigned alignment = 16; unsigned usage = 0; unsigned size = sbuf->b.b.width0; - sbuf->hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size); + sbuf->hwbuf = sws->buffer_create(sws, alignment, usage, size); if(!sbuf->hwbuf) return PIPE_ERROR_OUT_OF_MEMORY; @@ -476,12 +482,12 @@ svga_buffer_upload_piecewise(struct svga_screen *ss, if (offset + size > range->end) size = range->end - offset; - hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size); + hwbuf = sws->buffer_create(sws, alignment, usage, size); while (!hwbuf) { size /= 2; if (!size) return PIPE_ERROR_OUT_OF_MEMORY; - hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size); + hwbuf = sws->buffer_create(sws, alignment, usage, size); } SVGA_DBG(DEBUG_DMA, " bytes %u - %u\n", diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index f06b0323d8..ff83c750aa 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -163,12 +163,12 @@ svga_translate_format_render(enum pipe_format format) static INLINE void -svga_transfer_dma_band(struct svga_transfer *st, +svga_transfer_dma_band(struct svga_context *svga, + struct svga_transfer *st, SVGA3dTransferType transfer, unsigned y, unsigned h, unsigned srcy) { struct svga_texture *texture = svga_texture(st->base.resource); - struct svga_screen *screen = svga_screen(texture->b.b.screen); SVGA3dCopyBox box; enum pipe_error ret; @@ -195,20 +195,19 @@ svga_transfer_dma_band(struct svga_transfer *st, box.srcy = srcy; box.srcz = 0; - pipe_mutex_lock(screen->swc_mutex); - ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1); + ret = SVGA3D_SurfaceDMA(svga->swc, st, transfer, &box, 1); if(ret != PIPE_OK) { - screen->swc->flush(screen->swc, NULL); - ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1); + svga->swc->flush(svga->swc, NULL); + ret = SVGA3D_SurfaceDMA(svga->swc, st, transfer, &box, 1); assert(ret == PIPE_OK); } - pipe_mutex_unlock(screen->swc_mutex); } static INLINE void -svga_transfer_dma(struct svga_transfer *st, - SVGA3dTransferType transfer) +svga_transfer_dma(struct svga_context *svga, + struct svga_transfer *st, + SVGA3dTransferType transfer) { struct svga_texture *texture = svga_texture(st->base.resource); struct svga_screen *screen = svga_screen(texture->b.b.screen); @@ -223,10 +222,10 @@ svga_transfer_dma(struct svga_transfer *st, if(!st->swbuf) { /* Do the DMA transfer in a single go */ - svga_transfer_dma_band(st, transfer, st->base.box.y, st->base.box.height, 0); + svga_transfer_dma_band(svga, st, transfer, st->base.box.y, st->base.box.height, 0); if(transfer == SVGA3D_READ_HOST_VRAM) { - svga_screen_flush(screen, &fence); + svga_context_flush(svga, &fence); sws->fence_finish(sws, fence, 0); sws->fence_reference(sws, &fence, NULL); } @@ -256,7 +255,7 @@ svga_transfer_dma(struct svga_transfer *st, /* Wait for the previous DMAs to complete */ /* TODO: keep one DMA (at half the size) in the background */ if(y) { - svga_screen_flush(screen, &fence); + svga_context_flush(svga, &fence); sws->fence_finish(sws, fence, 0); sws->fence_reference(sws, &fence, NULL); } @@ -269,10 +268,10 @@ svga_transfer_dma(struct svga_transfer *st, } } - svga_transfer_dma_band(st, transfer, y, h, srcy); + svga_transfer_dma_band(svga, st, transfer, y, h, srcy); if(transfer == SVGA3D_READ_HOST_VRAM) { - svga_screen_flush(screen, &fence); + svga_context_flush(svga, &fence); sws->fence_finish(sws, fence, 0); hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_READ); @@ -342,6 +341,7 @@ svga_texture_get_transfer(struct pipe_context *pipe, unsigned usage, const struct pipe_box *box) { + struct svga_context *svga = svga_context(pipe); struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st; @@ -365,12 +365,12 @@ svga_texture_get_transfer(struct pipe_context *pipe, st->hw_nblocksy = nblocksy; - st->hwbuf = svga_winsys_buffer_create(ss, + st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy*st->base.stride); while(!st->hwbuf && (st->hw_nblocksy /= 2)) { - st->hwbuf = svga_winsys_buffer_create(ss, + st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy*st->base.stride); @@ -393,7 +393,7 @@ svga_texture_get_transfer(struct pipe_context *pipe, } if (usage & PIPE_TRANSFER_READ) - svga_transfer_dma(st, SVGA3D_READ_HOST_VRAM); + svga_transfer_dma(svga, st, SVGA3D_READ_HOST_VRAM); return &st->base; @@ -445,13 +445,14 @@ static void svga_texture_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *transfer) { + struct svga_context *svga = svga_context(pipe); struct svga_texture *tex = svga_texture(transfer->resource); struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st = svga_transfer(transfer); if (st->base.usage & PIPE_TRANSFER_WRITE) { - svga_transfer_dma(st, SVGA3D_WRITE_HOST_VRAM); + svga_transfer_dma(svga, st, SVGA3D_WRITE_HOST_VRAM); ss->texture_timestamp++; tex->view_age[transfer->sr.level] = ++(tex->age); tex->defined[transfer->sr.face][transfer->sr.level] = TRUE; diff --git a/src/gallium/drivers/svga/svga_sampler_view.c b/src/gallium/drivers/svga/svga_sampler_view.c index fbae552f78..6911f13f77 100644 --- a/src/gallium/drivers/svga/svga_sampler_view.c +++ b/src/gallium/drivers/svga/svga_sampler_view.c @@ -169,7 +169,7 @@ svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view * for (i = v->min_lod; i <= v->max_lod; i++) { for (k = 0; k < numFaces; k++) { if (v->age < tex->view_age[i]) - svga_texture_copy_handle(svga, NULL, + svga_texture_copy_handle(svga, tex->handle, 0, 0, 0, i, k, v->handle, 0, 0, 0, i - v->min_lod, k, u_minify(tex->b.b.width0, i), diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index ac310b6aed..45e477e65b 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -347,8 +347,6 @@ svga_destroy_screen( struct pipe_screen *screen ) pipe_mutex_destroy(svgascreen->swc_mutex); pipe_mutex_destroy(svgascreen->tex_mutex); - svgascreen->swc->destroy(svgascreen->swc); - svgascreen->sws->destroy(svgascreen->sws); FREE(svgascreen); @@ -418,10 +416,6 @@ svga_screen_create(struct svga_winsys_screen *sws) svgascreen->use_vs30 = svgascreen->use_ps30 = FALSE; #endif - svgascreen->swc = sws->context_create(sws); - if(!svgascreen->swc) - goto error2; - pipe_mutex_init(svgascreen->tex_mutex); pipe_mutex_init(svgascreen->swc_mutex); @@ -434,25 +428,6 @@ error1: return NULL; } -void svga_screen_flush( struct svga_screen *svgascreen, - struct pipe_fence_handle **pfence ) -{ - struct pipe_fence_handle *fence = NULL; - - SVGA_DBG(DEBUG_PERF, "%s\n", __FUNCTION__); - - pipe_mutex_lock(svgascreen->swc_mutex); - svgascreen->swc->flush(svgascreen->swc, &fence); - pipe_mutex_unlock(svgascreen->swc_mutex); - - svga_screen_cache_flush(svgascreen, fence); - - if(pfence) - *pfence = fence; - else - svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL); -} - struct svga_winsys_screen * svga_winsys_screen(struct pipe_screen *screen) { diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h index 9dc229b0a8..86ec89d88c 100644 --- a/src/gallium/drivers/svga/svga_screen.h +++ b/src/gallium/drivers/svga/svga_screen.h @@ -60,14 +60,11 @@ struct svga_screen boolean no_sampler_view; } debug; - /* The screen needs its own context */ - struct svga_winsys_context *swc; - struct SVGACmdMemory *fifo; - unsigned texture_timestamp; pipe_mutex tex_mutex; - pipe_mutex swc_mutex; /* Protects the use of swc and dirty_buffers */ - + + pipe_mutex swc_mutex; /* Used for buffer uploads */ + struct svga_host_surface_cache cache; }; @@ -83,7 +80,4 @@ struct svga_screen * svga_screen(struct pipe_screen *screen); #endif -void svga_screen_flush( struct svga_screen *svga_screen, - struct pipe_fence_handle **pfence ); - #endif /* SVGA_SCREEN_H */ diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index dc1d9a850d..bd2cc38004 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -43,7 +43,6 @@ void svga_texture_copy_handle(struct svga_context *svga, - struct svga_screen *ss, struct svga_winsys_surface *src_handle, unsigned src_x, unsigned src_y, unsigned src_z, unsigned src_level, unsigned src_face, @@ -56,7 +55,7 @@ svga_texture_copy_handle(struct svga_context *svga, enum pipe_error ret; SVGA3dCopyBox box, *boxes; - assert(svga || ss); + assert(svga); src.handle = src_handle; src.real_level = src_level; @@ -84,39 +83,20 @@ svga_texture_copy_handle(struct svga_context *svga, dst_handle, dst_level, dst_x, dst_y, dst_z); */ - if (svga) { + ret = SVGA3D_BeginSurfaceCopy(svga->swc, + &src.base, + &dst.base, + &boxes, 1); + if(ret != PIPE_OK) { + svga_context_flush(svga, NULL); ret = SVGA3D_BeginSurfaceCopy(svga->swc, &src.base, &dst.base, &boxes, 1); - if(ret != PIPE_OK) { - svga_context_flush(svga, NULL); - ret = SVGA3D_BeginSurfaceCopy(svga->swc, - &src.base, - &dst.base, - &boxes, 1); - assert(ret == PIPE_OK); - } - *boxes = box; - SVGA_FIFOCommitAll(svga->swc); - } else { - pipe_mutex_lock(ss->swc_mutex); - ret = SVGA3D_BeginSurfaceCopy(ss->swc, - &src.base, - &dst.base, - &boxes, 1); - if(ret != PIPE_OK) { - ss->swc->flush(ss->swc, NULL); - ret = SVGA3D_BeginSurfaceCopy(ss->swc, - &src.base, - &dst.base, - &boxes, 1); - assert(ret == PIPE_OK); - } - *boxes = box; - SVGA_FIFOCommitAll(ss->swc); - pipe_mutex_unlock(ss->swc_mutex); + assert(ret == PIPE_OK); } + *boxes = box; + SVGA_FIFOCommitAll(svga->swc); } @@ -183,7 +163,6 @@ svga_texture_view_surface(struct pipe_context *pipe, 1); svga_texture_copy_handle(svga_context(pipe), - ss, tex->handle, 0, 0, z_offset, i + start_mip, @@ -346,7 +325,7 @@ svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf) if (s->handle != tex->handle) { SVGA_DBG(DEBUG_VIEWS, "svga: Surface propagate: tex %p, level %u, from %p\n", tex, surf->level, surf); - svga_texture_copy_handle(svga_context(pipe), ss, + svga_texture_copy_handle(svga_context(pipe), s->handle, 0, 0, 0, s->real_level, s->real_face, tex->handle, 0, 0, surf->zslice, surf->level, surf->face, u_minify(tex->b.b.width0, surf->level), diff --git a/src/gallium/drivers/svga/svga_surface.h b/src/gallium/drivers/svga/svga_surface.h index b50ecdc994..13bd5b19b6 100644 --- a/src/gallium/drivers/svga/svga_surface.h +++ b/src/gallium/drivers/svga/svga_surface.h @@ -74,7 +74,6 @@ svga_texture_view_surface(struct pipe_context *pipe, void svga_texture_copy_handle(struct svga_context *svga, - struct svga_screen *ss, struct svga_winsys_surface *src_handle, unsigned src_x, unsigned src_y, unsigned src_z, unsigned src_level, unsigned src_face, |