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 takes care of user buffer uploads and vertex format fallbacks. 32 * It's designed for the drivers which don't want to use the Draw module. 33 * There is a more detailed description at the beginning of the .c file. 34 */ 35 36 #include "pipe/p_context.h" 37 #include "pipe/p_state.h" 38 #include "pipe/p_format.h" 39 40 struct cso_context; 41 struct cso_velems_state; 42 struct u_vbuf; 43 44 /* Hardware vertex fetcher limitations can be described by this structure. */ 45 struct u_vbuf_caps { 46 enum pipe_format format_translation[PIPE_FORMAT_COUNT]; 47 48 /* Whether vertex fetches don't have to be 4-byte-aligned. */ 49 /* TRUE if hardware supports it. */ 50 unsigned buffer_offset_unaligned:1; 51 unsigned buffer_stride_unaligned:1; 52 unsigned velem_src_offset_unaligned:1; 53 unsigned attrib_component_unaligned:1; 54 55 /* Whether the driver supports user vertex buffers. */ 56 unsigned user_vertex_buffers:1; 57 58 /* Maximum number of vertex buffers */ 59 unsigned max_vertex_buffers:6; 60 61 uint16_t supported_restart_modes; 62 uint16_t supported_prim_modes; 63 bool fallback_always; 64 bool fallback_only_for_user_vbuffers; 65 bool rewrite_ubyte_ibs; 66 bool rewrite_restart_index; 67 }; 68 69 70 void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps, 71 bool needs64b); 72 73 struct u_vbuf * 74 u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps); 75 76 void u_vbuf_destroy(struct u_vbuf *mgr); 77 78 /* State and draw functions. */ 79 void u_vbuf_set_flatshade_first(struct u_vbuf *mgr, bool flatshade_first); 80 void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, 81 const struct cso_velems_state *velems); 82 void u_vbuf_unset_vertex_elements(struct u_vbuf *mgr); 83 void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, 84 unsigned start_slot, unsigned count, 85 unsigned unbind_num_trailing_slots, 86 bool take_ownership, 87 const struct pipe_vertex_buffer *bufs); 88 void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info, 89 unsigned drawid_offset, 90 const struct pipe_draw_indirect_info *indirect, 91 const struct pipe_draw_start_count_bias *draws, 92 unsigned num_draws); 93 void u_vbuf_get_minmax_index(struct pipe_context *pipe, 94 const struct pipe_draw_info *info, 95 const struct pipe_draw_start_count_bias *draw, 96 unsigned *out_min_index, unsigned *out_max_index); 97 98 /* Save/restore functionality. */ 99 void u_vbuf_save_vertex_elements(struct u_vbuf *mgr); 100 void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr); 101 102 #endif 103