2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright 2009 Marek Olšák <maraeo@gmail.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
24 #include "draw/draw_context.h"
26 #include "util/u_math.h"
27 #include "util/u_memory.h"
29 #include "r300_context.h"
31 #include "r300_screen.h"
32 #include "r300_shader_semantics.h"
33 #include "r300_state.h"
34 #include "r300_state_derived.h"
35 #include "r300_state_inlines.h"
38 /* r300_state_derived: Various bits of state which are dependent upon
39 * currently bound CSO data. */
41 enum r300_rs_swizzle
{
47 static void r300_draw_emit_attrib(struct r300_context
* r300
,
48 enum attrib_emit emit
,
49 enum interp_mode interp
,
52 struct r300_vertex_shader
* vs
= r300
->vs_state
.state
;
53 struct tgsi_shader_info
* info
= &vs
->info
;
56 output
= draw_find_shader_output(r300
->draw
,
57 info
->output_semantic_name
[index
],
58 info
->output_semantic_index
[index
]);
59 draw_emit_vertex_attr(&r300
->vertex_info
, emit
, interp
, output
);
62 static void r300_draw_emit_all_attribs(struct r300_context
* r300
)
64 struct r300_vertex_shader
* vs
= r300
->vs_state
.state
;
65 struct r300_shader_semantics
* vs_outputs
= &vs
->outputs
;
69 if (vs_outputs
->pos
!= ATTR_UNUSED
) {
70 r300_draw_emit_attrib(r300
, EMIT_4F
, INTERP_PERSPECTIVE
,
77 if (vs_outputs
->psize
!= ATTR_UNUSED
) {
78 r300_draw_emit_attrib(r300
, EMIT_1F_PSIZE
, INTERP_POS
,
83 for (i
= 0; i
< ATTR_COLOR_COUNT
; i
++) {
84 if (vs_outputs
->color
[i
] != ATTR_UNUSED
) {
85 r300_draw_emit_attrib(r300
, EMIT_4F
, INTERP_LINEAR
,
86 vs_outputs
->color
[i
]);
90 /* XXX Back-face colors. */
92 /* Texture coordinates. */
93 /* Only 8 generic vertex attributes can be used. If there are more,
94 * they won't be rasterized. */
96 for (i
= 0; i
< ATTR_GENERIC_COUNT
&& gen_count
< 8; i
++) {
97 if (vs_outputs
->generic
[i
] != ATTR_UNUSED
) {
98 r300_draw_emit_attrib(r300
, EMIT_4F
, INTERP_PERSPECTIVE
,
99 vs_outputs
->generic
[i
]);
104 /* Fog coordinates. */
105 if (gen_count
< 8 && vs_outputs
->fog
!= ATTR_UNUSED
) {
106 r300_draw_emit_attrib(r300
, EMIT_4F
, INTERP_PERSPECTIVE
,
112 /* Update the PSC tables for SW TCL, using Draw. */
113 static void r300_swtcl_vertex_psc(struct r300_context
*r300
)
115 struct r300_vertex_stream_state
*vstream
= r300
->vertex_stream_state
.state
;
116 struct r300_vertex_shader
* vs
= r300
->vs_state
.state
;
117 struct vertex_info
* vinfo
= &r300
->vertex_info
;
118 uint16_t type
, swizzle
;
119 enum pipe_format format
;
120 unsigned i
, attrib_count
;
121 int* vs_output_tab
= vs
->stream_loc_notcl
;
124 memset(vstream
, 0, sizeof(struct r300_vertex_stream_state
));
126 /* For each Draw attribute, route it to the fragment shader according
127 * to the vs_output_tab. */
128 attrib_count
= vinfo
->num_attribs
;
129 DBG(r300
, DBG_DRAW
, "r300: attrib count: %d\n", attrib_count
);
130 for (i
= 0; i
< attrib_count
; i
++) {
131 DBG(r300
, DBG_DRAW
, "r300: attrib: offset %d, interp %d, size %d,"
132 " vs_output_tab %d\n", vinfo
->attrib
[i
].src_index
,
133 vinfo
->attrib
[i
].interp_mode
, vinfo
->attrib
[i
].emit
,
136 /* Make sure we have a proper destination for our attribute. */
137 assert(vs_output_tab
[i
] != -1);
139 format
= draw_translate_vinfo_format(vinfo
->attrib
[i
].emit
);
141 /* Obtain the type of data in this attribute. */
142 type
= r300_translate_vertex_data_type(format
) |
143 vs_output_tab
[i
] << R300_DST_VEC_LOC_SHIFT
;
145 /* Obtain the swizzle for this attribute. Note that the default
146 * swizzle in the hardware is not XYZW! */
147 swizzle
= r300_translate_vertex_data_swizzle(format
);
149 /* Add the attribute to the PSC table. */
151 vstream
->vap_prog_stream_cntl
[i
>> 1] |= type
<< 16;
152 vstream
->vap_prog_stream_cntl_ext
[i
>> 1] |= swizzle
<< 16;
154 vstream
->vap_prog_stream_cntl
[i
>> 1] |= type
;
155 vstream
->vap_prog_stream_cntl_ext
[i
>> 1] |= swizzle
;
159 /* Set the last vector in the PSC. */
163 vstream
->vap_prog_stream_cntl
[i
>> 1] |=
164 (R300_LAST_VEC
<< (i
& 1 ? 16 : 0));
166 vstream
->count
= (i
>> 1) + 1;
167 r300
->vertex_stream_state
.dirty
= TRUE
;
168 r300
->vertex_stream_state
.size
= (1 + vstream
->count
) * 2;
171 static void r300_rs_col(struct r300_rs_block
* rs
, int id
, int ptr
,
172 boolean swizzle_0001
)
174 rs
->ip
[id
] |= R300_RS_COL_PTR(ptr
);
176 rs
->ip
[id
] |= R300_RS_COL_FMT(R300_RS_COL_FMT_0001
);
178 rs
->ip
[id
] |= R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA
);
180 rs
->inst
[id
] |= R300_RS_INST_COL_ID(id
);
183 static void r300_rs_col_write(struct r300_rs_block
* rs
, int id
, int fp_offset
)
185 rs
->inst
[id
] |= R300_RS_INST_COL_CN_WRITE
|
186 R300_RS_INST_COL_ADDR(fp_offset
);
189 static void r300_rs_tex(struct r300_rs_block
* rs
, int id
, int ptr
,
190 enum r300_rs_swizzle swiz
)
192 if (swiz
== SWIZ_X001
) {
193 rs
->ip
[id
] |= R300_RS_TEX_PTR(ptr
*4) |
194 R300_RS_SEL_S(R300_RS_SEL_C0
) |
195 R300_RS_SEL_T(R300_RS_SEL_K0
) |
196 R300_RS_SEL_R(R300_RS_SEL_K0
) |
197 R300_RS_SEL_Q(R300_RS_SEL_K1
);
198 } else if (swiz
== SWIZ_XY01
) {
199 rs
->ip
[id
] |= R300_RS_TEX_PTR(ptr
*4) |
200 R300_RS_SEL_S(R300_RS_SEL_C0
) |
201 R300_RS_SEL_T(R300_RS_SEL_C1
) |
202 R300_RS_SEL_R(R300_RS_SEL_K0
) |
203 R300_RS_SEL_Q(R300_RS_SEL_K1
);
205 rs
->ip
[id
] |= R300_RS_TEX_PTR(ptr
*4) |
206 R300_RS_SEL_S(R300_RS_SEL_C0
) |
207 R300_RS_SEL_T(R300_RS_SEL_C1
) |
208 R300_RS_SEL_R(R300_RS_SEL_C2
) |
209 R300_RS_SEL_Q(R300_RS_SEL_C3
);
211 rs
->inst
[id
] |= R300_RS_INST_TEX_ID(id
);
214 static void r300_rs_tex_write(struct r300_rs_block
* rs
, int id
, int fp_offset
)
216 rs
->inst
[id
] |= R300_RS_INST_TEX_CN_WRITE
|
217 R300_RS_INST_TEX_ADDR(fp_offset
);
220 static void r500_rs_col(struct r300_rs_block
* rs
, int id
, int ptr
,
221 boolean swizzle_0001
)
223 rs
->ip
[id
] |= R500_RS_COL_PTR(ptr
);
225 rs
->ip
[id
] |= R500_RS_COL_FMT(R300_RS_COL_FMT_0001
);
227 rs
->ip
[id
] |= R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA
);
229 rs
->inst
[id
] |= R500_RS_INST_COL_ID(id
);
232 static void r500_rs_col_write(struct r300_rs_block
* rs
, int id
, int fp_offset
)
234 rs
->inst
[id
] |= R500_RS_INST_COL_CN_WRITE
|
235 R500_RS_INST_COL_ADDR(fp_offset
);
238 static void r500_rs_tex(struct r300_rs_block
* rs
, int id
, int ptr
,
239 enum r300_rs_swizzle swiz
)
241 int rs_tex_comp
= ptr
*4;
243 if (swiz
== SWIZ_X001
) {
244 rs
->ip
[id
] |= R500_RS_SEL_S(rs_tex_comp
) |
245 R500_RS_SEL_T(R500_RS_IP_PTR_K0
) |
246 R500_RS_SEL_R(R500_RS_IP_PTR_K0
) |
247 R500_RS_SEL_Q(R500_RS_IP_PTR_K1
);
248 } else if (swiz
== SWIZ_XY01
) {
249 rs
->ip
[id
] |= R500_RS_SEL_S(rs_tex_comp
) |
250 R500_RS_SEL_T(rs_tex_comp
+ 1) |
251 R500_RS_SEL_R(R500_RS_IP_PTR_K0
) |
252 R500_RS_SEL_Q(R500_RS_IP_PTR_K1
);
254 rs
->ip
[id
] |= R500_RS_SEL_S(rs_tex_comp
) |
255 R500_RS_SEL_T(rs_tex_comp
+ 1) |
256 R500_RS_SEL_R(rs_tex_comp
+ 2) |
257 R500_RS_SEL_Q(rs_tex_comp
+ 3);
259 rs
->inst
[id
] |= R500_RS_INST_TEX_ID(id
);
262 static void r500_rs_tex_write(struct r300_rs_block
* rs
, int id
, int fp_offset
)
264 rs
->inst
[id
] |= R500_RS_INST_TEX_CN_WRITE
|
265 R500_RS_INST_TEX_ADDR(fp_offset
);
268 /* Set up the RS block.
270 * This is the part of the chipset that actually does the rasterization
271 * of vertices into fragments. This is also the part of the chipset that
272 * locks up if any part of it is even slightly wrong. */
273 static void r300_update_rs_block(struct r300_context
* r300
,
274 struct r300_shader_semantics
* vs_outputs
,
275 struct r300_shader_semantics
* fs_inputs
)
277 struct r300_rs_block rs
= { { 0 } };
278 int i
, col_count
= 0, tex_count
= 0, fp_offset
= 0, count
;
279 void (*rX00_rs_col
)(struct r300_rs_block
*, int, int, boolean
);
280 void (*rX00_rs_col_write
)(struct r300_rs_block
*, int, int);
281 void (*rX00_rs_tex
)(struct r300_rs_block
*, int, int, enum r300_rs_swizzle
);
282 void (*rX00_rs_tex_write
)(struct r300_rs_block
*, int, int);
283 boolean any_bcolor_used
= vs_outputs
->bcolor
[0] != ATTR_UNUSED
||
284 vs_outputs
->bcolor
[1] != ATTR_UNUSED
;
286 if (r300
->screen
->caps
.is_r500
) {
287 rX00_rs_col
= r500_rs_col
;
288 rX00_rs_col_write
= r500_rs_col_write
;
289 rX00_rs_tex
= r500_rs_tex
;
290 rX00_rs_tex_write
= r500_rs_tex_write
;
292 rX00_rs_col
= r300_rs_col
;
293 rX00_rs_col_write
= r300_rs_col_write
;
294 rX00_rs_tex
= r300_rs_tex
;
295 rX00_rs_tex_write
= r300_rs_tex_write
;
298 /* Rasterize colors. */
299 for (i
= 0; i
< ATTR_COLOR_COUNT
; i
++) {
300 if (vs_outputs
->color
[i
] != ATTR_UNUSED
|| any_bcolor_used
||
301 vs_outputs
->color
[1] != ATTR_UNUSED
) {
302 /* Always rasterize if it's written by the VS,
303 * otherwise it locks up. */
304 rX00_rs_col(&rs
, col_count
, i
, FALSE
);
306 /* Write it to the FS input register if it's used by the FS. */
307 if (fs_inputs
->color
[i
] != ATTR_UNUSED
) {
308 rX00_rs_col_write(&rs
, col_count
, fp_offset
);
313 /* Skip the FS input register, leave it uninitialized. */
314 /* If we try to set it to (0,0,0,1), it will lock up. */
315 if (fs_inputs
->color
[i
] != ATTR_UNUSED
) {
321 /* Rasterize texture coordinates. */
322 for (i
= 0; i
< ATTR_GENERIC_COUNT
; i
++) {
323 bool sprite_coord
= !!(r300
->sprite_coord_enable
& (1 << i
));
325 if (vs_outputs
->generic
[i
] != ATTR_UNUSED
|| sprite_coord
) {
326 /* Always rasterize if it's written by the VS,
327 * otherwise it locks up. */
328 rX00_rs_tex(&rs
, tex_count
, tex_count
,
329 sprite_coord
? SWIZ_XY01
: SWIZ_XYZW
);
331 /* Write it to the FS input register if it's used by the FS. */
332 if (fs_inputs
->generic
[i
] != ATTR_UNUSED
) {
333 rX00_rs_tex_write(&rs
, tex_count
, fp_offset
);
335 debug_printf("r300: SpriteCoord (generic index %i) is being written to reg %i\n", i
, fp_offset
);
340 /* Skip the FS input register, leave it uninitialized. */
341 /* If we try to set it to (0,0,0,1), it will lock up. */
342 if (fs_inputs
->generic
[i
] != ATTR_UNUSED
) {
348 /* Rasterize fog coordinates. */
349 if (vs_outputs
->fog
!= ATTR_UNUSED
) {
350 /* Always rasterize if it's written by the VS,
351 * otherwise it locks up. */
352 rX00_rs_tex(&rs
, tex_count
, tex_count
, SWIZ_X001
);
354 /* Write it to the FS input register if it's used by the FS. */
355 if (fs_inputs
->fog
!= ATTR_UNUSED
) {
356 rX00_rs_tex_write(&rs
, tex_count
, fp_offset
);
361 /* Skip the FS input register, leave it uninitialized. */
362 /* If we try to set it to (0,0,0,1), it will lock up. */
363 if (fs_inputs
->fog
!= ATTR_UNUSED
) {
368 /* Rasterize WPOS. */
369 /* If the FS doesn't need it, it's not written by the VS. */
370 if (vs_outputs
->wpos
!= ATTR_UNUSED
&& fs_inputs
->wpos
!= ATTR_UNUSED
) {
371 rX00_rs_tex(&rs
, tex_count
, tex_count
, SWIZ_XYZW
);
372 rX00_rs_tex_write(&rs
, tex_count
, fp_offset
);
378 /* Rasterize at least one color, or bad things happen. */
379 if (col_count
== 0 && tex_count
== 0) {
380 rX00_rs_col(&rs
, 0, 0, TRUE
);
384 rs
.count
= (tex_count
*4) | (col_count
<< R300_IC_COUNT_SHIFT
) |
387 count
= MAX3(col_count
, tex_count
, 1);
388 rs
.inst_count
= count
- 1;
390 /* Now, after all that, see if we actually need to update the state. */
391 if (memcmp(r300
->rs_block_state
.state
, &rs
, sizeof(struct r300_rs_block
))) {
392 memcpy(r300
->rs_block_state
.state
, &rs
, sizeof(struct r300_rs_block
));
393 r300
->rs_block_state
.size
= 5 + count
*2;
397 /* Update the shader-dependant states. */
398 static void r300_update_derived_shader_state(struct r300_context
* r300
)
400 struct r300_vertex_shader
* vs
= r300
->vs_state
.state
;
402 r300_update_rs_block(r300
, &vs
->outputs
, &r300_fs(r300
)->shader
->inputs
);
405 static boolean
r300_dsa_writes_depth_stencil(struct r300_dsa_state
* dsa
)
407 /* We are interested only in the cases when a new depth or stencil value
408 * can be written and changed. */
410 /* We might optionally check for [Z func: never] and inspect the stencil
411 * state in a similar fashion, but it's not terribly important. */
412 return (dsa
->z_buffer_control
& R300_Z_WRITE_ENABLE
) ||
413 (dsa
->stencil_ref_mask
& R300_STENCILWRITEMASK_MASK
) ||
414 ((dsa
->z_buffer_control
& R500_STENCIL_REFMASK_FRONT_BACK
) &&
415 (dsa
->stencil_ref_bf
& R300_STENCILWRITEMASK_MASK
));
418 static boolean
r300_dsa_alpha_test_enabled(struct r300_dsa_state
* dsa
)
420 /* We are interested only in the cases when alpha testing can kill
422 uint32_t af
= dsa
->alpha_function
;
424 return (af
& R300_FG_ALPHA_FUNC_ENABLE
) &&
425 (af
& R300_FG_ALPHA_FUNC_ALWAYS
) != R300_FG_ALPHA_FUNC_ALWAYS
;
428 static void r300_update_ztop(struct r300_context
* r300
)
430 struct r300_ztop_state
* ztop_state
=
431 (struct r300_ztop_state
*)r300
->ztop_state
.state
;
433 /* This is important enough that I felt it warranted a comment.
435 * According to the docs, these are the conditions where ZTOP must be
437 * 1) Alpha testing enabled
438 * 2) Texture kill instructions in fragment shader
439 * 3) Chroma key culling enabled
440 * 4) W-buffering enabled
442 * The docs claim that for the first three cases, if no ZS writes happen,
443 * then ZTOP can be used.
445 * (3) will never apply since we do not support chroma-keyed operations.
446 * (4) will need to be re-examined (and this comment updated) if/when
447 * Hyper-Z becomes supported.
449 * Additionally, the following conditions require disabled ZTOP:
450 * 5) Depth writes in fragment shader
451 * 6) Outstanding occlusion queries
453 * This register causes stalls all the way from SC to CB when changed,
454 * but it is buffered on-chip so it does not hurt to write it if it has
461 if (r300_dsa_writes_depth_stencil(r300
->dsa_state
.state
) &&
462 (r300_dsa_alpha_test_enabled(r300
->dsa_state
.state
) || /* (1) */
463 r300_fs(r300
)->shader
->info
.uses_kill
)) { /* (2) */
464 ztop_state
->z_buffer_top
= R300_ZTOP_DISABLE
;
465 } else if (r300_fragment_shader_writes_depth(r300_fs(r300
))) { /* (5) */
466 ztop_state
->z_buffer_top
= R300_ZTOP_DISABLE
;
467 } else if (r300
->query_current
) { /* (6) */
468 ztop_state
->z_buffer_top
= R300_ZTOP_DISABLE
;
470 ztop_state
->z_buffer_top
= R300_ZTOP_ENABLE
;
473 r300
->ztop_state
.dirty
= TRUE
;
476 static void r300_merge_textures_and_samplers(struct r300_context
* r300
)
478 struct r300_textures_state
*state
=
479 (struct r300_textures_state
*)r300
->textures_state
.state
;
480 struct r300_texture_sampler_state
*texstate
;
481 struct r300_sampler_state
*sampler
;
482 struct r300_sampler_view
*view
;
483 struct r300_texture
*tex
;
484 unsigned min_level
, max_level
, i
, size
;
485 unsigned count
= MIN2(state
->sampler_view_count
,
486 state
->sampler_state_count
);
488 state
->tx_enable
= 0;
492 for (i
= 0; i
< count
; i
++) {
493 if (state
->sampler_views
[i
] && state
->sampler_states
[i
]) {
494 state
->tx_enable
|= 1 << i
;
496 view
= state
->sampler_views
[i
];
497 tex
= r300_texture(view
->base
.texture
);
498 sampler
= state
->sampler_states
[i
];
500 texstate
= &state
->regs
[i
];
501 texstate
->format
= view
->format
;
502 texstate
->filter0
= sampler
->filter0
;
503 texstate
->filter1
= sampler
->filter1
;
504 texstate
->border_color
= sampler
->border_color
;
506 /* to emulate 1D textures through 2D ones correctly */
507 if (tex
->b
.b
.target
== PIPE_TEXTURE_1D
) {
508 texstate
->filter0
&= ~R300_TX_WRAP_T_MASK
;
509 texstate
->filter0
|= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE
);
512 if (tex
->uses_pitch
) {
513 /* NPOT textures don't support mip filter, unfortunately.
514 * This prevents incorrect rendering. */
515 texstate
->filter0
&= ~R300_TX_MIN_FILTER_MIP_MASK
;
517 /* Mask out the mirrored flag. */
518 if (texstate
->filter0
& R300_TX_WRAP_S(R300_TX_MIRRORED
)) {
519 texstate
->filter0
&= ~R300_TX_WRAP_S(R300_TX_MIRRORED
);
521 if (texstate
->filter0
& R300_TX_WRAP_T(R300_TX_MIRRORED
)) {
522 texstate
->filter0
&= ~R300_TX_WRAP_T(R300_TX_MIRRORED
);
525 /* Change repeat to clamp-to-edge.
526 * (the repeat bit has a value of 0, no masking needed). */
527 if ((texstate
->filter0
& R300_TX_WRAP_S_MASK
) ==
528 R300_TX_WRAP_S(R300_TX_REPEAT
)) {
529 texstate
->filter0
|= R300_TX_WRAP_S(R300_TX_CLAMP_TO_EDGE
);
531 if ((texstate
->filter0
& R300_TX_WRAP_T_MASK
) ==
532 R300_TX_WRAP_T(R300_TX_REPEAT
)) {
533 texstate
->filter0
|= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE
);
536 /* determine min/max levels */
537 /* the MAX_MIP level is the largest (finest) one */
538 max_level
= MIN3(sampler
->max_lod
+ view
->base
.first_level
,
539 tex
->b
.b
.last_level
, view
->base
.last_level
);
540 min_level
= MIN2(sampler
->min_lod
+ view
->base
.first_level
,
542 texstate
->format
.format0
|= R300_TX_NUM_LEVELS(max_level
);
543 texstate
->filter0
|= R300_TX_MAX_MIP_LEVEL(min_level
);
546 texstate
->filter0
|= i
<< 28;
553 r300
->textures_state
.size
= size
;
555 /* Pick a fragment shader based on either the texture compare state
556 * or the uses_pitch flag. */
557 if (r300
->fs
.state
&& count
) {
558 if (r300_pick_fragment_shader(r300
)) {
559 r300_mark_fs_code_dirty(r300
);
564 void r300_update_derived_state(struct r300_context
* r300
)
566 if (r300
->textures_state
.dirty
) {
567 r300_merge_textures_and_samplers(r300
);
570 if (r300
->rs_block_state
.dirty
) {
571 r300_update_derived_shader_state(r300
);
575 memset(&r300
->vertex_info
, 0, sizeof(struct vertex_info
));
576 r300_draw_emit_all_attribs(r300
);
577 draw_compute_vertex_size(&r300
->vertex_info
);
578 r300_swtcl_vertex_psc(r300
);
581 r300_update_ztop(r300
);