X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_draw_elements.c;h=f0815b144ae85820ff4fe65a2dd95ad6641cc6aa;hb=725671a83a67cc8cf16c0913f6e1835fb272c2fb;hp=167d8178315657418adf70a960ea39061c022332;hpb=650e02003fbb5511ec758d993b7ec0a302ee2235;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index 167d8178315..f0815b144ae 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -23,49 +23,48 @@ * **********************************************************/ -#include "pipe/p_inlines.h" -#include "util/u_prim.h" +#include "util/u_inlines.h" #include "util/u_upload_mgr.h" #include "indices/u_indices.h" #include "svga_cmd.h" #include "svga_draw.h" #include "svga_draw_private.h" -#include "svga_screen_buffer.h" +#include "svga_resource_buffer.h" #include "svga_winsys.h" #include "svga_context.h" - #include "svga_hw_reg.h" static enum pipe_error translate_indices( struct svga_hwtnl *hwtnl, - struct pipe_buffer *src, + struct pipe_resource *src, unsigned offset, unsigned nr, unsigned index_size, u_translate_func translate, - struct pipe_buffer **out_buf ) + struct pipe_resource **out_buf ) { - struct pipe_screen *screen = hwtnl->svga->pipe.screen; + struct pipe_context *pipe = &hwtnl->svga->pipe; + struct pipe_transfer *src_transfer = NULL; + struct pipe_transfer *dst_transfer = NULL; unsigned size = index_size * nr; const void *src_map = NULL; - struct pipe_buffer *dst = NULL; + struct pipe_resource *dst = NULL; void *dst_map = NULL; - dst = screen->buffer_create( screen, 32, - PIPE_BUFFER_USAGE_INDEX | - PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_READ, - size ); + dst = pipe_buffer_create( pipe->screen, + PIPE_BIND_INDEX_BUFFER, + PIPE_USAGE_STATIC, + size ); if (dst == NULL) goto fail; - src_map = pipe_buffer_map( screen, src, PIPE_BUFFER_USAGE_CPU_READ ); + src_map = pipe_buffer_map( pipe, src, PIPE_TRANSFER_READ, &src_transfer ); if (src_map == NULL) goto fail; - dst_map = pipe_buffer_map( screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE ); + dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer ); if (dst_map == NULL) goto fail; @@ -73,21 +72,21 @@ translate_indices( struct svga_hwtnl *hwtnl, nr, dst_map ); - pipe_buffer_unmap( screen, src ); - pipe_buffer_unmap( screen, dst ); + pipe_buffer_unmap( pipe, src_transfer ); + pipe_buffer_unmap( pipe, dst_transfer ); *out_buf = dst; return PIPE_OK; fail: if (src_map) - screen->buffer_unmap( screen, src ); + pipe_buffer_unmap( pipe, src_transfer ); if (dst_map) - screen->buffer_unmap( screen, dst ); + pipe_buffer_unmap( pipe, dst_transfer ); if (dst) - screen->buffer_destroy( dst ); + pipe->screen->resource_destroy( pipe->screen, dst ); return PIPE_ERROR_OUT_OF_MEMORY; } @@ -98,38 +97,39 @@ fail: enum pipe_error svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, - struct pipe_buffer *index_buffer, + struct pipe_resource *index_buffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, - unsigned prim, + unsigned prim, unsigned start, - unsigned count, - unsigned bias ) + unsigned count ) { - struct pipe_buffer *upload_buffer = NULL; + struct pipe_resource *upload_buffer = NULL; SVGA3dPrimitiveRange range; unsigned hw_prim; unsigned hw_count; unsigned index_offset = start * index_size; - int ret = PIPE_OK; + enum pipe_error ret = PIPE_OK; hw_prim = svga_translate_prim(prim, count, &hw_count); if (hw_count == 0) goto done; - if (index_buffer && - svga_buffer_is_user_buffer(index_buffer)) + if (index_buffer && + svga_buffer_is_user_buffer(index_buffer)) { - assert( index_buffer->size >= index_offset + count * index_size ); + assert( index_buffer->width0 >= index_offset + count * index_size ); ret = u_upload_buffer( hwtnl->upload_ib, + 0, index_offset, count * index_size, index_buffer, &index_offset, - &upload_buffer ); - if (ret) + &upload_buffer); + if (ret != PIPE_OK) goto done; /* Don't need to worry about refcounting index_buffer as this is @@ -144,15 +144,15 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, range.indexArray.offset = index_offset; range.indexArray.stride = index_size; range.indexWidth = index_size; - range.indexBias = bias; - + range.indexBias = index_bias; + ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer ); - if (ret) + if (ret != PIPE_OK) goto done; done: if (upload_buffer) - pipe_buffer_reference( &upload_buffer, NULL ); + pipe_resource_reference( &upload_buffer, NULL ); return ret; } @@ -162,19 +162,19 @@ done: enum pipe_error svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, - struct pipe_buffer *index_buffer, + struct pipe_resource *index_buffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, - unsigned prim, unsigned start, unsigned count, - unsigned bias) + unsigned prim, unsigned start, unsigned count) { unsigned gen_prim, gen_size, gen_nr, gen_type; u_translate_func gen_func; enum pipe_error ret = PIPE_OK; - if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && - prim >= PIPE_PRIM_TRIANGLES) + if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && + prim >= PIPE_PRIM_TRIANGLES) { gen_type = u_unfilled_translator( prim, index_size, @@ -199,18 +199,18 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, &gen_func ); } - if (gen_type == U_TRANSLATE_MEMCPY) { - /* No need for translation, just pass through to hardware: + /* No need for translation, just pass through to hardware: */ return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer, index_size, + index_bias, min_index, max_index, - gen_prim, start, count, bias ); + gen_prim, start, count ); } else { - struct pipe_buffer *gen_buf = NULL; + struct pipe_resource *gen_buf = NULL; /* Need to allocate a new index buffer and run the translate * func to populate it. Could potentially cache this translated @@ -226,30 +226,25 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, gen_size, gen_func, &gen_buf ); - if (ret) + if (ret != PIPE_OK) goto done; ret = svga_hwtnl_simple_draw_range_elements( hwtnl, gen_buf, gen_size, + index_bias, min_index, max_index, gen_prim, 0, - gen_nr, - bias ); - if (ret) + gen_nr ); + if (ret != PIPE_OK) goto done; done: if (gen_buf) - pipe_buffer_reference( &gen_buf, NULL ); + pipe_resource_reference( &gen_buf, NULL ); return ret; } } - - - - -