diff options
author | Brian Paul <[email protected]> | 2013-10-28 09:43:08 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-10-29 08:09:34 -0600 |
commit | ea9fe9ebdbc37648af099848531ce301580fdeec (patch) | |
tree | 831bde94e385b963ba977fffc1af665c8508c3ef /src/gallium/drivers/svga | |
parent | 415d6dc5bd6915b0c17a1df0f9bd0ef4ca534a81 (diff) |
svga: reindent drawing code
Diffstat (limited to 'src/gallium/drivers/svga')
-rw-r--r-- | src/gallium/drivers/svga/svga_draw.c | 142 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_draw_arrays.c | 171 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_draw_elements.c | 152 |
3 files changed, 199 insertions, 266 deletions
diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c index a380334e900..5e46a2f11e8 100644 --- a/src/gallium/drivers/svga/svga_draw.c +++ b/src/gallium/drivers/svga/svga_draw.c @@ -50,7 +50,7 @@ svga_hwtnl_create(struct svga_context *svga) goto fail; hwtnl->svga = svga; - + hwtnl->cmd.swc = svga->swc; return hwtnl; @@ -59,14 +59,15 @@ fail: return NULL; } -void svga_hwtnl_destroy( struct svga_hwtnl *hwtnl ) + +void +svga_hwtnl_destroy(struct svga_hwtnl *hwtnl) { unsigned i, j; for (i = 0; i < PIPE_PRIM_MAX; i++) { for (j = 0; j < IDX_CACHE_MAX; j++) { - pipe_resource_reference( &hwtnl->index_cache[i][j].buffer, - NULL ); + pipe_resource_reference(&hwtnl->index_cache[i][j].buffer, NULL); } } @@ -75,54 +76,54 @@ void svga_hwtnl_destroy( struct svga_hwtnl *hwtnl ) for (i = 0; i < hwtnl->cmd.prim_count; i++) pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL); - FREE(hwtnl); } -void svga_hwtnl_set_flatshade( struct svga_hwtnl *hwtnl, - boolean flatshade, - boolean flatshade_first ) +void +svga_hwtnl_set_flatshade(struct svga_hwtnl *hwtnl, + boolean flatshade, boolean flatshade_first) { hwtnl->hw_pv = PV_FIRST; hwtnl->api_pv = (flatshade && !flatshade_first) ? PV_LAST : PV_FIRST; -} +} + -void svga_hwtnl_set_unfilled( struct svga_hwtnl *hwtnl, - unsigned mode ) +void +svga_hwtnl_set_unfilled(struct svga_hwtnl *hwtnl, unsigned mode) { hwtnl->api_fillmode = mode; -} +} + -void svga_hwtnl_reset_vdecl( struct svga_hwtnl *hwtnl, - unsigned count ) +void +svga_hwtnl_reset_vdecl(struct svga_hwtnl *hwtnl, unsigned count) { unsigned i; assert(hwtnl->cmd.prim_count == 0); for (i = count; i < hwtnl->cmd.vdecl_count; i++) { - pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i], - NULL); + pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i], NULL); } hwtnl->cmd.vdecl_count = count; } -void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl, - unsigned i, - const SVGA3dVertexDecl *decl, - struct pipe_resource *vb) +void +svga_hwtnl_vdecl(struct svga_hwtnl *hwtnl, + unsigned i, + const SVGA3dVertexDecl * decl, struct pipe_resource *vb) { assert(hwtnl->cmd.prim_count == 0); - assert( i < hwtnl->cmd.vdecl_count ); + assert(i < hwtnl->cmd.vdecl_count); hwtnl->cmd.vdecl[i] = *decl; - pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i], vb); + pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i], vb); } @@ -131,8 +132,8 @@ void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl, * for which no commands have been written yet. */ boolean -svga_hwtnl_is_buffer_referred( struct svga_hwtnl *hwtnl, - struct pipe_resource *buffer) +svga_hwtnl_is_buffer_referred(struct svga_hwtnl *hwtnl, + struct pipe_resource *buffer) { unsigned i; @@ -161,7 +162,7 @@ svga_hwtnl_is_buffer_referred( struct svga_hwtnl *hwtnl, enum pipe_error -svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) +svga_hwtnl_flush(struct svga_hwtnl *hwtnl) { struct svga_winsys_context *swc = hwtnl->cmd.swc; struct svga_context *svga = hwtnl->svga; @@ -191,8 +192,9 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) if (handle == NULL) return PIPE_ERROR_OUT_OF_MEMORY; } - else + else { handle = NULL; + } ib_handle[i] = handle; } @@ -216,18 +218,13 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) svga_surface(svga->curr.framebuffer.cbufs[0])->handle : NULL, hwtnl->cmd.prim_count); - ret = SVGA3D_BeginDrawPrimitives(swc, - &vdecl, - hwtnl->cmd.vdecl_count, - &prim, - hwtnl->cmd.prim_count); - if (ret != PIPE_OK) + ret = SVGA3D_BeginDrawPrimitives(swc, &vdecl, hwtnl->cmd.vdecl_count, + &prim, hwtnl->cmd.prim_count); + if (ret != PIPE_OK) return ret; - - memcpy( vdecl, - hwtnl->cmd.vdecl, - hwtnl->cmd.vdecl_count * sizeof hwtnl->cmd.vdecl[0]); + memcpy(vdecl, hwtnl->cmd.vdecl, + hwtnl->cmd.vdecl_count * sizeof hwtnl->cmd.vdecl[0]); for (i = 0; i < hwtnl->cmd.vdecl_count; i++) { /* Given rangeHint is considered to be relative to indexBias, and @@ -243,25 +240,20 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) vdecl[i].rangeHint.last = 0; } - swc->surface_relocation(swc, - &vdecl[i].array.surfaceId, - vb_handle[i], - SVGA_RELOC_READ); + swc->surface_relocation(swc, &vdecl[i].array.surfaceId, + vb_handle[i], SVGA_RELOC_READ); } - memcpy( prim, - hwtnl->cmd.prim, - hwtnl->cmd.prim_count * sizeof hwtnl->cmd.prim[0]); + memcpy(prim, hwtnl->cmd.prim, + hwtnl->cmd.prim_count * sizeof hwtnl->cmd.prim[0]); for (i = 0; i < hwtnl->cmd.prim_count; i++) { - swc->surface_relocation(swc, - &prim[i].indexArray.surfaceId, - ib_handle[i], - SVGA_RELOC_READ); + swc->surface_relocation(swc, &prim[i].indexArray.surfaceId, + ib_handle[i], SVGA_RELOC_READ); pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL); } - - SVGA_FIFOCommitAll( swc ); + + SVGA_FIFOCommitAll(swc); hwtnl->cmd.prim_count = 0; } @@ -269,8 +261,8 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) } -void svga_hwtnl_set_index_bias( struct svga_hwtnl *hwtnl, - int index_bias) +void +svga_hwtnl_set_index_bias(struct svga_hwtnl *hwtnl, int index_bias) { hwtnl->index_bias = index_bias; } @@ -281,11 +273,11 @@ void svga_hwtnl_set_index_bias( struct svga_hwtnl *hwtnl, * Internal functions: */ -enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, - const SVGA3dPrimitiveRange *range, - unsigned min_index, - unsigned max_index, - struct pipe_resource *ib ) +enum pipe_error +svga_hwtnl_prim(struct svga_hwtnl *hwtnl, + const SVGA3dPrimitiveRange * range, + unsigned min_index, + unsigned max_index, struct pipe_resource *ib) { enum pipe_error ret = PIPE_OK; @@ -310,40 +302,40 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, width = 4; break; case SVGA3D_DECLTYPE_FLOAT2: - width = 4*2; + width = 4 * 2; break; case SVGA3D_DECLTYPE_FLOAT3: - width = 4*3; + width = 4 * 3; break; case SVGA3D_DECLTYPE_FLOAT4: - width = 4*4; + width = 4 * 4; break; case SVGA3D_DECLTYPE_D3DCOLOR: width = 4; break; case SVGA3D_DECLTYPE_UBYTE4: - width = 1*4; + width = 1 * 4; break; case SVGA3D_DECLTYPE_SHORT2: - width = 2*2; + width = 2 * 2; break; case SVGA3D_DECLTYPE_SHORT4: - width = 2*4; + width = 2 * 4; break; case SVGA3D_DECLTYPE_UBYTE4N: - width = 1*4; + width = 1 * 4; break; case SVGA3D_DECLTYPE_SHORT2N: - width = 2*2; + width = 2 * 2; break; case SVGA3D_DECLTYPE_SHORT4N: - width = 2*4; + width = 2 * 4; break; case SVGA3D_DECLTYPE_USHORT2N: - width = 2*2; + width = 2 * 2; break; case SVGA3D_DECLTYPE_USHORT4N: - width = 2*4; + width = 2 * 4; break; case SVGA3D_DECLTYPE_UDEC3: width = 4; @@ -352,10 +344,10 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, width = 4; break; case SVGA3D_DECLTYPE_FLOAT16_2: - width = 2*2; + width = 2 * 2; break; case SVGA3D_DECLTYPE_FLOAT16_4: - width = 2*4; + width = 2 * 4; break; default: assert(0); @@ -364,7 +356,7 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, } if (index_bias >= 0) { - assert(offset + index_bias*stride + width <= size); + assert(offset + index_bias * stride + width <= size); } /* @@ -375,7 +367,7 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, assert(range->indexWidth == range->indexArray.stride); - if(ib) { + if (ib) { unsigned size = ib->width0; unsigned offset = range->indexArray.offset; unsigned stride = range->indexArray.stride; @@ -410,17 +402,17 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, break; } - assert(offset + count*stride <= size); + assert(offset + count * stride <= size); } } #endif - if (hwtnl->cmd.prim_count+1 >= QSZ) { - ret = svga_hwtnl_flush( hwtnl ); + if (hwtnl->cmd.prim_count + 1 >= QSZ) { + ret = svga_hwtnl_flush(hwtnl); if (ret != PIPE_OK) return ret; } - + /* min/max indices are relative to bias */ hwtnl->cmd.min_index[hwtnl->cmd.prim_count] = min_index; hwtnl->cmd.max_index[hwtnl->cmd.prim_count] = max_index; diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index 7adefd0c38c..5f03483390f 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -37,11 +37,11 @@ #define DBG 0 -static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl, - unsigned nr, - unsigned index_size, - u_generate_func generate, - struct pipe_resource **out_buf ) +static enum pipe_error +generate_indices(struct svga_hwtnl *hwtnl, + unsigned nr, + unsigned index_size, + u_generate_func generate, struct pipe_resource **out_buf) { struct pipe_context *pipe = &hwtnl->svga->pipe; struct pipe_transfer *transfer; @@ -49,40 +49,35 @@ 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, - PIPE_USAGE_STATIC, - size ); + dst = pipe_buffer_create(pipe->screen, + PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STATIC, size); if (dst == NULL) goto fail; - dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, - &transfer); + dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &transfer); if (dst_map == NULL) goto fail; - generate( nr, - dst_map ); + generate(nr, dst_map); - pipe_buffer_unmap( pipe, transfer ); + pipe_buffer_unmap(pipe, transfer); *out_buf = dst; return PIPE_OK; fail: if (dst_map) - pipe_buffer_unmap( pipe, transfer ); + pipe_buffer_unmap(pipe, transfer); if (dst) - pipe->screen->resource_destroy( pipe->screen, dst ); + pipe->screen->resource_destroy(pipe->screen, dst); return PIPE_ERROR_OUT_OF_MEMORY; } -static boolean compare( unsigned cached_nr, - unsigned nr, - unsigned type ) +static boolean +compare(unsigned cached_nr, unsigned nr, unsigned type) { if (type == U_GENERATE_REUSABLE) return cached_nr >= nr; @@ -91,35 +86,33 @@ static boolean compare( unsigned cached_nr, } -static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, - unsigned prim, - unsigned gen_type, - unsigned gen_nr, - unsigned gen_size, - u_generate_func generate, - struct pipe_resource **out_buf ) +static enum pipe_error +retrieve_or_generate_indices(struct svga_hwtnl *hwtnl, + unsigned prim, + unsigned gen_type, + unsigned gen_nr, + unsigned gen_size, + u_generate_func generate, + struct pipe_resource **out_buf) { enum pipe_error ret = PIPE_OK; int i; for (i = 0; i < IDX_CACHE_MAX; i++) { if (hwtnl->index_cache[prim][i].buffer != NULL && - hwtnl->index_cache[prim][i].generate == generate) - { - if (compare(hwtnl->index_cache[prim][i].gen_nr, gen_nr, gen_type)) - { - pipe_resource_reference( out_buf, - hwtnl->index_cache[prim][i].buffer ); + hwtnl->index_cache[prim][i].generate == generate) { + if (compare(hwtnl->index_cache[prim][i].gen_nr, gen_nr, gen_type)) { + pipe_resource_reference(out_buf, + hwtnl->index_cache[prim][i].buffer); if (DBG) debug_printf("%s retrieve %d/%d\n", __FUNCTION__, i, gen_nr); return PIPE_OK; } - else if (gen_type == U_GENERATE_REUSABLE) - { - pipe_resource_reference( &hwtnl->index_cache[prim][i].buffer, - NULL ); + 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__, @@ -130,28 +123,25 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, } } - if (i == IDX_CACHE_MAX) - { + if (i == IDX_CACHE_MAX) { 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) - { + if (hwtnl->index_cache[prim][i].buffer == NULL) { smallest = i; smallest_size = 0; } - else if (hwtnl->index_cache[prim][i].gen_nr < smallest) - { + else if (hwtnl->index_cache[prim][i].gen_nr < smallest) { smallest = i; smallest_size = hwtnl->index_cache[prim][i].gen_nr; } } - assert (smallest != IDX_CACHE_MAX); + assert(smallest != IDX_CACHE_MAX); - pipe_resource_reference( &hwtnl->index_cache[prim][smallest].buffer, - NULL ); + pipe_resource_reference(&hwtnl->index_cache[prim][smallest].buffer, + NULL); if (DBG) debug_printf("%s discard smallest %d/%d\n", __FUNCTION__, @@ -160,19 +150,13 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, i = smallest; } - ret = generate_indices( hwtnl, - gen_nr, - gen_size, - generate, - out_buf ); + ret = generate_indices(hwtnl, gen_nr, gen_size, generate, out_buf); if (ret != PIPE_OK) return ret; - hwtnl->index_cache[prim][i].generate = generate; hwtnl->index_cache[prim][i].gen_nr = gen_nr; - pipe_resource_reference( &hwtnl->index_cache[prim][i].buffer, - *out_buf ); + pipe_resource_reference(&hwtnl->index_cache[prim][i].buffer, *out_buf); if (DBG) debug_printf("%s cache %d/%d\n", __FUNCTION__, @@ -182,10 +166,9 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl, } - static enum pipe_error -simple_draw_arrays( struct svga_hwtnl *hwtnl, - unsigned prim, unsigned start, unsigned count ) +simple_draw_arrays(struct svga_hwtnl *hwtnl, + unsigned prim, unsigned start, unsigned count) { SVGA3dPrimitiveRange range; unsigned hw_prim; @@ -208,52 +191,44 @@ simple_draw_arrays( struct svga_hwtnl *hwtnl, * looking at those numbers knows to adjust them by * range.indexBias. */ - return svga_hwtnl_prim( hwtnl, &range, 0, count - 1, NULL ); + return svga_hwtnl_prim(hwtnl, &range, 0, count - 1, NULL); } enum pipe_error -svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, - unsigned prim, - unsigned start, - unsigned count) +svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl, + 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) - { + prim >= PIPE_PRIM_TRIANGLES) { /* Convert unfilled polygons into points, lines, triangles */ - gen_type = u_unfilled_generator( prim, - start, - count, - hwtnl->api_fillmode, - &gen_prim, - &gen_size, - &gen_nr, - &gen_func ); + gen_type = u_unfilled_generator(prim, + start, + count, + hwtnl->api_fillmode, + &gen_prim, + &gen_size, &gen_nr, &gen_func); } else { /* Convert PIPE_PRIM_LINE_LOOP to PIPE_PRIM_LINESTRIP, * convert PIPE_PRIM_POLYGON to PIPE_PRIM_TRIANGLE_FAN, * etc, if needed (as determined by svga_hw_prims mask). */ - gen_type = u_index_generator( svga_hw_prims, - prim, - start, - count, - hwtnl->api_pv, - hwtnl->hw_pv, - &gen_prim, - &gen_size, - &gen_nr, - &gen_func ); + gen_type = u_index_generator(svga_hw_prims, + prim, + start, + count, + hwtnl->api_pv, + hwtnl->hw_pv, + &gen_prim, &gen_size, &gen_nr, &gen_func); } if (gen_type == U_GENERATE_LINEAR) { - return simple_draw_arrays( hwtnl, gen_prim, start, count ); + return simple_draw_arrays(hwtnl, gen_prim, start, count); } else { struct pipe_resource *gen_buf = NULL; @@ -261,32 +236,28 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, /* Need to draw as indexed primitive. * Potentially need to run the gen func to build an index buffer. */ - ret = retrieve_or_generate_indices( hwtnl, - prim, - gen_type, - gen_nr, - gen_size, - gen_func, - &gen_buf ); + ret = retrieve_or_generate_indices(hwtnl, + prim, + gen_type, + gen_nr, + gen_size, gen_func, &gen_buf); if (ret != PIPE_OK) goto done; - ret = svga_hwtnl_simple_draw_range_elements( hwtnl, - gen_buf, - gen_size, - start, - 0, - count - 1, - gen_prim, - 0, - gen_nr ); + ret = svga_hwtnl_simple_draw_range_elements(hwtnl, + gen_buf, + gen_size, + start, + 0, + count - 1, + gen_prim, 0, gen_nr); if (ret != PIPE_OK) goto done; - done: +done: if (gen_buf) - pipe_resource_reference( &gen_buf, NULL ); + pipe_resource_reference(&gen_buf, NULL); return ret; } diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index c52ca2d91ec..b68dad0c3bb 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -36,13 +36,9 @@ static enum pipe_error -translate_indices( struct svga_hwtnl *hwtnl, - struct pipe_resource *src, - unsigned offset, - unsigned nr, - unsigned index_size, - u_translate_func translate, - struct pipe_resource **out_buf ) +translate_indices(struct svga_hwtnl *hwtnl, struct pipe_resource *src, + unsigned offset, unsigned nr, unsigned index_size, + u_translate_func translate, struct pipe_resource **out_buf) { struct pipe_context *pipe = &hwtnl->svga->pipe; struct pipe_transfer *src_transfer = NULL; @@ -52,58 +48,48 @@ 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, - PIPE_USAGE_STATIC, - 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( pipe, src, PIPE_TRANSFER_READ, &src_transfer ); + src_map = pipe_buffer_map(pipe, src, PIPE_TRANSFER_READ, &src_transfer); if (src_map == NULL) goto fail; - dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer ); + dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer); if (dst_map == NULL) goto fail; - translate( (const char *)src_map + offset, - nr, - dst_map ); + translate((const char *) src_map + offset, nr, dst_map); - pipe_buffer_unmap( pipe, src_transfer ); - pipe_buffer_unmap( pipe, dst_transfer ); + pipe_buffer_unmap(pipe, src_transfer); + pipe_buffer_unmap(pipe, dst_transfer); *out_buf = dst; return PIPE_OK; -fail: + fail: if (src_map) - pipe_buffer_unmap( pipe, src_transfer ); + pipe_buffer_unmap(pipe, src_transfer); if (dst_map) - pipe_buffer_unmap( pipe, dst_transfer ); + pipe_buffer_unmap(pipe, dst_transfer); if (dst) - pipe->screen->resource_destroy( pipe->screen, dst ); + pipe->screen->resource_destroy(pipe->screen, dst); return PIPE_ERROR_OUT_OF_MEMORY; } - - - enum pipe_error -svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, - struct pipe_resource *index_buffer, - unsigned index_size, - int index_bias, - unsigned min_index, - unsigned max_index, - unsigned prim, - unsigned start, - unsigned count ) +svga_hwtnl_simple_draw_range_elements(struct svga_hwtnl *hwtnl, + struct pipe_resource *index_buffer, + unsigned index_size, int index_bias, + unsigned min_index, unsigned max_index, + unsigned prim, unsigned start, + unsigned count) { struct pipe_resource *upload_buffer = NULL; SVGA3dPrimitiveRange range; @@ -129,68 +115,57 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, range.indexWidth = index_size; range.indexBias = index_bias; - ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer ); + ret = svga_hwtnl_prim(hwtnl, &range, min_index, max_index, index_buffer); if (ret != PIPE_OK) goto done; done: if (upload_buffer) - pipe_resource_reference( &upload_buffer, NULL ); + pipe_resource_reference(&upload_buffer, NULL); return ret; } - - enum pipe_error -svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, - struct pipe_resource *index_buffer, - unsigned index_size, - int index_bias, - unsigned min_index, - unsigned max_index, - unsigned prim, unsigned start, unsigned count) +svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl, + struct pipe_resource *index_buffer, + unsigned index_size, int index_bias, + unsigned min_index, unsigned max_index, + 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) - { - gen_type = u_unfilled_translator( prim, - index_size, - count, - hwtnl->api_fillmode, - &gen_prim, - &gen_size, - &gen_nr, - &gen_func ); + prim >= PIPE_PRIM_TRIANGLES) { + gen_type = u_unfilled_translator(prim, + index_size, + count, + hwtnl->api_fillmode, + &gen_prim, + &gen_size, &gen_nr, &gen_func); } - else - { - gen_type = u_index_translator( svga_hw_prims, - prim, - index_size, - count, - hwtnl->api_pv, - hwtnl->hw_pv, - &gen_prim, - &gen_size, - &gen_nr, - &gen_func ); + else { + gen_type = u_index_translator(svga_hw_prims, + prim, + index_size, + count, + hwtnl->api_pv, + hwtnl->hw_pv, + &gen_prim, &gen_size, &gen_nr, &gen_func); } if (gen_type == U_TRANSLATE_MEMCPY) { /* 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 ); + return svga_hwtnl_simple_draw_range_elements(hwtnl, index_buffer, + index_size, + index_bias, + min_index, + max_index, + gen_prim, start, count); } else { struct pipe_resource *gen_buf = NULL; @@ -202,31 +177,26 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, * GL though, as index buffers are typically used only once * there. */ - ret = translate_indices( hwtnl, - index_buffer, - start * index_size, - gen_nr, - gen_size, - gen_func, - &gen_buf ); + ret = translate_indices(hwtnl, + index_buffer, + start * index_size, + gen_nr, gen_size, gen_func, &gen_buf); 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 ); + ret = svga_hwtnl_simple_draw_range_elements(hwtnl, + gen_buf, + gen_size, + index_bias, + min_index, + max_index, + gen_prim, 0, gen_nr); if (ret != PIPE_OK) goto done; - done: +done: if (gen_buf) - pipe_resource_reference( &gen_buf, NULL ); + pipe_resource_reference(&gen_buf, NULL); return ret; } |