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
,
53 enum pipe_prim_type mode
,
57 struct pipe_draw_info info
;
59 util_draw_init_info(&info
);
63 info
.min_index
= start
;
64 info
.max_index
= start
+ count
- 1;
66 pipe
->draw_vbo(pipe
, &info
);
70 util_draw_elements(struct pipe_context
*pipe
,
73 int index_bias
, enum pipe_prim_type mode
,
77 struct pipe_draw_info info
;
79 util_draw_init_info(&info
);
80 info
.index
.user
= indices
;
81 info
.has_user_indices
= true;
82 info
.index_size
= index_size
;
86 info
.index_bias
= index_bias
;
88 pipe
->draw_vbo(pipe
, &info
);
92 util_draw_arrays_instanced(struct pipe_context
*pipe
,
93 enum pipe_prim_type mode
,
99 struct pipe_draw_info info
;
101 util_draw_init_info(&info
);
105 info
.start_instance
= start_instance
;
106 info
.instance_count
= instance_count
;
107 info
.min_index
= start
;
108 info
.max_index
= start
+ count
- 1;
110 pipe
->draw_vbo(pipe
, &info
);
114 util_draw_elements_instanced(struct pipe_context
*pipe
,
118 enum pipe_prim_type mode
,
124 struct pipe_draw_info info
;
126 util_draw_init_info(&info
);
127 info
.index
.user
= indices
;
128 info
.has_user_indices
= true;
129 info
.index_size
= index_size
;
133 info
.index_bias
= index_bias
;
134 info
.start_instance
= start_instance
;
135 info
.instance_count
= instance_count
;
137 pipe
->draw_vbo(pipe
, &info
);
141 /* This converts an indirect draw into a direct draw by mapping the indirect
142 * buffer, extracting its arguments, and calling pipe->draw_vbo.
145 util_draw_indirect(struct pipe_context
*pipe
,
146 const struct pipe_draw_info
*info
);
151 const struct pipe_vertex_buffer
*vertex_buffers
,
152 const struct pipe_vertex_element
*vertex_elements
,
153 unsigned nr_vertex_elements
,
154 const struct pipe_draw_info
*info
);
161 #endif /* !U_DRAW_H */