diff options
Diffstat (limited to 'src/gallium/drivers/svga')
-rw-r--r-- | src/gallium/drivers/svga/svga_draw_arrays.c | 54 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_draw_elements.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_pipe_draw.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_need_swtnl.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_vdecl.c | 14 |
5 files changed, 52 insertions, 93 deletions
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index 0ae0777e901..a506371c599 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -37,8 +37,6 @@ #define DBG 0 - - static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl, unsigned nr, unsigned index_size, @@ -51,8 +49,8 @@ static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl, struct pipe_resource *dst = NULL; void *dst_map = NULL; - dst = pipe_buffer_create( pipe->screen, - PIPE_BIND_INDEX_BUFFER, + dst = pipe_buffer_create( pipe->screen, + PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STATIC, size ); if (dst == NULL) @@ -77,10 +75,11 @@ fail: if (dst) pipe->screen->resource_destroy( pipe->screen, dst ); - + return PIPE_ERROR_OUT_OF_MEMORY; } + static boolean compare( unsigned cached_nr, unsigned nr, unsigned type ) @@ -91,6 +90,7 @@ static boolean compare( unsigned cached_nr, return cached_nr == nr; } + static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, unsigned prim, unsigned gen_type, @@ -111,18 +111,18 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, pipe_resource_reference( out_buf, hwtnl->index_cache[prim][i].buffer ); - if (DBG) + if (DBG) debug_printf("%s retrieve %d/%d\n", __FUNCTION__, i, gen_nr); return PIPE_OK; } - else if (gen_type == U_GENERATE_REUSABLE) + else if (gen_type == U_GENERATE_REUSABLE) { pipe_resource_reference( &hwtnl->index_cache[prim][i].buffer, NULL ); - if (DBG) - debug_printf("%s discard %d/%d\n", __FUNCTION__, + if (DBG) + debug_printf("%s discard %d/%d\n", __FUNCTION__, i, hwtnl->index_cache[prim][i].gen_nr); break; @@ -134,7 +134,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, { unsigned smallest = 0; unsigned smallest_size = ~0; - + for (i = 0; i < IDX_CACHE_MAX && smallest_size; i++) { if (hwtnl->index_cache[prim][i].buffer == NULL) { @@ -154,14 +154,13 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, NULL ); if (DBG) - debug_printf("%s discard smallest %d/%d\n", __FUNCTION__, + debug_printf("%s discard smallest %d/%d\n", __FUNCTION__, smallest, smallest_size); - + i = smallest; } - - - ret = generate_indices( hwtnl, + + ret = generate_indices( hwtnl, gen_nr, gen_size, generate, @@ -176,7 +175,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, *out_buf ); if (DBG) - debug_printf("%s cache %d/%d\n", __FUNCTION__, + debug_printf("%s cache %d/%d\n", __FUNCTION__, i, hwtnl->index_cache[prim][i].gen_nr); return PIPE_OK; @@ -195,7 +194,7 @@ simple_draw_arrays( struct svga_hwtnl *hwtnl, hw_prim = svga_translate_prim(prim, count, &hw_count); if (hw_count == 0) return PIPE_ERROR_BAD_INPUT; - + range.primType = hw_prim; range.primitiveCount = hw_count; range.indexArray.surfaceId = SVGA3D_INVALID_ID; @@ -213,26 +212,18 @@ simple_draw_arrays( struct svga_hwtnl *hwtnl, } - - - - - - - - -enum pipe_error +enum pipe_error svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, - unsigned prim, - unsigned start, + unsigned prim, + unsigned start, unsigned count) { unsigned gen_prim, gen_size, gen_nr, gen_type; u_generate_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_generator( prim, start, @@ -262,7 +253,7 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, else { struct pipe_resource *gen_buf = NULL; - /* Need to draw as indexed primitive. + /* Need to draw as indexed primitive. * Potentially need to run the gen func to build an index buffer. */ ret = retrieve_or_generate_indices( hwtnl, @@ -295,4 +286,3 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, return ret; } } - diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index 1c20881a34d..f0815b144ae 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -33,7 +33,6 @@ #include "svga_resource_buffer.h" #include "svga_winsys.h" #include "svga_context.h" - #include "svga_hw_reg.h" @@ -54,8 +53,8 @@ translate_indices( struct svga_hwtnl *hwtnl, struct pipe_resource *dst = NULL; void *dst_map = NULL; - dst = pipe_buffer_create( pipe->screen, - PIPE_BIND_INDEX_BUFFER, + dst = pipe_buffer_create( pipe->screen, + PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STATIC, size ); if (dst == NULL) @@ -103,7 +102,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, int index_bias, unsigned min_index, unsigned max_index, - unsigned prim, + unsigned prim, unsigned start, unsigned count ) { @@ -118,8 +117,8 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, 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->width0 >= index_offset + count * index_size ); @@ -146,7 +145,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, range.indexArray.stride = index_size; range.indexWidth = index_size; range.indexBias = index_bias; - + ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer ); if (ret != PIPE_OK) goto done; @@ -174,8 +173,8 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, 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, @@ -200,9 +199,8 @@ 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, @@ -250,8 +248,3 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, return ret; } } - - - - - diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c index 280c431d609..e72032e685d 100644 --- a/src/gallium/drivers/svga/svga_pipe_draw.c +++ b/src/gallium/drivers/svga/svga_pipe_draw.c @@ -23,15 +23,16 @@ * **********************************************************/ -#include "svga_cmd.h" #include "util/u_format.h" #include "util/u_inlines.h" #include "util/u_prim.h" #include "util/u_time.h" +#include "util/u_upload_mgr.h" #include "indices/u_indices.h" #include "svga_hw_reg.h" +#include "svga_cmd.h" #include "svga_context.h" #include "svga_screen.h" #include "svga_draw.h" @@ -39,7 +40,7 @@ #include "svga_swtnl.h" #include "svga_debug.h" #include "svga_resource_buffer.h" -#include "util/u_upload_mgr.h" + /** * Determine the ranges to upload for the user-buffers referenced @@ -51,7 +52,6 @@ * may be uploaded to different hardware buffers chosen by the utility * upload manager. */ - static void svga_user_buffer_range(struct svga_context *svga, unsigned start, @@ -106,13 +106,13 @@ svga_user_buffer_range(struct svga_context *svga, } } + /** * svga_upload_user_buffers - upload parts of user buffers * * This function streams a part of a user buffer to hw and fills * svga_buffer::uploaded with information on the upload. */ - static int svga_upload_user_buffers(struct svga_context *svga, unsigned start, @@ -168,6 +168,7 @@ svga_upload_user_buffers(struct svga_context *svga, return PIPE_OK; } + /** * svga_release_user_upl_buffers - release uploaded parts of user buffers * @@ -179,7 +180,6 @@ svga_upload_user_buffers(struct svga_context *svga, * svga_buffer::source_offset is set to 0, and svga_buffer::uploaded::buffer * is set to 0. */ - static void svga_release_user_upl_buffers(struct svga_context *svga) { @@ -222,8 +222,8 @@ retry_draw_range_elements( struct svga_context *svga, int index_bias, unsigned min_index, unsigned max_index, - unsigned prim, - unsigned start, + unsigned prim, + unsigned start, unsigned count, unsigned instance_count, boolean do_retry ) @@ -273,8 +273,8 @@ retry: static enum pipe_error retry_draw_arrays( struct svga_context *svga, - unsigned prim, - unsigned start, + unsigned prim, + unsigned start, unsigned count, unsigned instance_count, boolean do_retry ) @@ -305,7 +305,7 @@ retry_draw_arrays( struct svga_context *svga, return PIPE_OK; retry: - if (ret == PIPE_ERROR_OUT_OF_MEMORY && do_retry) + if (ret == PIPE_ERROR_OUT_OF_MEMORY && do_retry) { svga_context_flush( svga, NULL ); @@ -346,7 +346,7 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) svga->curr.reduced_prim = reduced_prim; svga->dirty |= SVGA_NEW_REDUCED_PRIMITIVE; } - + needed_swtnl = svga->state.sw.need_swtnl; svga_update_state_retry( svga, SVGA_STATE_NEED_SWTNL ); diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index 704866861b1..38ed77cfff0 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -25,22 +25,17 @@ #include "util/u_inlines.h" #include "pipe/p_state.h" - - #include "svga_context.h" #include "svga_state.h" #include "svga_debug.h" #include "svga_hw_reg.h" -/*********************************************************************** - */ - /** * Given a gallium vertex element format, return the corresponding SVGA3D * format. Return SVGA3D_DECLTYPE_MAX for unsupported gallium formats. */ -static INLINE SVGA3dDeclType +static INLINE SVGA3dDeclType svga_translate_vertex_format(enum pipe_format format) { switch (format) { @@ -72,8 +67,7 @@ svga_translate_vertex_format(enum pipe_format format) static enum pipe_error -update_need_swvfetch( struct svga_context *svga, - unsigned dirty ) +update_need_swvfetch(struct svga_context *svga, unsigned dirty) { unsigned i; boolean need_swvfetch = FALSE; @@ -96,11 +90,11 @@ update_need_swvfetch( struct svga_context *svga, svga->state.sw.need_swvfetch = need_swvfetch; svga->dirty |= SVGA_NEW_NEED_SWVFETCH; } - + return PIPE_OK; } -struct svga_tracked_state svga_update_need_swvfetch = +struct svga_tracked_state svga_update_need_swvfetch = { "update need_swvfetch", ( SVGA_NEW_VELEMENT ), @@ -108,14 +102,10 @@ struct svga_tracked_state svga_update_need_swvfetch = }; -/*********************************************************************** - */ static enum pipe_error -update_need_pipeline( struct svga_context *svga, - unsigned dirty ) +update_need_pipeline(struct svga_context *svga, unsigned dirty) { - boolean need_pipeline = FALSE; struct svga_vertex_shader *vs = svga->curr.vs; @@ -176,7 +166,7 @@ update_need_pipeline( struct svga_context *svga, } -struct svga_tracked_state svga_update_need_pipeline = +struct svga_tracked_state svga_update_need_pipeline = { "need pipeline", (SVGA_NEW_RAST | @@ -187,12 +177,8 @@ struct svga_tracked_state svga_update_need_pipeline = }; -/*********************************************************************** - */ - static enum pipe_error -update_need_swtnl( struct svga_context *svga, - unsigned dirty ) +update_need_swtnl(struct svga_context *svga, unsigned dirty) { boolean need_swtnl; @@ -227,7 +213,7 @@ update_need_swtnl( struct svga_context *svga, svga->dirty |= SVGA_NEW_NEED_SWTNL; svga->swtnl.new_vdecl = TRUE; } - + return PIPE_OK; } diff --git a/src/gallium/drivers/svga/svga_state_vdecl.c b/src/gallium/drivers/svga/svga_state_vdecl.c index 706d9959ca0..557f304d23e 100644 --- a/src/gallium/drivers/svga/svga_state_vdecl.c +++ b/src/gallium/drivers/svga/svga_state_vdecl.c @@ -34,13 +34,9 @@ #include "svga_tgsi.h" #include "svga_screen.h" #include "svga_resource_buffer.h" - #include "svga_hw_reg.h" -/*********************************************************************** - */ - static enum pipe_error emit_hw_vs_vdecl(struct svga_context *svga, unsigned dirty) @@ -53,7 +49,7 @@ emit_hw_vs_vdecl(struct svga_context *svga, unsigned dirty) assert(svga->curr.velems->count >= svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]); - svga_hwtnl_reset_vdecl( svga->hwtnl, + svga_hwtnl_reset_vdecl( svga->hwtnl, svga->curr.velems->count ); /** @@ -144,7 +140,7 @@ emit_hw_vdecl(struct svga_context *svga, unsigned dirty) } -struct svga_tracked_state svga_hw_vdecl = +struct svga_tracked_state svga_hw_vdecl = { "hw vertex decl state (hwtnl version)", ( SVGA_NEW_NEED_SWTNL | @@ -155,9 +151,3 @@ struct svga_tracked_state svga_hw_vdecl = SVGA_NEW_VS ), emit_hw_vdecl }; - - - - - - |