1 #include "pipe/p_context.h"
2 #include "pipe/p_state.h"
3 #include "pipe/p_util.h"
5 #include "nv50_context.h"
8 nv50_prim(unsigned mode
)
11 case PIPE_PRIM_POINTS
: return NV50TCL_VERTEX_BEGIN_POINTS
;
12 case PIPE_PRIM_LINES
: return NV50TCL_VERTEX_BEGIN_LINES
;
13 case PIPE_PRIM_LINE_LOOP
: return NV50TCL_VERTEX_BEGIN_LINE_LOOP
;
14 case PIPE_PRIM_LINE_STRIP
: return NV50TCL_VERTEX_BEGIN_LINE_STRIP
;
15 case PIPE_PRIM_TRIANGLES
: return NV50TCL_VERTEX_BEGIN_TRIANGLES
;
16 case PIPE_PRIM_TRIANGLE_STRIP
:
17 return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP
;
18 case PIPE_PRIM_TRIANGLE_FAN
: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN
;
19 case PIPE_PRIM_QUADS
: return NV50TCL_VERTEX_BEGIN_QUADS
;
20 case PIPE_PRIM_QUAD_STRIP
: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP
;
21 case PIPE_PRIM_POLYGON
: return NV50TCL_VERTEX_BEGIN_POLYGON
;
26 NOUVEAU_ERR("invalid primitive type %d\n", mode
);
27 return NV50TCL_VERTEX_BEGIN_POINTS
;
31 nv50_draw_arrays(struct pipe_context
*pipe
, unsigned mode
, unsigned start
,
34 struct nv50_context
*nv50
= nv50_context(pipe
);
36 nv50_state_validate(nv50
);
38 BEGIN_RING(tesla
, 0x142c, 1);
40 BEGIN_RING(tesla
, 0x142c, 1);
43 BEGIN_RING(tesla
, NV50TCL_VERTEX_BEGIN
, 1);
44 OUT_RING (nv50_prim(mode
));
45 BEGIN_RING(tesla
, NV50TCL_VERTEX_BUFFER_FIRST
, 2);
48 BEGIN_RING(tesla
, NV50TCL_VERTEX_END
, 1);
51 pipe
->flush(pipe
, 0, NULL
);
56 nv50_draw_elements(struct pipe_context
*pipe
,
57 struct pipe_buffer
*indexBuffer
, unsigned indexSize
,
58 unsigned mode
, unsigned start
, unsigned count
)
60 struct nv50_context
*nv50
= nv50_context(pipe
);
62 nv50_state_validate(nv50
);
64 NOUVEAU_ERR("unimplemented\n");
69 nv50_vbo_validate(struct nv50_context
*nv50
)
71 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
72 struct nouveau_stateobj
*vtxbuf
, *vtxfmt
;
75 vtxbuf
= so_new(nv50
->vtxelt_nr
* 4, nv50
->vtxelt_nr
* 2);
76 vtxfmt
= so_new(nv50
->vtxelt_nr
+ 1, 0);
77 so_method(vtxfmt
, tesla
, 0x1ac0, nv50
->vtxelt_nr
);
79 for (i
= 0; i
< nv50
->vtxelt_nr
; i
++) {
80 struct pipe_vertex_element
*ve
= &nv50
->vtxelt
[i
];
81 struct pipe_vertex_buffer
*vb
=
82 &nv50
->vtxbuf
[ve
->vertex_buffer_index
];
84 switch (ve
->src_format
) {
85 case PIPE_FORMAT_R32G32B32_FLOAT
:
86 so_data(vtxfmt
, 0x7e100000 | i
);
91 pf_sprint_name(fmt
, ve
->src_format
);
92 NOUVEAU_ERR("invalid vbo format %s\n", fmt
);
98 so_method(vtxbuf
, tesla
, 0x900 + (i
* 16), 3);
99 so_data (vtxbuf
, 0x20000000 | vb
->pitch
);
100 so_reloc (vtxbuf
, vb
->buffer
, vb
->buffer_offset
+
101 ve
->src_offset
, NOUVEAU_BO_VRAM
| NOUVEAU_BO_RD
|
102 NOUVEAU_BO_HIGH
, 0, 0);
103 so_reloc (vtxbuf
, vb
->buffer
, vb
->buffer_offset
+
104 ve
->src_offset
, NOUVEAU_BO_VRAM
| NOUVEAU_BO_RD
|
105 NOUVEAU_BO_LOW
, 0, 0);
108 so_emit(nv50
->screen
->nvws
, vtxfmt
);
109 so_ref (NULL
, &vtxfmt
);
110 so_emit(nv50
->screen
->nvws
, vtxbuf
);
111 so_ref (NULL
, &vtxbuf
);