2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
23 #include "draw/draw_pipe.h"
24 #include "util/u_memory.h"
27 #include "r300_context.h"
30 /* r300_swtcl_emit: Primitive vertex emission using an immediate
31 * vertex buffer and no HW TCL. */
35 struct draw_stage draw
;
37 struct r300_context
* r300
;
40 static INLINE
struct swtcl_stage
* swtcl_stage(struct draw_stage
* draw
) {
41 return (struct swtcl_stage
*)draw
;
44 static void r300_emit_vertex(struct r300_context
* r300
,
45 const struct vertex_header
* vertex
)
50 static INLINE
void r300_emit_prim(struct draw_stage
* draw
,
51 struct prim_header
* prim
,
55 struct r300_context
* r300
= swtcl_stage(draw
)->r300
;
59 r300_emit_dirty_state(r300
);
61 /* XXX should be count * vtx size */
62 BEGIN_CS(2 + count
+ 6);
63 OUT_CS(CP_PACKET3(R200_3D_DRAW_IMMD_2
, count
));
64 OUT_CS(hwprim
| R300_PRIM_WALK_RING
|
65 (count
<< R300_PRIM_NUM_VERTICES_SHIFT
));
67 for (i
= 0; i
< count
; i
++) {
68 r300_emit_vertex(r300
, prim
->v
[i
]);
74 /* Just as an aside...
76 * Radeons can do many more primitives:
85 * The following were just the only ones in Draw. */
87 static void r300_emit_point(struct draw_stage
* draw
, struct prim_header
* prim
)
89 r300_emit_prim(draw
, prim
, R300_PRIM_TYPE_POINT
, 1);
92 static void r300_emit_line(struct draw_stage
* draw
, struct prim_header
* prim
)
94 r300_emit_prim(draw
, prim
, R300_PRIM_TYPE_LINE
, 2);
97 static void r300_emit_tri(struct draw_stage
* draw
, struct prim_header
* prim
)
99 r300_emit_prim(draw
, prim
, R300_PRIM_TYPE_TRI_LIST
, 3);
102 static void r300_swtcl_flush(struct draw_stage
* draw
, unsigned flags
)
106 static void r300_reset_stipple(struct draw_stage
* draw
)
111 static void r300_swtcl_destroy(struct draw_stage
* draw
)
116 struct draw_stage
* r300_draw_swtcl_stage(struct r300_context
* r300
)
118 struct swtcl_stage
* swtcl
= CALLOC_STRUCT(swtcl_stage
);
121 swtcl
->draw
.point
= r300_emit_point
;
122 swtcl
->draw
.line
= r300_emit_line
;
123 swtcl
->draw
.tri
= r300_emit_tri
;
124 swtcl
->draw
.flush
= r300_swtcl_flush
;
125 swtcl
->draw
.reset_stipple_counter
= r300_reset_stipple
;
126 swtcl
->draw
.destroy
= r300_swtcl_destroy
;