X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_swtnl_draw.c;h=832249523cc1b34cfd8f55ea632af119e3a890ba;hb=6f7371619c5edcde647ae8f4822d1b5bae050ef6;hp=8b14c913f726b465b326e0dc5089a9c3f94dc4e1;hpb=8fc433fa0f8c5364454858f9be919387feda440c;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index 8b14c913f72..832249523cc 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -25,11 +25,11 @@ #include "draw/draw_context.h" #include "draw/draw_vbuf.h" -#include "pipe/p_inlines.h" +#include "util/u_inlines.h" #include "pipe/p_state.h" -#include "util/u_memory.h" #include "svga_context.h" +#include "svga_screen.h" #include "svga_swtnl.h" #include "svga_state.h" #include "svga_swtnl_private.h" @@ -37,13 +37,12 @@ enum pipe_error -svga_swtnl_draw_range_elements(struct svga_context *svga, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned min_index, - unsigned max_index, - unsigned prim, unsigned start, unsigned count) +svga_swtnl_draw_vbo(struct svga_context *svga, + const struct pipe_draw_info *info) { + struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = { 0 }; + struct pipe_transfer *ib_transfer = NULL; + struct pipe_transfer *cb_transfer = NULL; struct draw_context *draw = svga->swtnl.draw; unsigned i; const void *map; @@ -53,8 +52,11 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, assert(svga->state.sw.need_swtnl); assert(draw); + /* Make sure that the need_swtnl flag does not go away */ + svga->state.sw.in_swtnl_draw = TRUE; + ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW); - if (ret) { + if (ret != PIPE_OK) { svga_context_flush(svga, NULL); ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW); svga->swtnl.new_vbuf = TRUE; @@ -65,37 +67,40 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, * Map vertex buffers */ for (i = 0; i < svga->curr.num_vertex_buffers; i++) { - map = pipe_buffer_map(svga->pipe.screen, - svga->curr.vb[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - - draw_set_mapped_vertex_buffer(draw, i, map); + if (svga->curr.vb[i].buffer) { + map = pipe_buffer_map(&svga->pipe, + svga->curr.vb[i].buffer, + PIPE_TRANSFER_READ, + &vb_transfer[i]); + + draw_set_mapped_vertex_buffer(draw, i, map, ~0); + } } /* Map index buffer, if present */ - if (indexBuffer) { - map = pipe_buffer_map(svga->pipe.screen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); - - draw_set_mapped_element_buffer_range(draw, - indexSize, - min_index, - max_index, - map); + map = NULL; + if (info->indexed && svga->curr.ib.buffer) { + map = pipe_buffer_map(&svga->pipe, svga->curr.ib.buffer, + PIPE_TRANSFER_READ, + &ib_transfer); + draw_set_indexes(draw, + (const ubyte *) map + svga->curr.ib.offset, + svga->curr.ib.index_size, ~0); } - - if (svga->curr.cb[PIPE_SHADER_VERTEX]) { - map = pipe_buffer_map(svga->pipe.screen, - svga->curr.cb[PIPE_SHADER_VERTEX], - PIPE_BUFFER_USAGE_CPU_READ); + + if (svga->curr.cbufs[PIPE_SHADER_VERTEX].buffer) { + map = pipe_buffer_map(&svga->pipe, + svga->curr.cbufs[PIPE_SHADER_VERTEX].buffer, + PIPE_TRANSFER_READ, + &cb_transfer); assert(map); draw_set_mapped_constant_buffer( - draw, + draw, PIPE_SHADER_VERTEX, 0, map, - svga->curr.cb[PIPE_SHADER_VERTEX]->size); + svga->curr.cbufs[PIPE_SHADER_VERTEX].buffer->width0); } - draw_arrays(svga->swtnl.draw, prim, start, count); + draw_vbo(draw, info); draw_flush(svga->swtnl.draw); @@ -106,20 +111,25 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, * unmap vertex/index buffers */ for (i = 0; i < svga->curr.num_vertex_buffers; i++) { - pipe_buffer_unmap(svga->pipe.screen, svga->curr.vb[i].buffer); - draw_set_mapped_vertex_buffer(draw, i, NULL); + if (svga->curr.vb[i].buffer) { + pipe_buffer_unmap(&svga->pipe, vb_transfer[i]); + draw_set_mapped_vertex_buffer(draw, i, NULL, 0); + } } - if (indexBuffer) { - pipe_buffer_unmap(svga->pipe.screen, indexBuffer); - draw_set_mapped_element_buffer(draw, 0, NULL); + if (ib_transfer) { + pipe_buffer_unmap(&svga->pipe, ib_transfer); + draw_set_indexes(draw, NULL, 0, 0); } - if (svga->curr.cb[PIPE_SHADER_VERTEX]) { - pipe_buffer_unmap(svga->pipe.screen, - svga->curr.cb[PIPE_SHADER_VERTEX]); + if (svga->curr.cbufs[PIPE_SHADER_VERTEX].buffer) { + pipe_buffer_unmap(&svga->pipe, cb_transfer); } + /* Now safe to remove the need_swtnl flag in any update_state call */ + svga->state.sw.in_swtnl_draw = FALSE; + svga->dirty |= SVGA_NEW_NEED_PIPELINE | SVGA_NEW_NEED_SWVFETCH; + return ret; } @@ -128,6 +138,8 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, boolean svga_init_swtnl( struct svga_context *svga ) { + struct svga_screen *screen = svga_screen(svga->pipe.screen); + svga->swtnl.backend = svga_vbuf_render_create(svga); if(!svga->swtnl.backend) goto fail; @@ -135,7 +147,7 @@ boolean svga_init_swtnl( struct svga_context *svga ) /* * Create drawing context and plug our rendering stage into it. */ - svga->swtnl.draw = draw_create(); + svga->swtnl.draw = draw_create(&svga->pipe); if (svga->swtnl.draw == NULL) goto fail; @@ -145,15 +157,40 @@ boolean svga_init_swtnl( struct svga_context *svga ) draw_set_render(svga->swtnl.draw, svga->swtnl.backend); - draw_install_aaline_stage(svga->swtnl.draw, &svga->pipe); - draw_install_aapoint_stage(svga->swtnl.draw, &svga->pipe); + svga->blitter = util_blitter_create(&svga->pipe); + if (!svga->blitter) + goto fail; + + /* must be done before installing Draw stages */ + util_blitter_cache_all_shaders(svga->blitter); + + if (!screen->haveLineSmooth) + draw_install_aaline_stage(svga->swtnl.draw, &svga->pipe); + + /* always install polygon stipple stage */ draw_install_pstipple_stage(svga->swtnl.draw, &svga->pipe); - draw_set_driver_clipping(svga->swtnl.draw, debug_get_bool_option("SVGA_SWTNL_FSE", FALSE)); + /* enable/disable line stipple stage depending on device caps */ + draw_enable_line_stipple(svga->swtnl.draw, !screen->haveLineStipple); + + /* always install AA point stage */ + draw_install_aapoint_stage(svga->swtnl.draw, &svga->pipe); + + /* Set wide line threshold above device limit (so we'll never really use it) + */ + draw_wide_line_threshold(svga->swtnl.draw, + MAX2(screen->maxLineWidth, + screen->maxLineWidthAA)); + + if (debug_get_bool_option("SVGA_SWTNL_FSE", FALSE)) + draw_set_driver_clipping(svga->swtnl.draw, TRUE, TRUE, TRUE, FALSE); return TRUE; fail: + if (svga->blitter) + util_blitter_destroy(svga->blitter); + if (svga->swtnl.backend) svga->swtnl.backend->destroy( svga->swtnl.backend );