13192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz/********************************************************** 23192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * Copyright 2008-2009 VMware, Inc. All rights reserved. 33192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * 43192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * Permission is hereby granted, free of charge, to any person 53192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * obtaining a copy of this software and associated documentation 63192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * files (the "Software"), to deal in the Software without 73192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * restriction, including without limitation the rights to use, copy, 83192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * modify, merge, publish, distribute, sublicense, and/or sell copies 93192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * of the Software, and to permit persons to whom the Software is 103192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * furnished to do so, subject to the following conditions: 113192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * 123192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * The above copyright notice and this permission notice shall be 133192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * included in all copies or substantial portions of the Software. 143192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * 153192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 163192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 173192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 183192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 193192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 203192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 213192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 223192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * SOFTWARE. 233192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * 243192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz **********************************************************/ 253192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2628486880ca3ec39419ccee0cb1a3bedc9ef7117cJosé Fonseca#include "util/u_inlines.h" 273192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "util/u_upload_mgr.h" 283192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "indices/u_indices.h" 293192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 303192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "svga_cmd.h" 313192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "svga_draw.h" 323192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "svga_draw_private.h" 33287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "svga_resource_buffer.h" 343192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "svga_winsys.h" 353192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "svga_context.h" 363192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 373192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz#include "svga_hw_reg.h" 383192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 393192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 403192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzstatic enum pipe_error 413192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantztranslate_indices( struct svga_hwtnl *hwtnl, 42287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *src, 433192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned offset, 443192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned nr, 453192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned index_size, 463192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz u_translate_func translate, 47287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource **out_buf ) 483192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz{ 49287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_context *pipe = &hwtnl->svga->pipe; 50287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_transfer *src_transfer = NULL; 51287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_transfer *dst_transfer = NULL; 523192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned size = index_size * nr; 533192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz const void *src_map = NULL; 54287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *dst = NULL; 553192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz void *dst_map = NULL; 563192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 57287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell dst = pipe_buffer_create( pipe->screen, 58287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell PIPE_BIND_INDEX_BUFFER, 59eafb7f234d11a290b00dcaf5492b9bdad1cf5148Marek Olšák PIPE_USAGE_STATIC, 60287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell size ); 613192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (dst == NULL) 623192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto fail; 633192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 64287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell src_map = pipe_buffer_map( pipe, src, PIPE_TRANSFER_READ, &src_transfer ); 653192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (src_map == NULL) 663192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto fail; 673192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 68287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer ); 693192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (dst_map == NULL) 703192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto fail; 713192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 723192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz translate( (const char *)src_map + offset, 733192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz nr, 743192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz dst_map ); 753192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 76ec51092a72e2dff1e9b1362d813fe4691cda89b7Marek Olšák pipe_buffer_unmap( pipe, src_transfer ); 77ec51092a72e2dff1e9b1362d813fe4691cda89b7Marek Olšák pipe_buffer_unmap( pipe, dst_transfer ); 783192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 793192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz *out_buf = dst; 803192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz return PIPE_OK; 813192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 823192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzfail: 833192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (src_map) 84ec51092a72e2dff1e9b1362d813fe4691cda89b7Marek Olšák pipe_buffer_unmap( pipe, src_transfer ); 853192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 863192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (dst_map) 87ec51092a72e2dff1e9b1362d813fe4691cda89b7Marek Olšák pipe_buffer_unmap( pipe, dst_transfer ); 883192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 893192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (dst) 90287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell pipe->screen->resource_destroy( pipe->screen, dst ); 913192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 923192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz return PIPE_ERROR_OUT_OF_MEMORY; 933192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz} 943192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 953192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 963192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 973192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 983192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 993192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzenum pipe_error 1003192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzsvga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, 101287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *index_buffer, 1023192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned index_size, 1039515b78859b52b4532cc9e06366428f2c49c7869José Fonseca int index_bias, 1043192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned min_index, 1053192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned max_index, 1063192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned prim, 1073192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned start, 1089515b78859b52b4532cc9e06366428f2c49c7869José Fonseca unsigned count ) 1093192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz{ 110287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *upload_buffer = NULL; 1113192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz SVGA3dPrimitiveRange range; 1123192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned hw_prim; 1133192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned hw_count; 1143192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned index_offset = start * index_size; 1155f053bf4ae092df9e5ff6ab38caf9867e6fe46bfBrian Paul enum pipe_error ret = PIPE_OK; 1163192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1173192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz hw_prim = svga_translate_prim(prim, count, &hw_count); 1183192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (hw_count == 0) 1193192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto done; 1203192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1213192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (index_buffer && 1223192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz svga_buffer_is_user_buffer(index_buffer)) 1233192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz { 124287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell assert( index_buffer->width0 >= index_offset + count * index_size ); 1253192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1263192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz ret = u_upload_buffer( hwtnl->upload_ib, 12706286110b4fc0ff80ae21bb3d8ff9909db1f5d47Marek Olšák 0, 1283192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_offset, 1293192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz count * index_size, 1303192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_buffer, 1313192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &index_offset, 132f94d390213308d4aca1515c75acc6865ebb45796Marek Olšák &upload_buffer); 1335f053bf4ae092df9e5ff6ab38caf9867e6fe46bfBrian Paul if (ret != PIPE_OK) 1343192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto done; 1353192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1363192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz /* Don't need to worry about refcounting index_buffer as this is 1373192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * just a stack variable without a counted reference of its own. 1383192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * The caller holds the reference. 1393192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz */ 1403192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_buffer = upload_buffer; 1413192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz } 1423192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1433192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz range.primType = hw_prim; 1443192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz range.primitiveCount = hw_count; 1453192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz range.indexArray.offset = index_offset; 1463192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz range.indexArray.stride = index_size; 1473192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz range.indexWidth = index_size; 1489515b78859b52b4532cc9e06366428f2c49c7869José Fonseca range.indexBias = index_bias; 1493192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1503192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer ); 1515f053bf4ae092df9e5ff6ab38caf9867e6fe46bfBrian Paul if (ret != PIPE_OK) 1523192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto done; 1533192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1543192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzdone: 1553192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (upload_buffer) 156287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell pipe_resource_reference( &upload_buffer, NULL ); 1573192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1583192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz return ret; 1593192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz} 1603192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1613192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1623192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1633192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1643192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzenum pipe_error 1653192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantzsvga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, 166287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *index_buffer, 1673192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned index_size, 1689515b78859b52b4532cc9e06366428f2c49c7869José Fonseca int index_bias, 1693192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned min_index, 1703192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned max_index, 1719515b78859b52b4532cc9e06366428f2c49c7869José Fonseca unsigned prim, unsigned start, unsigned count) 1723192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz{ 1733192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz unsigned gen_prim, gen_size, gen_nr, gen_type; 1743192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz u_translate_func gen_func; 1753192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz enum pipe_error ret = PIPE_OK; 1763192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 1773192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && 1783192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz prim >= PIPE_PRIM_TRIANGLES) 1793192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz { 1803192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_type = u_unfilled_translator( prim, 1813192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_size, 1823192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz count, 1833192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz hwtnl->api_fillmode, 1843192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_prim, 1853192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_size, 1863192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_nr, 1873192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_func ); 1883192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz } 1893192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz else 1903192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz { 1913192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_type = u_index_translator( svga_hw_prims, 1923192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz prim, 1933192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_size, 1943192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz count, 1953192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz hwtnl->api_pv, 1963192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz hwtnl->hw_pv, 1973192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_prim, 1983192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_size, 1993192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_nr, 2003192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_func ); 2013192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz } 2023192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2033192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2043192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (gen_type == U_TRANSLATE_MEMCPY) { 2053192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz /* No need for translation, just pass through to hardware: 2063192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz */ 2073192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer, 2083192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_size, 2099515b78859b52b4532cc9e06366428f2c49c7869José Fonseca index_bias, 2103192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz min_index, 2113192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz max_index, 2129515b78859b52b4532cc9e06366428f2c49c7869José Fonseca gen_prim, start, count ); 2133192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz } 2143192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz else { 215287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *gen_buf = NULL; 2163192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2173192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz /* Need to allocate a new index buffer and run the translate 2183192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * func to populate it. Could potentially cache this translated 2193192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * index buffer with the original to avoid future 2203192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * re-translations. Not much point if we're just accelerating 2213192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * GL though, as index buffers are typically used only once 2223192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz * there. 2233192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz */ 2243192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz ret = translate_indices( hwtnl, 2253192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz index_buffer, 2263192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz start * index_size, 2273192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_nr, 2283192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_size, 2293192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_func, 2303192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz &gen_buf ); 2315f053bf4ae092df9e5ff6ab38caf9867e6fe46bfBrian Paul if (ret != PIPE_OK) 2323192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto done; 2333192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2343192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz ret = svga_hwtnl_simple_draw_range_elements( hwtnl, 2353192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_buf, 2363192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_size, 2379515b78859b52b4532cc9e06366428f2c49c7869José Fonseca index_bias, 2383192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz min_index, 2393192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz max_index, 2403192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz gen_prim, 2413192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 0, 2429515b78859b52b4532cc9e06366428f2c49c7869José Fonseca gen_nr ); 2435f053bf4ae092df9e5ff6ab38caf9867e6fe46bfBrian Paul if (ret != PIPE_OK) 2443192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz goto done; 2453192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2463192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz done: 2473192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz if (gen_buf) 248287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell pipe_resource_reference( &gen_buf, NULL ); 2493192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2503192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz return ret; 2513192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz } 2523192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz} 2533192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2543192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2553192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2563192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 2573192633d4abe262d413e41feb871fe8deed409d8Jakob Bornecrantz 258