u_vbuf.h revision e0773da1e897164ed7597437070e32b867734ee5
1/************************************************************************** 2 * 3 * Copyright 2011 Marek Olšák <maraeo@gmail.com> 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#ifndef U_VBUF_H 29#define U_VBUF_H 30 31/* This module builds upon u_upload_mgr and translate_cache and takes care of 32 * user buffer uploads and vertex format fallbacks. It's designed 33 * for the drivers which don't always use the Draw module. (e.g. for HWTCL) 34 */ 35 36#include "pipe/p_context.h" 37#include "pipe/p_state.h" 38 39struct cso_context; 40struct u_vbuf; 41 42/* Hardware vertex fetcher limitations can be described by this structure. */ 43struct u_vbuf_caps { 44 /* Vertex format CAPs. */ 45 /* TRUE if hardware supports it. */ 46 unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */ 47 unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */ 48 unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */ 49 unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */ 50 unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */ 51 52 /* Whether vertex fetches don't have to be dword-aligned. */ 53 /* TRUE if hardware supports it. */ 54 unsigned fetch_dword_unaligned:1; 55 56 /* Whether the driver supports user vertex buffers. */ 57 unsigned user_vertex_buffers:1; 58}; 59 60 61void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps); 62 63struct u_vbuf * 64u_vbuf_create(struct pipe_context *pipe, 65 struct u_vbuf_caps *caps); 66 67void u_vbuf_destroy(struct u_vbuf *mgr); 68 69/* State and draw functions. */ 70void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, unsigned count, 71 const struct pipe_vertex_element *states); 72void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, unsigned count, 73 const struct pipe_vertex_buffer *bufs); 74void u_vbuf_set_index_buffer(struct u_vbuf *mgr, 75 const struct pipe_index_buffer *ib); 76void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info); 77 78/* Save/restore functionality. */ 79void u_vbuf_save_vertex_elements(struct u_vbuf *mgr); 80void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr); 81void u_vbuf_save_vertex_buffers(struct u_vbuf *mgr); 82void u_vbuf_restore_vertex_buffers(struct u_vbuf *mgr); 83 84#endif 85