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