Merge remote-tracking branch 'mesa-public/master' into vulkan
[mesa.git] / src / gallium / drivers / ddebug / dd_context.c
1 /**************************************************************************
2 *
3 * Copyright 2015 Advanced Micro Devices, Inc.
4 * Copyright 2008 VMware, Inc.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * on the rights to use, copy, modify, merge, publish, distribute, sub
11 * license, and/or sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "dd_pipe.h"
29 #include "tgsi/tgsi_parse.h"
30 #include "util/u_memory.h"
31
32
33 static void
34 safe_memcpy(void *dst, const void *src, size_t size)
35 {
36 if (src)
37 memcpy(dst, src, size);
38 else
39 memset(dst, 0, size);
40 }
41
42
43 /********************************************************************
44 * queries
45 */
46
47 static struct dd_query *
48 dd_query(struct pipe_query *query)
49 {
50 return (struct dd_query *)query;
51 }
52
53 static struct pipe_query *
54 dd_query_unwrap(struct pipe_query *query)
55 {
56 if (query) {
57 return dd_query(query)->query;
58 } else {
59 return NULL;
60 }
61 }
62
63 static struct pipe_query *
64 dd_context_create_query(struct pipe_context *_pipe, unsigned query_type,
65 unsigned index)
66 {
67 struct pipe_context *pipe = dd_context(_pipe)->pipe;
68 struct pipe_query *query;
69
70 query = pipe->create_query(pipe, query_type, index);
71
72 /* Wrap query object. */
73 if (query) {
74 struct dd_query *dd_query = CALLOC_STRUCT(dd_query);
75 if (dd_query) {
76 dd_query->type = query_type;
77 dd_query->query = query;
78 query = (struct pipe_query *)dd_query;
79 } else {
80 pipe->destroy_query(pipe, query);
81 query = NULL;
82 }
83 }
84
85 return query;
86 }
87
88 static void
89 dd_context_destroy_query(struct pipe_context *_pipe,
90 struct pipe_query *query)
91 {
92 struct pipe_context *pipe = dd_context(_pipe)->pipe;
93
94 pipe->destroy_query(pipe, dd_query_unwrap(query));
95 FREE(query);
96 }
97
98 static boolean
99 dd_context_begin_query(struct pipe_context *_pipe, struct pipe_query *query)
100 {
101 struct dd_context *dctx = dd_context(_pipe);
102 struct pipe_context *pipe = dctx->pipe;
103
104 return pipe->begin_query(pipe, dd_query_unwrap(query));
105 }
106
107 static void
108 dd_context_end_query(struct pipe_context *_pipe, struct pipe_query *query)
109 {
110 struct dd_context *dctx = dd_context(_pipe);
111 struct pipe_context *pipe = dctx->pipe;
112
113 pipe->end_query(pipe, dd_query_unwrap(query));
114 }
115
116 static boolean
117 dd_context_get_query_result(struct pipe_context *_pipe,
118 struct pipe_query *query, boolean wait,
119 union pipe_query_result *result)
120 {
121 struct pipe_context *pipe = dd_context(_pipe)->pipe;
122
123 return pipe->get_query_result(pipe, dd_query_unwrap(query), wait, result);
124 }
125
126 static void
127 dd_context_render_condition(struct pipe_context *_pipe,
128 struct pipe_query *query, boolean condition,
129 uint mode)
130 {
131 struct dd_context *dctx = dd_context(_pipe);
132 struct pipe_context *pipe = dctx->pipe;
133
134 pipe->render_condition(pipe, dd_query_unwrap(query), condition, mode);
135 dctx->render_cond.query = dd_query(query);
136 dctx->render_cond.condition = condition;
137 dctx->render_cond.mode = mode;
138 }
139
140
141 /********************************************************************
142 * constant (immutable) non-shader states
143 */
144
145 #define DD_CSO_CREATE(name, shortname) \
146 static void * \
147 dd_context_create_##name##_state(struct pipe_context *_pipe, \
148 const struct pipe_##name##_state *state) \
149 { \
150 struct pipe_context *pipe = dd_context(_pipe)->pipe; \
151 struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
152 \
153 if (!hstate) \
154 return NULL; \
155 hstate->cso = pipe->create_##name##_state(pipe, state); \
156 hstate->state.shortname = *state; \
157 return hstate; \
158 }
159
160 #define DD_CSO_BIND(name, shortname) \
161 static void \
162 dd_context_bind_##name##_state(struct pipe_context *_pipe, void *state) \
163 { \
164 struct dd_context *dctx = dd_context(_pipe); \
165 struct pipe_context *pipe = dctx->pipe; \
166 struct dd_state *hstate = state; \
167 \
168 dctx->shortname = hstate; \
169 pipe->bind_##name##_state(pipe, hstate ? hstate->cso : NULL); \
170 }
171
172 #define DD_CSO_DELETE(name) \
173 static void \
174 dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
175 { \
176 struct dd_context *dctx = dd_context(_pipe); \
177 struct pipe_context *pipe = dctx->pipe; \
178 struct dd_state *hstate = state; \
179 \
180 pipe->delete_##name##_state(pipe, hstate->cso); \
181 FREE(hstate); \
182 }
183
184 #define DD_CSO_WHOLE(name, shortname) \
185 DD_CSO_CREATE(name, shortname) \
186 DD_CSO_BIND(name, shortname) \
187 DD_CSO_DELETE(name)
188
189 DD_CSO_WHOLE(blend, blend)
190 DD_CSO_WHOLE(rasterizer, rs)
191 DD_CSO_WHOLE(depth_stencil_alpha, dsa)
192
193 DD_CSO_CREATE(sampler, sampler)
194 DD_CSO_DELETE(sampler)
195
196 static void
197 dd_context_bind_sampler_states(struct pipe_context *_pipe, unsigned shader,
198 unsigned start, unsigned count, void **states)
199 {
200 struct dd_context *dctx = dd_context(_pipe);
201 struct pipe_context *pipe = dctx->pipe;
202
203 memcpy(&dctx->sampler_states[shader][start], states,
204 sizeof(void*) * count);
205
206 if (states) {
207 void *samp[PIPE_MAX_SAMPLERS];
208 int i;
209
210 for (i = 0; i < count; i++) {
211 struct dd_state *s = states[i];
212 samp[i] = s ? s->cso : NULL;
213 }
214
215 pipe->bind_sampler_states(pipe, shader, start, count, samp);
216 }
217 else
218 pipe->bind_sampler_states(pipe, shader, start, count, NULL);
219 }
220
221 static void *
222 dd_context_create_vertex_elements_state(struct pipe_context *_pipe,
223 unsigned num_elems,
224 const struct pipe_vertex_element *elems)
225 {
226 struct pipe_context *pipe = dd_context(_pipe)->pipe;
227 struct dd_state *hstate = CALLOC_STRUCT(dd_state);
228
229 if (!hstate)
230 return NULL;
231 hstate->cso = pipe->create_vertex_elements_state(pipe, num_elems, elems);
232 memcpy(hstate->state.velems.velems, elems, sizeof(elems[0]) * num_elems);
233 hstate->state.velems.count = num_elems;
234 return hstate;
235 }
236
237 DD_CSO_BIND(vertex_elements, velems)
238 DD_CSO_DELETE(vertex_elements)
239
240
241 /********************************************************************
242 * shaders
243 */
244
245 #define DD_SHADER(NAME, name) \
246 static void * \
247 dd_context_create_##name##_state(struct pipe_context *_pipe, \
248 const struct pipe_shader_state *state) \
249 { \
250 struct pipe_context *pipe = dd_context(_pipe)->pipe; \
251 struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
252 \
253 if (!hstate) \
254 return NULL; \
255 hstate->cso = pipe->create_##name##_state(pipe, state); \
256 hstate->state.shader = *state; \
257 hstate->state.shader.tokens = tgsi_dup_tokens(state->tokens); \
258 return hstate; \
259 } \
260 \
261 static void \
262 dd_context_bind_##name##_state(struct pipe_context *_pipe, void *state) \
263 { \
264 struct dd_context *dctx = dd_context(_pipe); \
265 struct pipe_context *pipe = dctx->pipe; \
266 struct dd_state *hstate = state; \
267 \
268 dctx->shaders[PIPE_SHADER_##NAME] = hstate; \
269 pipe->bind_##name##_state(pipe, hstate ? hstate->cso : NULL); \
270 } \
271 \
272 static void \
273 dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
274 { \
275 struct dd_context *dctx = dd_context(_pipe); \
276 struct pipe_context *pipe = dctx->pipe; \
277 struct dd_state *hstate = state; \
278 \
279 pipe->delete_##name##_state(pipe, hstate->cso); \
280 tgsi_free_tokens(hstate->state.shader.tokens); \
281 FREE(hstate); \
282 }
283
284 DD_SHADER(FRAGMENT, fs)
285 DD_SHADER(VERTEX, vs)
286 DD_SHADER(GEOMETRY, gs)
287 DD_SHADER(TESS_CTRL, tcs)
288 DD_SHADER(TESS_EVAL, tes)
289
290
291 /********************************************************************
292 * immediate states
293 */
294
295 #define DD_IMM_STATE(name, type, deref, ref) \
296 static void \
297 dd_context_set_##name(struct pipe_context *_pipe, type deref) \
298 { \
299 struct dd_context *dctx = dd_context(_pipe); \
300 struct pipe_context *pipe = dctx->pipe; \
301 \
302 dctx->name = deref; \
303 pipe->set_##name(pipe, ref); \
304 }
305
306 DD_IMM_STATE(blend_color, const struct pipe_blend_color, *state, state)
307 DD_IMM_STATE(stencil_ref, const struct pipe_stencil_ref, *state, state)
308 DD_IMM_STATE(clip_state, const struct pipe_clip_state, *state, state)
309 DD_IMM_STATE(sample_mask, unsigned, sample_mask, sample_mask)
310 DD_IMM_STATE(min_samples, unsigned, min_samples, min_samples)
311 DD_IMM_STATE(framebuffer_state, const struct pipe_framebuffer_state, *state, state)
312 DD_IMM_STATE(polygon_stipple, const struct pipe_poly_stipple, *state, state)
313
314 static void
315 dd_context_set_constant_buffer(struct pipe_context *_pipe,
316 uint shader, uint index,
317 struct pipe_constant_buffer *constant_buffer)
318 {
319 struct dd_context *dctx = dd_context(_pipe);
320 struct pipe_context *pipe = dctx->pipe;
321
322 safe_memcpy(&dctx->constant_buffers[shader][index], constant_buffer,
323 sizeof(*constant_buffer));
324 pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
325 }
326
327 static void
328 dd_context_set_scissor_states(struct pipe_context *_pipe,
329 unsigned start_slot, unsigned num_scissors,
330 const struct pipe_scissor_state *states)
331 {
332 struct dd_context *dctx = dd_context(_pipe);
333 struct pipe_context *pipe = dctx->pipe;
334
335 safe_memcpy(&dctx->scissors[start_slot], states,
336 sizeof(*states) * num_scissors);
337 pipe->set_scissor_states(pipe, start_slot, num_scissors, states);
338 }
339
340 static void
341 dd_context_set_viewport_states(struct pipe_context *_pipe,
342 unsigned start_slot, unsigned num_viewports,
343 const struct pipe_viewport_state *states)
344 {
345 struct dd_context *dctx = dd_context(_pipe);
346 struct pipe_context *pipe = dctx->pipe;
347
348 safe_memcpy(&dctx->viewports[start_slot], states,
349 sizeof(*states) * num_viewports);
350 pipe->set_viewport_states(pipe, start_slot, num_viewports, states);
351 }
352
353 static void dd_context_set_tess_state(struct pipe_context *_pipe,
354 const float default_outer_level[4],
355 const float default_inner_level[2])
356 {
357 struct dd_context *dctx = dd_context(_pipe);
358 struct pipe_context *pipe = dctx->pipe;
359
360 memcpy(dctx->tess_default_levels, default_outer_level, sizeof(float) * 4);
361 memcpy(dctx->tess_default_levels+4, default_inner_level, sizeof(float) * 2);
362 pipe->set_tess_state(pipe, default_outer_level, default_inner_level);
363 }
364
365
366 /********************************************************************
367 * views
368 */
369
370 static struct pipe_surface *
371 dd_context_create_surface(struct pipe_context *_pipe,
372 struct pipe_resource *resource,
373 const struct pipe_surface *surf_tmpl)
374 {
375 struct pipe_context *pipe = dd_context(_pipe)->pipe;
376 struct pipe_surface *view =
377 pipe->create_surface(pipe, resource, surf_tmpl);
378
379 if (!view)
380 return NULL;
381 view->context = _pipe;
382 return view;
383 }
384
385 static void
386 dd_context_surface_destroy(struct pipe_context *_pipe,
387 struct pipe_surface *surf)
388 {
389 struct pipe_context *pipe = dd_context(_pipe)->pipe;
390
391 pipe->surface_destroy(pipe, surf);
392 }
393
394 static struct pipe_sampler_view *
395 dd_context_create_sampler_view(struct pipe_context *_pipe,
396 struct pipe_resource *resource,
397 const struct pipe_sampler_view *templ)
398 {
399 struct pipe_context *pipe = dd_context(_pipe)->pipe;
400 struct pipe_sampler_view *view =
401 pipe->create_sampler_view(pipe, resource, templ);
402
403 if (!view)
404 return NULL;
405 view->context = _pipe;
406 return view;
407 }
408
409 static void
410 dd_context_sampler_view_destroy(struct pipe_context *_pipe,
411 struct pipe_sampler_view *view)
412 {
413 struct pipe_context *pipe = dd_context(_pipe)->pipe;
414
415 pipe->sampler_view_destroy(pipe, view);
416 }
417
418 static struct pipe_image_view *
419 dd_context_create_image_view(struct pipe_context *_pipe,
420 struct pipe_resource *resource,
421 const struct pipe_image_view *templ)
422 {
423 struct pipe_context *pipe = dd_context(_pipe)->pipe;
424 struct pipe_image_view *view =
425 pipe->create_image_view(pipe, resource, templ);
426
427 if (!view)
428 return NULL;
429 view->context = _pipe;
430 return view;
431 }
432
433 static void
434 dd_context_image_view_destroy(struct pipe_context *_pipe,
435 struct pipe_image_view *view)
436 {
437 struct pipe_context *pipe = dd_context(_pipe)->pipe;
438
439 pipe->image_view_destroy(pipe, view);
440 }
441
442 static struct pipe_stream_output_target *
443 dd_context_create_stream_output_target(struct pipe_context *_pipe,
444 struct pipe_resource *res,
445 unsigned buffer_offset,
446 unsigned buffer_size)
447 {
448 struct pipe_context *pipe = dd_context(_pipe)->pipe;
449 struct pipe_stream_output_target *view =
450 pipe->create_stream_output_target(pipe, res, buffer_offset,
451 buffer_size);
452
453 if (!view)
454 return NULL;
455 view->context = _pipe;
456 return view;
457 }
458
459 static void
460 dd_context_stream_output_target_destroy(struct pipe_context *_pipe,
461 struct pipe_stream_output_target *target)
462 {
463 struct pipe_context *pipe = dd_context(_pipe)->pipe;
464
465 pipe->stream_output_target_destroy(pipe, target);
466 }
467
468
469 /********************************************************************
470 * set states
471 */
472
473 static void
474 dd_context_set_sampler_views(struct pipe_context *_pipe, unsigned shader,
475 unsigned start, unsigned num,
476 struct pipe_sampler_view **views)
477 {
478 struct dd_context *dctx = dd_context(_pipe);
479 struct pipe_context *pipe = dctx->pipe;
480
481 safe_memcpy(&dctx->sampler_views[shader][start], views,
482 sizeof(views[0]) * num);
483 pipe->set_sampler_views(pipe, shader, start, num, views);
484 }
485
486 static void
487 dd_context_set_shader_images(struct pipe_context *_pipe, unsigned shader,
488 unsigned start, unsigned num,
489 struct pipe_image_view **views)
490 {
491 struct dd_context *dctx = dd_context(_pipe);
492 struct pipe_context *pipe = dctx->pipe;
493
494 safe_memcpy(&dctx->shader_images[shader][start], views,
495 sizeof(views[0]) * num);
496 pipe->set_shader_images(pipe, shader, start, num, views);
497 }
498
499 static void
500 dd_context_set_shader_buffers(struct pipe_context *_pipe, unsigned shader,
501 unsigned start, unsigned num_buffers,
502 struct pipe_shader_buffer *buffers)
503 {
504 struct dd_context *dctx = dd_context(_pipe);
505 struct pipe_context *pipe = dctx->pipe;
506
507 safe_memcpy(&dctx->shader_buffers[shader][start], buffers,
508 sizeof(buffers[0]) * num_buffers);
509 pipe->set_shader_buffers(pipe, shader, start, num_buffers, buffers);
510 }
511
512 static void
513 dd_context_set_vertex_buffers(struct pipe_context *_pipe,
514 unsigned start, unsigned num_buffers,
515 const struct pipe_vertex_buffer *buffers)
516 {
517 struct dd_context *dctx = dd_context(_pipe);
518 struct pipe_context *pipe = dctx->pipe;
519
520 safe_memcpy(&dctx->vertex_buffers[start], buffers,
521 sizeof(buffers[0]) * num_buffers);
522 pipe->set_vertex_buffers(pipe, start, num_buffers, buffers);
523 }
524
525 static void
526 dd_context_set_index_buffer(struct pipe_context *_pipe,
527 const struct pipe_index_buffer *ib)
528 {
529 struct dd_context *dctx = dd_context(_pipe);
530 struct pipe_context *pipe = dctx->pipe;
531
532 safe_memcpy(&dctx->index_buffer, ib, sizeof(*ib));
533 pipe->set_index_buffer(pipe, ib);
534 }
535
536 static void
537 dd_context_set_stream_output_targets(struct pipe_context *_pipe,
538 unsigned num_targets,
539 struct pipe_stream_output_target **tgs,
540 const unsigned *offsets)
541 {
542 struct dd_context *dctx = dd_context(_pipe);
543 struct pipe_context *pipe = dctx->pipe;
544
545 dctx->num_so_targets = num_targets;
546 safe_memcpy(dctx->so_targets, tgs, sizeof(*tgs) * num_targets);
547 safe_memcpy(dctx->so_offsets, offsets, sizeof(*offsets) * num_targets);
548 pipe->set_stream_output_targets(pipe, num_targets, tgs, offsets);
549 }
550
551 static void
552 dd_context_destroy(struct pipe_context *_pipe)
553 {
554 struct dd_context *dctx = dd_context(_pipe);
555 struct pipe_context *pipe = dctx->pipe;
556
557 pipe->destroy(pipe);
558 FREE(dctx);
559 }
560
561
562 /********************************************************************
563 * transfer
564 */
565
566 static void *
567 dd_context_transfer_map(struct pipe_context *_pipe,
568 struct pipe_resource *resource, unsigned level,
569 unsigned usage, const struct pipe_box *box,
570 struct pipe_transfer **transfer)
571 {
572 struct pipe_context *pipe = dd_context(_pipe)->pipe;
573
574 return pipe->transfer_map(pipe, resource, level, usage, box, transfer);
575 }
576
577 static void
578 dd_context_transfer_flush_region(struct pipe_context *_pipe,
579 struct pipe_transfer *transfer,
580 const struct pipe_box *box)
581 {
582 struct pipe_context *pipe = dd_context(_pipe)->pipe;
583
584 pipe->transfer_flush_region(pipe, transfer, box);
585 }
586
587 static void
588 dd_context_transfer_unmap(struct pipe_context *_pipe,
589 struct pipe_transfer *transfer)
590 {
591 struct pipe_context *pipe = dd_context(_pipe)->pipe;
592
593 pipe->transfer_unmap(pipe, transfer);
594 }
595
596 static void
597 dd_context_transfer_inline_write(struct pipe_context *_pipe,
598 struct pipe_resource *resource,
599 unsigned level, unsigned usage,
600 const struct pipe_box *box,
601 const void *data, unsigned stride,
602 unsigned layer_stride)
603 {
604 struct pipe_context *pipe = dd_context(_pipe)->pipe;
605
606 pipe->transfer_inline_write(pipe, resource, level, usage, box, data,
607 stride, layer_stride);
608 }
609
610
611 /********************************************************************
612 * miscellaneous
613 */
614
615 static void
616 dd_context_texture_barrier(struct pipe_context *_pipe)
617 {
618 struct pipe_context *pipe = dd_context(_pipe)->pipe;
619
620 pipe->texture_barrier(pipe);
621 }
622
623 static void
624 dd_context_memory_barrier(struct pipe_context *_pipe, unsigned flags)
625 {
626 struct pipe_context *pipe = dd_context(_pipe)->pipe;
627
628 pipe->memory_barrier(pipe, flags);
629 }
630
631 static void
632 dd_context_get_sample_position(struct pipe_context *_pipe,
633 unsigned sample_count, unsigned sample_index,
634 float *out_value)
635 {
636 struct pipe_context *pipe = dd_context(_pipe)->pipe;
637
638 return pipe->get_sample_position(pipe, sample_count, sample_index,
639 out_value);
640 }
641
642 static void
643 dd_context_invalidate_resource(struct pipe_context *_pipe,
644 struct pipe_resource *resource)
645 {
646 struct pipe_context *pipe = dd_context(_pipe)->pipe;
647
648 pipe->invalidate_resource(pipe, resource);
649 }
650
651 static enum pipe_reset_status
652 dd_context_get_device_reset_status(struct pipe_context *_pipe)
653 {
654 struct pipe_context *pipe = dd_context(_pipe)->pipe;
655
656 return pipe->get_device_reset_status(pipe);
657 }
658
659 static void
660 dd_context_dump_debug_state(struct pipe_context *_pipe, FILE *stream,
661 unsigned flags)
662 {
663 struct pipe_context *pipe = dd_context(_pipe)->pipe;
664
665 return pipe->dump_debug_state(pipe, stream, flags);
666 }
667
668 struct pipe_context *
669 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
670 {
671 struct dd_context *dctx;
672
673 if (!pipe)
674 return NULL;
675
676 dctx = CALLOC_STRUCT(dd_context);
677 if (!dctx) {
678 pipe->destroy(pipe);
679 return NULL;
680 }
681
682 dctx->pipe = pipe;
683 dctx->base.priv = pipe->priv; /* expose wrapped priv data */
684 dctx->base.screen = &dscreen->base;
685
686 dctx->base.destroy = dd_context_destroy;
687
688 CTX_INIT(render_condition);
689 CTX_INIT(create_query);
690 CTX_INIT(destroy_query);
691 CTX_INIT(begin_query);
692 CTX_INIT(end_query);
693 CTX_INIT(get_query_result);
694 CTX_INIT(create_blend_state);
695 CTX_INIT(bind_blend_state);
696 CTX_INIT(delete_blend_state);
697 CTX_INIT(create_sampler_state);
698 CTX_INIT(bind_sampler_states);
699 CTX_INIT(delete_sampler_state);
700 CTX_INIT(create_rasterizer_state);
701 CTX_INIT(bind_rasterizer_state);
702 CTX_INIT(delete_rasterizer_state);
703 CTX_INIT(create_depth_stencil_alpha_state);
704 CTX_INIT(bind_depth_stencil_alpha_state);
705 CTX_INIT(delete_depth_stencil_alpha_state);
706 CTX_INIT(create_fs_state);
707 CTX_INIT(bind_fs_state);
708 CTX_INIT(delete_fs_state);
709 CTX_INIT(create_vs_state);
710 CTX_INIT(bind_vs_state);
711 CTX_INIT(delete_vs_state);
712 CTX_INIT(create_gs_state);
713 CTX_INIT(bind_gs_state);
714 CTX_INIT(delete_gs_state);
715 CTX_INIT(create_tcs_state);
716 CTX_INIT(bind_tcs_state);
717 CTX_INIT(delete_tcs_state);
718 CTX_INIT(create_tes_state);
719 CTX_INIT(bind_tes_state);
720 CTX_INIT(delete_tes_state);
721 CTX_INIT(create_vertex_elements_state);
722 CTX_INIT(bind_vertex_elements_state);
723 CTX_INIT(delete_vertex_elements_state);
724 CTX_INIT(set_blend_color);
725 CTX_INIT(set_stencil_ref);
726 CTX_INIT(set_sample_mask);
727 CTX_INIT(set_min_samples);
728 CTX_INIT(set_clip_state);
729 CTX_INIT(set_constant_buffer);
730 CTX_INIT(set_framebuffer_state);
731 CTX_INIT(set_polygon_stipple);
732 CTX_INIT(set_scissor_states);
733 CTX_INIT(set_viewport_states);
734 CTX_INIT(set_sampler_views);
735 CTX_INIT(set_tess_state);
736 CTX_INIT(set_shader_buffers);
737 CTX_INIT(set_shader_images);
738 CTX_INIT(set_vertex_buffers);
739 CTX_INIT(set_index_buffer);
740 CTX_INIT(create_stream_output_target);
741 CTX_INIT(stream_output_target_destroy);
742 CTX_INIT(set_stream_output_targets);
743 CTX_INIT(create_sampler_view);
744 CTX_INIT(sampler_view_destroy);
745 CTX_INIT(create_surface);
746 CTX_INIT(surface_destroy);
747 CTX_INIT(create_image_view);
748 CTX_INIT(image_view_destroy);
749 CTX_INIT(transfer_map);
750 CTX_INIT(transfer_flush_region);
751 CTX_INIT(transfer_unmap);
752 CTX_INIT(transfer_inline_write);
753 CTX_INIT(texture_barrier);
754 CTX_INIT(memory_barrier);
755 /* create_video_codec */
756 /* create_video_buffer */
757 /* create_compute_state */
758 /* bind_compute_state */
759 /* delete_compute_state */
760 /* set_compute_resources */
761 /* set_global_binding */
762 CTX_INIT(get_sample_position);
763 CTX_INIT(invalidate_resource);
764 CTX_INIT(get_device_reset_status);
765 CTX_INIT(dump_debug_state);
766
767 dd_init_draw_functions(dctx);
768
769 dctx->sample_mask = ~0;
770 return &dctx->base;
771 }