14a49301eSmrg/************************************************************************** 24a49301eSmrg * 3af69d88dSmrg * Copyright 2007 VMware, Inc. 44a49301eSmrg * All Rights Reserved. 54a49301eSmrg * 64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 74a49301eSmrg * copy of this software and associated documentation files (the 84a49301eSmrg * "Software"), to deal in the Software without restriction, including 94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish, 104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to 114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to 124a49301eSmrg * the following conditions: 134a49301eSmrg * 144a49301eSmrg * The above copyright notice and this permission notice (including the 154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions 164a49301eSmrg * of the Software. 174a49301eSmrg * 184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 254a49301eSmrg * 264a49301eSmrg **************************************************************************/ 274a49301eSmrg 284a49301eSmrg/** 294a49301eSmrg * \file 304a49301eSmrg * Vertex buffer drawing stage. 314a49301eSmrg * 32af69d88dSmrg * \author Keith Whitwell <keithw@vmware.com> 33af69d88dSmrg * \author Jose Fonseca <jfonseca@vmware.com> 344a49301eSmrg */ 354a49301eSmrg 364a49301eSmrg#ifndef DRAW_VBUF_H_ 374a49301eSmrg#define DRAW_VBUF_H_ 384a49301eSmrg 394a49301eSmrg 404a49301eSmrg#include "pipe/p_compiler.h" 4101e04c3fSmrg#include "pipe/p_defines.h" 424a49301eSmrg 434a49301eSmrg 444a49301eSmrgstruct pipe_rasterizer_state; 454a49301eSmrgstruct draw_context; 464a49301eSmrgstruct vertex_info; 47af69d88dSmrgstruct pipe_query_data_pipeline_statistics; 484a49301eSmrg 494a49301eSmrg 504a49301eSmrg/** 514a49301eSmrg * Interface for hardware vertex buffer rendering. 524a49301eSmrg */ 534a49301eSmrgstruct vbuf_render { 544a49301eSmrg 554a49301eSmrg /** 564a49301eSmrg * Driver limits. May be tuned lower to improve cache hits on 574a49301eSmrg * index list. 584a49301eSmrg */ 594a49301eSmrg unsigned max_indices; 604a49301eSmrg unsigned max_vertex_buffer_bytes; 614a49301eSmrg 624a49301eSmrg /** 634a49301eSmrg * Query if the hardware driver needs assistance for a particular 644a49301eSmrg * combination of rasterizer state and primitive. 654a49301eSmrg * 664a49301eSmrg * Currently optional. 674a49301eSmrg */ 684a49301eSmrg boolean (*need_pipeline)(const struct vbuf_render *render, 694a49301eSmrg const struct pipe_rasterizer_state *rasterizer, 704a49301eSmrg unsigned int prim ); 714a49301eSmrg 724a49301eSmrg 734a49301eSmrg /** 744a49301eSmrg * Get the hardware vertex format. 754a49301eSmrg * 764a49301eSmrg * XXX: have this in draw_context instead? 774a49301eSmrg */ 784a49301eSmrg const struct vertex_info *(*get_vertex_info)( struct vbuf_render * ); 794a49301eSmrg 804a49301eSmrg /** 814a49301eSmrg * Request a destination for vertices. 824a49301eSmrg * Hardware renderers will use ttm memory, others will just malloc 834a49301eSmrg * something. 844a49301eSmrg */ 854a49301eSmrg boolean (*allocate_vertices)( struct vbuf_render *, 864a49301eSmrg ushort vertex_size, 874a49301eSmrg ushort nr_vertices ); 884a49301eSmrg 894a49301eSmrg void *(*map_vertices)( struct vbuf_render * ); 904a49301eSmrg void (*unmap_vertices)( struct vbuf_render *, 914a49301eSmrg ushort min_index, 924a49301eSmrg ushort max_index ); 934a49301eSmrg 944a49301eSmrg /** 954a49301eSmrg * Notify the renderer of the current primitive when it changes. 964a49301eSmrg * Must succeed for TRIANGLES, LINES and POINTS. Other prims at 974a49301eSmrg * the discretion of the driver, for the benefit of the passthrough 984a49301eSmrg * path. 994a49301eSmrg */ 10001e04c3fSmrg void (*set_primitive)( struct vbuf_render *, enum pipe_prim_type prim ); 1014a49301eSmrg 1027ec681f3Smrg /** 1037ec681f3Smrg * Notify the renderer of the current view index. 1047ec681f3Smrg */ 1057ec681f3Smrg void (*set_view_index)( struct vbuf_render *, unsigned view_index ); 1067ec681f3Smrg 1074a49301eSmrg /** 1083464ebd5Sriastradh * Draw indexed primitives. Note that indices are ushort. The driver 1093464ebd5Sriastradh * must complete this call, if necessary splitting the index list itself. 1104a49301eSmrg */ 1113464ebd5Sriastradh void (*draw_elements)( struct vbuf_render *, 1123464ebd5Sriastradh const ushort *indices, 1133464ebd5Sriastradh uint nr_indices ); 1144a49301eSmrg 1153464ebd5Sriastradh /* Draw non-indexed primitives. 1164a49301eSmrg */ 1174a49301eSmrg void (*draw_arrays)( struct vbuf_render *, 1184a49301eSmrg unsigned start, 1194a49301eSmrg uint nr ); 1204a49301eSmrg 1214a49301eSmrg /** 1224a49301eSmrg * Called when vbuf is done with this set of vertices: 1234a49301eSmrg */ 1244a49301eSmrg void (*release_vertices)( struct vbuf_render * ); 1254a49301eSmrg 1264a49301eSmrg void (*destroy)( struct vbuf_render * ); 1273464ebd5Sriastradh 1283464ebd5Sriastradh 1293464ebd5Sriastradh /** 1303464ebd5Sriastradh * Called after writing data to the stream out buffers 1313464ebd5Sriastradh */ 1323464ebd5Sriastradh void (*set_stream_output_info)( struct vbuf_render *vbufr, 133361fc4cbSmaya unsigned stream, 1343464ebd5Sriastradh unsigned primitive_count, 135af69d88dSmrg unsigned primitive_generated ); 136af69d88dSmrg 137af69d88dSmrg /** 138af69d88dSmrg * Called after all relevant statistics have been accumulated. 139af69d88dSmrg */ 140af69d88dSmrg void (*pipeline_statistics)( 141af69d88dSmrg struct vbuf_render *vbufr, 142af69d88dSmrg const struct pipe_query_data_pipeline_statistics *stats ); 1434a49301eSmrg}; 1444a49301eSmrg 1454a49301eSmrg 1464a49301eSmrg 1474a49301eSmrgstruct draw_stage * 1484a49301eSmrgdraw_vbuf_stage( struct draw_context *draw, 1494a49301eSmrg struct vbuf_render *render ); 1504a49301eSmrg 1514a49301eSmrg 1524a49301eSmrg#endif /*DRAW_VBUF_H_*/ 153