1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci/** 29bf215546Sopenharmony_ci * \file 30bf215546Sopenharmony_ci * Vertex buffer drawing stage. 31bf215546Sopenharmony_ci * 32bf215546Sopenharmony_ci * \author Keith Whitwell <keithw@vmware.com> 33bf215546Sopenharmony_ci * \author Jose Fonseca <jfonseca@vmware.com> 34bf215546Sopenharmony_ci */ 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#ifndef DRAW_VBUF_H_ 37bf215546Sopenharmony_ci#define DRAW_VBUF_H_ 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 41bf215546Sopenharmony_ci#include "pipe/p_defines.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_cistruct pipe_rasterizer_state; 45bf215546Sopenharmony_cistruct draw_context; 46bf215546Sopenharmony_cistruct vertex_info; 47bf215546Sopenharmony_cistruct pipe_query_data_pipeline_statistics; 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci/** 51bf215546Sopenharmony_ci * Interface for hardware vertex buffer rendering. 52bf215546Sopenharmony_ci */ 53bf215546Sopenharmony_cistruct vbuf_render { 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci /** 56bf215546Sopenharmony_ci * Driver limits. May be tuned lower to improve cache hits on 57bf215546Sopenharmony_ci * index list. 58bf215546Sopenharmony_ci */ 59bf215546Sopenharmony_ci unsigned max_indices; 60bf215546Sopenharmony_ci unsigned max_vertex_buffer_bytes; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci /** 63bf215546Sopenharmony_ci * Query if the hardware driver needs assistance for a particular 64bf215546Sopenharmony_ci * combination of rasterizer state and primitive. 65bf215546Sopenharmony_ci * 66bf215546Sopenharmony_ci * Currently optional. 67bf215546Sopenharmony_ci */ 68bf215546Sopenharmony_ci boolean (*need_pipeline)(const struct vbuf_render *render, 69bf215546Sopenharmony_ci const struct pipe_rasterizer_state *rasterizer, 70bf215546Sopenharmony_ci unsigned int prim); 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ci /** 74bf215546Sopenharmony_ci * Get the hardware vertex format. 75bf215546Sopenharmony_ci * 76bf215546Sopenharmony_ci * XXX: have this in draw_context instead? 77bf215546Sopenharmony_ci */ 78bf215546Sopenharmony_ci const struct vertex_info *(*get_vertex_info)(struct vbuf_render *); 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci /** 81bf215546Sopenharmony_ci * Request a destination for vertices. 82bf215546Sopenharmony_ci * Hardware renderers will use ttm memory, others will just malloc 83bf215546Sopenharmony_ci * something. 84bf215546Sopenharmony_ci */ 85bf215546Sopenharmony_ci boolean (*allocate_vertices)(struct vbuf_render *, 86bf215546Sopenharmony_ci ushort vertex_size, 87bf215546Sopenharmony_ci ushort nr_vertices); 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci void *(*map_vertices)(struct vbuf_render *); 90bf215546Sopenharmony_ci void (*unmap_vertices)(struct vbuf_render *, 91bf215546Sopenharmony_ci ushort min_index, 92bf215546Sopenharmony_ci ushort max_index); 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci /** 95bf215546Sopenharmony_ci * Notify the renderer of the current primitive when it changes. 96bf215546Sopenharmony_ci * Must succeed for TRIANGLES, LINES and POINTS. Other prims at 97bf215546Sopenharmony_ci * the discretion of the driver, for the benefit of the passthrough 98bf215546Sopenharmony_ci * path. 99bf215546Sopenharmony_ci */ 100bf215546Sopenharmony_ci void (*set_primitive)(struct vbuf_render *, enum pipe_prim_type prim); 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_ci /** 103bf215546Sopenharmony_ci * Notify the renderer of the current view index. 104bf215546Sopenharmony_ci */ 105bf215546Sopenharmony_ci void (*set_view_index)(struct vbuf_render *, unsigned view_index); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_ci /** 108bf215546Sopenharmony_ci * Draw indexed primitives. Note that indices are ushort. The driver 109bf215546Sopenharmony_ci * must complete this call, if necessary splitting the index list itself. 110bf215546Sopenharmony_ci */ 111bf215546Sopenharmony_ci void (*draw_elements)(struct vbuf_render *, 112bf215546Sopenharmony_ci const ushort *indices, 113bf215546Sopenharmony_ci uint nr_indices); 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci /* Draw non-indexed primitives. 116bf215546Sopenharmony_ci */ 117bf215546Sopenharmony_ci void (*draw_arrays)(struct vbuf_render *, 118bf215546Sopenharmony_ci unsigned start, 119bf215546Sopenharmony_ci uint nr); 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci /** 122bf215546Sopenharmony_ci * Called when vbuf is done with this set of vertices: 123bf215546Sopenharmony_ci */ 124bf215546Sopenharmony_ci void (*release_vertices)(struct vbuf_render *); 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci void (*destroy)(struct vbuf_render *); 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_ci /** 130bf215546Sopenharmony_ci * Called after writing data to the stream out buffers 131bf215546Sopenharmony_ci */ 132bf215546Sopenharmony_ci void (*set_stream_output_info)(struct vbuf_render *vbufr, 133bf215546Sopenharmony_ci unsigned stream, 134bf215546Sopenharmony_ci unsigned primitive_count, 135bf215546Sopenharmony_ci unsigned primitive_generated); 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_ci /** 138bf215546Sopenharmony_ci * Called after all relevant statistics have been accumulated. 139bf215546Sopenharmony_ci */ 140bf215546Sopenharmony_ci void (*pipeline_statistics)( 141bf215546Sopenharmony_ci struct vbuf_render *vbufr, 142bf215546Sopenharmony_ci const struct pipe_query_data_pipeline_statistics *stats); 143bf215546Sopenharmony_ci}; 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_cistruct draw_stage * 148bf215546Sopenharmony_cidraw_vbuf_stage(struct draw_context *draw, 149bf215546Sopenharmony_ci struct vbuf_render *render); 150bf215546Sopenharmony_ci 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci#endif /*DRAW_VBUF_H_*/ 153