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 nr
, void **sampler
)
236 struct nv30_context
*nv30
= nv30_context(pipe
);
239 for (unit
= 0; unit
< nr
; unit
++) {
240 nv30
->tex_sampler
[unit
] = sampler
[unit
];
241 nv30
->dirty_samplers
|= (1 << unit
);
246 nv30_sampler_state_delete(struct pipe_context
*pipe
, void *hwcso
)
252 nv30_set_sampler_texture(struct pipe_context
*pipe
, unsigned nr
,
253 struct pipe_texture
**miptree
)
255 struct nv30_context
*nv30
= nv30_context(pipe
);
258 for (unit
= 0; unit
< nr
; unit
++) {
259 nv30
->tex_miptree
[unit
] = (struct nv30_miptree
*)miptree
[unit
];
260 nv30
->dirty_samplers
|= (1 << unit
);
265 nv30_rasterizer_state_create(struct pipe_context
*pipe
,
266 const struct pipe_rasterizer_state
*cso
)
268 struct nv30_rasterizer_state
*rs
;
273 * offset_cw/ccw -nohw
277 * offset_units / offset_scale
279 rs
= malloc(sizeof(struct nv30_rasterizer_state
));
281 rs
->shade_model
= cso
->flatshade
? 0x1d00 : 0x1d01;
283 rs
->line_width
= (unsigned char)(cso
->line_width
* 8.0) & 0xff;
284 rs
->line_smooth_en
= cso
->line_smooth
? 1 : 0;
285 rs
->line_stipple_en
= cso
->line_stipple_enable
? 1 : 0;
286 rs
->line_stipple
= (cso
->line_stipple_pattern
<< 16) |
287 cso
->line_stipple_factor
;
289 rs
->point_size
= *(uint32_t*)&cso
->point_size
;
291 rs
->poly_smooth_en
= cso
->poly_smooth
? 1 : 0;
292 rs
->poly_stipple_en
= cso
->poly_stipple_enable
? 1 : 0;
294 if (cso
->front_winding
== PIPE_WINDING_CCW
) {
295 rs
->front_face
= NV34TCL_FRONT_FACE_CCW
;
296 rs
->poly_mode_front
= nvgl_polygon_mode(cso
->fill_ccw
);
297 rs
->poly_mode_back
= nvgl_polygon_mode(cso
->fill_cw
);
299 rs
->front_face
= NV34TCL_FRONT_FACE_CW
;
300 rs
->poly_mode_front
= nvgl_polygon_mode(cso
->fill_cw
);
301 rs
->poly_mode_back
= nvgl_polygon_mode(cso
->fill_ccw
);
304 switch (cso
->cull_mode
) {
305 case PIPE_WINDING_CCW
:
306 rs
->cull_face_en
= 1;
307 if (cso
->front_winding
== PIPE_WINDING_CCW
)
308 rs
->cull_face
= NV34TCL_CULL_FACE_FRONT
;
310 rs
->cull_face
= NV34TCL_CULL_FACE_BACK
;
312 case PIPE_WINDING_CW
:
313 rs
->cull_face_en
= 1;
314 if (cso
->front_winding
== PIPE_WINDING_CW
)
315 rs
->cull_face
= NV34TCL_CULL_FACE_FRONT
;
317 rs
->cull_face
= NV34TCL_CULL_FACE_BACK
;
319 case PIPE_WINDING_BOTH
:
320 rs
->cull_face_en
= 1;
321 rs
->cull_face
= NV34TCL_CULL_FACE_FRONT_AND_BACK
;
323 case PIPE_WINDING_NONE
:
325 rs
->cull_face_en
= 0;
330 if (cso
->point_sprite
) {
331 rs
->point_sprite
= (1 << 0);
332 for (i
= 0; i
< 8; i
++) {
333 if (cso
->sprite_coord_mode
[i
] != PIPE_SPRITE_COORD_NONE
)
334 rs
->point_sprite
|= (1 << (8 + i
));
337 rs
->point_sprite
= 0;
344 nv30_rasterizer_state_bind(struct pipe_context
*pipe
, void *hwcso
)
346 struct nv30_context
*nv30
= nv30_context(pipe
);
347 struct nv30_rasterizer_state
*rs
= hwcso
;
349 BEGIN_RING(rankine
, NV34TCL_SHADE_MODEL
, 1);
350 OUT_RING (rs
->shade_model
);
352 BEGIN_RING(rankine
, NV34TCL_LINE_WIDTH
, 2);
353 OUT_RING (rs
->line_width
);
354 OUT_RING (rs
->line_smooth_en
);
355 BEGIN_RING(rankine
, NV34TCL_LINE_STIPPLE_ENABLE
, 2);
356 OUT_RING (rs
->line_stipple_en
);
357 OUT_RING (rs
->line_stipple
);
359 BEGIN_RING(rankine
, NV34TCL_POINT_SIZE
, 1);
360 OUT_RING (rs
->point_size
);
362 BEGIN_RING(rankine
, NV34TCL_POLYGON_MODE_FRONT
, 6);
363 OUT_RING (rs
->poly_mode_front
);
364 OUT_RING (rs
->poly_mode_back
);
365 OUT_RING (rs
->cull_face
);
366 OUT_RING (rs
->front_face
);
367 OUT_RING (rs
->poly_smooth_en
);
368 OUT_RING (rs
->cull_face_en
);
370 BEGIN_RING(rankine
, NV34TCL_POLYGON_STIPPLE_ENABLE
, 1);
371 OUT_RING (rs
->poly_stipple_en
);
373 BEGIN_RING(rankine
, NV34TCL_POINT_SPRITE
, 1);
374 OUT_RING (rs
->point_sprite
);
378 nv30_rasterizer_state_delete(struct pipe_context
*pipe
, void *hwcso
)
384 nv30_translate_stencil(const struct pipe_depth_stencil_alpha_state
*cso
,
385 unsigned idx
, struct nv30_stencil_push
*hw
)
387 hw
->enable
= cso
->stencil
[idx
].enabled
? 1 : 0;
388 hw
->wmask
= cso
->stencil
[idx
].write_mask
;
389 hw
->func
= nvgl_comparison_op(cso
->stencil
[idx
].func
);
390 hw
->ref
= cso
->stencil
[idx
].ref_value
;
391 hw
->vmask
= cso
->stencil
[idx
].value_mask
;
392 hw
->fail
= nvgl_stencil_op(cso
->stencil
[idx
].fail_op
);
393 hw
->zfail
= nvgl_stencil_op(cso
->stencil
[idx
].zfail_op
);
394 hw
->zpass
= nvgl_stencil_op(cso
->stencil
[idx
].zpass_op
);
398 nv30_depth_stencil_alpha_state_create(struct pipe_context
*pipe
,
399 const struct pipe_depth_stencil_alpha_state
*cso
)
401 struct nv30_depth_stencil_alpha_state
*hw
;
403 hw
= malloc(sizeof(struct nv30_depth_stencil_alpha_state
));
405 hw
->depth
.func
= nvgl_comparison_op(cso
->depth
.func
);
406 hw
->depth
.write_enable
= cso
->depth
.writemask
? 1 : 0;
407 hw
->depth
.test_enable
= cso
->depth
.enabled
? 1 : 0;
409 nv30_translate_stencil(cso
, 0, &hw
->stencil
.front
);
410 nv30_translate_stencil(cso
, 1, &hw
->stencil
.back
);
412 hw
->alpha
.enabled
= cso
->alpha
.enabled
? 1 : 0;
413 hw
->alpha
.func
= nvgl_comparison_op(cso
->alpha
.func
);
414 hw
->alpha
.ref
= float_to_ubyte(cso
->alpha
.ref
);
420 nv30_depth_stencil_alpha_state_bind(struct pipe_context
*pipe
, void *hwcso
)
422 struct nv30_context
*nv30
= nv30_context(pipe
);
423 struct nv30_depth_stencil_alpha_state
*hw
= hwcso
;
425 BEGIN_RING(rankine
, NV34TCL_DEPTH_FUNC
, 3);
426 OUT_RINGp ((uint32_t *)&hw
->depth
, 3);
427 BEGIN_RING(rankine
, NV34TCL_STENCIL_BACK_ENABLE
, 16);
428 OUT_RINGp ((uint32_t *)&hw
->stencil
.back
, 8);
429 OUT_RINGp ((uint32_t *)&hw
->stencil
.front
, 8);
430 BEGIN_RING(rankine
, NV34TCL_ALPHA_FUNC_ENABLE
, 3);
431 OUT_RINGp ((uint32_t *)&hw
->alpha
.enabled
, 3);
435 nv30_depth_stencil_alpha_state_delete(struct pipe_context
*pipe
, void *hwcso
)
441 nv30_vp_state_create(struct pipe_context
*pipe
,
442 const struct pipe_shader_state
*cso
)
444 struct nv30_vertex_program
*vp
;
446 vp
= CALLOC(1, sizeof(struct nv30_vertex_program
));
453 nv30_vp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
455 struct nv30_context
*nv30
= nv30_context(pipe
);
456 struct nv30_vertex_program
*vp
= hwcso
;
458 nv30
->vertprog
.current
= vp
;
459 nv30
->dirty
|= NV30_NEW_VERTPROG
;
463 nv30_vp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
465 struct nv30_context
*nv30
= nv30_context(pipe
);
466 struct nv30_vertex_program
*vp
= hwcso
;
468 nv30_vertprog_destroy(nv30
, vp
);
473 nv30_fp_state_create(struct pipe_context
*pipe
,
474 const struct pipe_shader_state
*cso
)
476 struct nv30_fragment_program
*fp
;
478 fp
= CALLOC(1, sizeof(struct nv30_fragment_program
));
485 nv30_fp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
487 struct nv30_context
*nv30
= nv30_context(pipe
);
488 struct nv30_fragment_program
*fp
= hwcso
;
490 nv30
->fragprog
.current
= fp
;
491 nv30
->dirty
|= NV30_NEW_FRAGPROG
;
495 nv30_fp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
497 struct nv30_context
*nv30
= nv30_context(pipe
);
498 struct nv30_fragment_program
*fp
= hwcso
;
500 nv30_fragprog_destroy(nv30
, fp
);
505 nv30_set_blend_color(struct pipe_context
*pipe
,
506 const struct pipe_blend_color
*bcol
)
508 struct nv30_context
*nv30
= nv30_context(pipe
);
510 BEGIN_RING(rankine
, NV34TCL_BLEND_FUNC_COLOR
, 1);
511 OUT_RING ((float_to_ubyte(bcol
->color
[3]) << 24) |
512 (float_to_ubyte(bcol
->color
[0]) << 16) |
513 (float_to_ubyte(bcol
->color
[1]) << 8) |
514 (float_to_ubyte(bcol
->color
[2]) << 0));
518 nv30_set_clip_state(struct pipe_context
*pipe
,
519 const struct pipe_clip_state
*clip
)
524 nv30_set_constant_buffer(struct pipe_context
*pipe
, uint shader
, uint index
,
525 const struct pipe_constant_buffer
*buf
)
527 struct nv30_context
*nv30
= nv30_context(pipe
);
529 if (shader
== PIPE_SHADER_VERTEX
) {
530 nv30
->vertprog
.constant_buf
= buf
->buffer
;
531 nv30
->dirty
|= NV30_NEW_VERTPROG
;
533 if (shader
== PIPE_SHADER_FRAGMENT
) {
534 nv30
->fragprog
.constant_buf
= buf
->buffer
;
535 nv30
->dirty
|= NV30_NEW_FRAGPROG
;
540 nv30_set_framebuffer_state(struct pipe_context
*pipe
,
541 const struct pipe_framebuffer_state
*fb
)
543 struct nv30_context
*nv30
= nv30_context(pipe
);
544 struct pipe_surface
*rt
[4], *zeta
= NULL
;
545 uint32_t rt_enable
, rt_format
, w
= 0, h
= 0;
546 int i
, colour_format
= 0, zeta_format
= 0;
549 for (i
= 0; i
< 2; i
++) {
554 assert(w
== fb
->cbufs
[i
]->width
);
555 assert(h
== fb
->cbufs
[i
]->height
);
556 assert(colour_format
== fb
->cbufs
[i
]->format
);
558 w
= fb
->cbufs
[i
]->width
;
559 h
= fb
->cbufs
[i
]->height
;
560 colour_format
= fb
->cbufs
[i
]->format
;
561 rt_enable
|= (NV34TCL_RT_ENABLE_COLOR0
<< i
);
562 rt
[i
] = fb
->cbufs
[i
];
566 if (rt_enable
& (NV34TCL_RT_ENABLE_COLOR1
| NV34TCL_RT_ENABLE_COLOR2
|
567 NV34TCL_RT_ENABLE_COLOR3
))
568 rt_enable
|= NV34TCL_RT_ENABLE_MRT
;
572 assert(w
== fb
->zsbuf
->width
);
573 assert(h
== fb
->zsbuf
->height
);
575 w
= fb
->zsbuf
->width
;
576 h
= fb
->zsbuf
->height
;
579 zeta_format
= fb
->zsbuf
->format
;
583 rt_format
= NV34TCL_RT_FORMAT_TYPE_LINEAR
;
585 switch (colour_format
) {
586 case PIPE_FORMAT_A8R8G8B8_UNORM
:
588 rt_format
|= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8
;
590 case PIPE_FORMAT_R5G6B5_UNORM
:
591 rt_format
|= NV34TCL_RT_FORMAT_COLOR_R5G6B5
;
597 switch (zeta_format
) {
598 case PIPE_FORMAT_Z16_UNORM
:
599 rt_format
|= NV34TCL_RT_FORMAT_ZETA_Z16
;
601 case PIPE_FORMAT_Z24S8_UNORM
:
603 rt_format
|= NV34TCL_RT_FORMAT_ZETA_Z24S8
;
609 if (rt_enable
& NV34TCL_RT_ENABLE_COLOR0
) {
610 uint32_t pitch
= rt
[0]->pitch
* rt
[0]->cpp
;
612 pitch
|= (zeta
->pitch
* zeta
->cpp
)<<16;
617 BEGIN_RING(rankine
, NV34TCL_COLOR0_PITCH
, 1);
619 nv30
->rt
[0] = rt
[0]->buffer
;
622 if (rt_enable
& NV34TCL_RT_ENABLE_COLOR1
) {
623 BEGIN_RING(rankine
, NV34TCL_COLOR1_PITCH
, 1);
624 OUT_RING (rt
[1]->pitch
* rt
[1]->cpp
);
625 nv30
->rt
[1] = rt
[1]->buffer
;
630 nv30
->zeta
= zeta
->buffer
;
633 nv30
->rt_enable
= rt_enable
;
634 BEGIN_RING(rankine
, NV34TCL_RT_ENABLE
, 1);
635 OUT_RING (rt_enable
);
636 BEGIN_RING(rankine
, NV34TCL_RT_HORIZ
, 3);
637 OUT_RING ((w
<< 16) | 0);
638 OUT_RING ((h
<< 16) | 0);
639 OUT_RING (rt_format
);
640 BEGIN_RING(rankine
, NV34TCL_VIEWPORT_HORIZ
, 2);
641 OUT_RING ((w
<< 16) | 0);
642 OUT_RING ((h
<< 16) | 0);
643 BEGIN_RING(rankine
, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
644 OUT_RING (((w
- 1) << 16) | 0);
645 OUT_RING (((h
- 1) << 16) | 0);
649 nv30_set_polygon_stipple(struct pipe_context
*pipe
,
650 const struct pipe_poly_stipple
*stipple
)
652 struct nv30_context
*nv30
= nv30_context(pipe
);
654 BEGIN_RING(rankine
, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
655 OUT_RINGp ((uint32_t *)stipple
->stipple
, 32);
659 nv30_set_scissor_state(struct pipe_context
*pipe
,
660 const struct pipe_scissor_state
*s
)
662 struct nv30_context
*nv30
= nv30_context(pipe
);
664 BEGIN_RING(rankine
, NV34TCL_SCISSOR_HORIZ
, 2);
665 OUT_RING (((s
->maxx
- s
->minx
) << 16) | s
->minx
);
666 OUT_RING (((s
->maxy
- s
->miny
) << 16) | s
->miny
);
670 nv30_set_viewport_state(struct pipe_context
*pipe
,
671 const struct pipe_viewport_state
*vpt
)
673 struct nv30_context
*nv30
= nv30_context(pipe
);
675 BEGIN_RING(rankine
, NV34TCL_VIEWPORT_TRANSLATE_X
, 8);
676 OUT_RINGf (vpt
->translate
[0]);
677 OUT_RINGf (vpt
->translate
[1]);
678 OUT_RINGf (vpt
->translate
[2]);
679 OUT_RINGf (vpt
->translate
[3]);
680 OUT_RINGf (vpt
->scale
[0]);
681 OUT_RINGf (vpt
->scale
[1]);
682 OUT_RINGf (vpt
->scale
[2]);
683 OUT_RINGf (vpt
->scale
[3]);
687 nv30_set_vertex_buffer(struct pipe_context
*pipe
, unsigned index
,
688 const struct pipe_vertex_buffer
*vb
)
690 struct nv30_context
*nv30
= nv30_context(pipe
);
692 nv30
->vtxbuf
[index
] = *vb
;
694 nv30
->dirty
|= NV30_NEW_ARRAYS
;
698 nv30_set_vertex_element(struct pipe_context
*pipe
, unsigned index
,
699 const struct pipe_vertex_element
*ve
)
701 struct nv30_context
*nv30
= nv30_context(pipe
);
703 nv30
->vtxelt
[index
] = *ve
;
705 nv30
->dirty
|= NV30_NEW_ARRAYS
;
709 nv30_init_state_functions(struct nv30_context
*nv30
)
711 nv30
->pipe
.create_blend_state
= nv30_blend_state_create
;
712 nv30
->pipe
.bind_blend_state
= nv30_blend_state_bind
;
713 nv30
->pipe
.delete_blend_state
= nv30_blend_state_delete
;
715 nv30
->pipe
.create_sampler_state
= nv30_sampler_state_create
;
716 nv30
->pipe
.bind_sampler_states
= nv30_sampler_state_bind
;
717 nv30
->pipe
.delete_sampler_state
= nv30_sampler_state_delete
;
718 nv30
->pipe
.set_sampler_textures
= nv30_set_sampler_texture
;
720 nv30
->pipe
.create_rasterizer_state
= nv30_rasterizer_state_create
;
721 nv30
->pipe
.bind_rasterizer_state
= nv30_rasterizer_state_bind
;
722 nv30
->pipe
.delete_rasterizer_state
= nv30_rasterizer_state_delete
;
724 nv30
->pipe
.create_depth_stencil_alpha_state
=
725 nv30_depth_stencil_alpha_state_create
;
726 nv30
->pipe
.bind_depth_stencil_alpha_state
=
727 nv30_depth_stencil_alpha_state_bind
;
728 nv30
->pipe
.delete_depth_stencil_alpha_state
=
729 nv30_depth_stencil_alpha_state_delete
;
731 nv30
->pipe
.create_vs_state
= nv30_vp_state_create
;
732 nv30
->pipe
.bind_vs_state
= nv30_vp_state_bind
;
733 nv30
->pipe
.delete_vs_state
= nv30_vp_state_delete
;
735 nv30
->pipe
.create_fs_state
= nv30_fp_state_create
;
736 nv30
->pipe
.bind_fs_state
= nv30_fp_state_bind
;
737 nv30
->pipe
.delete_fs_state
= nv30_fp_state_delete
;
739 nv30
->pipe
.set_blend_color
= nv30_set_blend_color
;
740 nv30
->pipe
.set_clip_state
= nv30_set_clip_state
;
741 nv30
->pipe
.set_constant_buffer
= nv30_set_constant_buffer
;
742 nv30
->pipe
.set_framebuffer_state
= nv30_set_framebuffer_state
;
743 nv30
->pipe
.set_polygon_stipple
= nv30_set_polygon_stipple
;
744 nv30
->pipe
.set_scissor_state
= nv30_set_scissor_state
;
745 nv30
->pipe
.set_viewport_state
= nv30_set_viewport_state
;
747 nv30
->pipe
.set_vertex_buffer
= nv30_set_vertex_buffer
;
748 nv30
->pipe
.set_vertex_element
= nv30_set_vertex_element
;