summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_vbuf.h
blob: 604e8c8b8b0f2358fb4b0f5cfff867f93e513198 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**************************************************************************
 *
 * Copyright 2011 Marek Olšák <maraeo@gmail.com>
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 **************************************************************************/

#ifndef U_VBUF_H
#define U_VBUF_H

/* This module takes care of user buffer uploads and vertex format fallbacks.
 * It's designed for the drivers which don't want to use the Draw module.
 * There is a more detailed description at the beginning of the .c file.
 */

#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "pipe/p_format.h"

struct cso_context;
struct u_vbuf;

#define U_VBUF_FLAG_NO_USER_VBOS (1 << 0)

/* Hardware vertex fetcher limitations can be described by this structure. */
struct u_vbuf_caps {
   enum pipe_format format_translation[PIPE_FORMAT_COUNT];

   /* Whether vertex fetches don't have to be 4-byte-aligned. */
   /* TRUE if hardware supports it. */
   unsigned buffer_offset_unaligned:1;
   unsigned buffer_stride_unaligned:1;
   unsigned velem_src_offset_unaligned:1;

   /* Whether the driver supports user vertex buffers. */
   unsigned user_vertex_buffers:1;
};


boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
                        unsigned flags);

struct u_vbuf *
u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps);

void u_vbuf_destroy(struct u_vbuf *mgr);

/* State and draw functions. */
void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, unsigned count,
                                const struct pipe_vertex_element *states);
void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
                               unsigned start_slot, unsigned count,
                               const struct pipe_vertex_buffer *bufs);
void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info);
void u_vbuf_get_minmax_index(struct pipe_context *pipe,
                             const struct pipe_draw_info *info,
                             unsigned *out_min_index, unsigned *out_max_index);

/* Save/restore functionality. */
void u_vbuf_save_vertex_elements(struct u_vbuf *mgr);
void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr);
void u_vbuf_save_vertex_buffer0(struct u_vbuf *mgr);
void u_vbuf_restore_vertex_buffer0(struct u_vbuf *mgr);

#endif