1 #include "pipe/p_state.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_util.h"
4 #include "pipe/p_inlines.h"
6 #include "draw/draw_context.h"
8 #include "nv40_context.h"
9 #include "nv40_state.h"
12 nv40_blend_state_create(struct pipe_context
*pipe
,
13 const struct pipe_blend_state
*cso
)
15 struct nv40_context
*nv40
= nv40_context(pipe
);
16 struct nouveau_grobj
*curie
= nv40
->screen
->curie
;
17 struct nv40_blend_state
*bso
= CALLOC(1, sizeof(*bso
));
18 struct nouveau_stateobj
*so
= so_new(16, 0);
20 if (cso
->blend_enable
) {
21 so_method(so
, curie
, NV40TCL_BLEND_ENABLE
, 3);
23 so_data (so
, (nvgl_blend_func(cso
->alpha_src_factor
) << 16) |
24 nvgl_blend_func(cso
->rgb_src_factor
));
25 so_data (so
, nvgl_blend_func(cso
->alpha_dst_factor
) << 16 |
26 nvgl_blend_func(cso
->rgb_dst_factor
));
27 so_method(so
, curie
, NV40TCL_BLEND_EQUATION
, 1);
28 so_data (so
, nvgl_blend_eqn(cso
->alpha_func
) << 16 |
29 nvgl_blend_eqn(cso
->rgb_func
));
31 so_method(so
, curie
, NV40TCL_BLEND_ENABLE
, 1);
35 so_method(so
, curie
, NV40TCL_COLOR_MASK
, 1);
36 so_data (so
, (((cso
->colormask
& PIPE_MASK_A
) ? (0x01 << 24) : 0) |
37 ((cso
->colormask
& PIPE_MASK_R
) ? (0x01 << 16) : 0) |
38 ((cso
->colormask
& PIPE_MASK_G
) ? (0x01 << 8) : 0) |
39 ((cso
->colormask
& PIPE_MASK_B
) ? (0x01 << 0) : 0)));
41 if (cso
->logicop_enable
) {
42 so_method(so
, curie
, NV40TCL_COLOR_LOGIC_OP_ENABLE
, 2);
44 so_data (so
, nvgl_logicop_func(cso
->logicop_func
));
46 so_method(so
, curie
, NV40TCL_COLOR_LOGIC_OP_ENABLE
, 1);
50 so_method(so
, curie
, NV40TCL_DITHER_ENABLE
, 1);
51 so_data (so
, cso
->dither
? 1 : 0);
59 nv40_blend_state_bind(struct pipe_context
*pipe
, void *hwcso
)
61 struct nv40_context
*nv40
= nv40_context(pipe
);
64 nv40
->dirty
|= NV40_NEW_BLEND
;
68 nv40_blend_state_delete(struct pipe_context
*pipe
, void *hwcso
)
70 struct nv40_blend_state
*bso
= hwcso
;
72 so_ref(NULL
, &bso
->so
);
77 static INLINE
unsigned
78 wrap_mode(unsigned wrap
) {
82 case PIPE_TEX_WRAP_REPEAT
:
83 ret
= NV40TCL_TEX_WRAP_S_REPEAT
;
85 case PIPE_TEX_WRAP_MIRROR_REPEAT
:
86 ret
= NV40TCL_TEX_WRAP_S_MIRRORED_REPEAT
;
88 case PIPE_TEX_WRAP_CLAMP_TO_EDGE
:
89 ret
= NV40TCL_TEX_WRAP_S_CLAMP_TO_EDGE
;
91 case PIPE_TEX_WRAP_CLAMP_TO_BORDER
:
92 ret
= NV40TCL_TEX_WRAP_S_CLAMP_TO_BORDER
;
94 case PIPE_TEX_WRAP_CLAMP
:
95 ret
= NV40TCL_TEX_WRAP_S_CLAMP
;
97 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE
:
98 ret
= NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_EDGE
;
100 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER
:
101 ret
= NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_BORDER
;
103 case PIPE_TEX_WRAP_MIRROR_CLAMP
:
104 ret
= NV40TCL_TEX_WRAP_S_MIRROR_CLAMP
;
107 NOUVEAU_ERR("unknown wrap mode: %d\n", wrap
);
108 ret
= NV40TCL_TEX_WRAP_S_REPEAT
;
112 return ret
>> NV40TCL_TEX_WRAP_S_SHIFT
;
116 nv40_sampler_state_create(struct pipe_context
*pipe
,
117 const struct pipe_sampler_state
*cso
)
119 struct nv40_sampler_state
*ps
;
122 ps
= MALLOC(sizeof(struct nv40_sampler_state
));
125 if (!cso
->normalized_coords
)
126 ps
->fmt
|= NV40TCL_TEX_FORMAT_RECT
;
128 ps
->wrap
= ((wrap_mode(cso
->wrap_s
) << NV40TCL_TEX_WRAP_S_SHIFT
) |
129 (wrap_mode(cso
->wrap_t
) << NV40TCL_TEX_WRAP_T_SHIFT
) |
130 (wrap_mode(cso
->wrap_r
) << NV40TCL_TEX_WRAP_R_SHIFT
));
133 if (cso
->max_anisotropy
>= 2.0) {
134 /* no idea, binary driver sets it, works without it.. meh.. */
135 ps
->wrap
|= (1 << 5);
137 if (cso
->max_anisotropy
>= 16.0) {
138 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_16X
;
140 if (cso
->max_anisotropy
>= 12.0) {
141 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_12X
;
143 if (cso
->max_anisotropy
>= 10.0) {
144 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_10X
;
146 if (cso
->max_anisotropy
>= 8.0) {
147 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_8X
;
149 if (cso
->max_anisotropy
>= 6.0) {
150 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_6X
;
152 if (cso
->max_anisotropy
>= 4.0) {
153 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_4X
;
155 ps
->en
|= NV40TCL_TEX_ENABLE_ANISO_2X
;
159 switch (cso
->mag_img_filter
) {
160 case PIPE_TEX_FILTER_LINEAR
:
161 filter
|= NV40TCL_TEX_FILTER_MAG_LINEAR
;
163 case PIPE_TEX_FILTER_NEAREST
:
165 filter
|= NV40TCL_TEX_FILTER_MAG_NEAREST
;
169 switch (cso
->min_img_filter
) {
170 case PIPE_TEX_FILTER_LINEAR
:
171 switch (cso
->min_mip_filter
) {
172 case PIPE_TEX_MIPFILTER_NEAREST
:
173 filter
|= NV40TCL_TEX_FILTER_MIN_LINEAR_MIPMAP_NEAREST
;
175 case PIPE_TEX_MIPFILTER_LINEAR
:
176 filter
|= NV40TCL_TEX_FILTER_MIN_LINEAR_MIPMAP_LINEAR
;
178 case PIPE_TEX_MIPFILTER_NONE
:
180 filter
|= NV40TCL_TEX_FILTER_MIN_LINEAR
;
184 case PIPE_TEX_FILTER_NEAREST
:
186 switch (cso
->min_mip_filter
) {
187 case PIPE_TEX_MIPFILTER_NEAREST
:
188 filter
|= NV40TCL_TEX_FILTER_MIN_NEAREST_MIPMAP_NEAREST
;
190 case PIPE_TEX_MIPFILTER_LINEAR
:
191 filter
|= NV40TCL_TEX_FILTER_MIN_NEAREST_MIPMAP_LINEAR
;
193 case PIPE_TEX_MIPFILTER_NONE
:
195 filter
|= NV40TCL_TEX_FILTER_MIN_NEAREST
;
206 limit
= CLAMP(cso
->lod_bias
, -16.0, 15.0);
207 ps
->filt
|= (int)(cso
->lod_bias
* 256.0) & 0x1fff;
209 limit
= CLAMP(cso
->max_lod
, 0.0, 15.0);
210 ps
->en
|= (int)(limit
* 256.0) << 7;
212 limit
= CLAMP(cso
->min_lod
, 0.0, 15.0);
213 ps
->en
|= (int)(limit
* 256.0) << 19;
217 if (cso
->compare_mode
== PIPE_TEX_COMPARE_R_TO_TEXTURE
) {
218 switch (cso
->compare_func
) {
219 case PIPE_FUNC_NEVER
:
220 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_NEVER
;
222 case PIPE_FUNC_GREATER
:
223 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_GREATER
;
225 case PIPE_FUNC_EQUAL
:
226 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_EQUAL
;
228 case PIPE_FUNC_GEQUAL
:
229 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_GEQUAL
;
232 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_LESS
;
234 case PIPE_FUNC_NOTEQUAL
:
235 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_NOTEQUAL
;
237 case PIPE_FUNC_LEQUAL
:
238 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_LEQUAL
;
240 case PIPE_FUNC_ALWAYS
:
241 ps
->wrap
|= NV40TCL_TEX_WRAP_RCOMP_ALWAYS
;
248 ps
->bcol
= ((float_to_ubyte(cso
->border_color
[3]) << 24) |
249 (float_to_ubyte(cso
->border_color
[0]) << 16) |
250 (float_to_ubyte(cso
->border_color
[1]) << 8) |
251 (float_to_ubyte(cso
->border_color
[2]) << 0));
257 nv40_sampler_state_bind(struct pipe_context
*pipe
, unsigned nr
, void **sampler
)
259 struct nv40_context
*nv40
= nv40_context(pipe
);
262 for (unit
= 0; unit
< nr
; unit
++) {
263 nv40
->tex_sampler
[unit
] = sampler
[unit
];
264 nv40
->dirty_samplers
|= (1 << unit
);
267 for (unit
= nr
; unit
< nv40
->nr_samplers
; unit
++) {
268 nv40
->tex_sampler
[unit
] = NULL
;
269 nv40
->dirty_samplers
|= (1 << unit
);
272 nv40
->nr_samplers
= nr
;
273 nv40
->dirty
|= NV40_NEW_SAMPLER
;
277 nv40_sampler_state_delete(struct pipe_context
*pipe
, void *hwcso
)
283 nv40_set_sampler_texture(struct pipe_context
*pipe
, unsigned nr
,
284 struct pipe_texture
**miptree
)
286 struct nv40_context
*nv40
= nv40_context(pipe
);
289 for (unit
= 0; unit
< nr
; unit
++) {
290 pipe_texture_reference((struct pipe_texture
**)
291 &nv40
->tex_miptree
[unit
], miptree
[unit
]);
292 nv40
->dirty_samplers
|= (1 << unit
);
295 for (unit
= nr
; unit
< nv40
->nr_textures
; unit
++) {
296 pipe_texture_reference((struct pipe_texture
**)
297 &nv40
->tex_miptree
[unit
], NULL
);
298 nv40
->dirty_samplers
|= (1 << unit
);
301 nv40
->nr_textures
= nr
;
302 nv40
->dirty
|= NV40_NEW_SAMPLER
;
306 nv40_rasterizer_state_create(struct pipe_context
*pipe
,
307 const struct pipe_rasterizer_state
*cso
)
309 struct nv40_context
*nv40
= nv40_context(pipe
);
310 struct nv40_rasterizer_state
*rsso
= CALLOC(1, sizeof(*rsso
));
311 struct nouveau_stateobj
*so
= so_new(32, 0);
312 struct nouveau_grobj
*curie
= nv40
->screen
->curie
;
320 so_method(so
, curie
, NV40TCL_SHADE_MODEL
, 1);
321 so_data (so
, cso
->flatshade
? NV40TCL_SHADE_MODEL_FLAT
:
322 NV40TCL_SHADE_MODEL_SMOOTH
);
324 so_method(so
, curie
, NV40TCL_LINE_WIDTH
, 2);
325 so_data (so
, (unsigned char)(cso
->line_width
* 8.0) & 0xff);
326 so_data (so
, cso
->line_smooth
? 1 : 0);
327 so_method(so
, curie
, NV40TCL_LINE_STIPPLE_ENABLE
, 2);
328 so_data (so
, cso
->line_stipple_enable
? 1 : 0);
329 so_data (so
, (cso
->line_stipple_pattern
<< 16) |
330 cso
->line_stipple_factor
);
332 so_method(so
, curie
, NV40TCL_POINT_SIZE
, 1);
333 so_data (so
, fui(cso
->point_size
));
335 so_method(so
, curie
, NV40TCL_POLYGON_MODE_FRONT
, 6);
336 if (cso
->front_winding
== PIPE_WINDING_CCW
) {
337 so_data(so
, nvgl_polygon_mode(cso
->fill_ccw
));
338 so_data(so
, nvgl_polygon_mode(cso
->fill_cw
));
339 switch (cso
->cull_mode
) {
340 case PIPE_WINDING_CCW
:
341 so_data(so
, NV40TCL_CULL_FACE_FRONT
);
343 case PIPE_WINDING_CW
:
344 so_data(so
, NV40TCL_CULL_FACE_BACK
);
346 case PIPE_WINDING_BOTH
:
347 so_data(so
, NV40TCL_CULL_FACE_FRONT_AND_BACK
);
350 so_data(so
, NV40TCL_CULL_FACE_BACK
);
353 so_data(so
, NV40TCL_FRONT_FACE_CCW
);
355 so_data(so
, nvgl_polygon_mode(cso
->fill_cw
));
356 so_data(so
, nvgl_polygon_mode(cso
->fill_ccw
));
357 switch (cso
->cull_mode
) {
358 case PIPE_WINDING_CCW
:
359 so_data(so
, NV40TCL_CULL_FACE_BACK
);
361 case PIPE_WINDING_CW
:
362 so_data(so
, NV40TCL_CULL_FACE_FRONT
);
364 case PIPE_WINDING_BOTH
:
365 so_data(so
, NV40TCL_CULL_FACE_FRONT_AND_BACK
);
368 so_data(so
, NV40TCL_CULL_FACE_BACK
);
371 so_data(so
, NV40TCL_FRONT_FACE_CW
);
373 so_data(so
, cso
->poly_smooth
? 1 : 0);
374 so_data(so
, (cso
->cull_mode
!= PIPE_WINDING_NONE
) ? 1 : 0);
376 so_method(so
, curie
, NV40TCL_POLYGON_STIPPLE_ENABLE
, 1);
377 so_data (so
, cso
->poly_stipple_enable
? 1 : 0);
379 so_method(so
, curie
, NV40TCL_POLYGON_OFFSET_POINT_ENABLE
, 3);
380 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_POINT
) ||
381 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_POINT
))
385 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_LINE
) ||
386 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_LINE
))
390 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_FILL
) ||
391 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_FILL
))
395 if (cso
->offset_cw
|| cso
->offset_ccw
) {
396 so_method(so
, curie
, NV40TCL_POLYGON_OFFSET_FACTOR
, 2);
397 so_data (so
, fui(cso
->offset_scale
));
398 so_data (so
, fui(cso
->offset_units
* 2));
401 so_method(so
, curie
, NV40TCL_POINT_SPRITE
, 1);
402 if (cso
->point_sprite
) {
403 unsigned psctl
= (1 << 0), i
;
405 for (i
= 0; i
< 8; i
++) {
406 if (cso
->sprite_coord_mode
[i
] != PIPE_SPRITE_COORD_NONE
)
407 psctl
|= (1 << (8 + i
));
415 so_ref(so
, &rsso
->so
);
421 nv40_rasterizer_state_bind(struct pipe_context
*pipe
, void *hwcso
)
423 struct nv40_context
*nv40
= nv40_context(pipe
);
425 nv40
->rasterizer
= hwcso
;
426 nv40
->dirty
|= NV40_NEW_RAST
;
427 nv40
->draw_dirty
|= NV40_NEW_RAST
;
431 nv40_rasterizer_state_delete(struct pipe_context
*pipe
, void *hwcso
)
433 struct nv40_rasterizer_state
*rsso
= hwcso
;
435 so_ref(NULL
, &rsso
->so
);
440 nv40_depth_stencil_alpha_state_create(struct pipe_context
*pipe
,
441 const struct pipe_depth_stencil_alpha_state
*cso
)
443 struct nv40_context
*nv40
= nv40_context(pipe
);
444 struct nv40_zsa_state
*zsaso
= CALLOC(1, sizeof(*zsaso
));
445 struct nouveau_stateobj
*so
= so_new(32, 0);
446 struct nouveau_grobj
*curie
= nv40
->screen
->curie
;
448 so_method(so
, curie
, NV40TCL_DEPTH_FUNC
, 3);
449 so_data (so
, nvgl_comparison_op(cso
->depth
.func
));
450 so_data (so
, cso
->depth
.writemask
? 1 : 0);
451 so_data (so
, cso
->depth
.enabled
? 1 : 0);
453 so_method(so
, curie
, NV40TCL_ALPHA_TEST_ENABLE
, 3);
454 so_data (so
, cso
->alpha
.enabled
? 1 : 0);
455 so_data (so
, nvgl_comparison_op(cso
->alpha
.func
));
456 so_data (so
, float_to_ubyte(cso
->alpha
.ref
));
458 if (cso
->stencil
[0].enabled
) {
459 so_method(so
, curie
, NV40TCL_STENCIL_FRONT_ENABLE
, 8);
460 so_data (so
, cso
->stencil
[0].enabled
? 1 : 0);
461 so_data (so
, cso
->stencil
[0].write_mask
);
462 so_data (so
, nvgl_comparison_op(cso
->stencil
[0].func
));
463 so_data (so
, cso
->stencil
[0].ref_value
);
464 so_data (so
, cso
->stencil
[0].value_mask
);
465 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].fail_op
));
466 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].zfail_op
));
467 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].zpass_op
));
469 so_method(so
, curie
, NV40TCL_STENCIL_FRONT_ENABLE
, 1);
473 if (cso
->stencil
[1].enabled
) {
474 so_method(so
, curie
, NV40TCL_STENCIL_BACK_ENABLE
, 8);
475 so_data (so
, cso
->stencil
[1].enabled
? 1 : 0);
476 so_data (so
, cso
->stencil
[1].write_mask
);
477 so_data (so
, nvgl_comparison_op(cso
->stencil
[1].func
));
478 so_data (so
, cso
->stencil
[1].ref_value
);
479 so_data (so
, cso
->stencil
[1].value_mask
);
480 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].fail_op
));
481 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].zfail_op
));
482 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].zpass_op
));
484 so_method(so
, curie
, NV40TCL_STENCIL_BACK_ENABLE
, 1);
488 so_ref(so
, &zsaso
->so
);
490 return (void *)zsaso
;
494 nv40_depth_stencil_alpha_state_bind(struct pipe_context
*pipe
, void *hwcso
)
496 struct nv40_context
*nv40
= nv40_context(pipe
);
499 nv40
->dirty
|= NV40_NEW_ZSA
;
503 nv40_depth_stencil_alpha_state_delete(struct pipe_context
*pipe
, void *hwcso
)
505 struct nv40_zsa_state
*zsaso
= hwcso
;
507 so_ref(NULL
, &zsaso
->so
);
512 nv40_vp_state_create(struct pipe_context
*pipe
,
513 const struct pipe_shader_state
*cso
)
515 struct nv40_context
*nv40
= nv40_context(pipe
);
516 struct nv40_vertex_program
*vp
;
518 vp
= CALLOC(1, sizeof(struct nv40_vertex_program
));
520 vp
->draw
= draw_create_vertex_shader(nv40
->draw
, &vp
->pipe
);
526 nv40_vp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
528 struct nv40_context
*nv40
= nv40_context(pipe
);
530 nv40
->vertprog
= hwcso
;
531 nv40
->dirty
|= NV40_NEW_VERTPROG
;
532 nv40
->draw_dirty
|= NV40_NEW_VERTPROG
;
536 nv40_vp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
538 struct nv40_context
*nv40
= nv40_context(pipe
);
539 struct nv40_vertex_program
*vp
= hwcso
;
541 draw_delete_vertex_shader(nv40
->draw
, vp
->draw
);
542 nv40_vertprog_destroy(nv40
, vp
);
547 nv40_fp_state_create(struct pipe_context
*pipe
,
548 const struct pipe_shader_state
*cso
)
550 struct nv40_fragment_program
*fp
;
552 fp
= CALLOC(1, sizeof(struct nv40_fragment_program
));
555 tgsi_scan_shader(fp
->pipe
.tokens
, &fp
->info
);
561 nv40_fp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
563 struct nv40_context
*nv40
= nv40_context(pipe
);
565 nv40
->fragprog
= hwcso
;
566 nv40
->dirty
|= NV40_NEW_FRAGPROG
;
570 nv40_fp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
572 struct nv40_context
*nv40
= nv40_context(pipe
);
573 struct nv40_fragment_program
*fp
= hwcso
;
575 nv40_fragprog_destroy(nv40
, fp
);
580 nv40_set_blend_color(struct pipe_context
*pipe
,
581 const struct pipe_blend_color
*bcol
)
583 struct nv40_context
*nv40
= nv40_context(pipe
);
585 nv40
->blend_colour
= *bcol
;
586 nv40
->dirty
|= NV40_NEW_BCOL
;
590 nv40_set_clip_state(struct pipe_context
*pipe
,
591 const struct pipe_clip_state
*clip
)
593 struct nv40_context
*nv40
= nv40_context(pipe
);
596 nv40
->dirty
|= NV40_NEW_UCP
;
597 nv40
->draw_dirty
|= NV40_NEW_UCP
;
601 nv40_set_constant_buffer(struct pipe_context
*pipe
, uint shader
, uint index
,
602 const struct pipe_constant_buffer
*buf
)
604 struct nv40_context
*nv40
= nv40_context(pipe
);
606 nv40
->constbuf
[shader
] = buf
->buffer
;
607 nv40
->constbuf_nr
[shader
] = buf
->size
/ (4 * sizeof(float));
609 if (shader
== PIPE_SHADER_VERTEX
) {
610 nv40
->dirty
|= NV40_NEW_VERTPROG
;
612 if (shader
== PIPE_SHADER_FRAGMENT
) {
613 nv40
->dirty
|= NV40_NEW_FRAGPROG
;
618 nv40_set_framebuffer_state(struct pipe_context
*pipe
,
619 const struct pipe_framebuffer_state
*fb
)
621 struct nv40_context
*nv40
= nv40_context(pipe
);
623 nv40
->framebuffer
= *fb
;
624 nv40
->dirty
|= NV40_NEW_FB
;
628 nv40_set_polygon_stipple(struct pipe_context
*pipe
,
629 const struct pipe_poly_stipple
*stipple
)
631 struct nv40_context
*nv40
= nv40_context(pipe
);
633 memcpy(nv40
->stipple
, stipple
->stipple
, 4 * 32);
634 nv40
->dirty
|= NV40_NEW_STIPPLE
;
638 nv40_set_scissor_state(struct pipe_context
*pipe
,
639 const struct pipe_scissor_state
*s
)
641 struct nv40_context
*nv40
= nv40_context(pipe
);
644 nv40
->dirty
|= NV40_NEW_SCISSOR
;
648 nv40_set_viewport_state(struct pipe_context
*pipe
,
649 const struct pipe_viewport_state
*vpt
)
651 struct nv40_context
*nv40
= nv40_context(pipe
);
653 nv40
->viewport
= *vpt
;
654 nv40
->dirty
|= NV40_NEW_VIEWPORT
;
655 nv40
->draw_dirty
|= NV40_NEW_VIEWPORT
;
659 nv40_set_vertex_buffers(struct pipe_context
*pipe
, unsigned count
,
660 const struct pipe_vertex_buffer
*vb
)
662 struct nv40_context
*nv40
= nv40_context(pipe
);
664 memcpy(nv40
->vtxbuf
, vb
, sizeof(*vb
) * count
);
665 nv40
->vtxbuf_nr
= count
;
667 nv40
->dirty
|= NV40_NEW_ARRAYS
;
668 nv40
->draw_dirty
|= NV40_NEW_ARRAYS
;
672 nv40_set_vertex_elements(struct pipe_context
*pipe
, unsigned count
,
673 const struct pipe_vertex_element
*ve
)
675 struct nv40_context
*nv40
= nv40_context(pipe
);
677 memcpy(nv40
->vtxelt
, ve
, sizeof(*ve
) * count
);
678 nv40
->vtxelt_nr
= count
;
680 nv40
->dirty
|= NV40_NEW_ARRAYS
;
681 nv40
->draw_dirty
|= NV40_NEW_ARRAYS
;
685 nv40_set_edgeflags(struct pipe_context
*pipe
, const unsigned *bitfield
)
687 struct nv40_context
*nv40
= nv40_context(pipe
);
689 nv40
->edgeflags
= bitfield
;
690 nv40
->dirty
|= NV40_NEW_ARRAYS
;
691 nv40
->draw_dirty
|= NV40_NEW_ARRAYS
;
695 nv40_init_state_functions(struct nv40_context
*nv40
)
697 nv40
->pipe
.create_blend_state
= nv40_blend_state_create
;
698 nv40
->pipe
.bind_blend_state
= nv40_blend_state_bind
;
699 nv40
->pipe
.delete_blend_state
= nv40_blend_state_delete
;
701 nv40
->pipe
.create_sampler_state
= nv40_sampler_state_create
;
702 nv40
->pipe
.bind_sampler_states
= nv40_sampler_state_bind
;
703 nv40
->pipe
.delete_sampler_state
= nv40_sampler_state_delete
;
704 nv40
->pipe
.set_sampler_textures
= nv40_set_sampler_texture
;
706 nv40
->pipe
.create_rasterizer_state
= nv40_rasterizer_state_create
;
707 nv40
->pipe
.bind_rasterizer_state
= nv40_rasterizer_state_bind
;
708 nv40
->pipe
.delete_rasterizer_state
= nv40_rasterizer_state_delete
;
710 nv40
->pipe
.create_depth_stencil_alpha_state
=
711 nv40_depth_stencil_alpha_state_create
;
712 nv40
->pipe
.bind_depth_stencil_alpha_state
=
713 nv40_depth_stencil_alpha_state_bind
;
714 nv40
->pipe
.delete_depth_stencil_alpha_state
=
715 nv40_depth_stencil_alpha_state_delete
;
717 nv40
->pipe
.create_vs_state
= nv40_vp_state_create
;
718 nv40
->pipe
.bind_vs_state
= nv40_vp_state_bind
;
719 nv40
->pipe
.delete_vs_state
= nv40_vp_state_delete
;
721 nv40
->pipe
.create_fs_state
= nv40_fp_state_create
;
722 nv40
->pipe
.bind_fs_state
= nv40_fp_state_bind
;
723 nv40
->pipe
.delete_fs_state
= nv40_fp_state_delete
;
725 nv40
->pipe
.set_blend_color
= nv40_set_blend_color
;
726 nv40
->pipe
.set_clip_state
= nv40_set_clip_state
;
727 nv40
->pipe
.set_constant_buffer
= nv40_set_constant_buffer
;
728 nv40
->pipe
.set_framebuffer_state
= nv40_set_framebuffer_state
;
729 nv40
->pipe
.set_polygon_stipple
= nv40_set_polygon_stipple
;
730 nv40
->pipe
.set_scissor_state
= nv40_set_scissor_state
;
731 nv40
->pipe
.set_viewport_state
= nv40_set_viewport_state
;
733 nv40
->pipe
.set_edgeflags
= nv40_set_edgeflags
;
734 nv40
->pipe
.set_vertex_buffers
= nv40_set_vertex_buffers
;
735 nv40
->pipe
.set_vertex_elements
= nv40_set_vertex_elements
;