1 #include "pipe/p_state.h"
2 #include "pipe/p_defines.h"
3 #include "util/u_inlines.h"
5 #include "tgsi/tgsi_parse.h"
7 #include "nv30_context.h"
8 #include "nv30_state.h"
11 nv30_blend_state_create(struct pipe_context
*pipe
,
12 const struct pipe_blend_state
*cso
)
14 struct nv30_context
*nv30
= nv30_context(pipe
);
15 struct nouveau_grobj
*rankine
= nv30
->screen
->rankine
;
16 struct nv30_blend_state
*bso
= CALLOC(1, sizeof(*bso
));
17 struct nouveau_stateobj
*so
= so_new(5, 8, 0);
19 if (cso
->rt
[0].blend_enable
) {
20 so_method(so
, rankine
, NV34TCL_BLEND_FUNC_ENABLE
, 3);
22 so_data (so
, (nvgl_blend_func(cso
->rt
[0].alpha_src_factor
) << 16) |
23 nvgl_blend_func(cso
->rt
[0].rgb_src_factor
));
24 so_data (so
, nvgl_blend_func(cso
->rt
[0].alpha_dst_factor
) << 16 |
25 nvgl_blend_func(cso
->rt
[0].rgb_dst_factor
));
26 /* FIXME: Gallium assumes GL_EXT_blend_func_separate.
27 It is not the case for NV30 */
28 so_method(so
, rankine
, NV34TCL_BLEND_EQUATION
, 1);
29 so_data (so
, nvgl_blend_eqn(cso
->rt
[0].rgb_func
));
31 so_method(so
, rankine
, NV34TCL_BLEND_FUNC_ENABLE
, 1);
35 so_method(so
, rankine
, NV34TCL_COLOR_MASK
, 1);
36 so_data (so
, (((cso
->rt
[0].colormask
& PIPE_MASK_A
) ? (0x01 << 24) : 0) |
37 ((cso
->rt
[0].colormask
& PIPE_MASK_R
) ? (0x01 << 16) : 0) |
38 ((cso
->rt
[0].colormask
& PIPE_MASK_G
) ? (0x01 << 8) : 0) |
39 ((cso
->rt
[0].colormask
& PIPE_MASK_B
) ? (0x01 << 0) : 0)));
41 if (cso
->logicop_enable
) {
42 so_method(so
, rankine
, NV34TCL_COLOR_LOGIC_OP_ENABLE
, 2);
44 so_data (so
, nvgl_logicop_func(cso
->logicop_func
));
46 so_method(so
, rankine
, NV34TCL_COLOR_LOGIC_OP_ENABLE
, 1);
50 so_method(so
, rankine
, NV34TCL_DITHER_ENABLE
, 1);
51 so_data (so
, cso
->dither
? 1 : 0);
60 nv30_blend_state_bind(struct pipe_context
*pipe
, void *hwcso
)
62 struct nv30_context
*nv30
= nv30_context(pipe
);
65 nv30
->dirty
|= NV30_NEW_BLEND
;
69 nv30_blend_state_delete(struct pipe_context
*pipe
, void *hwcso
)
71 struct nv30_blend_state
*bso
= hwcso
;
73 so_ref(NULL
, &bso
->so
);
78 static INLINE
unsigned
79 wrap_mode(unsigned wrap
) {
83 case PIPE_TEX_WRAP_REPEAT
:
84 ret
= NV34TCL_TX_WRAP_S_REPEAT
;
86 case PIPE_TEX_WRAP_MIRROR_REPEAT
:
87 ret
= NV34TCL_TX_WRAP_S_MIRRORED_REPEAT
;
89 case PIPE_TEX_WRAP_CLAMP_TO_EDGE
:
90 ret
= NV34TCL_TX_WRAP_S_CLAMP_TO_EDGE
;
92 case PIPE_TEX_WRAP_CLAMP_TO_BORDER
:
93 ret
= NV34TCL_TX_WRAP_S_CLAMP_TO_BORDER
;
95 case PIPE_TEX_WRAP_CLAMP
:
96 ret
= NV34TCL_TX_WRAP_S_CLAMP
;
98 /* case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
99 ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP_TO_EDGE;
101 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
102 ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP_TO_BORDER;
104 case PIPE_TEX_WRAP_MIRROR_CLAMP:
105 ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP;
108 NOUVEAU_ERR("unknown wrap mode: %d\n", wrap
);
109 ret
= NV34TCL_TX_WRAP_S_REPEAT
;
113 return ret
>> NV34TCL_TX_WRAP_S_SHIFT
;
117 nv30_sampler_state_create(struct pipe_context
*pipe
,
118 const struct pipe_sampler_state
*cso
)
120 struct nv30_sampler_state
*ps
;
123 ps
= MALLOC(sizeof(struct nv30_sampler_state
));
126 /* TODO: Not all RECTs formats have this bit set, bits 15-8 of format
127 are the tx format to use. We should store normalized coord flag
128 in sampler state structure, and set appropriate format in
131 /*NV34TCL_TX_FORMAT_RECT*/
132 /*if (!cso->normalized_coords) {
136 ps
->wrap
= ((wrap_mode(cso
->wrap_s
) << NV34TCL_TX_WRAP_S_SHIFT
) |
137 (wrap_mode(cso
->wrap_t
) << NV34TCL_TX_WRAP_T_SHIFT
) |
138 (wrap_mode(cso
->wrap_r
) << NV34TCL_TX_WRAP_R_SHIFT
));
142 if (cso
->max_anisotropy
>= 8) {
143 ps
->en
|= NV34TCL_TX_ENABLE_ANISO_8X
;
145 if (cso
->max_anisotropy
>= 4) {
146 ps
->en
|= NV34TCL_TX_ENABLE_ANISO_4X
;
148 if (cso
->max_anisotropy
>= 2) {
149 ps
->en
|= NV34TCL_TX_ENABLE_ANISO_2X
;
152 switch (cso
->mag_img_filter
) {
153 case PIPE_TEX_FILTER_LINEAR
:
154 filter
|= NV34TCL_TX_FILTER_MAGNIFY_LINEAR
;
156 case PIPE_TEX_FILTER_NEAREST
:
158 filter
|= NV34TCL_TX_FILTER_MAGNIFY_NEAREST
;
162 switch (cso
->min_img_filter
) {
163 case PIPE_TEX_FILTER_LINEAR
:
164 switch (cso
->min_mip_filter
) {
165 case PIPE_TEX_MIPFILTER_NEAREST
:
166 filter
|= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST
;
168 case PIPE_TEX_MIPFILTER_LINEAR
:
169 filter
|= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR
;
171 case PIPE_TEX_MIPFILTER_NONE
:
173 filter
|= NV34TCL_TX_FILTER_MINIFY_LINEAR
;
177 case PIPE_TEX_FILTER_NEAREST
:
179 switch (cso
->min_mip_filter
) {
180 case PIPE_TEX_MIPFILTER_NEAREST
:
181 filter
|= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST
;
183 case PIPE_TEX_MIPFILTER_LINEAR
:
184 filter
|= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR
;
186 case PIPE_TEX_MIPFILTER_NONE
:
188 filter
|= NV34TCL_TX_FILTER_MINIFY_NEAREST
;
199 limit
= CLAMP(cso
->lod_bias
, -16.0, 15.0);
200 ps
->filt
|= (int)(cso
->lod_bias
* 256.0) & 0x1fff;
202 limit
= CLAMP(cso
->max_lod
, 0.0, 15.0);
203 ps
->en
|= (int)(limit
) << 14 /*NV34TCL_TX_ENABLE_MIPMAP_MAX_LOD_SHIFT*/;
205 limit
= CLAMP(cso
->min_lod
, 0.0, 15.0);
206 ps
->en
|= (int)(limit
) << 26 /*NV34TCL_TX_ENABLE_MIPMAP_MIN_LOD_SHIFT*/;
209 if (cso
->compare_mode
== PIPE_TEX_COMPARE_R_TO_TEXTURE
) {
210 switch (cso
->compare_func
) {
211 case PIPE_FUNC_NEVER
:
212 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_NEVER
;
214 case PIPE_FUNC_GREATER
:
215 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_GREATER
;
217 case PIPE_FUNC_EQUAL
:
218 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_EQUAL
;
220 case PIPE_FUNC_GEQUAL
:
221 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_GEQUAL
;
224 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_LESS
;
226 case PIPE_FUNC_NOTEQUAL
:
227 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_NOTEQUAL
;
229 case PIPE_FUNC_LEQUAL
:
230 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_LEQUAL
;
232 case PIPE_FUNC_ALWAYS
:
233 ps
->wrap
|= NV34TCL_TX_WRAP_RCOMP_ALWAYS
;
240 ps
->bcol
= ((float_to_ubyte(cso
->border_color
[3]) << 24) |
241 (float_to_ubyte(cso
->border_color
[0]) << 16) |
242 (float_to_ubyte(cso
->border_color
[1]) << 8) |
243 (float_to_ubyte(cso
->border_color
[2]) << 0));
249 nv30_sampler_state_bind(struct pipe_context
*pipe
, unsigned nr
, void **sampler
)
251 struct nv30_context
*nv30
= nv30_context(pipe
);
254 for (unit
= 0; unit
< nr
; unit
++) {
255 nv30
->tex_sampler
[unit
] = sampler
[unit
];
256 nv30
->dirty_samplers
|= (1 << unit
);
259 for (unit
= nr
; unit
< nv30
->nr_samplers
; unit
++) {
260 nv30
->tex_sampler
[unit
] = NULL
;
261 nv30
->dirty_samplers
|= (1 << unit
);
264 nv30
->nr_samplers
= nr
;
265 nv30
->dirty
|= NV30_NEW_SAMPLER
;
269 nv30_sampler_state_delete(struct pipe_context
*pipe
, void *hwcso
)
275 nv30_set_fragment_sampler_views(struct pipe_context
*pipe
,
277 struct pipe_sampler_view
**views
)
279 struct nv30_context
*nv30
= nv30_context(pipe
);
282 for (unit
= 0; unit
< nr
; unit
++) {
283 pipe_sampler_view_reference(&nv30
->fragment_sampler_views
[unit
], views
[unit
]);
284 pipe_texture_reference((struct pipe_texture
**)
285 &nv30
->tex_miptree
[unit
], views
[unit
]->texture
);
286 nv30
->dirty_samplers
|= (1 << unit
);
289 for (unit
= nr
; unit
< nv30
->nr_textures
; unit
++) {
290 pipe_sampler_view_reference(&nv30
->fragment_sampler_views
[unit
], NULL
);
291 pipe_texture_reference((struct pipe_texture
**)
292 &nv30
->tex_miptree
[unit
], NULL
);
293 nv30
->dirty_samplers
|= (1 << unit
);
296 nv30
->nr_textures
= nr
;
297 nv30
->dirty
|= NV30_NEW_SAMPLER
;
300 static struct pipe_sampler_view
*
301 nv30_create_sampler_view(struct pipe_context
*pipe
,
302 struct pipe_texture
*texture
,
303 const struct pipe_sampler_view
*templ
)
305 struct pipe_sampler_view
*view
= CALLOC_STRUCT(pipe_sampler_view
);
309 view
->reference
.count
= 1;
310 view
->texture
= NULL
;
311 pipe_texture_reference(&view
->texture
, texture
);
312 view
->context
= pipe
;
320 nv30_sampler_view_destroy(struct pipe_context
*pipe
,
321 struct pipe_sampler_view
*view
)
323 pipe_texture_reference(&view
->texture
, NULL
);
328 nv30_rasterizer_state_create(struct pipe_context
*pipe
,
329 const struct pipe_rasterizer_state
*cso
)
331 struct nv30_context
*nv30
= nv30_context(pipe
);
332 struct nv30_rasterizer_state
*rsso
= CALLOC(1, sizeof(*rsso
));
333 struct nouveau_stateobj
*so
= so_new(9, 19, 0);
334 struct nouveau_grobj
*rankine
= nv30
->screen
->rankine
;
342 so_method(so
, rankine
, NV34TCL_SHADE_MODEL
, 1);
343 so_data (so
, cso
->flatshade
? NV34TCL_SHADE_MODEL_FLAT
:
344 NV34TCL_SHADE_MODEL_SMOOTH
);
346 so_method(so
, rankine
, NV34TCL_LINE_WIDTH
, 2);
347 so_data (so
, (unsigned char)(cso
->line_width
* 8.0) & 0xff);
348 so_data (so
, cso
->line_smooth
? 1 : 0);
349 so_method(so
, rankine
, NV34TCL_LINE_STIPPLE_ENABLE
, 2);
350 so_data (so
, cso
->line_stipple_enable
? 1 : 0);
351 so_data (so
, (cso
->line_stipple_pattern
<< 16) |
352 cso
->line_stipple_factor
);
354 so_method(so
, rankine
, NV34TCL_POINT_SIZE
, 1);
355 so_data (so
, fui(cso
->point_size
));
357 so_method(so
, rankine
, NV34TCL_POLYGON_MODE_FRONT
, 6);
358 if (cso
->front_winding
== PIPE_WINDING_CCW
) {
359 so_data(so
, nvgl_polygon_mode(cso
->fill_ccw
));
360 so_data(so
, nvgl_polygon_mode(cso
->fill_cw
));
361 switch (cso
->cull_mode
) {
362 case PIPE_WINDING_CCW
:
363 so_data(so
, NV34TCL_CULL_FACE_FRONT
);
365 case PIPE_WINDING_CW
:
366 so_data(so
, NV34TCL_CULL_FACE_BACK
);
368 case PIPE_WINDING_BOTH
:
369 so_data(so
, NV34TCL_CULL_FACE_FRONT_AND_BACK
);
372 so_data(so
, NV34TCL_CULL_FACE_BACK
);
375 so_data(so
, NV34TCL_FRONT_FACE_CCW
);
377 so_data(so
, nvgl_polygon_mode(cso
->fill_cw
));
378 so_data(so
, nvgl_polygon_mode(cso
->fill_ccw
));
379 switch (cso
->cull_mode
) {
380 case PIPE_WINDING_CCW
:
381 so_data(so
, NV34TCL_CULL_FACE_BACK
);
383 case PIPE_WINDING_CW
:
384 so_data(so
, NV34TCL_CULL_FACE_FRONT
);
386 case PIPE_WINDING_BOTH
:
387 so_data(so
, NV34TCL_CULL_FACE_FRONT_AND_BACK
);
390 so_data(so
, NV34TCL_CULL_FACE_BACK
);
393 so_data(so
, NV34TCL_FRONT_FACE_CW
);
395 so_data(so
, cso
->poly_smooth
? 1 : 0);
396 so_data(so
, (cso
->cull_mode
!= PIPE_WINDING_NONE
) ? 1 : 0);
398 so_method(so
, rankine
, NV34TCL_POLYGON_STIPPLE_ENABLE
, 1);
399 so_data (so
, cso
->poly_stipple_enable
? 1 : 0);
401 so_method(so
, rankine
, NV34TCL_POLYGON_OFFSET_POINT_ENABLE
, 3);
402 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_POINT
) ||
403 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_POINT
))
407 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_LINE
) ||
408 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_LINE
))
412 if ((cso
->offset_cw
&& cso
->fill_cw
== PIPE_POLYGON_MODE_FILL
) ||
413 (cso
->offset_ccw
&& cso
->fill_ccw
== PIPE_POLYGON_MODE_FILL
))
417 if (cso
->offset_cw
|| cso
->offset_ccw
) {
418 so_method(so
, rankine
, NV34TCL_POLYGON_OFFSET_FACTOR
, 2);
419 so_data (so
, fui(cso
->offset_scale
));
420 so_data (so
, fui(cso
->offset_units
* 2));
423 so_method(so
, rankine
, NV34TCL_POINT_SPRITE
, 1);
424 if (cso
->point_quad_rasterization
) {
425 unsigned psctl
= (1 << 0), i
;
427 for (i
= 0; i
< 8; i
++) {
428 if ((cso
->sprite_coord_enable
>> i
) & 1)
429 psctl
|= (1 << (8 + i
));
437 so_ref(so
, &rsso
->so
);
444 nv30_rasterizer_state_bind(struct pipe_context
*pipe
, void *hwcso
)
446 struct nv30_context
*nv30
= nv30_context(pipe
);
448 nv30
->rasterizer
= hwcso
;
449 nv30
->dirty
|= NV30_NEW_RAST
;
450 /*nv30->draw_dirty |= NV30_NEW_RAST;*/
454 nv30_rasterizer_state_delete(struct pipe_context
*pipe
, void *hwcso
)
456 struct nv30_rasterizer_state
*rsso
= hwcso
;
458 so_ref(NULL
, &rsso
->so
);
463 nv30_depth_stencil_alpha_state_create(struct pipe_context
*pipe
,
464 const struct pipe_depth_stencil_alpha_state
*cso
)
466 struct nv30_context
*nv30
= nv30_context(pipe
);
467 struct nv30_zsa_state
*zsaso
= CALLOC(1, sizeof(*zsaso
));
468 struct nouveau_stateobj
*so
= so_new(6, 20, 0);
469 struct nouveau_grobj
*rankine
= nv30
->screen
->rankine
;
471 so_method(so
, rankine
, NV34TCL_DEPTH_FUNC
, 3);
472 so_data (so
, nvgl_comparison_op(cso
->depth
.func
));
473 so_data (so
, cso
->depth
.writemask
? 1 : 0);
474 so_data (so
, cso
->depth
.enabled
? 1 : 0);
476 so_method(so
, rankine
, NV34TCL_ALPHA_FUNC_ENABLE
, 3);
477 so_data (so
, cso
->alpha
.enabled
? 1 : 0);
478 so_data (so
, nvgl_comparison_op(cso
->alpha
.func
));
479 so_data (so
, float_to_ubyte(cso
->alpha
.ref_value
));
481 if (cso
->stencil
[0].enabled
) {
482 so_method(so
, rankine
, NV34TCL_STENCIL_FRONT_ENABLE
, 3);
483 so_data (so
, cso
->stencil
[0].enabled
? 1 : 0);
484 so_data (so
, cso
->stencil
[0].writemask
);
485 so_data (so
, nvgl_comparison_op(cso
->stencil
[0].func
));
486 so_method(so
, rankine
, NV34TCL_STENCIL_FRONT_FUNC_MASK
, 4);
487 so_data (so
, cso
->stencil
[0].valuemask
);
488 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].fail_op
));
489 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].zfail_op
));
490 so_data (so
, nvgl_stencil_op(cso
->stencil
[0].zpass_op
));
492 so_method(so
, rankine
, NV34TCL_STENCIL_FRONT_ENABLE
, 1);
496 if (cso
->stencil
[1].enabled
) {
497 so_method(so
, rankine
, NV34TCL_STENCIL_BACK_ENABLE
, 3);
498 so_data (so
, cso
->stencil
[1].enabled
? 1 : 0);
499 so_data (so
, cso
->stencil
[1].writemask
);
500 so_data (so
, nvgl_comparison_op(cso
->stencil
[1].func
));
501 so_method(so
, rankine
, NV34TCL_STENCIL_BACK_FUNC_MASK
, 4);
502 so_data (so
, cso
->stencil
[1].valuemask
);
503 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].fail_op
));
504 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].zfail_op
));
505 so_data (so
, nvgl_stencil_op(cso
->stencil
[1].zpass_op
));
507 so_method(so
, rankine
, NV34TCL_STENCIL_BACK_ENABLE
, 1);
511 so_ref(so
, &zsaso
->so
);
514 return (void *)zsaso
;
518 nv30_depth_stencil_alpha_state_bind(struct pipe_context
*pipe
, void *hwcso
)
520 struct nv30_context
*nv30
= nv30_context(pipe
);
523 nv30
->dirty
|= NV30_NEW_ZSA
;
527 nv30_depth_stencil_alpha_state_delete(struct pipe_context
*pipe
, void *hwcso
)
529 struct nv30_zsa_state
*zsaso
= hwcso
;
531 so_ref(NULL
, &zsaso
->so
);
536 nv30_vp_state_create(struct pipe_context
*pipe
,
537 const struct pipe_shader_state
*cso
)
539 /*struct nv30_context *nv30 = nv30_context(pipe);*/
540 struct nv30_vertex_program
*vp
;
542 vp
= CALLOC(1, sizeof(struct nv30_vertex_program
));
543 vp
->pipe
.tokens
= tgsi_dup_tokens(cso
->tokens
);
544 /*vp->draw = draw_create_vertex_shader(nv30->draw, &vp->pipe);*/
550 nv30_vp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
552 struct nv30_context
*nv30
= nv30_context(pipe
);
554 nv30
->vertprog
= hwcso
;
555 nv30
->dirty
|= NV30_NEW_VERTPROG
;
556 /*nv30->draw_dirty |= NV30_NEW_VERTPROG;*/
560 nv30_vp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
562 struct nv30_context
*nv30
= nv30_context(pipe
);
563 struct nv30_vertex_program
*vp
= hwcso
;
565 /*draw_delete_vertex_shader(nv30->draw, vp->draw);*/
566 nv30_vertprog_destroy(nv30
, vp
);
567 FREE((void*)vp
->pipe
.tokens
);
572 nv30_fp_state_create(struct pipe_context
*pipe
,
573 const struct pipe_shader_state
*cso
)
575 struct nv30_fragment_program
*fp
;
577 fp
= CALLOC(1, sizeof(struct nv30_fragment_program
));
578 fp
->pipe
.tokens
= tgsi_dup_tokens(cso
->tokens
);
580 tgsi_scan_shader(fp
->pipe
.tokens
, &fp
->info
);
586 nv30_fp_state_bind(struct pipe_context
*pipe
, void *hwcso
)
588 struct nv30_context
*nv30
= nv30_context(pipe
);
590 nv30
->fragprog
= hwcso
;
591 nv30
->dirty
|= NV30_NEW_FRAGPROG
;
595 nv30_fp_state_delete(struct pipe_context
*pipe
, void *hwcso
)
597 struct nv30_context
*nv30
= nv30_context(pipe
);
598 struct nv30_fragment_program
*fp
= hwcso
;
600 nv30_fragprog_destroy(nv30
, fp
);
601 FREE((void*)fp
->pipe
.tokens
);
606 nv30_set_blend_color(struct pipe_context
*pipe
,
607 const struct pipe_blend_color
*bcol
)
609 struct nv30_context
*nv30
= nv30_context(pipe
);
611 nv30
->blend_colour
= *bcol
;
612 nv30
->dirty
|= NV30_NEW_BCOL
;
616 nv30_set_stencil_ref(struct pipe_context
*pipe
,
617 const struct pipe_stencil_ref
*sr
)
619 struct nv30_context
*nv30
= nv30_context(pipe
);
621 nv30
->stencil_ref
= *sr
;
622 nv30
->dirty
|= NV30_NEW_SR
;
626 nv30_set_clip_state(struct pipe_context
*pipe
,
627 const struct pipe_clip_state
*clip
)
632 nv30_set_constant_buffer(struct pipe_context
*pipe
, uint shader
, uint index
,
633 struct pipe_buffer
*buf
)
635 struct nv30_context
*nv30
= nv30_context(pipe
);
637 nv30
->constbuf
[shader
] = buf
;
638 nv30
->constbuf_nr
[shader
] = buf
->size
/ (4 * sizeof(float));
640 if (shader
== PIPE_SHADER_VERTEX
) {
641 nv30
->dirty
|= NV30_NEW_VERTPROG
;
643 if (shader
== PIPE_SHADER_FRAGMENT
) {
644 nv30
->dirty
|= NV30_NEW_FRAGPROG
;
649 nv30_set_framebuffer_state(struct pipe_context
*pipe
,
650 const struct pipe_framebuffer_state
*fb
)
652 struct nv30_context
*nv30
= nv30_context(pipe
);
654 nv30
->framebuffer
= *fb
;
655 nv30
->dirty
|= NV30_NEW_FB
;
659 nv30_set_polygon_stipple(struct pipe_context
*pipe
,
660 const struct pipe_poly_stipple
*stipple
)
662 struct nv30_context
*nv30
= nv30_context(pipe
);
664 memcpy(nv30
->stipple
, stipple
->stipple
, 4 * 32);
665 nv30
->dirty
|= NV30_NEW_STIPPLE
;
669 nv30_set_scissor_state(struct pipe_context
*pipe
,
670 const struct pipe_scissor_state
*s
)
672 struct nv30_context
*nv30
= nv30_context(pipe
);
675 nv30
->dirty
|= NV30_NEW_SCISSOR
;
679 nv30_set_viewport_state(struct pipe_context
*pipe
,
680 const struct pipe_viewport_state
*vpt
)
682 struct nv30_context
*nv30
= nv30_context(pipe
);
684 nv30
->viewport
= *vpt
;
685 nv30
->dirty
|= NV30_NEW_VIEWPORT
;
686 /*nv30->draw_dirty |= NV30_NEW_VIEWPORT;*/
690 nv30_set_vertex_buffers(struct pipe_context
*pipe
, unsigned count
,
691 const struct pipe_vertex_buffer
*vb
)
693 struct nv30_context
*nv30
= nv30_context(pipe
);
695 memcpy(nv30
->vtxbuf
, vb
, sizeof(*vb
) * count
);
696 nv30
->vtxbuf_nr
= count
;
698 nv30
->dirty
|= NV30_NEW_ARRAYS
;
699 /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
703 nv30_vtxelts_state_create(struct pipe_context
*pipe
,
704 unsigned num_elements
,
705 const struct pipe_vertex_element
*elements
)
707 struct nv30_vtxelt_state
*cso
= CALLOC_STRUCT(nv30_vtxelt_state
);
709 assert(num_elements
< 16); /* not doing fallbacks yet */
710 cso
->num_elements
= num_elements
;
711 memcpy(cso
->pipe
, elements
, num_elements
* sizeof(*elements
));
713 /* nv30_vtxelt_construct(cso);*/
719 nv30_vtxelts_state_delete(struct pipe_context
*pipe
, void *hwcso
)
725 nv30_vtxelts_state_bind(struct pipe_context
*pipe
, void *hwcso
)
727 struct nv30_context
*nv30
= nv30_context(pipe
);
729 nv30
->vtxelt
= hwcso
;
730 nv30
->dirty
|= NV30_NEW_ARRAYS
;
731 /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
735 nv30_init_state_functions(struct nv30_context
*nv30
)
737 nv30
->pipe
.create_blend_state
= nv30_blend_state_create
;
738 nv30
->pipe
.bind_blend_state
= nv30_blend_state_bind
;
739 nv30
->pipe
.delete_blend_state
= nv30_blend_state_delete
;
741 nv30
->pipe
.create_sampler_state
= nv30_sampler_state_create
;
742 nv30
->pipe
.bind_fragment_sampler_states
= nv30_sampler_state_bind
;
743 nv30
->pipe
.delete_sampler_state
= nv30_sampler_state_delete
;
744 nv30
->pipe
.set_fragment_sampler_views
= nv30_set_fragment_sampler_views
;
745 nv30
->pipe
.create_sampler_view
= nv30_create_sampler_view
;
746 nv30
->pipe
.sampler_view_destroy
= nv30_sampler_view_destroy
;
748 nv30
->pipe
.create_rasterizer_state
= nv30_rasterizer_state_create
;
749 nv30
->pipe
.bind_rasterizer_state
= nv30_rasterizer_state_bind
;
750 nv30
->pipe
.delete_rasterizer_state
= nv30_rasterizer_state_delete
;
752 nv30
->pipe
.create_depth_stencil_alpha_state
=
753 nv30_depth_stencil_alpha_state_create
;
754 nv30
->pipe
.bind_depth_stencil_alpha_state
=
755 nv30_depth_stencil_alpha_state_bind
;
756 nv30
->pipe
.delete_depth_stencil_alpha_state
=
757 nv30_depth_stencil_alpha_state_delete
;
759 nv30
->pipe
.create_vs_state
= nv30_vp_state_create
;
760 nv30
->pipe
.bind_vs_state
= nv30_vp_state_bind
;
761 nv30
->pipe
.delete_vs_state
= nv30_vp_state_delete
;
763 nv30
->pipe
.create_fs_state
= nv30_fp_state_create
;
764 nv30
->pipe
.bind_fs_state
= nv30_fp_state_bind
;
765 nv30
->pipe
.delete_fs_state
= nv30_fp_state_delete
;
767 nv30
->pipe
.set_blend_color
= nv30_set_blend_color
;
768 nv30
->pipe
.set_stencil_ref
= nv30_set_stencil_ref
;
769 nv30
->pipe
.set_clip_state
= nv30_set_clip_state
;
770 nv30
->pipe
.set_constant_buffer
= nv30_set_constant_buffer
;
771 nv30
->pipe
.set_framebuffer_state
= nv30_set_framebuffer_state
;
772 nv30
->pipe
.set_polygon_stipple
= nv30_set_polygon_stipple
;
773 nv30
->pipe
.set_scissor_state
= nv30_set_scissor_state
;
774 nv30
->pipe
.set_viewport_state
= nv30_set_viewport_state
;
776 nv30
->pipe
.create_vertex_elements_state
= nv30_vtxelts_state_create
;
777 nv30
->pipe
.delete_vertex_elements_state
= nv30_vtxelts_state_delete
;
778 nv30
->pipe
.bind_vertex_elements_state
= nv30_vtxelts_state_bind
;
780 nv30
->pipe
.set_vertex_buffers
= nv30_set_vertex_buffers
;