diff options
Diffstat (limited to 'src/gallium/drivers/svga')
-rw-r--r-- | src/gallium/drivers/svga/svga_context.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_draw_arrays.c | 5 | ||||
-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_host.c | 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 | 27 | ||||
-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 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_winsys.h | 13 |
14 files changed, 73 insertions, 118 deletions
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 3228a6d3d7f..75d8afb2ea8 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_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index 005996d05d3..da33fae62f1 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -277,12 +277,13 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, ret = svga_hwtnl_simple_draw_range_elements( hwtnl, gen_buf, gen_size, + start, 0, count - 1, gen_prim, 0, - gen_nr, - start ); + gen_nr ); + if (ret) goto done; diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 9c6f5858ba4..96fb4b8e536 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 18eeff9c67e..198d4013328 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 55e7321184f..d3ec11bfd52 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_host.c b/src/gallium/drivers/svga/svga_resource_buffer_host.c deleted file mode 100644 index 139597f9cb0..00000000000 --- a/src/gallium/drivers/svga/svga_resource_buffer_host.c +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index acef60f4647..3de5216a949 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 f06b0323d8c..ff83c750aaf 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 fbae552f78f..6911f13f778 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 aeda3dcad51..27ac09e275d 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -34,6 +34,7 @@ #include "svga_resource_texture.h" #include "svga_resource.h" #include "svga_debug.h" +#include "svga_surface.h" #include "svga3d_shaderdefs.h" @@ -346,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); @@ -397,6 +396,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_finish = svga_fence_finish; svgascreen->sws = sws; + svga_screen_init_surface_functions(screen); svga_init_screen_resource_functions(svgascreen); svgascreen->use_ps30 = @@ -416,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); @@ -432,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 9dc229b0a87..86ec89d88c1 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 dc1d9a850df..bd2cc380048 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 b50ecdc9942..13bd5b19b61 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, diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index 3892addafd1..c155f5dae2f 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -85,7 +85,7 @@ struct svga_winsys_context /** * Emit a relocation for a host surface. * - * @param flags PIPE_BUFFER_USAGE_GPU_READ/WRITE + * @param flags bitmask of SVGA_RELOC_* flags * * NOTE: Order of this call does matter. It should be the same order * as relocations appear in the command buffer. @@ -99,7 +99,7 @@ struct svga_winsys_context /** * Emit a relocation for a guest memory region. * - * @param flags PIPE_BUFFER_USAGE_GPU_READ/WRITE + * @param flags bitmask of SVGA_RELOC_* flags * * NOTE: Order of this call does matter. It should be the same order * as relocations appear in the command buffer. @@ -230,7 +230,7 @@ struct svga_winsys_screen /** * Buffer management. Buffer attributes are mostly fixed over its lifetime. * - * XXX usage seems to be a bitmask of SVGA_BUFFER_USAGE_* flags. + * @param usage bitmask of SVGA_BUFFER_USAGE_* flags. * * alignment indicates the client's alignment requirements, eg for * SSE instructions. @@ -243,15 +243,12 @@ struct svga_winsys_screen /** * Map the entire data store of a buffer object into the client's address. - * flags is a bitmask of: - * - PB_USAGE_CPU_READ/WRITE - * - PB_USAGE_DONTBLOCK - * - PB_USAGE_UNSYNCHRONIZED + * flags is a bitmaks of PIPE_TRANSFER_* */ void * (*buffer_map)( struct svga_winsys_screen *sws, struct svga_winsys_buffer *buf, - unsigned usage ); + unsigned flags ); void (*buffer_unmap)( struct svga_winsys_screen *sws, |