1 #include "pipe/p_state.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_util.h"
5 #include "nv30_context.h"
6 #include "nv30_state.h"
9 nv30_blend_state_create(struct pipe_context
*pipe
,
10 const struct pipe_blend_state
*cso
)
12 struct nv30_blend_state
*cb
;
14 cb
= malloc(sizeof(struct nv30_blend_state
));
16 cb
->b_enable
= cso
->blend_enable
? 1 : 0;
17 cb
->b_srcfunc
= ((nvgl_blend_func(cso
->alpha_src_factor
)<<16) |
18 (nvgl_blend_func(cso
->rgb_src_factor
)));
19 cb
->b_dstfunc
= ((nvgl_blend_func(cso
->alpha_dst_factor
)<<16) |
20 (nvgl_blend_func(cso
->rgb_dst_factor
)));
21 cb
->b_eqn
= ((nvgl_blend_eqn(cso
->alpha_func
) << 16) |
22 (nvgl_blend_eqn(cso
->rgb_func
)));
24 cb
->l_enable
= cso
->logicop_enable
? 1 : 0;
25 cb
->l_op
= nvgl_logicop_func(cso
->logicop_func
);
27 cb
->c_mask
= (((cso
->colormask
& PIPE_MASK_A
) ? (0x01<<24) : 0) |
28 ((cso
->colormask
& PIPE_MASK_R
) ? (0x01<<16) : 0) |
29 ((cso
->colormask
& PIPE_MASK_G
) ? (0x01<< 8) : 0) |
30 ((cso
->colormask
& PIPE_MASK_B
) ? (0x01<< 0) : 0));
32 cb
->d_enable
= cso
->dither
? 1 : 0;
38 nv30_blend_state_bind(struct pipe_context
*pipe
, void *hwcso
)
40 struct nv30_context
*nv30
= nv30_context(pipe
);
41 struct nv30_blend_state
*cb
= hwcso
;
43 BEGIN_RING(rankine
, NV34TCL_DITHER_ENABLE
, 1);
44 OUT_RING (cb
->d_enable
);
46 BEGIN_RING(rankine
, NV34TCL_BLEND_FUNC_ENABLE
, 3);
47 OUT_RING (cb
->b_enable
);
48 OUT_RING (cb
->b_srcfunc
);
49 OUT_RING (cb
->b_dstfunc
);
50 BEGIN_RING(rankine
, NV34TCL_BLEND_FUNC_EQUATION
, 1);
53 BEGIN_RING(rankine
, NV34TCL_COLOR_MASK
, 1);
54 OUT_RING (cb
->c_mask
);
56 BEGIN_RING(rankine
, NV34TCL_COLOR_LOGIC_OP_ENABLE
, 2);
57 OUT_RING (cb
->l_enable
);
62 nv30_blend_state_delete(struct pipe_context
*pipe
, void *hwcso
)
68 static INLINE
unsigned
69 wrap_mode(unsigned wrap
) {
73 case PIPE_TEX_WRAP_REPEAT
:
74 ret
= NV34TCL_TX_WRAP_S_REPEAT
;
76 case PIPE_TEX_WRAP_MIRROR_REPEAT
:
77 ret
= NV34TCL_TX_WRAP_S_MIRRORED_REPEAT
;
79 case PIPE_TEX_WRAP_CLAMP_TO_EDGE
:
80 ret
= NV34TCL_TX_WRAP_S_CLAMP_TO_EDGE
;
82 case PIPE_TEX_WRAP_CLAMP_TO_BORDER
:
83 ret
= NV34TCL_TX_WRAP_S_CLAMP_TO_BORDER
;
85 case PIPE_TEX_WRAP_CLAMP
:
86 ret
= NV34TCL_TX_WRAP_S_CLAMP
;
88 /* case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
89 ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP_TO_EDGE;
91 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
92 ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP_TO_BORDER;
94 case PIPE_TEX_WRAP_MIRROR_CLAMP:
95 ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP;
98 NOUVEAU_ERR("unknown wrap mode: %d\n", wrap
);
99 ret
= NV34TCL_TX_WRAP_S_REPEAT
;
103 return ret
>> NV34TCL_TX_WRAP_S_SHIFT
;
107 nv30_sampler_state_create(struct pipe_context
*pipe
,
108 const struct pipe_sampler_state
*cso
)
110 struct nv30_sampler_state
*ps
;
113 ps
= malloc(sizeof(struct nv30_sampler_state
));
116 if (!cso
->normalized_coords
)
117 ps
->fmt
|= NV34TCL_TX_FORMAT_RECT
;
119 ps
->wrap
= ((wrap_mode(cso
->wrap_s
) << NV34TCL_TX_WRAP_S_SHIFT
) |
120 (wrap_mode(cso
->wrap_t
) << NV34TCL_TX_WRAP_T_SHIFT
) |
121 (wrap_mode(cso
->wrap_r
) << NV34TCL_TX_WRAP_R_SHIFT
));
124 if (cso
->max_anisotropy
>= 2.0) {
125 /* no idea, binary driver sets it, works without it.. meh.. */
126 ps
->wrap
|= (1 << 5);
128 /* if (cso->max_anisotropy >= 16.0) {
129 ps->en |= NV34TCL_TX_ENABLE_ANISO_16X;
131 if (cso->max_anisotropy >= 12.0) {
132 ps->en |= NV34TCL_TX_ENABLE_ANISO_12X;
134 if (cso->max_anisotropy >= 10.0) {
135 ps->en |= NV34TCL_TX_ENABLE_ANISO_10X;
137 if (cso->max_anisotropy >= 8.0) {
138 ps->en |= NV34TCL_TX_ENABLE_ANISO_8X;
140 if (cso->max_anisotropy >= 6.0) {
141 ps->en |= NV34TCL_TX_ENABLE_ANISO_6X;
143 if (cso->max_anisotropy >= 4.0) {
144 ps->en |= NV34TCL_TX_ENABLE_ANISO_4X;
146 ps->en |= NV34TCL_TX_ENABLE_ANISO_2X;
150 switch (cso
->mag_img_filter
) {
151 case PIPE_TEX_FILTER_LINEAR
:
152 filter
|= NV34TCL_TX_FILTER_MAGNIFY_LINEAR
;
154 case PIPE_TEX_FILTER_NEAREST
:
156 filter
|= NV34TCL_TX_FILTER_MAGNIFY_NEAREST
;
160 switch (cso
->min_img_filter
) {
161 case PIPE_TEX_FILTER_LINEAR
:
162 switch (cso
->min_mip_filter
) {
163 case PIPE_TEX_MIPFILTER_NEAREST
:
164 filter
|= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST
;
166 case PIPE_TEX_MIPFILTER_LINEAR
:
167 filter
|= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR
;
169 case PIPE_TEX_MIPFILTER_NONE
:
171 filter
|= NV34TCL_TX_FILTER_MINIFY_LINEAR
;
175 case PIPE_TEX_FILTER_NEAREST
:
177 switch (cso
->min_mip_filter
) {
178 case PIPE_TEX_MIPFILTER_NEAREST
:
179 filter
|= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST
;
181 case PIPE_TEX_MIPFILTER_LINEAR
:
182 filter
|= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR
;
184 case PIPE_TEX_MIPFILTER_NONE
:
186 filter
|= NV34TCL_TX_FILTER_MINIFY_NEAREST
;
194 /* if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
195 switch (cso->compare_func) {
196 case PIPE_FUNC_NEVER:
197 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NEVER;
199 case PIPE_FUNC_GREATER:
200 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GREATER;
202 case PIPE_FUNC_EQUAL:
203 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_EQUAL;
205 case PIPE_FUNC_GEQUAL:
206 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GEQUAL;
209 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LESS;
211 case PIPE_FUNC_NOTEQUAL:
212 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NOTEQUAL;
214 case PIPE_FUNC_LEQUAL:
215 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LEQUAL;
217 case PIPE_FUNC_ALWAYS:
218 ps->wrap |= NV34TCL_TX_WRAP_RCOMP_ALWAYS;
225 ps
->bcol
= ((float_to_ubyte(cso
->border_color
[3]) << 24) |
226 (float_to_ubyte(cso
->border_color
[0]) << 16) |
227 (float_to_ubyte(cso
->border_color
[1]) << 8) |
228 (float_to_ubyte(cso
->border_color
[2]) << 0));
234 nv30_sampler_state_bind(struct pipe_context
*pipe
, unsigned unit
,
237 struct nv30_context
*nv30
= nv30_context(pipe
);
238 struct nv30_sampler_state
*ps
= hwcso
;
240 nv30
->tex_sampler
[unit
] = ps
;
241 nv30
->dirty_samplers
|= (1 << unit
);
245 nv30_sampler_state_delete(struct pipe_context
*pipe
, void *hwcso
)
251 nv30_set_sampler_texture(struct pipe_context
*pipe
, unsigned unit
,
252 struct pipe_texture
*miptree
)
254 struct nv30_context
*nv30
= nv30_context(pipe
);
256 nv30
->tex_miptree
[unit
] = (struct nv30_miptree
*)miptree
;
257 nv30
->dirty_samplers
|= (1 << unit
);
261 nv30_rasterizer_state_create(struct pipe_context
*pipe
,
262 const struct pipe_rasterizer_state
*cso
)
264 struct nv30_rasterizer_state
*rs
;
269 * offset_cw/ccw -nohw
273 * offset_units / offset_scale
275 rs
= malloc(sizeof(struct nv30_rasterizer_state
));
277 rs
->shade_model
= cso
->flatshade
? 0x1d00 : 0x1d01;
279 rs
->line_width
= (unsigned char)(cso
->line_width
* 8.0) & 0xff;
280 rs
->line_smooth_en
= cso
->line_smooth
? 1 : 0;
281 rs
->line_stipple_en
= cso
->line_stipple_enable
? 1 : 0;
282 rs
->line_stipple
= (cso
->line_stipple_pattern
<< 16) |
283 cso
->line_stipple_factor
;
285 rs
->point_size
= *(uint32_t*)&cso
->point_size
;
287 rs
->poly_smooth_en
= cso
->poly_smooth
? 1 : 0;
288 rs
->poly_stipple_en
= cso
->poly_stipple_enable
? 1 : 0;
290 if (cso
->front_winding
== PIPE_WINDING_CCW
) {
291 rs
->front_face
= NV34TCL_FRONT_FACE_CCW
;
292 rs
->poly_mode_front
= nvgl_polygon_mode(cso
->fill_ccw
);
293 rs
->poly_mode_back
= nvgl_polygon_mode(cso
->fill_cw
);
295 rs
->front_face
= NV34TCL_FRONT_FACE_CW
;
296 rs
->poly_mode_front
= nvgl_polygon_mode(cso
->fill_cw
);
297 rs
->poly_mode_back
= nvgl_polygon_mode(cso
->fill_ccw
);
300 switch (cso
->cull_mode
) {
301 case PIPE_WINDING_CCW
:
302 rs
->cull_face_en
= 1;
303 if (cso
->front_winding
== PIPE_WINDING_CCW
)
304 rs
->cull_face
= NV34TCL_CULL_FACE_FRONT
;
306 rs
->cull_face
= NV34TCL_CULL_FACE_BACK
;
308 case PIPE_WINDING_CW
:
309 rs
->cull_face_en
= 1;
310 if (cso
->front_winding
== PIPE_WINDING_CW
)
311 rs
->cull_face
= NV34TCL_CULL_FACE_FRONT
;
313 rs
->cull_face
= NV34TCL_CULL_FACE_BACK
;
315 case PIPE_WINDING_BOTH
:
316 rs
->cull_face_en
= 1;
317 rs
->cull_face
= NV34TCL_CULL_FACE_FRONT_AND_BACK
;
319 case PIPE_WINDING_NONE
:
321 rs
->cull_face_en
= 0;
326 if (cso
->point_sprite
) {
327 rs
->point_sprite
= (1 << 0);
328 for (i
= 0; i
< 8; i
++) {
329 if (cso
->sprite_coord_mode
[i
] != PIPE_SPRITE_COORD_NONE
)
330 rs
->point_sprite
|= (1 << (8 + i
));
333 rs
->point_sprite
= 0;
340 nv30_rasterizer_state_bind(struct pipe_context
*pipe
, void *hwcso
)
342 struct nv30_context
*nv30
= nv30_context(pipe
);
343 struct nv30_rasterizer_state
*rs
= hwcso
;
345 BEGIN_RING(rankine
, NV34TCL_SHADE_MODEL
, 1);
346 OUT_RING (rs
->shade_model
);
348 BEGIN_RING(rankine
, NV34TCL_LINE_WIDTH
, 2);
349 OUT_RING (rs
->line_width
);
350 OUT_RING (rs
->line_smooth_en
);
351 BEGIN_RING(rankine
, NV34TCL_LINE_STIPPLE_ENABLE
, 2);
352 OUT_RING (rs
->line_stipple_en
);
353 OUT_RING (rs
->line_stipple
);
355 BEGIN_RING(rankine
, NV34TCL_POINT_SIZE
, 1);
356 OUT_RING (rs
->point_size
);
358 BEGIN_RING(rankine
, NV34TCL_POLYGON_MODE_FRONT
, 6);
359 OUT_RING (rs
->poly_mode_front
);
360 OUT_RING (rs
->poly_mode_back
);
361 OUT_RING (rs
->cull_face
);
362 OUT_RING (rs
->front_face
);
363 OUT_RING (rs
->poly_smooth_en
);
364 OUT_RING (rs
->cull_face_en
);
366 BEGIN_RING(rankine
, NV34TCL_POLYGON_STIPPLE_ENABLE
, 1);
367 OUT_RING (rs
->poly_stipple_en
);
369 BEGIN_RING(rankine
, NV34TCL_POINT_SPRITE
, 1);
370 OUT_RING (rs
->point_sprite
);
374 nv30_rasterizer_state_delete(struct pipe_context
*pipe
, void *hwcso
)
380 nv30_translate_stencil(const struct pipe_depth_stencil_alpha_state
*cso
,
381 unsigned idx
, struct nv30_stencil_push
*hw
)
383 hw
->enable
= cso
->stencil
[idx
].enabled
? 1 : 0;
384 hw
->wmask
= cso
->stencil
[idx
].write_mask
;
385 hw
->func
= nvgl_comparison_op(cso
->stencil
[idx
].func
);
386 hw
->ref
= cso
->stencil
[idx
].ref_value
;
387 hw
->vmask
= cso
->stencil
[idx
].value_mask
;
388 hw
->fail
= nvgl_stencil_op(cso
->stencil
[idx
].fail_op
);
389 hw
->zfail
= nvgl_stencil_op(cso
->stencil
[idx
].zfail_op
);
390 hw
->zpass
= nvgl_stencil_op(cso
->stencil
[idx
].zpass_op
);
394 nv30_depth_stencil_alpha_state_create(struct pipe_context
*pipe
,
395 const struct pipe_depth_stencil_alpha_state
*cso
)
397 struct nv30_depth_stencil_alpha_state
*hw
;
399 hw
= malloc(sizeof(struct nv30_depth_stencil_alpha_state
));
401 hw
->depth
.func
= nvgl_comparison_op(cso
->depth
.func
);
402 hw
->depth
.write_enable
= cso
->depth
.writemask
? 1 : 0;
403 hw
->depth
.test_enable
= cso
->depth
.enabled
? 1 : 0;
405 nv30_translate_stencil(cso
, 0, &hw
->stencil
.front
);
406 nv30_translate_stencil(cso
, 1, &hw
->stencil
.back
);
408 hw
->alpha
.enabled
= cso
->alpha
.enabled
? 1 : 0;
409 hw
->alpha
.func
= nvgl_comparison_op(cso
->alpha
.func
);
410 hw
->alpha
.ref
= float_to_ubyte(cso
->alpha
.ref
);
416 nv30_depth_stencil_alpha_state_bind(struct pipe_context
*pipe
, void *hwcso
)
418 struct nv30_context
*nv30
= nv30_context(pipe
);
419 struct nv30_depth_stencil_alpha_state
*hw
= hwcso
;
421 BEGIN_RING(rankine
, NV34TCL_DEPTH_FUNC
, 3);
422 OUT_RINGp ((uint32_t *)&hw
->depth
, 3);
423 BEGIN_RING(rankine
, NV34TCL_STENCIL_BACK_ENABLE
, 16);
424 OUT_RINGp ((uint32_t *)&hw
->stencil
.back
, 8);
425 OUT_RINGp ((uint32_t *)&hw
->stencil
.front
, 8);
426 BEGIN_RING(rankine
, NV34TCL_ALPHA_FUNC_ENABLE
, 3);
427 OUT_RINGp ((uint32_t *)&hw
->alpha
.enabled
, 3);
431 nv30_depth_stencil_alpha_state_delete(struct pipe_context
*pipe
, void *hwcso
)
437 nv30_vp_state_create(struct pipe_context
*pipe
,
438 const struct pipe_shader_state
*cso
)
440 struct nv30_vertex_program
*vp
;
442 vp
= CALLOC(1, sizeof(struct nv30_vertex_program
));
449 nv30_vp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
451 struct nv30_context
*nv30
= nv30_context(pipe
);
452 struct nv30_vertex_program
*vp
= hwcso
;
454 nv30
->vertprog
.current
= vp
;
455 nv30
->dirty
|= NV30_NEW_VERTPROG
;
459 nv30_vp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
461 struct nv30_context
*nv30
= nv30_context(pipe
);
462 struct nv30_vertex_program
*vp
= hwcso
;
464 nv30_vertprog_destroy(nv30
, vp
);
469 nv30_fp_state_create(struct pipe_context
*pipe
,
470 const struct pipe_shader_state
*cso
)
472 struct nv30_fragment_program
*fp
;
474 fp
= CALLOC(1, sizeof(struct nv30_fragment_program
));
481 nv30_fp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
483 struct nv30_context
*nv30
= nv30_context(pipe
);
484 struct nv30_fragment_program
*fp
= hwcso
;
486 nv30
->fragprog
.current
= fp
;
487 nv30
->dirty
|= NV30_NEW_FRAGPROG
;
491 nv30_fp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
493 struct nv30_context
*nv30
= nv30_context(pipe
);
494 struct nv30_fragment_program
*fp
= hwcso
;
496 nv30_fragprog_destroy(nv30
, fp
);
501 nv30_set_blend_color(struct pipe_context
*pipe
,
502 const struct pipe_blend_color
*bcol
)
504 struct nv30_context
*nv30
= nv30_context(pipe
);
506 BEGIN_RING(rankine
, NV34TCL_BLEND_FUNC_COLOR
, 1);
507 OUT_RING ((float_to_ubyte(bcol
->color
[3]) << 24) |
508 (float_to_ubyte(bcol
->color
[0]) << 16) |
509 (float_to_ubyte(bcol
->color
[1]) << 8) |
510 (float_to_ubyte(bcol
->color
[2]) << 0));
514 nv30_set_clip_state(struct pipe_context
*pipe
,
515 const struct pipe_clip_state
*clip
)
520 nv30_set_constant_buffer(struct pipe_context
*pipe
, uint shader
, uint index
,
521 const struct pipe_constant_buffer
*buf
)
523 struct nv30_context
*nv30
= nv30_context(pipe
);
525 if (shader
== PIPE_SHADER_VERTEX
) {
526 nv30
->vertprog
.constant_buf
= buf
->buffer
;
527 nv30
->dirty
|= NV30_NEW_VERTPROG
;
529 if (shader
== PIPE_SHADER_FRAGMENT
) {
530 nv30
->fragprog
.constant_buf
= buf
->buffer
;
531 nv30
->dirty
|= NV30_NEW_FRAGPROG
;
536 nv30_set_framebuffer_state(struct pipe_context
*pipe
,
537 const struct pipe_framebuffer_state
*fb
)
539 struct nv30_context
*nv30
= nv30_context(pipe
);
540 struct pipe_surface
*rt
[4], *zeta
= NULL
;
541 uint32_t rt_enable
, rt_format
, w
= 0, h
= 0;
542 int i
, colour_format
= 0, zeta_format
= 0;
545 for (i
= 0; i
< 4; i
++) {
550 assert(w
== fb
->cbufs
[i
]->width
);
551 assert(h
== fb
->cbufs
[i
]->height
);
552 assert(colour_format
== fb
->cbufs
[i
]->format
);
554 w
= fb
->cbufs
[i
]->width
;
555 h
= fb
->cbufs
[i
]->height
;
556 colour_format
= fb
->cbufs
[i
]->format
;
557 rt_enable
|= (NV34TCL_RT_ENABLE_COLOR0
<< i
);
558 rt
[i
] = fb
->cbufs
[i
];
562 if (rt_enable
& (NV34TCL_RT_ENABLE_COLOR1
| NV34TCL_RT_ENABLE_COLOR2
|
563 NV34TCL_RT_ENABLE_COLOR3
))
564 rt_enable
|= NV34TCL_RT_ENABLE_MRT
;
568 assert(w
== fb
->zsbuf
->width
);
569 assert(h
== fb
->zsbuf
->height
);
571 w
= fb
->zsbuf
->width
;
572 h
= fb
->zsbuf
->height
;
575 zeta_format
= fb
->zsbuf
->format
;
579 rt_format
= NV34TCL_RT_FORMAT_TYPE_LINEAR
;
581 switch (colour_format
) {
582 case PIPE_FORMAT_A8R8G8B8_UNORM
:
584 rt_format
|= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8
;
586 case PIPE_FORMAT_R5G6B5_UNORM
:
587 rt_format
|= NV34TCL_RT_FORMAT_COLOR_R5G6B5
;
593 switch (zeta_format
) {
594 case PIPE_FORMAT_Z16_UNORM
:
595 rt_format
|= NV34TCL_RT_FORMAT_ZETA_Z16
;
597 case PIPE_FORMAT_Z24S8_UNORM
:
599 rt_format
|= NV34TCL_RT_FORMAT_ZETA_Z24S8
;
605 if (rt_enable
& NV34TCL_RT_ENABLE_COLOR0
) {
606 uint32_t pitch
= rt
[0]->pitch
* rt
[0]->cpp
;
608 pitch
|= (zeta
->pitch
* zeta
->cpp
)<<16;
613 BEGIN_RING(rankine
, NV34TCL_COLOR0_PITCH
, 1);
615 nv30
->rt
[0] = rt
[0]->buffer
;
618 if (rt_enable
& NV34TCL_RT_ENABLE_COLOR1
) {
619 BEGIN_RING(rankine
, NV34TCL_COLOR1_PITCH
, 1);
620 OUT_RING (rt
[1]->pitch
* rt
[1]->cpp
);
621 nv30
->rt
[1] = rt
[1]->buffer
;
626 nv30
->zeta
= zeta
->buffer
;
629 nv30
->rt_enable
= rt_enable
;
630 BEGIN_RING(rankine
, NV34TCL_RT_ENABLE
, 1);
631 OUT_RING (rt_enable
);
632 BEGIN_RING(rankine
, NV34TCL_RT_HORIZ
, 3);
633 OUT_RING ((w
<< 16) | 0);
634 OUT_RING ((h
<< 16) | 0);
635 OUT_RING (rt_format
);
636 BEGIN_RING(rankine
, NV34TCL_VIEWPORT_HORIZ
, 2);
637 OUT_RING ((w
<< 16) | 0);
638 OUT_RING ((h
<< 16) | 0);
639 BEGIN_RING(rankine
, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
640 OUT_RING (((w
- 1) << 16) | 0);
641 OUT_RING (((h
- 1) << 16) | 0);
645 nv30_set_polygon_stipple(struct pipe_context
*pipe
,
646 const struct pipe_poly_stipple
*stipple
)
648 struct nv30_context
*nv30
= nv30_context(pipe
);
650 BEGIN_RING(rankine
, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
651 OUT_RINGp ((uint32_t *)stipple
->stipple
, 32);
655 nv30_set_scissor_state(struct pipe_context
*pipe
,
656 const struct pipe_scissor_state
*s
)
658 struct nv30_context
*nv30
= nv30_context(pipe
);
660 BEGIN_RING(rankine
, NV34TCL_SCISSOR_HORIZ
, 2);
661 OUT_RING (((s
->maxx
- s
->minx
) << 16) | s
->minx
);
662 OUT_RING (((s
->maxy
- s
->miny
) << 16) | s
->miny
);
666 nv30_set_viewport_state(struct pipe_context
*pipe
,
667 const struct pipe_viewport_state
*vpt
)
669 struct nv30_context
*nv30
= nv30_context(pipe
);
671 BEGIN_RING(rankine
, NV34TCL_VIEWPORT_TRANSLATE_X
, 8);
672 OUT_RINGf (vpt
->translate
[0]);
673 OUT_RINGf (vpt
->translate
[1]);
674 OUT_RINGf (vpt
->translate
[2]);
675 OUT_RINGf (vpt
->translate
[3]);
676 OUT_RINGf (vpt
->scale
[0]);
677 OUT_RINGf (vpt
->scale
[1]);
678 OUT_RINGf (vpt
->scale
[2]);
679 OUT_RINGf (vpt
->scale
[3]);
683 nv30_set_vertex_buffer(struct pipe_context
*pipe
, unsigned index
,
684 const struct pipe_vertex_buffer
*vb
)
686 struct nv30_context
*nv30
= nv30_context(pipe
);
688 nv30
->vtxbuf
[index
] = *vb
;
690 nv30
->dirty
|= NV30_NEW_ARRAYS
;
694 nv30_set_vertex_element(struct pipe_context
*pipe
, unsigned index
,
695 const struct pipe_vertex_element
*ve
)
697 struct nv30_context
*nv30
= nv30_context(pipe
);
699 nv30
->vtxelt
[index
] = *ve
;
701 nv30
->dirty
|= NV30_NEW_ARRAYS
;
705 nv30_init_state_functions(struct nv30_context
*nv30
)
707 nv30
->pipe
.create_blend_state
= nv30_blend_state_create
;
708 nv30
->pipe
.bind_blend_state
= nv30_blend_state_bind
;
709 nv30
->pipe
.delete_blend_state
= nv30_blend_state_delete
;
711 nv30
->pipe
.create_sampler_state
= nv30_sampler_state_create
;
712 nv30
->pipe
.bind_sampler_state
= nv30_sampler_state_bind
;
713 nv30
->pipe
.delete_sampler_state
= nv30_sampler_state_delete
;
714 nv30
->pipe
.set_sampler_texture
= nv30_set_sampler_texture
;
716 nv30
->pipe
.create_rasterizer_state
= nv30_rasterizer_state_create
;
717 nv30
->pipe
.bind_rasterizer_state
= nv30_rasterizer_state_bind
;
718 nv30
->pipe
.delete_rasterizer_state
= nv30_rasterizer_state_delete
;
720 nv30
->pipe
.create_depth_stencil_alpha_state
=
721 nv30_depth_stencil_alpha_state_create
;
722 nv30
->pipe
.bind_depth_stencil_alpha_state
=
723 nv30_depth_stencil_alpha_state_bind
;
724 nv30
->pipe
.delete_depth_stencil_alpha_state
=
725 nv30_depth_stencil_alpha_state_delete
;
727 nv30
->pipe
.create_vs_state
= nv30_vp_state_create
;
728 nv30
->pipe
.bind_vs_state
= nv30_vp_state_bind
;
729 nv30
->pipe
.delete_vs_state
= nv30_vp_state_delete
;
731 nv30
->pipe
.create_fs_state
= nv30_fp_state_create
;
732 nv30
->pipe
.bind_fs_state
= nv30_fp_state_bind
;
733 nv30
->pipe
.delete_fs_state
= nv30_fp_state_delete
;
735 nv30
->pipe
.set_blend_color
= nv30_set_blend_color
;
736 nv30
->pipe
.set_clip_state
= nv30_set_clip_state
;
737 nv30
->pipe
.set_constant_buffer
= nv30_set_constant_buffer
;
738 nv30
->pipe
.set_framebuffer_state
= nv30_set_framebuffer_state
;
739 nv30
->pipe
.set_polygon_stipple
= nv30_set_polygon_stipple
;
740 nv30
->pipe
.set_scissor_state
= nv30_set_scissor_state
;
741 nv30
->pipe
.set_viewport_state
= nv30_set_viewport_state
;
743 nv30
->pipe
.set_vertex_buffer
= nv30_set_vertex_buffer
;
744 nv30
->pipe
.set_vertex_element
= nv30_set_vertex_element
;