util: Include missing header in u_draw.h.
[mesa.git] / src / gallium / auxiliary / util / u_draw.h
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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_DRAW_H
29 #define U_DRAW_H
30
31
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_context.h"
34 #include "pipe/p_state.h"
35
36
37 static INLINE void
38 util_draw_init_info(struct pipe_draw_info *info)
39 {
40 memset(info, 0, sizeof(*info));
41 info->instance_count = 1;
42 info->max_index = 0xffffffff;
43 }
44
45
46 static INLINE void
47 util_draw_arrays(struct pipe_context *pipe, uint mode, uint start, uint count)
48 {
49 struct pipe_draw_info info;
50
51 util_draw_init_info(&info);
52 info.mode = mode;
53 info.start = start;
54 info.count = count;
55 info.min_index = start;
56 info.max_index = start + count - 1;
57
58 pipe->draw_vbo(pipe, &info);
59 }
60
61 static INLINE void
62 util_draw_elements(struct pipe_context *pipe, int index_bias,
63 uint mode, uint start, uint count)
64 {
65 struct pipe_draw_info info;
66
67 util_draw_init_info(&info);
68 info.indexed = TRUE;
69 info.mode = mode;
70 info.start = start;
71 info.count = count;
72 info.index_bias = index_bias;
73
74 pipe->draw_vbo(pipe, &info);
75 }
76
77 static INLINE void
78 util_draw_arrays_instanced(struct pipe_context *pipe,
79 uint mode, uint start, uint count,
80 uint start_instance,
81 uint instance_count)
82 {
83 struct pipe_draw_info info;
84
85 util_draw_init_info(&info);
86 info.mode = mode;
87 info.start = start;
88 info.count = count;
89 info.start_instance = start_instance;
90 info.instance_count = instance_count;
91 info.min_index = start;
92 info.max_index = start + count - 1;
93
94 pipe->draw_vbo(pipe, &info);
95 }
96
97 static INLINE void
98 util_draw_elements_instanced(struct pipe_context *pipe,
99 int index_bias,
100 uint mode, uint start, uint count,
101 uint start_instance,
102 uint instance_count)
103 {
104 struct pipe_draw_info info;
105
106 util_draw_init_info(&info);
107 info.indexed = TRUE;
108 info.mode = mode;
109 info.start = start;
110 info.count = count;
111 info.index_bias = index_bias;
112 info.start_instance = start_instance;
113 info.instance_count = instance_count;
114
115 pipe->draw_vbo(pipe, &info);
116 }
117
118 static INLINE void
119 util_draw_range_elements(struct pipe_context *pipe,
120 int index_bias,
121 uint min_index,
122 uint max_index,
123 uint mode, uint start, uint count)
124 {
125 struct pipe_draw_info info;
126
127 util_draw_init_info(&info);
128 info.indexed = TRUE;
129 info.mode = mode;
130 info.start = start;
131 info.count = count;
132 info.index_bias = index_bias;
133 info.min_index = min_index;
134 info.max_index = max_index;
135
136 pipe->draw_vbo(pipe, &info);
137 }
138
139 #endif