0899e1145a833550241d68901a75a418b11cb809
1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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 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.
26 **************************************************************************/
34 #include "pipe/p_defines.h"
35 #include "pipe/p_context.h"
36 #include "util/u_simple_screen.h"
37 #include "util/u_inlines.h"
38 #include "util/u_prim.h"
40 #include "sp_context.h"
43 #include "sp_buffer.h"
45 #include "draw/draw_context.h"
53 * Draw vertex arrays, with optional indexing.
54 * Basically, map the vertex buffers (and drawing surfaces), then hand off
55 * the drawing to the 'draw' module.
58 softpipe_draw_range_elements_instanced(struct pipe_context
*pipe
,
59 struct pipe_buffer
*indexBuffer
,
66 unsigned startInstance
,
67 unsigned instanceCount
);
71 softpipe_draw_arrays(struct pipe_context
*pipe
, unsigned mode
,
72 unsigned start
, unsigned count
)
74 softpipe_draw_range_elements_instanced(pipe
,
88 softpipe_draw_range_elements(struct pipe_context
*pipe
,
89 struct pipe_buffer
*indexBuffer
,
93 unsigned mode
, unsigned start
, unsigned count
)
95 softpipe_draw_range_elements_instanced(pipe
,
109 softpipe_draw_elements(struct pipe_context
*pipe
,
110 struct pipe_buffer
*indexBuffer
,
112 unsigned mode
, unsigned start
, unsigned count
)
114 softpipe_draw_range_elements_instanced(pipe
,
127 softpipe_draw_arrays_instanced(struct pipe_context
*pipe
,
131 unsigned startInstance
,
132 unsigned instanceCount
)
134 softpipe_draw_range_elements_instanced(pipe
,
147 softpipe_draw_elements_instanced(struct pipe_context
*pipe
,
148 struct pipe_buffer
*indexBuffer
,
153 unsigned startInstance
,
154 unsigned instanceCount
)
156 softpipe_draw_range_elements_instanced(pipe
,
169 softpipe_draw_range_elements_instanced(struct pipe_context
*pipe
,
170 struct pipe_buffer
*indexBuffer
,
177 unsigned startInstance
,
178 unsigned instanceCount
)
180 struct softpipe_context
*sp
= softpipe_context(pipe
);
181 struct draw_context
*draw
= sp
->draw
;
184 if (!softpipe_check_render_cond(sp
))
187 sp
->reduced_api_prim
= u_reduced_prim(mode
);
190 softpipe_update_derived(sp
);
193 softpipe_map_transfers(sp
);
195 /* Map vertex buffers */
196 for (i
= 0; i
< sp
->num_vertex_buffers
; i
++) {
197 void *buf
= softpipe_buffer(sp
->vertex_buffer
[i
].buffer
)->data
;
198 draw_set_mapped_vertex_buffer(draw
, i
, buf
);
201 /* Map index buffer, if present */
203 void *mapped_indexes
= softpipe_buffer(indexBuffer
)->data
;
204 draw_set_mapped_element_buffer_range(draw
,
210 /* no index/element buffer */
211 draw_set_mapped_element_buffer_range(draw
,
219 draw_arrays_instanced(draw
, mode
, start
, count
, startInstance
, instanceCount
);
221 /* unmap vertex/index buffers - will cause draw module to flush */
222 for (i
= 0; i
< sp
->num_vertex_buffers
; i
++) {
223 draw_set_mapped_vertex_buffer(draw
, i
, NULL
);
226 draw_set_mapped_element_buffer(draw
, 0, NULL
);
230 * TODO: Flush only when a user vertex/index buffer is present
231 * (or even better, modify draw module to do this
232 * internally when this condition is seen?)
236 /* Note: leave drawing surfaces mapped */
237 sp
->dirty_render_cache
= TRUE
;