1 #include "draw/draw_context.h"
2 #include "pipe/p_context.h"
3 #include "pipe/p_state.h"
5 #include "nv10_context.h"
6 #include "nv10_state.h"
8 #include "nouveau/nouveau_channel.h"
9 #include "nouveau/nouveau_pushbuf.h"
11 boolean
nv10_draw_elements( struct pipe_context
*pipe
,
12 struct pipe_buffer
*indexBuffer
,
14 unsigned prim
, unsigned start
, unsigned count
)
16 struct nv10_context
*nv10
= nv10_context( pipe
);
17 struct draw_context
*draw
= nv10
->draw
;
20 nv10_emit_hw_state(nv10
);
25 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++) {
26 if (nv10
->vtxbuf
[i
].buffer
) {
28 = pipe
->winsys
->buffer_map(pipe
->winsys
,
29 nv10
->vtxbuf
[i
].buffer
,
30 PIPE_BUFFER_USAGE_CPU_READ
);
31 draw_set_mapped_vertex_buffer(draw
, i
, buf
);
34 /* Map index buffer, if present */
37 = pipe
->winsys
->buffer_map(pipe
->winsys
, indexBuffer
,
38 PIPE_BUFFER_USAGE_CPU_READ
);
39 draw_set_mapped_element_buffer(draw
, indexSize
, mapped_indexes
);
42 /* no index/element buffer */
43 draw_set_mapped_element_buffer(draw
, 0, NULL
);
46 draw_set_mapped_constant_buffer(draw
,
47 nv10
->constbuf
[PIPE_SHADER_VERTEX
],
48 nv10
->constbuf_nr
[PIPE_SHADER_VERTEX
]);
51 draw_arrays(nv10
->draw
, prim
, start
, count
);
54 * unmap vertex/index buffers
56 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++) {
57 if (nv10
->vtxbuf
[i
].buffer
) {
58 pipe
->winsys
->buffer_unmap(pipe
->winsys
, nv10
->vtxbuf
[i
].buffer
);
59 draw_set_mapped_vertex_buffer(draw
, i
, NULL
);
63 pipe
->winsys
->buffer_unmap(pipe
->winsys
, indexBuffer
);
64 draw_set_mapped_element_buffer(draw
, 0, NULL
);
70 boolean
nv10_draw_arrays( struct pipe_context
*pipe
,
71 unsigned prim
, unsigned start
, unsigned count
)
73 return nv10_draw_elements(pipe
, NULL
, 0, prim
, start
, count
);