Nouveau: Rename nv20/ files as nv20.
[mesa.git] / src / gallium / drivers / nv20 / nv20_vbo.c
1 #include "draw/draw_context.h"
2 #include "pipe/p_context.h"
3 #include "pipe/p_state.h"
4
5 #include "nv10_context.h"
6 #include "nv10_state.h"
7
8 #include "nouveau/nouveau_channel.h"
9 #include "nouveau/nouveau_pushbuf.h"
10
11 boolean nv10_draw_elements( struct pipe_context *pipe,
12 struct pipe_buffer *indexBuffer,
13 unsigned indexSize,
14 unsigned prim, unsigned start, unsigned count)
15 {
16 struct nv10_context *nv10 = nv10_context( pipe );
17 struct draw_context *draw = nv10->draw;
18 unsigned i;
19
20 nv10_emit_hw_state(nv10);
21
22 /*
23 * Map vertex buffers
24 */
25 for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
26 if (nv10->vtxbuf[i].buffer) {
27 void *buf
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);
32 }
33 }
34 /* Map index buffer, if present */
35 if (indexBuffer) {
36 void *mapped_indexes
37 = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
38 PIPE_BUFFER_USAGE_CPU_READ);
39 draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
40 }
41 else {
42 /* no index/element buffer */
43 draw_set_mapped_element_buffer(draw, 0, NULL);
44 }
45
46 draw_set_mapped_constant_buffer(draw,
47 nv10->constbuf[PIPE_SHADER_VERTEX],
48 nv10->constbuf_nr[PIPE_SHADER_VERTEX]);
49
50 /* draw! */
51 draw_arrays(nv10->draw, prim, start, count);
52
53 /*
54 * unmap vertex/index buffers
55 */
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);
60 }
61 }
62 if (indexBuffer) {
63 pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
64 draw_set_mapped_element_buffer(draw, 0, NULL);
65 }
66
67 return TRUE;
68 }
69
70 boolean nv10_draw_arrays( struct pipe_context *pipe,
71 unsigned prim, unsigned start, unsigned count)
72 {
73 return nv10_draw_elements(pipe, NULL, 0, prim, start, count);
74 }
75
76
77