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