2 * Copyright 2008 Ben Skeggs
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #include "pipe/p_state.h"
24 #include "pipe/p_defines.h"
25 #include "util/u_inlines.h"
27 #include "tgsi/tgsi_parse.h"
29 #include "nv50_context.h"
30 #include "nv50_texture.h"
32 #include "nouveau/nouveau_stateobj.h"
34 static INLINE
uint32_t
35 nv50_colormask(unsigned mask
)
39 if (mask
& PIPE_MASK_R
)
41 if (mask
& PIPE_MASK_G
)
43 if (mask
& PIPE_MASK_B
)
45 if (mask
& PIPE_MASK_A
)
52 nv50_blend_state_create(struct pipe_context
*pipe
,
53 const struct pipe_blend_state
*cso
)
55 struct nouveau_stateobj
*so
= so_new(5, 24, 0);
56 struct nouveau_grobj
*tesla
= nv50_context(pipe
)->screen
->tesla
;
57 struct nv50_blend_stateobj
*bso
= CALLOC_STRUCT(nv50_blend_stateobj
);
58 unsigned i
, blend_enabled
= 0;
64 so_method(so
, tesla
, NV50TCL_BLEND_ENABLE(0), 8);
65 if (cso
->independent_blend_enable
) {
66 for (i
= 0; i
< 8; ++i
) {
67 so_data(so
, cso
->rt
[i
].blend_enable
);
68 if (cso
->rt
[i
].blend_enable
)
72 if (cso
->rt
[0].blend_enable
) {
74 for (i
= 0; i
< 8; i
++)
77 for (i
= 0; i
< 8; i
++)
81 so_method(so
, tesla
, NV50TCL_BLEND_EQUATION_RGB
, 5);
82 so_data (so
, nvgl_blend_eqn(cso
->rt
[0].rgb_func
));
83 so_data (so
, 0x4000 | nvgl_blend_func(cso
->rt
[0].rgb_src_factor
));
84 so_data (so
, 0x4000 | nvgl_blend_func(cso
->rt
[0].rgb_dst_factor
));
85 so_data (so
, nvgl_blend_eqn(cso
->rt
[0].alpha_func
));
86 so_data (so
, 0x4000 | nvgl_blend_func(cso
->rt
[0].alpha_src_factor
));
87 so_method(so
, tesla
, NV50TCL_BLEND_FUNC_DST_ALPHA
, 1);
88 so_data (so
, 0x4000 | nvgl_blend_func(cso
->rt
[0].alpha_dst_factor
));
91 if (cso
->logicop_enable
== 0 ) {
92 so_method(so
, tesla
, NV50TCL_LOGIC_OP_ENABLE
, 1);
95 so_method(so
, tesla
, NV50TCL_LOGIC_OP_ENABLE
, 2);
97 so_data (so
, nvgl_logicop_func(cso
->logicop_func
));
100 so_method(so
, tesla
, NV50TCL_COLOR_MASK(0), 8);
101 if (cso
->independent_blend_enable
)
102 for (i
= 0; i
< 8; ++i
)
103 so_data(so
, nv50_colormask(cso
->rt
[i
].colormask
));
105 uint32_t cmask
= nv50_colormask(cso
->rt
[0].colormask
);
106 for (i
= 0; i
< 8; i
++)
111 so_ref(so
, &bso
->so
);
117 nv50_blend_state_bind(struct pipe_context
*pipe
, void *hwcso
)
119 struct nv50_context
*nv50
= nv50_context(pipe
);
122 nv50
->dirty
|= NV50_NEW_BLEND
;
126 nv50_blend_state_delete(struct pipe_context
*pipe
, void *hwcso
)
128 struct nv50_blend_stateobj
*bso
= hwcso
;
130 so_ref(NULL
, &bso
->so
);
134 static INLINE
unsigned
135 wrap_mode(unsigned wrap
)
138 case PIPE_TEX_WRAP_REPEAT
:
139 return NV50TSC_1_0_WRAPS_REPEAT
;
140 case PIPE_TEX_WRAP_MIRROR_REPEAT
:
141 return NV50TSC_1_0_WRAPS_MIRROR_REPEAT
;
142 case PIPE_TEX_WRAP_CLAMP_TO_EDGE
:
143 return NV50TSC_1_0_WRAPS_CLAMP_TO_EDGE
;
144 case PIPE_TEX_WRAP_CLAMP_TO_BORDER
:
145 return NV50TSC_1_0_WRAPS_CLAMP_TO_BORDER
;
146 case PIPE_TEX_WRAP_CLAMP
:
147 return NV50TSC_1_0_WRAPS_CLAMP
;
148 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE
:
149 return NV50TSC_1_0_WRAPS_MIRROR_CLAMP_TO_EDGE
;
150 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER
:
151 return NV50TSC_1_0_WRAPS_MIRROR_CLAMP_TO_BORDER
;
152 case PIPE_TEX_WRAP_MIRROR_CLAMP
:
153 return NV50TSC_1_0_WRAPS_MIRROR_CLAMP
;
155 NOUVEAU_ERR("unknown wrap mode: %d\n", wrap
);
156 return NV50TSC_1_0_WRAPS_REPEAT
;
160 nv50_sampler_state_create(struct pipe_context
*pipe
,
161 const struct pipe_sampler_state
*cso
)
163 struct nv50_sampler_stateobj
*sso
= CALLOC(1, sizeof(*sso
));
164 unsigned *tsc
= sso
->tsc
;
167 tsc
[0] = (0x00026000 |
168 (wrap_mode(cso
->wrap_s
) << 0) |
169 (wrap_mode(cso
->wrap_t
) << 3) |
170 (wrap_mode(cso
->wrap_r
) << 6));
172 switch (cso
->mag_img_filter
) {
173 case PIPE_TEX_FILTER_LINEAR
:
174 tsc
[1] |= NV50TSC_1_1_MAGF_LINEAR
;
176 case PIPE_TEX_FILTER_NEAREST
:
178 tsc
[1] |= NV50TSC_1_1_MAGF_NEAREST
;
182 switch (cso
->min_img_filter
) {
183 case PIPE_TEX_FILTER_LINEAR
:
184 tsc
[1] |= NV50TSC_1_1_MINF_LINEAR
;
186 case PIPE_TEX_FILTER_NEAREST
:
188 tsc
[1] |= NV50TSC_1_1_MINF_NEAREST
;
192 switch (cso
->min_mip_filter
) {
193 case PIPE_TEX_MIPFILTER_LINEAR
:
194 tsc
[1] |= NV50TSC_1_1_MIPF_LINEAR
;
196 case PIPE_TEX_MIPFILTER_NEAREST
:
197 tsc
[1] |= NV50TSC_1_1_MIPF_NEAREST
;
199 case PIPE_TEX_MIPFILTER_NONE
:
201 tsc
[1] |= NV50TSC_1_1_MIPF_NONE
;
205 if (cso
->max_anisotropy
>= 16.0)
208 if (cso
->max_anisotropy
>= 12.0)
211 tsc
[0] |= (int)(cso
->max_anisotropy
* 0.5f
) << 20;
213 if (cso
->max_anisotropy
>= 4.0)
214 tsc
[1] |= NV50TSC_1_1_UNKN_ANISO_35
;
216 if (cso
->max_anisotropy
>= 2.0)
217 tsc
[1] |= NV50TSC_1_1_UNKN_ANISO_15
;
220 if (cso
->compare_mode
== PIPE_TEX_COMPARE_R_TO_TEXTURE
) {
221 /* XXX: must be deactivated for non-shadow textures */
223 tsc
[0] |= (nvgl_comparison_op(cso
->compare_func
) & 0x7) << 10;
226 limit
= CLAMP(cso
->lod_bias
, -16.0, 15.0);
227 tsc
[1] |= ((int)(limit
* 256.0) & 0x1fff) << 12;
229 tsc
[2] |= ((int)CLAMP(cso
->max_lod
, 0.0, 15.0) << 20) |
230 ((int)CLAMP(cso
->min_lod
, 0.0, 15.0) << 8);
232 tsc
[4] = fui(cso
->border_color
[0]);
233 tsc
[5] = fui(cso
->border_color
[1]);
234 tsc
[6] = fui(cso
->border_color
[2]);
235 tsc
[7] = fui(cso
->border_color
[3]);
237 sso
->normalized
= cso
->normalized_coords
;
242 nv50_sampler_state_bind(struct pipe_context
*pipe
, unsigned type
,
243 unsigned nr
, void **sampler
)
245 struct nv50_context
*nv50
= nv50_context(pipe
);
247 memcpy(nv50
->sampler
[type
], sampler
, nr
* sizeof(void *));
249 nv50
->sampler_nr
[type
] = nr
;
250 nv50
->dirty
|= NV50_NEW_SAMPLER
;
254 nv50_vp_sampler_state_bind(struct pipe_context
*pipe
, unsigned nr
, void **s
)
256 nv50_sampler_state_bind(pipe
, PIPE_SHADER_VERTEX
, nr
, s
);
260 nv50_fp_sampler_state_bind(struct pipe_context
*pipe
, unsigned nr
, void **s
)
262 nv50_sampler_state_bind(pipe
, PIPE_SHADER_FRAGMENT
, nr
, s
);
266 nv50_sampler_state_delete(struct pipe_context
*pipe
, void *hwcso
)
272 nv50_set_sampler_texture(struct pipe_context
*pipe
, unsigned type
,
273 unsigned nr
, struct pipe_texture
**pt
)
275 struct nv50_context
*nv50
= nv50_context(pipe
);
278 for (i
= 0; i
< nr
; i
++)
279 pipe_texture_reference((void *)&nv50
->miptree
[type
][i
], pt
[i
]);
280 for (i
= nr
; i
< nv50
->miptree_nr
[type
]; i
++)
281 pipe_texture_reference((void *)&nv50
->miptree
[type
][i
], NULL
);
283 nv50
->miptree_nr
[type
] = nr
;
284 nv50
->dirty
|= NV50_NEW_TEXTURE
;
288 nv50_set_vp_sampler_textures(struct pipe_context
*pipe
,
289 unsigned nr
, struct pipe_texture
**pt
)
291 nv50_set_sampler_texture(pipe
, PIPE_SHADER_VERTEX
, nr
, pt
);
295 nv50_set_fp_sampler_textures(struct pipe_context
*pipe
,
296 unsigned nr
, struct pipe_texture
**pt
)
298 nv50_set_sampler_texture(pipe
, PIPE_SHADER_FRAGMENT
, nr
, pt
);
302 nv50_rasterizer_state_create(struct pipe_context
*pipe
,
303 const struct pipe_rasterizer_state
*cso
)
305 struct nouveau_stateobj
*so
= so_new(15, 21, 0);
306 struct nouveau_grobj
*tesla
= nv50_context(pipe
)->screen
->tesla
;
307 struct nv50_rasterizer_stateobj
*rso
=
308 CALLOC_STRUCT(nv50_rasterizer_stateobj
);
314 * - point_sprite / sprite_coord_mode
317 so_method(so
, tesla
, NV50TCL_SHADE_MODEL
, 1);
318 so_data (so
, cso
->flatshade
? NV50TCL_SHADE_MODEL_FLAT
:
319 NV50TCL_SHADE_MODEL_SMOOTH
);
320 so_method(so
, tesla
, NV50TCL_PROVOKING_VERTEX_LAST
, 1);
321 so_data (so
, cso
->flatshade_first
? 0 : 1);
323 so_method(so
, tesla
, NV50TCL_VERTEX_TWO_SIDE_ENABLE
, 1);
324 so_data (so
, cso
->light_twoside
);
326 so_method(so
, tesla
, NV50TCL_LINE_WIDTH
, 1);
327 so_data (so
, fui(cso
->line_width
));
328 so_method(so
, tesla
, NV50TCL_LINE_SMOOTH_ENABLE
, 1);
329 so_data (so
, cso
->line_smooth
? 1 : 0);
330 if (cso
->line_stipple_enable
) {
331 so_method(so
, tesla
, NV50TCL_LINE_STIPPLE_ENABLE
, 1);
333 so_method(so
, tesla
, NV50TCL_LINE_STIPPLE_PATTERN
, 1);
334 so_data (so
, (cso
->line_stipple_pattern
<< 8) |
335 cso
->line_stipple_factor
);
337 so_method(so
, tesla
, NV50TCL_LINE_STIPPLE_ENABLE
, 1);
341 so_method(so
, tesla
, NV50TCL_POINT_SIZE
, 1);
342 so_data (so
, fui(cso
->point_size
));
344 so_method(so
, tesla
, NV50TCL_POINT_SPRITE_ENABLE
, 1);
345 so_data (so
, cso
->point_quad_rasterization
? 1 : 0);
347 so_method(so
, tesla
, NV50TCL_POLYGON_MODE_FRONT
, 3);
348 if (cso
->front_winding
== PIPE_WINDING_CCW
) {
349 so_data(so
, nvgl_polygon_mode(cso
->fill_ccw
));
350 so_data(so
, nvgl_polygon_mode(cso
->fill_cw
));
352 so_data(so
, nvgl_polygon_mode(cso
->fill_cw
));
353 so_data(so
, nvgl_polygon_mode(cso
->fill_ccw
));
355 so_data(so
, cso
->poly_smooth
? 1 : 0);
357 so_method(so
, tesla
, NV50TCL_CULL_FACE_ENABLE
, 3);
358 so_data (so
, cso
->cull_mode
!= PIPE_WINDING_NONE
);
359 if (cso
->front_winding
== PIPE_WINDING_CCW
) {
360 so_data(so
, NV50TCL_FRONT_FACE_CCW
);
361 switch (cso
->cull_mode
) {
362 case PIPE_WINDING_CCW
:
363 so_data(so
, NV50TCL_CULL_FACE_FRONT
);
365 case PIPE_WINDING_CW
:
366 so_data(so
, NV50TCL_CULL_FACE_BACK
);
368 case PIPE_WINDING_BOTH
:
369 so_data(so
, NV50TCL_CULL_FACE_FRONT_AND_BACK
);
372 so_data(so
, NV50TCL_CULL_FACE_BACK
);
376 so_data(so
, NV50TCL_FRONT_FACE_CW
);
377 switch (cso
->cull_mode
) {
378 case PIPE_WINDING_CCW
:
379 so_data(so
, NV50TCL_CULL_FACE_BACK
);
381 case PIPE_WINDING_CW
:
382 so_data(so
, NV50TCL_CULL_FACE_FRONT
);
384 case PIPE_WINDING_BOTH
:
385 so_data(so
, NV50TCL_CULL_FACE_FRONT_AND_BACK
);
388 so_data(so
, NV50TCL_CULL_FACE_BACK
);
393 so_method(so
, tesla
, NV50TCL_POLYGON_STIPPLE_ENABLE
, 1);
394 so_data (so
, cso
->poly_stipple_enable
? 1 : 0);
396 so_method(so
, tesla
, NV50TCL_POLYGON_OFFSET_POINT_ENABLE
, 3);
397 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_POINT
) ||
398 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_POINT
))
402 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_LINE
) ||
403 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_LINE
))
407 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_FILL
) ||
408 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_FILL
))
413 if (cso
->offset_cw
|| cso
->offset_ccw
) {
414 so_method(so
, tesla
, NV50TCL_POLYGON_OFFSET_FACTOR
, 1);
415 so_data (so
, fui(cso
->offset_scale
));
416 so_method(so
, tesla
, NV50TCL_POLYGON_OFFSET_UNITS
, 1);
417 so_data (so
, fui(cso
->offset_units
* 2.0f
));
421 so_ref(so
, &rso
->so
);
427 nv50_rasterizer_state_bind(struct pipe_context
*pipe
, void *hwcso
)
429 struct nv50_context
*nv50
= nv50_context(pipe
);
431 nv50
->rasterizer
= hwcso
;
432 nv50
->dirty
|= NV50_NEW_RASTERIZER
;
436 nv50_rasterizer_state_delete(struct pipe_context
*pipe
, void *hwcso
)
438 struct nv50_rasterizer_stateobj
*rso
= hwcso
;
440 so_ref(NULL
, &rso
->so
);
445 nv50_depth_stencil_alpha_state_create(struct pipe_context
*pipe
,
446 const struct pipe_depth_stencil_alpha_state
*cso
)
448 struct nouveau_grobj
*tesla
= nv50_context(pipe
)->screen
->tesla
;
449 struct nv50_zsa_stateobj
*zsa
= CALLOC_STRUCT(nv50_zsa_stateobj
);
450 struct nouveau_stateobj
*so
= so_new(9, 21, 0);
452 so_method(so
, tesla
, NV50TCL_DEPTH_WRITE_ENABLE
, 1);
453 so_data (so
, cso
->depth
.writemask
? 1 : 0);
454 if (cso
->depth
.enabled
) {
455 so_method(so
, tesla
, NV50TCL_DEPTH_TEST_ENABLE
, 1);
457 so_method(so
, tesla
, NV50TCL_DEPTH_TEST_FUNC
, 1);
458 so_data (so
, nvgl_comparison_op(cso
->depth
.func
));
460 so_method(so
, tesla
, NV50TCL_DEPTH_TEST_ENABLE
, 1);
464 if (cso
->stencil
[0].enabled
) {
465 so_method(so
, tesla
, NV50TCL_STENCIL_FRONT_ENABLE
, 5);
467 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].fail_op
));
468 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].zfail_op
));
469 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].zpass_op
));
470 so_data (so
, nvgl_comparison_op(cso
->stencil
[0].func
));
471 so_method(so
, tesla
, NV50TCL_STENCIL_FRONT_MASK
, 2);
472 so_data (so
, cso
->stencil
[0].writemask
);
473 so_data (so
, cso
->stencil
[0].valuemask
);
475 so_method(so
, tesla
, NV50TCL_STENCIL_FRONT_ENABLE
, 1);
479 if (cso
->stencil
[1].enabled
) {
480 so_method(so
, tesla
, NV50TCL_STENCIL_BACK_ENABLE
, 5);
482 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].fail_op
));
483 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].zfail_op
));
484 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].zpass_op
));
485 so_data (so
, nvgl_comparison_op(cso
->stencil
[1].func
));
486 so_method(so
, tesla
, NV50TCL_STENCIL_BACK_MASK
, 2);
487 so_data (so
, cso
->stencil
[1].writemask
);
488 so_data (so
, cso
->stencil
[1].valuemask
);
490 so_method(so
, tesla
, NV50TCL_STENCIL_BACK_ENABLE
, 1);
494 if (cso
->alpha
.enabled
) {
495 so_method(so
, tesla
, NV50TCL_ALPHA_TEST_ENABLE
, 1);
497 so_method(so
, tesla
, NV50TCL_ALPHA_TEST_REF
, 2);
498 so_data (so
, fui(cso
->alpha
.ref_value
));
499 so_data (so
, nvgl_comparison_op(cso
->alpha
.func
));
501 so_method(so
, tesla
, NV50TCL_ALPHA_TEST_ENABLE
, 1);
506 so_ref(so
, &zsa
->so
);
512 nv50_depth_stencil_alpha_state_bind(struct pipe_context
*pipe
, void *hwcso
)
514 struct nv50_context
*nv50
= nv50_context(pipe
);
517 nv50
->dirty
|= NV50_NEW_ZSA
;
521 nv50_depth_stencil_alpha_state_delete(struct pipe_context
*pipe
, void *hwcso
)
523 struct nv50_zsa_stateobj
*zsa
= hwcso
;
525 so_ref(NULL
, &zsa
->so
);
530 nv50_vp_state_create(struct pipe_context
*pipe
,
531 const struct pipe_shader_state
*cso
)
533 struct nv50_program
*p
= CALLOC_STRUCT(nv50_program
);
535 p
->pipe
.tokens
= tgsi_dup_tokens(cso
->tokens
);
536 p
->type
= PIPE_SHADER_VERTEX
;
537 tgsi_scan_shader(p
->pipe
.tokens
, &p
->info
);
542 nv50_vp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
544 struct nv50_context
*nv50
= nv50_context(pipe
);
546 nv50
->vertprog
= hwcso
;
547 nv50
->dirty
|= NV50_NEW_VERTPROG
;
551 nv50_vp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
553 struct nv50_context
*nv50
= nv50_context(pipe
);
554 struct nv50_program
*p
= hwcso
;
556 nv50_program_destroy(nv50
, p
);
557 FREE((void *)p
->pipe
.tokens
);
562 nv50_fp_state_create(struct pipe_context
*pipe
,
563 const struct pipe_shader_state
*cso
)
565 struct nv50_program
*p
= CALLOC_STRUCT(nv50_program
);
567 p
->pipe
.tokens
= tgsi_dup_tokens(cso
->tokens
);
568 p
->type
= PIPE_SHADER_FRAGMENT
;
569 tgsi_scan_shader(p
->pipe
.tokens
, &p
->info
);
574 nv50_fp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
576 struct nv50_context
*nv50
= nv50_context(pipe
);
578 nv50
->fragprog
= hwcso
;
579 nv50
->dirty
|= NV50_NEW_FRAGPROG
;
583 nv50_fp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
585 struct nv50_context
*nv50
= nv50_context(pipe
);
586 struct nv50_program
*p
= hwcso
;
588 nv50_program_destroy(nv50
, p
);
589 FREE((void *)p
->pipe
.tokens
);
594 nv50_gp_state_create(struct pipe_context
*pipe
,
595 const struct pipe_shader_state
*cso
)
597 struct nv50_program
*p
= CALLOC_STRUCT(nv50_program
);
599 p
->pipe
.tokens
= tgsi_dup_tokens(cso
->tokens
);
600 p
->type
= PIPE_SHADER_GEOMETRY
;
601 tgsi_scan_shader(p
->pipe
.tokens
, &p
->info
);
606 nv50_gp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
608 struct nv50_context
*nv50
= nv50_context(pipe
);
610 nv50
->fragprog
= hwcso
;
611 nv50
->dirty
|= NV50_NEW_GEOMPROG
;
615 nv50_gp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
617 struct nv50_context
*nv50
= nv50_context(pipe
);
618 struct nv50_program
*p
= hwcso
;
620 nv50_program_destroy(nv50
, p
);
621 FREE((void *)p
->pipe
.tokens
);
626 nv50_set_blend_color(struct pipe_context
*pipe
,
627 const struct pipe_blend_color
*bcol
)
629 struct nv50_context
*nv50
= nv50_context(pipe
);
631 nv50
->blend_colour
= *bcol
;
632 nv50
->dirty
|= NV50_NEW_BLEND_COLOUR
;
636 nv50_set_stencil_ref(struct pipe_context
*pipe
,
637 const struct pipe_stencil_ref
*sr
)
639 struct nv50_context
*nv50
= nv50_context(pipe
);
641 nv50
->stencil_ref
= *sr
;
642 nv50
->dirty
|= NV50_NEW_STENCIL_REF
;
646 nv50_set_clip_state(struct pipe_context
*pipe
,
647 const struct pipe_clip_state
*clip
)
652 nv50_set_constant_buffer(struct pipe_context
*pipe
, uint shader
, uint index
,
653 struct pipe_buffer
*buf
)
655 struct nv50_context
*nv50
= nv50_context(pipe
);
657 if (shader
== PIPE_SHADER_VERTEX
) {
658 nv50
->constbuf
[PIPE_SHADER_VERTEX
] = buf
;
659 nv50
->dirty
|= NV50_NEW_VERTPROG_CB
;
661 if (shader
== PIPE_SHADER_FRAGMENT
) {
662 nv50
->constbuf
[PIPE_SHADER_FRAGMENT
] = buf
;
663 nv50
->dirty
|= NV50_NEW_FRAGPROG_CB
;
665 if (shader
== PIPE_SHADER_GEOMETRY
) {
666 nv50
->constbuf
[PIPE_SHADER_GEOMETRY
] = buf
;
667 nv50
->dirty
|= NV50_NEW_GEOMPROG_CB
;
672 nv50_set_framebuffer_state(struct pipe_context
*pipe
,
673 const struct pipe_framebuffer_state
*fb
)
675 struct nv50_context
*nv50
= nv50_context(pipe
);
677 nv50
->framebuffer
= *fb
;
678 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
;
682 nv50_set_polygon_stipple(struct pipe_context
*pipe
,
683 const struct pipe_poly_stipple
*stipple
)
685 struct nv50_context
*nv50
= nv50_context(pipe
);
687 nv50
->stipple
= *stipple
;
688 nv50
->dirty
|= NV50_NEW_STIPPLE
;
692 nv50_set_scissor_state(struct pipe_context
*pipe
,
693 const struct pipe_scissor_state
*s
)
695 struct nv50_context
*nv50
= nv50_context(pipe
);
698 nv50
->dirty
|= NV50_NEW_SCISSOR
;
702 nv50_set_viewport_state(struct pipe_context
*pipe
,
703 const struct pipe_viewport_state
*vpt
)
705 struct nv50_context
*nv50
= nv50_context(pipe
);
707 nv50
->viewport
= *vpt
;
708 nv50
->dirty
|= NV50_NEW_VIEWPORT
;
712 nv50_set_vertex_buffers(struct pipe_context
*pipe
, unsigned count
,
713 const struct pipe_vertex_buffer
*vb
)
715 struct nv50_context
*nv50
= nv50_context(pipe
);
717 memcpy(nv50
->vtxbuf
, vb
, sizeof(*vb
) * count
);
718 nv50
->vtxbuf_nr
= count
;
720 nv50
->dirty
|= NV50_NEW_ARRAYS
;
724 nv50_set_vertex_elements(struct pipe_context
*pipe
, unsigned count
,
725 const struct pipe_vertex_element
*ve
)
727 struct nv50_context
*nv50
= nv50_context(pipe
);
729 memcpy(nv50
->vtxelt
, ve
, sizeof(*ve
) * count
);
730 nv50
->vtxelt_nr
= count
;
732 nv50
->dirty
|= NV50_NEW_ARRAYS
;
736 nv50_init_state_functions(struct nv50_context
*nv50
)
738 nv50
->pipe
.create_blend_state
= nv50_blend_state_create
;
739 nv50
->pipe
.bind_blend_state
= nv50_blend_state_bind
;
740 nv50
->pipe
.delete_blend_state
= nv50_blend_state_delete
;
742 nv50
->pipe
.create_sampler_state
= nv50_sampler_state_create
;
743 nv50
->pipe
.delete_sampler_state
= nv50_sampler_state_delete
;
744 nv50
->pipe
.bind_fragment_sampler_states
= nv50_fp_sampler_state_bind
;
745 nv50
->pipe
.bind_vertex_sampler_states
= nv50_vp_sampler_state_bind
;
746 nv50
->pipe
.set_fragment_sampler_textures
= nv50_set_fp_sampler_textures
;
747 nv50
->pipe
.set_vertex_sampler_textures
= nv50_set_vp_sampler_textures
;
749 nv50
->pipe
.create_rasterizer_state
= nv50_rasterizer_state_create
;
750 nv50
->pipe
.bind_rasterizer_state
= nv50_rasterizer_state_bind
;
751 nv50
->pipe
.delete_rasterizer_state
= nv50_rasterizer_state_delete
;
753 nv50
->pipe
.create_depth_stencil_alpha_state
=
754 nv50_depth_stencil_alpha_state_create
;
755 nv50
->pipe
.bind_depth_stencil_alpha_state
=
756 nv50_depth_stencil_alpha_state_bind
;
757 nv50
->pipe
.delete_depth_stencil_alpha_state
=
758 nv50_depth_stencil_alpha_state_delete
;
760 nv50
->pipe
.create_vs_state
= nv50_vp_state_create
;
761 nv50
->pipe
.bind_vs_state
= nv50_vp_state_bind
;
762 nv50
->pipe
.delete_vs_state
= nv50_vp_state_delete
;
764 nv50
->pipe
.create_fs_state
= nv50_fp_state_create
;
765 nv50
->pipe
.bind_fs_state
= nv50_fp_state_bind
;
766 nv50
->pipe
.delete_fs_state
= nv50_fp_state_delete
;
768 nv50
->pipe
.create_gs_state
= nv50_gp_state_create
;
769 nv50
->pipe
.bind_gs_state
= nv50_gp_state_bind
;
770 nv50
->pipe
.delete_gs_state
= nv50_gp_state_delete
;
772 nv50
->pipe
.set_blend_color
= nv50_set_blend_color
;
773 nv50
->pipe
.set_stencil_ref
= nv50_set_stencil_ref
;
774 nv50
->pipe
.set_clip_state
= nv50_set_clip_state
;
775 nv50
->pipe
.set_constant_buffer
= nv50_set_constant_buffer
;
776 nv50
->pipe
.set_framebuffer_state
= nv50_set_framebuffer_state
;
777 nv50
->pipe
.set_polygon_stipple
= nv50_set_polygon_stipple
;
778 nv50
->pipe
.set_scissor_state
= nv50_set_scissor_state
;
779 nv50
->pipe
.set_viewport_state
= nv50_set_viewport_state
;
781 nv50
->pipe
.set_vertex_buffers
= nv50_set_vertex_buffers
;
782 nv50
->pipe
.set_vertex_elements
= nv50_set_vertex_elements
;