X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_context.c;h=3b30b9e341ea3de8116c3e604effe4e80874049c;hb=3ed0a099c70e9d771e60e0ddf70bc0b5ba83a483;hp=af99c9de37ccb91de8795cf73fa25d919096aacd;hpb=562c127693200822f04a145db50add1be2425d7b;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index af99c9de37c..3b30b9e341e 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -26,7 +26,7 @@ #include "svga_cmd.h" #include "pipe/p_defines.h" -#include "pipe/p_inlines.h" +#include "util/u_inlines.h" #include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_bitmask.h" @@ -34,8 +34,9 @@ #include "svga_context.h" #include "svga_screen.h" -#include "svga_screen_texture.h" -#include "svga_screen_buffer.h" +#include "svga_resource_texture.h" +#include "svga_resource_buffer.h" +#include "svga_resource.h" #include "svga_winsys.h" #include "svga_swtnl.h" #include "svga_draw.h" @@ -66,67 +67,15 @@ static void svga_destroy( struct pipe_context *pipe ) util_bitmask_destroy( svga->fs_bm ); for(shader = 0; shader < PIPE_SHADER_TYPES; ++shader) - pipe_buffer_reference( &svga->curr.cb[shader], NULL ); + pipe_resource_reference( &svga->curr.cb[shader], NULL ); FREE( svga ); } -static unsigned int -svga_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - struct svga_texture *tex = svga_texture(texture); - struct svga_screen *ss = svga_screen(pipe->screen); - - /** - * The screen does not cache texture writes. - */ - - if (!tex->handle || ss->sws->surface_is_flushed(ss->sws, tex->handle)) - return PIPE_UNREFERENCED; - /** - * sws->surface_is_flushed() does not distinguish between read references - * and write references. So assume a reference is both. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - -static unsigned int -svga_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - struct svga_screen *ss = svga_screen(pipe->screen); - struct svga_buffer *sbuf = svga_buffer(buf); - - /** - * XXX: Check this. - * The screen may cache buffer writes, but when we map, we map out - * of those cached writes, so we don't need to set a - * PIPE_REFERENCED_FOR_WRITE flag for cached buffers. - */ - - if (!sbuf->handle || ss->sws->surface_is_flushed(ss->sws, sbuf->handle)) - return PIPE_UNREFERENCED; - - /** - * sws->surface_is_flushed() does not distinguish between read references - * and write references. So assume a reference is both, - * however, we make an exception for index- and vertex buffers, to avoid - * a flush in st_bufferobj_get_subdata, during display list replay. - */ - - if (sbuf->base.usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_INDEX)) - return PIPE_REFERENCED_FOR_READ; - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - - -struct pipe_context *svga_context_create( struct pipe_screen *screen ) +struct pipe_context *svga_context_create( struct pipe_screen *screen, + void *priv ) { struct svga_screen *svgascreen = svga_screen(screen); struct svga_context *svga = NULL; @@ -138,16 +87,15 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen ) svga->pipe.winsys = screen->winsys; svga->pipe.screen = screen; + svga->pipe.priv = priv; svga->pipe.destroy = svga_destroy; svga->pipe.clear = svga_clear; - svga->pipe.is_texture_referenced = svga_is_texture_referenced; - svga->pipe.is_buffer_referenced = svga_is_buffer_referenced; - svga->swc = svgascreen->sws->context_create(svgascreen->sws); if(!svga->swc) goto no_swc; + svga_init_resource_functions(svga); svga_init_blend_functions(svga); svga_init_blit_functions(svga); svga_init_depth_stencil_functions(svga); @@ -162,6 +110,7 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen ) svga_init_constbuffer_functions(svga); svga_init_query_functions(svga); + /* debug */ svga->debug.no_swtnl = debug_get_bool_option("SVGA_NO_SWTNL", FALSE); svga->debug.force_swtnl = debug_get_bool_option("SVGA_FORCE_SWTNL", FALSE); @@ -179,17 +128,17 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen ) if (svga->vs_bm == NULL) goto no_vs_bm; - svga->upload_ib = u_upload_create( svga->pipe.screen, + svga->upload_ib = u_upload_create( &svga->pipe, 32 * 1024, 16, - PIPE_BUFFER_USAGE_INDEX ); + PIPE_BIND_INDEX_BUFFER ); if (svga->upload_ib == NULL) goto no_upload_ib; - svga->upload_vb = u_upload_create( svga->pipe.screen, + svga->upload_vb = u_upload_create( &svga->pipe, 128 * 1024, 16, - PIPE_BUFFER_USAGE_VERTEX ); + PIPE_BIND_VERTEX_BUFFER ); if (svga->upload_vb == NULL) goto no_upload_vb; @@ -215,7 +164,6 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen ) svga->state.hw_draw.num_views = 0; svga->dirty = ~0; - svga->state.white_fs_id = SVGA3D_INVALID_ID; LIST_INITHEAD(&svga->dirty_buffers); @@ -246,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; @@ -254,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); } @@ -285,3 +239,8 @@ void svga_hwtnl_flush_retry( struct svga_context *svga ) assert(ret == 0); } +struct svga_winsys_context * +svga_winsys_context( struct pipe_context *pipe ) +{ + return svga_context( pipe )->swc; +}