32a81997528ddc2789d7ea7f2bf3f12f0b2ff7fe
[mesa.git] / src / gallium / drivers / nvfx / nvfx_state.c
1 #include "pipe/p_state.h"
2 #include "pipe/p_defines.h"
3 #include "util/u_inlines.h"
4
5 #include "draw/draw_context.h"
6
7 #include "tgsi/tgsi_parse.h"
8
9 #include "nvfx_context.h"
10 #include "nvfx_state.h"
11 #include "nvfx_tex.h"
12
13 static void *
14 nvfx_blend_state_create(struct pipe_context *pipe,
15 const struct pipe_blend_state *cso)
16 {
17 struct nvfx_context *nvfx = nvfx_context(pipe);
18 struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
19 struct nvfx_blend_state *bso = CALLOC(1, sizeof(*bso));
20 struct nouveau_stateobj *so = so_new(5, 8, 0);
21
22 if (cso->rt[0].blend_enable) {
23 so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 3);
24 so_data (so, 1);
25 so_data (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
26 nvgl_blend_func(cso->rt[0].rgb_src_factor));
27 so_data (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
28 nvgl_blend_func(cso->rt[0].rgb_dst_factor));
29 if(nvfx->screen->base.device->chipset < 0x40) {
30 so_method(so, eng3d, NV34TCL_BLEND_EQUATION, 1);
31 so_data (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
32 } else {
33 so_method(so, eng3d, NV40TCL_BLEND_EQUATION, 1);
34 so_data (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 |
35 nvgl_blend_eqn(cso->rt[0].rgb_func));
36 }
37 } else {
38 so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 1);
39 so_data (so, 0);
40 }
41
42 so_method(so, eng3d, NV34TCL_COLOR_MASK, 1);
43 so_data (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
44 ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
45 ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 << 8) : 0) |
46 ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 << 0) : 0)));
47
48 /* TODO: add NV40 MRT color mask */
49
50 if (cso->logicop_enable) {
51 so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
52 so_data (so, 1);
53 so_data (so, nvgl_logicop_func(cso->logicop_func));
54 } else {
55 so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
56 so_data (so, 0);
57 }
58
59 so_method(so, eng3d, NV34TCL_DITHER_ENABLE, 1);
60 so_data (so, cso->dither ? 1 : 0);
61
62 so_ref(so, &bso->so);
63 so_ref(NULL, &so);
64 bso->pipe = *cso;
65 return (void *)bso;
66 }
67
68 static void
69 nvfx_blend_state_bind(struct pipe_context *pipe, void *hwcso)
70 {
71 struct nvfx_context *nvfx = nvfx_context(pipe);
72
73 nvfx->blend = hwcso;
74 nvfx->dirty |= NVFX_NEW_BLEND;
75 }
76
77 static void
78 nvfx_blend_state_delete(struct pipe_context *pipe, void *hwcso)
79 {
80 struct nvfx_blend_state *bso = hwcso;
81
82 so_ref(NULL, &bso->so);
83 FREE(bso);
84 }
85
86 static void *
87 nvfx_sampler_state_create(struct pipe_context *pipe,
88 const struct pipe_sampler_state *cso)
89 {
90 struct nvfx_context *nvfx = nvfx_context(pipe);
91 struct nvfx_sampler_state *ps;
92
93 ps = MALLOC(sizeof(struct nvfx_sampler_state));
94
95 /* on nv30, we use this as an internal flag */
96 ps->fmt = cso->normalized_coords ? 0 : NV40TCL_TEX_FORMAT_RECT;
97 ps->en = 0;
98 ps->filt = nvfx_tex_filter(cso);
99 ps->wrap = (nvfx_tex_wrap_mode(cso->wrap_s) << NV34TCL_TX_WRAP_S_SHIFT) |
100 (nvfx_tex_wrap_mode(cso->wrap_t) << NV34TCL_TX_WRAP_T_SHIFT) |
101 (nvfx_tex_wrap_mode(cso->wrap_r) << NV34TCL_TX_WRAP_R_SHIFT) |
102 nvfx_tex_wrap_compare_mode(cso);
103 ps->bcol = nvfx_tex_border_color(cso->border_color);
104
105 if(nvfx->is_nv4x)
106 nv40_sampler_state_init(pipe, ps, cso);
107 else
108 nv30_sampler_state_init(pipe, ps, cso);
109
110 return (void *)ps;
111 }
112
113 static void
114 nvfx_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
115 {
116 struct nvfx_context *nvfx = nvfx_context(pipe);
117 unsigned unit;
118
119 for (unit = 0; unit < nr; unit++) {
120 nvfx->tex_sampler[unit] = sampler[unit];
121 nvfx->dirty_samplers |= (1 << unit);
122 }
123
124 for (unit = nr; unit < nvfx->nr_samplers; unit++) {
125 nvfx->tex_sampler[unit] = NULL;
126 nvfx->dirty_samplers |= (1 << unit);
127 }
128
129 nvfx->nr_samplers = nr;
130 nvfx->dirty |= NVFX_NEW_SAMPLER;
131 }
132
133 static void
134 nvfx_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
135 {
136 FREE(hwcso);
137 }
138
139 static void
140 nvfx_set_fragment_sampler_views(struct pipe_context *pipe,
141 unsigned nr,
142 struct pipe_sampler_view **views)
143 {
144 struct nvfx_context *nvfx = nvfx_context(pipe);
145 unsigned unit;
146
147 for (unit = 0; unit < nr; unit++) {
148 pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit],
149 views[unit]);
150 pipe_texture_reference((struct pipe_texture **)
151 &nvfx->tex_miptree[unit], miptree[unit]);
152 nvfx->dirty_samplers |= (1 << unit);
153 }
154
155 for (unit = nr; unit < nvfx->nr_textures; unit++) {
156 pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit],
157 NULL);
158 pipe_texture_reference((struct pipe_texture **)
159 &nvfx->tex_miptree[unit], NULL);
160 nvfx->dirty_samplers |= (1 << unit);
161 }
162
163 nvfx->nr_textures = nr;
164 nvfx->dirty |= NVFX_NEW_SAMPLER;
165 }
166
167
168 static struct pipe_sampler_view *
169 nv30_create_sampler_view(struct pipe_context *pipe,
170 struct pipe_texture *texture,
171 const struct pipe_sampler_view *templ)
172 {
173 struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
174
175 if (view) {
176 *view = *templ;
177 view->reference.count = 1;
178 view->texture = NULL;
179 pipe_texture_reference(&view->texture, texture);
180 view->context = pipe;
181 }
182
183 return view;
184 }
185
186
187 static void
188 nv30_sampler_view_destroy(struct pipe_context *pipe,
189 struct pipe_sampler_view *view)
190 {
191 pipe_texture_reference(&view->texture, NULL);
192 FREE(view);
193 }
194
195 static void *
196 nvfx_rasterizer_state_create(struct pipe_context *pipe,
197 const struct pipe_rasterizer_state *cso)
198 {
199 struct nvfx_context *nvfx = nvfx_context(pipe);
200 struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
201 struct nouveau_stateobj *so = so_new(9, 19, 0);
202 struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
203
204 /*XXX: ignored:
205 * light_twoside
206 * point_smooth -nohw
207 * multisample
208 */
209
210 so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
211 so_data (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
212 NV34TCL_SHADE_MODEL_SMOOTH);
213
214 so_method(so, eng3d, NV34TCL_LINE_WIDTH, 2);
215 so_data (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
216 so_data (so, cso->line_smooth ? 1 : 0);
217 so_method(so, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
218 so_data (so, cso->line_stipple_enable ? 1 : 0);
219 so_data (so, (cso->line_stipple_pattern << 16) |
220 cso->line_stipple_factor);
221
222 so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
223 so_data (so, fui(cso->point_size));
224
225 so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
226 if (cso->front_winding == PIPE_WINDING_CCW) {
227 so_data(so, nvgl_polygon_mode(cso->fill_ccw));
228 so_data(so, nvgl_polygon_mode(cso->fill_cw));
229 switch (cso->cull_mode) {
230 case PIPE_WINDING_CCW:
231 so_data(so, NV34TCL_CULL_FACE_FRONT);
232 break;
233 case PIPE_WINDING_CW:
234 so_data(so, NV34TCL_CULL_FACE_BACK);
235 break;
236 case PIPE_WINDING_BOTH:
237 so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
238 break;
239 default:
240 so_data(so, NV34TCL_CULL_FACE_BACK);
241 break;
242 }
243 so_data(so, NV34TCL_FRONT_FACE_CCW);
244 } else {
245 so_data(so, nvgl_polygon_mode(cso->fill_cw));
246 so_data(so, nvgl_polygon_mode(cso->fill_ccw));
247 switch (cso->cull_mode) {
248 case PIPE_WINDING_CCW:
249 so_data(so, NV34TCL_CULL_FACE_BACK);
250 break;
251 case PIPE_WINDING_CW:
252 so_data(so, NV34TCL_CULL_FACE_FRONT);
253 break;
254 case PIPE_WINDING_BOTH:
255 so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
256 break;
257 default:
258 so_data(so, NV34TCL_CULL_FACE_BACK);
259 break;
260 }
261 so_data(so, NV34TCL_FRONT_FACE_CW);
262 }
263 so_data(so, cso->poly_smooth ? 1 : 0);
264 so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
265
266 so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
267 so_data (so, cso->poly_stipple_enable ? 1 : 0);
268
269 so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
270 if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
271 (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
272 so_data(so, 1);
273 else
274 so_data(so, 0);
275 if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
276 (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
277 so_data(so, 1);
278 else
279 so_data(so, 0);
280 if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
281 (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
282 so_data(so, 1);
283 else
284 so_data(so, 0);
285 if (cso->offset_cw || cso->offset_ccw) {
286 so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
287 so_data (so, fui(cso->offset_scale));
288 so_data (so, fui(cso->offset_units * 2));
289 }
290
291 so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
292 if (cso->point_quad_rasterization) {
293 unsigned psctl = (1 << 0), i;
294
295 for (i = 0; i < 8; i++) {
296 if ((cso->sprite_coord_enable >> i) & 1)
297 psctl |= (1 << (8 + i));
298 }
299
300 so_data(so, psctl);
301 } else {
302 so_data(so, 0);
303 }
304
305 so_ref(so, &rsso->so);
306 so_ref(NULL, &so);
307 rsso->pipe = *cso;
308 return (void *)rsso;
309 }
310
311 static void
312 nvfx_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
313 {
314 struct nvfx_context *nvfx = nvfx_context(pipe);
315
316 nvfx->rasterizer = hwcso;
317 nvfx->dirty |= NVFX_NEW_RAST;
318 nvfx->draw_dirty |= NVFX_NEW_RAST;
319 }
320
321 static void
322 nvfx_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
323 {
324 struct nvfx_rasterizer_state *rsso = hwcso;
325
326 so_ref(NULL, &rsso->so);
327 FREE(rsso);
328 }
329
330 static void *
331 nvfx_depth_stencil_alpha_state_create(struct pipe_context *pipe,
332 const struct pipe_depth_stencil_alpha_state *cso)
333 {
334 struct nvfx_context *nvfx = nvfx_context(pipe);
335 struct nvfx_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
336 struct nouveau_stateobj *so = so_new(6, 20, 0);
337 struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
338
339 so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
340 so_data (so, nvgl_comparison_op(cso->depth.func));
341 so_data (so, cso->depth.writemask ? 1 : 0);
342 so_data (so, cso->depth.enabled ? 1 : 0);
343
344 so_method(so, eng3d, NV34TCL_ALPHA_FUNC_ENABLE, 3);
345 so_data (so, cso->alpha.enabled ? 1 : 0);
346 so_data (so, nvgl_comparison_op(cso->alpha.func));
347 so_data (so, float_to_ubyte(cso->alpha.ref_value));
348
349 if (cso->stencil[0].enabled) {
350 so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 3);
351 so_data (so, cso->stencil[0].enabled ? 1 : 0);
352 so_data (so, cso->stencil[0].writemask);
353 so_data (so, nvgl_comparison_op(cso->stencil[0].func));
354 so_method(so, eng3d, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
355 so_data (so, cso->stencil[0].valuemask);
356 so_data (so, nvgl_stencil_op(cso->stencil[0].fail_op));
357 so_data (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
358 so_data (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
359 } else {
360 so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 1);
361 so_data (so, 0);
362 }
363
364 if (cso->stencil[1].enabled) {
365 so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 3);
366 so_data (so, cso->stencil[1].enabled ? 1 : 0);
367 so_data (so, cso->stencil[1].writemask);
368 so_data (so, nvgl_comparison_op(cso->stencil[1].func));
369 so_method(so, eng3d, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
370 so_data (so, cso->stencil[1].valuemask);
371 so_data (so, nvgl_stencil_op(cso->stencil[1].fail_op));
372 so_data (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
373 so_data (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
374 } else {
375 so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 1);
376 so_data (so, 0);
377 }
378
379 so_ref(so, &zsaso->so);
380 so_ref(NULL, &so);
381 zsaso->pipe = *cso;
382 return (void *)zsaso;
383 }
384
385 static void
386 nvfx_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
387 {
388 struct nvfx_context *nvfx = nvfx_context(pipe);
389
390 nvfx->zsa = hwcso;
391 nvfx->dirty |= NVFX_NEW_ZSA;
392 }
393
394 static void
395 nvfx_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
396 {
397 struct nvfx_zsa_state *zsaso = hwcso;
398
399 so_ref(NULL, &zsaso->so);
400 FREE(zsaso);
401 }
402
403 static void *
404 nvfx_vp_state_create(struct pipe_context *pipe,
405 const struct pipe_shader_state *cso)
406 {
407 struct nvfx_context *nvfx = nvfx_context(pipe);
408 struct nvfx_vertex_program *vp;
409
410 vp = CALLOC(1, sizeof(struct nvfx_vertex_program));
411 vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
412 vp->draw = draw_create_vertex_shader(nvfx->draw, &vp->pipe);
413
414 return (void *)vp;
415 }
416
417 static void
418 nvfx_vp_state_bind(struct pipe_context *pipe, void *hwcso)
419 {
420 struct nvfx_context *nvfx = nvfx_context(pipe);
421
422 nvfx->vertprog = hwcso;
423 nvfx->dirty |= NVFX_NEW_VERTPROG;
424 nvfx->draw_dirty |= NVFX_NEW_VERTPROG;
425 }
426
427 static void
428 nvfx_vp_state_delete(struct pipe_context *pipe, void *hwcso)
429 {
430 struct nvfx_context *nvfx = nvfx_context(pipe);
431 struct nvfx_vertex_program *vp = hwcso;
432
433 draw_delete_vertex_shader(nvfx->draw, vp->draw);
434 nvfx_vertprog_destroy(nvfx, vp);
435 FREE((void*)vp->pipe.tokens);
436 FREE(vp);
437 }
438
439 static void *
440 nvfx_fp_state_create(struct pipe_context *pipe,
441 const struct pipe_shader_state *cso)
442 {
443 struct nvfx_fragment_program *fp;
444
445 fp = CALLOC(1, sizeof(struct nvfx_fragment_program));
446 fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
447
448 tgsi_scan_shader(fp->pipe.tokens, &fp->info);
449
450 return (void *)fp;
451 }
452
453 static void
454 nvfx_fp_state_bind(struct pipe_context *pipe, void *hwcso)
455 {
456 struct nvfx_context *nvfx = nvfx_context(pipe);
457
458 nvfx->fragprog = hwcso;
459 nvfx->dirty |= NVFX_NEW_FRAGPROG;
460 }
461
462 static void
463 nvfx_fp_state_delete(struct pipe_context *pipe, void *hwcso)
464 {
465 struct nvfx_context *nvfx = nvfx_context(pipe);
466 struct nvfx_fragment_program *fp = hwcso;
467
468 nvfx_fragprog_destroy(nvfx, fp);
469 FREE((void*)fp->pipe.tokens);
470 FREE(fp);
471 }
472
473 static void
474 nvfx_set_blend_color(struct pipe_context *pipe,
475 const struct pipe_blend_color *bcol)
476 {
477 struct nvfx_context *nvfx = nvfx_context(pipe);
478
479 nvfx->blend_colour = *bcol;
480 nvfx->dirty |= NVFX_NEW_BCOL;
481 }
482
483 static void
484 nvfx_set_stencil_ref(struct pipe_context *pipe,
485 const struct pipe_stencil_ref *sr)
486 {
487 struct nvfx_context *nvfx = nvfx_context(pipe);
488
489 nvfx->stencil_ref = *sr;
490 nvfx->dirty |= NVFX_NEW_SR;
491 }
492
493 static void
494 nvfx_set_clip_state(struct pipe_context *pipe,
495 const struct pipe_clip_state *clip)
496 {
497 struct nvfx_context *nvfx = nvfx_context(pipe);
498
499 nvfx->clip = *clip;
500 nvfx->dirty |= NVFX_NEW_UCP;
501 nvfx->draw_dirty |= NVFX_NEW_UCP;
502 }
503
504 static void
505 nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
506 struct pipe_buffer *buf )
507 {
508 struct nvfx_context *nvfx = nvfx_context(pipe);
509
510 nvfx->constbuf[shader] = buf;
511 nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
512
513 if (shader == PIPE_SHADER_VERTEX) {
514 nvfx->dirty |= NVFX_NEW_VERTPROG;
515 } else
516 if (shader == PIPE_SHADER_FRAGMENT) {
517 nvfx->dirty |= NVFX_NEW_FRAGPROG;
518 }
519 }
520
521 static void
522 nvfx_set_framebuffer_state(struct pipe_context *pipe,
523 const struct pipe_framebuffer_state *fb)
524 {
525 struct nvfx_context *nvfx = nvfx_context(pipe);
526
527 nvfx->framebuffer = *fb;
528 nvfx->dirty |= NVFX_NEW_FB;
529 }
530
531 static void
532 nvfx_set_polygon_stipple(struct pipe_context *pipe,
533 const struct pipe_poly_stipple *stipple)
534 {
535 struct nvfx_context *nvfx = nvfx_context(pipe);
536
537 memcpy(nvfx->stipple, stipple->stipple, 4 * 32);
538 nvfx->dirty |= NVFX_NEW_STIPPLE;
539 }
540
541 static void
542 nvfx_set_scissor_state(struct pipe_context *pipe,
543 const struct pipe_scissor_state *s)
544 {
545 struct nvfx_context *nvfx = nvfx_context(pipe);
546
547 nvfx->scissor = *s;
548 nvfx->dirty |= NVFX_NEW_SCISSOR;
549 }
550
551 static void
552 nvfx_set_viewport_state(struct pipe_context *pipe,
553 const struct pipe_viewport_state *vpt)
554 {
555 struct nvfx_context *nvfx = nvfx_context(pipe);
556
557 nvfx->viewport = *vpt;
558 nvfx->dirty |= NVFX_NEW_VIEWPORT;
559 nvfx->draw_dirty |= NVFX_NEW_VIEWPORT;
560 }
561
562 static void
563 nvfx_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
564 const struct pipe_vertex_buffer *vb)
565 {
566 struct nvfx_context *nvfx = nvfx_context(pipe);
567
568 memcpy(nvfx->vtxbuf, vb, sizeof(*vb) * count);
569 nvfx->vtxbuf_nr = count;
570
571 nvfx->dirty |= NVFX_NEW_ARRAYS;
572 nvfx->draw_dirty |= NVFX_NEW_ARRAYS;
573 }
574
575 static void *
576 nvfx_vtxelts_state_create(struct pipe_context *pipe,
577 unsigned num_elements,
578 const struct pipe_vertex_element *elements)
579 {
580 struct nvfx_vtxelt_state *cso = CALLOC_STRUCT(nvfx_vtxelt_state);
581
582 assert(num_elements < 16); /* not doing fallbacks yet */
583 cso->num_elements = num_elements;
584 memcpy(cso->pipe, elements, num_elements * sizeof(*elements));
585
586 /* nvfx_vtxelt_construct(cso);*/
587
588 return (void *)cso;
589 }
590
591 static void
592 nvfx_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
593 {
594 FREE(hwcso);
595 }
596
597 static void
598 nvfx_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
599 {
600 struct nvfx_context *nvfx = nvfx_context(pipe);
601
602 nvfx->vtxelt = hwcso;
603 nvfx->dirty |= NVFX_NEW_ARRAYS;
604 /*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
605 }
606
607 void
608 nvfx_init_state_functions(struct nvfx_context *nvfx)
609 {
610 nvfx->pipe.create_blend_state = nvfx_blend_state_create;
611 nvfx->pipe.bind_blend_state = nvfx_blend_state_bind;
612 nvfx->pipe.delete_blend_state = nvfx_blend_state_delete;
613
614 nvfx->pipe.create_sampler_state = nvfx_sampler_state_create;
615 nvfx->pipe.bind_fragment_sampler_states = nvfx_sampler_state_bind;
616 nvfx->pipe.delete_sampler_state = nvfx_sampler_state_delete;
617 nvfx->pipe.set_fragment_sampler_textures = nvfx_set_sampler_texture;
618
619 nvfx->pipe.create_rasterizer_state = nvfx_rasterizer_state_create;
620 nvfx->pipe.bind_rasterizer_state = nvfx_rasterizer_state_bind;
621 nvfx->pipe.delete_rasterizer_state = nvfx_rasterizer_state_delete;
622
623 nvfx->pipe.create_depth_stencil_alpha_state =
624 nvfx_depth_stencil_alpha_state_create;
625 nvfx->pipe.bind_depth_stencil_alpha_state =
626 nvfx_depth_stencil_alpha_state_bind;
627 nvfx->pipe.delete_depth_stencil_alpha_state =
628 nvfx_depth_stencil_alpha_state_delete;
629
630 nvfx->pipe.create_vs_state = nvfx_vp_state_create;
631 nvfx->pipe.bind_vs_state = nvfx_vp_state_bind;
632 nvfx->pipe.delete_vs_state = nvfx_vp_state_delete;
633
634 nvfx->pipe.create_fs_state = nvfx_fp_state_create;
635 nvfx->pipe.bind_fs_state = nvfx_fp_state_bind;
636 nvfx->pipe.delete_fs_state = nvfx_fp_state_delete;
637
638 nvfx->pipe.set_blend_color = nvfx_set_blend_color;
639 nvfx->pipe.set_stencil_ref = nvfx_set_stencil_ref;
640 nvfx->pipe.set_clip_state = nvfx_set_clip_state;
641 nvfx->pipe.set_constant_buffer = nvfx_set_constant_buffer;
642 nvfx->pipe.set_framebuffer_state = nvfx_set_framebuffer_state;
643 nvfx->pipe.set_polygon_stipple = nvfx_set_polygon_stipple;
644 nvfx->pipe.set_scissor_state = nvfx_set_scissor_state;
645 nvfx->pipe.set_viewport_state = nvfx_set_viewport_state;
646
647 nvfx->pipe.create_vertex_elements_state = nvfx_vtxelts_state_create;
648 nvfx->pipe.delete_vertex_elements_state = nvfx_vtxelts_state_delete;
649 nvfx->pipe.bind_vertex_elements_state = nvfx_vtxelts_state_bind;
650
651 nvfx->pipe.set_vertex_buffers = nvfx_set_vertex_buffers;
652 }