5c0880f6ce40f4b319718730897f8269d3339f95
1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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 VMWARE 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.
26 **************************************************************************/
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_context.h"
34 #include "pipe/p_state.h"
43 util_draw_init_info(struct pipe_draw_info
*info
)
45 memset(info
, 0, sizeof(*info
));
46 info
->instance_count
= 1;
47 info
->max_index
= 0xffffffff;
52 util_draw_arrays(struct pipe_context
*pipe
, uint mode
, uint start
, uint count
)
54 struct pipe_draw_info info
;
56 util_draw_init_info(&info
);
60 info
.min_index
= start
;
61 info
.max_index
= start
+ count
- 1;
63 pipe
->draw_vbo(pipe
, &info
);
67 util_draw_elements(struct pipe_context
*pipe
, int index_bias
,
68 uint mode
, uint start
, uint count
)
70 struct pipe_draw_info info
;
72 util_draw_init_info(&info
);
77 info
.index_bias
= index_bias
;
79 pipe
->draw_vbo(pipe
, &info
);
83 util_draw_arrays_instanced(struct pipe_context
*pipe
,
84 uint mode
, uint start
, uint count
,
88 struct pipe_draw_info info
;
90 util_draw_init_info(&info
);
94 info
.start_instance
= start_instance
;
95 info
.instance_count
= instance_count
;
96 info
.min_index
= start
;
97 info
.max_index
= start
+ count
- 1;
99 pipe
->draw_vbo(pipe
, &info
);
103 util_draw_elements_instanced(struct pipe_context
*pipe
,
105 uint mode
, uint start
, uint count
,
109 struct pipe_draw_info info
;
111 util_draw_init_info(&info
);
116 info
.index_bias
= index_bias
;
117 info
.start_instance
= start_instance
;
118 info
.instance_count
= instance_count
;
120 pipe
->draw_vbo(pipe
, &info
);
124 util_draw_range_elements(struct pipe_context
*pipe
,
128 uint mode
, uint start
, uint count
)
130 struct pipe_draw_info info
;
132 util_draw_init_info(&info
);
137 info
.index_bias
= index_bias
;
138 info
.min_index
= min_index
;
139 info
.max_index
= max_index
;
141 pipe
->draw_vbo(pipe
, &info
);
145 /* This converts an indirect draw into a direct draw by mapping the indirect
146 * buffer, extracting its arguments, and calling pipe->draw_vbo.
149 util_draw_indirect(struct pipe_context
*pipe
,
150 const struct pipe_draw_info
*info
);
155 const struct pipe_vertex_buffer
*vertex_buffers
,
156 const struct pipe_vertex_element
*vertex_elements
,
157 unsigned nr_vertex_elements
,
158 const struct pipe_draw_info
*info
);
165 #endif /* !U_DRAW_H */