1 #include "draw/draw_context.h"
2 #include "pipe/p_context.h"
3 #include "pipe/p_state.h"
4 #include "pipe/p_util.h"
6 #include "nv10_context.h"
7 #include "nv10_state.h"
9 #include "nouveau/nouveau_channel.h"
10 #include "nouveau/nouveau_pushbuf.h"
12 boolean
nv10_draw_elements( struct pipe_context
*pipe
,
13 struct pipe_buffer
*indexBuffer
,
15 unsigned prim
, unsigned start
, unsigned count
)
17 struct nv10_context
*nv10
= nv10_context( pipe
);
18 struct draw_context
*draw
= nv10
->draw
;
21 nv10_emit_hw_state(nv10
);
26 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++) {
27 if (nv10
->vtxbuf
[i
].buffer
) {
29 = pipe
->winsys
->buffer_map(pipe
->winsys
,
30 nv10
->vtxbuf
[i
].buffer
,
31 PIPE_BUFFER_USAGE_CPU_READ
);
32 draw_set_mapped_vertex_buffer(draw
, i
, buf
);
35 /* Map index buffer, if present */
38 = pipe
->winsys
->buffer_map(pipe
->winsys
, indexBuffer
,
39 PIPE_BUFFER_USAGE_CPU_READ
);
40 draw_set_mapped_element_buffer(draw
, indexSize
, mapped_indexes
);
43 /* no index/element buffer */
44 draw_set_mapped_element_buffer(draw
, 0, NULL
);
47 draw_set_mapped_constant_buffer(draw
,
48 nv10
->constbuf
[PIPE_SHADER_VERTEX
],
49 nv10
->constbuf_nr
[PIPE_SHADER_VERTEX
]);
52 draw_arrays(nv10
->draw
, prim
, start
, count
);
55 * unmap vertex/index buffers
57 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++) {
58 if (nv10
->vtxbuf
[i
].buffer
) {
59 pipe
->winsys
->buffer_unmap(pipe
->winsys
, nv10
->vtxbuf
[i
].buffer
);
60 draw_set_mapped_vertex_buffer(draw
, i
, NULL
);
64 pipe
->winsys
->buffer_unmap(pipe
->winsys
, indexBuffer
);
65 draw_set_mapped_element_buffer(draw
, 0, NULL
);
71 boolean
nv10_draw_arrays( struct pipe_context
*pipe
,
72 unsigned prim
, unsigned start
, unsigned count
)
74 return nv10_draw_elements(pipe
, NULL
, 0, prim
, start
, count
);