1 #include "draw/draw_context.h"
2 #include "pipe/p_context.h"
3 #include "pipe/p_state.h"
4 #include "pipe/p_inlines.h"
6 #include "nv04_context.h"
7 #include "nv04_state.h"
9 #include "nouveau/nouveau_channel.h"
10 #include "nouveau/nouveau_pushbuf.h"
12 boolean
nv04_draw_elements( struct pipe_context
*pipe
,
13 struct pipe_buffer
*indexBuffer
,
15 unsigned prim
, unsigned start
, unsigned count
)
17 struct pipe_screen
*pscreen
= pipe
->screen
;
18 struct nv04_context
*nv04
= nv04_context( pipe
);
19 struct draw_context
*draw
= nv04
->draw
;
22 nv04_emit_hw_state(nv04
);
27 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++) {
28 if (nv04
->vtxbuf
[i
].buffer
) {
30 = pipe_buffer_map(pscreen
,
31 nv04
->vtxbuf
[i
].buffer
,
32 PIPE_BUFFER_USAGE_CPU_READ
);
33 draw_set_mapped_vertex_buffer(draw
, i
, buf
);
36 /* Map index buffer, if present */
39 = pipe_buffer_map(pscreen
, indexBuffer
,
40 PIPE_BUFFER_USAGE_CPU_READ
);
41 draw_set_mapped_element_buffer(draw
, indexSize
, mapped_indexes
);
44 /* no index/element buffer */
45 draw_set_mapped_element_buffer(draw
, 0, NULL
);
48 draw_set_mapped_constant_buffer(draw
,
49 nv04
->constbuf
[PIPE_SHADER_VERTEX
],
50 nv04
->constbuf_nr
[PIPE_SHADER_VERTEX
]);
53 draw_arrays(nv04
->draw
, prim
, start
, count
);
56 * unmap vertex/index buffers
58 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++) {
59 if (nv04
->vtxbuf
[i
].buffer
) {
60 pipe_buffer_unmap(pscreen
, nv04
->vtxbuf
[i
].buffer
);
61 draw_set_mapped_vertex_buffer(draw
, i
, NULL
);
65 pipe_buffer_unmap(pscreen
, indexBuffer
);
66 draw_set_mapped_element_buffer(draw
, 0, NULL
);
72 boolean
nv04_draw_arrays( struct pipe_context
*pipe
,
73 unsigned prim
, unsigned start
, unsigned count
)
75 printf("coucou in draw arrays\n");
76 return nv04_draw_elements(pipe
, NULL
, 0, prim
, start
, count
);