gallium/radeon: assume X11 DRI3 can use at most 5 back buffers
[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 bool
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 return 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_set_active_query_state(struct pipe_context *_pipe, boolean enable)
128 {
129 struct pipe_context *pipe = dd_context(_pipe)->pipe;
130
131 pipe->set_active_query_state(pipe, enable);
132 }
133
134 static void
135 dd_context_render_condition(struct pipe_context *_pipe,
136 struct pipe_query *query, boolean condition,
137 uint mode)
138 {
139 struct dd_context *dctx = dd_context(_pipe);
140 struct pipe_context *pipe = dctx->pipe;
141
142 pipe->render_condition(pipe, dd_query_unwrap(query), condition, mode);
143 dctx->render_cond.query = dd_query(query);
144 dctx->render_cond.condition = condition;
145 dctx->render_cond.mode = mode;
146 }
147
148
149 /********************************************************************
150 * constant (immutable) non-shader states
151 */
152
153 #define DD_CSO_CREATE(name, shortname) \
154 static void * \
155 dd_context_create_##name##_state(struct pipe_context *_pipe, \
156 const struct pipe_##name##_state *state) \
157 { \
158 struct pipe_context *pipe = dd_context(_pipe)->pipe; \
159 struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
160 \
161 if (!hstate) \
162 return NULL; \
163 hstate->cso = pipe->create_##name##_state(pipe, state); \
164 hstate->state.shortname = *state; \
165 return hstate; \
166 }
167
168 #define DD_CSO_BIND(name, shortname) \
169 static void \
170 dd_context_bind_##name##_state(struct pipe_context *_pipe, void *state) \
171 { \
172 struct dd_context *dctx = dd_context(_pipe); \
173 struct pipe_context *pipe = dctx->pipe; \
174 struct dd_state *hstate = state; \
175 \
176 dctx->shortname = hstate; \
177 pipe->bind_##name##_state(pipe, hstate ? hstate->cso : NULL); \
178 }
179
180 #define DD_CSO_DELETE(name) \
181 static void \
182 dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
183 { \
184 struct dd_context *dctx = dd_context(_pipe); \
185 struct pipe_context *pipe = dctx->pipe; \
186 struct dd_state *hstate = state; \
187 \
188 pipe->delete_##name##_state(pipe, hstate->cso); \
189 FREE(hstate); \
190 }
191
192 #define DD_CSO_WHOLE(name, shortname) \
193 DD_CSO_CREATE(name, shortname) \
194 DD_CSO_BIND(name, shortname) \
195 DD_CSO_DELETE(name)
196
197 DD_CSO_WHOLE(blend, blend)
198 DD_CSO_WHOLE(rasterizer, rs)
199 DD_CSO_WHOLE(depth_stencil_alpha, dsa)
200
201 DD_CSO_CREATE(sampler, sampler)
202 DD_CSO_DELETE(sampler)
203
204 static void
205 dd_context_bind_sampler_states(struct pipe_context *_pipe, unsigned shader,
206 unsigned start, unsigned count, void **states)
207 {
208 struct dd_context *dctx = dd_context(_pipe);
209 struct pipe_context *pipe = dctx->pipe;
210
211 memcpy(&dctx->sampler_states[shader][start], states,
212 sizeof(void*) * count);
213
214 if (states) {
215 void *samp[PIPE_MAX_SAMPLERS];
216 int i;
217
218 for (i = 0; i < count; i++) {
219 struct dd_state *s = states[i];
220 samp[i] = s ? s->cso : NULL;
221 }
222
223 pipe->bind_sampler_states(pipe, shader, start, count, samp);
224 }
225 else
226 pipe->bind_sampler_states(pipe, shader, start, count, NULL);
227 }
228
229 static void *
230 dd_context_create_vertex_elements_state(struct pipe_context *_pipe,
231 unsigned num_elems,
232 const struct pipe_vertex_element *elems)
233 {
234 struct pipe_context *pipe = dd_context(_pipe)->pipe;
235 struct dd_state *hstate = CALLOC_STRUCT(dd_state);
236
237 if (!hstate)
238 return NULL;
239 hstate->cso = pipe->create_vertex_elements_state(pipe, num_elems, elems);
240 memcpy(hstate->state.velems.velems, elems, sizeof(elems[0]) * num_elems);
241 hstate->state.velems.count = num_elems;
242 return hstate;
243 }
244
245 DD_CSO_BIND(vertex_elements, velems)
246 DD_CSO_DELETE(vertex_elements)
247
248
249 /********************************************************************
250 * shaders
251 */
252
253 #define DD_SHADER_NOCREATE(NAME, name) \
254 static void \
255 dd_context_bind_##name##_state(struct pipe_context *_pipe, void *state) \
256 { \
257 struct dd_context *dctx = dd_context(_pipe); \
258 struct pipe_context *pipe = dctx->pipe; \
259 struct dd_state *hstate = state; \
260 \
261 dctx->shaders[PIPE_SHADER_##NAME] = hstate; \
262 pipe->bind_##name##_state(pipe, hstate ? hstate->cso : NULL); \
263 } \
264 \
265 static void \
266 dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
267 { \
268 struct dd_context *dctx = dd_context(_pipe); \
269 struct pipe_context *pipe = dctx->pipe; \
270 struct dd_state *hstate = state; \
271 \
272 pipe->delete_##name##_state(pipe, hstate->cso); \
273 tgsi_free_tokens(hstate->state.shader.tokens); \
274 FREE(hstate); \
275 }
276
277 #define DD_SHADER(NAME, name) \
278 static void * \
279 dd_context_create_##name##_state(struct pipe_context *_pipe, \
280 const struct pipe_shader_state *state) \
281 { \
282 struct pipe_context *pipe = dd_context(_pipe)->pipe; \
283 struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
284 \
285 if (!hstate) \
286 return NULL; \
287 hstate->cso = pipe->create_##name##_state(pipe, state); \
288 hstate->state.shader = *state; \
289 hstate->state.shader.tokens = tgsi_dup_tokens(state->tokens); \
290 return hstate; \
291 } \
292 \
293 DD_SHADER_NOCREATE(NAME, name)
294
295 DD_SHADER(FRAGMENT, fs)
296 DD_SHADER(VERTEX, vs)
297 DD_SHADER(GEOMETRY, gs)
298 DD_SHADER(TESS_CTRL, tcs)
299 DD_SHADER(TESS_EVAL, tes)
300
301 static void * \
302 dd_context_create_compute_state(struct pipe_context *_pipe,
303 const struct pipe_compute_state *state)
304 {
305 struct pipe_context *pipe = dd_context(_pipe)->pipe;
306 struct dd_state *hstate = CALLOC_STRUCT(dd_state);
307
308 if (!hstate)
309 return NULL;
310 hstate->cso = pipe->create_compute_state(pipe, state);
311
312 if (state->ir_type == PIPE_SHADER_IR_TGSI)
313 hstate->state.shader.tokens = tgsi_dup_tokens(state->prog);
314
315 return hstate;
316 }
317
318 DD_SHADER_NOCREATE(COMPUTE, compute)
319
320 /********************************************************************
321 * immediate states
322 */
323
324 #define DD_IMM_STATE(name, type, deref, ref) \
325 static void \
326 dd_context_set_##name(struct pipe_context *_pipe, type deref) \
327 { \
328 struct dd_context *dctx = dd_context(_pipe); \
329 struct pipe_context *pipe = dctx->pipe; \
330 \
331 dctx->name = deref; \
332 pipe->set_##name(pipe, ref); \
333 }
334
335 DD_IMM_STATE(blend_color, const struct pipe_blend_color, *state, state)
336 DD_IMM_STATE(stencil_ref, const struct pipe_stencil_ref, *state, state)
337 DD_IMM_STATE(clip_state, const struct pipe_clip_state, *state, state)
338 DD_IMM_STATE(sample_mask, unsigned, sample_mask, sample_mask)
339 DD_IMM_STATE(min_samples, unsigned, min_samples, min_samples)
340 DD_IMM_STATE(framebuffer_state, const struct pipe_framebuffer_state, *state, state)
341 DD_IMM_STATE(polygon_stipple, const struct pipe_poly_stipple, *state, state)
342
343 static void
344 dd_context_set_constant_buffer(struct pipe_context *_pipe,
345 uint shader, uint index,
346 const struct pipe_constant_buffer *constant_buffer)
347 {
348 struct dd_context *dctx = dd_context(_pipe);
349 struct pipe_context *pipe = dctx->pipe;
350
351 safe_memcpy(&dctx->constant_buffers[shader][index], constant_buffer,
352 sizeof(*constant_buffer));
353 pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
354 }
355
356 static void
357 dd_context_set_scissor_states(struct pipe_context *_pipe,
358 unsigned start_slot, unsigned num_scissors,
359 const struct pipe_scissor_state *states)
360 {
361 struct dd_context *dctx = dd_context(_pipe);
362 struct pipe_context *pipe = dctx->pipe;
363
364 safe_memcpy(&dctx->scissors[start_slot], states,
365 sizeof(*states) * num_scissors);
366 pipe->set_scissor_states(pipe, start_slot, num_scissors, states);
367 }
368
369 static void
370 dd_context_set_viewport_states(struct pipe_context *_pipe,
371 unsigned start_slot, unsigned num_viewports,
372 const struct pipe_viewport_state *states)
373 {
374 struct dd_context *dctx = dd_context(_pipe);
375 struct pipe_context *pipe = dctx->pipe;
376
377 safe_memcpy(&dctx->viewports[start_slot], states,
378 sizeof(*states) * num_viewports);
379 pipe->set_viewport_states(pipe, start_slot, num_viewports, states);
380 }
381
382 static void dd_context_set_tess_state(struct pipe_context *_pipe,
383 const float default_outer_level[4],
384 const float default_inner_level[2])
385 {
386 struct dd_context *dctx = dd_context(_pipe);
387 struct pipe_context *pipe = dctx->pipe;
388
389 memcpy(dctx->tess_default_levels, default_outer_level, sizeof(float) * 4);
390 memcpy(dctx->tess_default_levels+4, default_inner_level, sizeof(float) * 2);
391 pipe->set_tess_state(pipe, default_outer_level, default_inner_level);
392 }
393
394
395 /********************************************************************
396 * views
397 */
398
399 static struct pipe_surface *
400 dd_context_create_surface(struct pipe_context *_pipe,
401 struct pipe_resource *resource,
402 const struct pipe_surface *surf_tmpl)
403 {
404 struct pipe_context *pipe = dd_context(_pipe)->pipe;
405 struct pipe_surface *view =
406 pipe->create_surface(pipe, resource, surf_tmpl);
407
408 if (!view)
409 return NULL;
410 view->context = _pipe;
411 return view;
412 }
413
414 static void
415 dd_context_surface_destroy(struct pipe_context *_pipe,
416 struct pipe_surface *surf)
417 {
418 struct pipe_context *pipe = dd_context(_pipe)->pipe;
419
420 pipe->surface_destroy(pipe, surf);
421 }
422
423 static struct pipe_sampler_view *
424 dd_context_create_sampler_view(struct pipe_context *_pipe,
425 struct pipe_resource *resource,
426 const struct pipe_sampler_view *templ)
427 {
428 struct pipe_context *pipe = dd_context(_pipe)->pipe;
429 struct pipe_sampler_view *view =
430 pipe->create_sampler_view(pipe, resource, templ);
431
432 if (!view)
433 return NULL;
434 view->context = _pipe;
435 return view;
436 }
437
438 static void
439 dd_context_sampler_view_destroy(struct pipe_context *_pipe,
440 struct pipe_sampler_view *view)
441 {
442 struct pipe_context *pipe = dd_context(_pipe)->pipe;
443
444 pipe->sampler_view_destroy(pipe, view);
445 }
446
447 static struct pipe_stream_output_target *
448 dd_context_create_stream_output_target(struct pipe_context *_pipe,
449 struct pipe_resource *res,
450 unsigned buffer_offset,
451 unsigned buffer_size)
452 {
453 struct pipe_context *pipe = dd_context(_pipe)->pipe;
454 struct pipe_stream_output_target *view =
455 pipe->create_stream_output_target(pipe, res, buffer_offset,
456 buffer_size);
457
458 if (!view)
459 return NULL;
460 view->context = _pipe;
461 return view;
462 }
463
464 static void
465 dd_context_stream_output_target_destroy(struct pipe_context *_pipe,
466 struct pipe_stream_output_target *target)
467 {
468 struct pipe_context *pipe = dd_context(_pipe)->pipe;
469
470 pipe->stream_output_target_destroy(pipe, target);
471 }
472
473
474 /********************************************************************
475 * set states
476 */
477
478 static void
479 dd_context_set_sampler_views(struct pipe_context *_pipe, unsigned shader,
480 unsigned start, unsigned num,
481 struct pipe_sampler_view **views)
482 {
483 struct dd_context *dctx = dd_context(_pipe);
484 struct pipe_context *pipe = dctx->pipe;
485
486 safe_memcpy(&dctx->sampler_views[shader][start], views,
487 sizeof(views[0]) * num);
488 pipe->set_sampler_views(pipe, shader, start, num, views);
489 }
490
491 static void
492 dd_context_set_shader_images(struct pipe_context *_pipe, unsigned shader,
493 unsigned start, unsigned num,
494 const struct pipe_image_view *views)
495 {
496 struct dd_context *dctx = dd_context(_pipe);
497 struct pipe_context *pipe = dctx->pipe;
498
499 safe_memcpy(&dctx->shader_images[shader][start], views,
500 sizeof(views[0]) * num);
501 pipe->set_shader_images(pipe, shader, start, num, views);
502 }
503
504 static void
505 dd_context_set_shader_buffers(struct pipe_context *_pipe, unsigned shader,
506 unsigned start, unsigned num_buffers,
507 const struct pipe_shader_buffer *buffers)
508 {
509 struct dd_context *dctx = dd_context(_pipe);
510 struct pipe_context *pipe = dctx->pipe;
511
512 safe_memcpy(&dctx->shader_buffers[shader][start], buffers,
513 sizeof(buffers[0]) * num_buffers);
514 pipe->set_shader_buffers(pipe, shader, start, num_buffers, buffers);
515 }
516
517 static void
518 dd_context_set_vertex_buffers(struct pipe_context *_pipe,
519 unsigned start, unsigned num_buffers,
520 const struct pipe_vertex_buffer *buffers)
521 {
522 struct dd_context *dctx = dd_context(_pipe);
523 struct pipe_context *pipe = dctx->pipe;
524
525 safe_memcpy(&dctx->vertex_buffers[start], buffers,
526 sizeof(buffers[0]) * num_buffers);
527 pipe->set_vertex_buffers(pipe, start, num_buffers, buffers);
528 }
529
530 static void
531 dd_context_set_index_buffer(struct pipe_context *_pipe,
532 const struct pipe_index_buffer *ib)
533 {
534 struct dd_context *dctx = dd_context(_pipe);
535 struct pipe_context *pipe = dctx->pipe;
536
537 safe_memcpy(&dctx->index_buffer, ib, sizeof(*ib));
538 pipe->set_index_buffer(pipe, ib);
539 }
540
541 static void
542 dd_context_set_stream_output_targets(struct pipe_context *_pipe,
543 unsigned num_targets,
544 struct pipe_stream_output_target **tgs,
545 const unsigned *offsets)
546 {
547 struct dd_context *dctx = dd_context(_pipe);
548 struct pipe_context *pipe = dctx->pipe;
549
550 dctx->num_so_targets = num_targets;
551 safe_memcpy(dctx->so_targets, tgs, sizeof(*tgs) * num_targets);
552 safe_memcpy(dctx->so_offsets, offsets, sizeof(*offsets) * num_targets);
553 pipe->set_stream_output_targets(pipe, num_targets, tgs, offsets);
554 }
555
556 static void
557 dd_context_destroy(struct pipe_context *_pipe)
558 {
559 struct dd_context *dctx = dd_context(_pipe);
560 struct pipe_context *pipe = dctx->pipe;
561
562 pipe->destroy(pipe);
563 FREE(dctx);
564 }
565
566
567 /********************************************************************
568 * transfer
569 */
570
571 static void *
572 dd_context_transfer_map(struct pipe_context *_pipe,
573 struct pipe_resource *resource, unsigned level,
574 unsigned usage, const struct pipe_box *box,
575 struct pipe_transfer **transfer)
576 {
577 struct pipe_context *pipe = dd_context(_pipe)->pipe;
578
579 return pipe->transfer_map(pipe, resource, level, usage, box, transfer);
580 }
581
582 static void
583 dd_context_transfer_flush_region(struct pipe_context *_pipe,
584 struct pipe_transfer *transfer,
585 const struct pipe_box *box)
586 {
587 struct pipe_context *pipe = dd_context(_pipe)->pipe;
588
589 pipe->transfer_flush_region(pipe, transfer, box);
590 }
591
592 static void
593 dd_context_transfer_unmap(struct pipe_context *_pipe,
594 struct pipe_transfer *transfer)
595 {
596 struct pipe_context *pipe = dd_context(_pipe)->pipe;
597
598 pipe->transfer_unmap(pipe, transfer);
599 }
600
601 static void
602 dd_context_transfer_inline_write(struct pipe_context *_pipe,
603 struct pipe_resource *resource,
604 unsigned level, unsigned usage,
605 const struct pipe_box *box,
606 const void *data, unsigned stride,
607 unsigned layer_stride)
608 {
609 struct pipe_context *pipe = dd_context(_pipe)->pipe;
610
611 pipe->transfer_inline_write(pipe, resource, level, usage, box, data,
612 stride, layer_stride);
613 }
614
615
616 /********************************************************************
617 * miscellaneous
618 */
619
620 static void
621 dd_context_texture_barrier(struct pipe_context *_pipe)
622 {
623 struct pipe_context *pipe = dd_context(_pipe)->pipe;
624
625 pipe->texture_barrier(pipe);
626 }
627
628 static void
629 dd_context_memory_barrier(struct pipe_context *_pipe, unsigned flags)
630 {
631 struct pipe_context *pipe = dd_context(_pipe)->pipe;
632
633 pipe->memory_barrier(pipe, flags);
634 }
635
636 static void
637 dd_context_get_sample_position(struct pipe_context *_pipe,
638 unsigned sample_count, unsigned sample_index,
639 float *out_value)
640 {
641 struct pipe_context *pipe = dd_context(_pipe)->pipe;
642
643 return pipe->get_sample_position(pipe, sample_count, sample_index,
644 out_value);
645 }
646
647 static void
648 dd_context_invalidate_resource(struct pipe_context *_pipe,
649 struct pipe_resource *resource)
650 {
651 struct pipe_context *pipe = dd_context(_pipe)->pipe;
652
653 pipe->invalidate_resource(pipe, resource);
654 }
655
656 static enum pipe_reset_status
657 dd_context_get_device_reset_status(struct pipe_context *_pipe)
658 {
659 struct pipe_context *pipe = dd_context(_pipe)->pipe;
660
661 return pipe->get_device_reset_status(pipe);
662 }
663
664 static void
665 dd_context_dump_debug_state(struct pipe_context *_pipe, FILE *stream,
666 unsigned flags)
667 {
668 struct pipe_context *pipe = dd_context(_pipe)->pipe;
669
670 return pipe->dump_debug_state(pipe, stream, flags);
671 }
672
673 struct pipe_context *
674 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
675 {
676 struct dd_context *dctx;
677
678 if (!pipe)
679 return NULL;
680
681 dctx = CALLOC_STRUCT(dd_context);
682 if (!dctx) {
683 pipe->destroy(pipe);
684 return NULL;
685 }
686
687 dctx->pipe = pipe;
688 dctx->base.priv = pipe->priv; /* expose wrapped priv data */
689 dctx->base.screen = &dscreen->base;
690
691 dctx->base.destroy = dd_context_destroy;
692
693 CTX_INIT(render_condition);
694 CTX_INIT(create_query);
695 CTX_INIT(destroy_query);
696 CTX_INIT(begin_query);
697 CTX_INIT(end_query);
698 CTX_INIT(get_query_result);
699 CTX_INIT(set_active_query_state);
700 CTX_INIT(create_blend_state);
701 CTX_INIT(bind_blend_state);
702 CTX_INIT(delete_blend_state);
703 CTX_INIT(create_sampler_state);
704 CTX_INIT(bind_sampler_states);
705 CTX_INIT(delete_sampler_state);
706 CTX_INIT(create_rasterizer_state);
707 CTX_INIT(bind_rasterizer_state);
708 CTX_INIT(delete_rasterizer_state);
709 CTX_INIT(create_depth_stencil_alpha_state);
710 CTX_INIT(bind_depth_stencil_alpha_state);
711 CTX_INIT(delete_depth_stencil_alpha_state);
712 CTX_INIT(create_fs_state);
713 CTX_INIT(bind_fs_state);
714 CTX_INIT(delete_fs_state);
715 CTX_INIT(create_vs_state);
716 CTX_INIT(bind_vs_state);
717 CTX_INIT(delete_vs_state);
718 CTX_INIT(create_gs_state);
719 CTX_INIT(bind_gs_state);
720 CTX_INIT(delete_gs_state);
721 CTX_INIT(create_tcs_state);
722 CTX_INIT(bind_tcs_state);
723 CTX_INIT(delete_tcs_state);
724 CTX_INIT(create_tes_state);
725 CTX_INIT(bind_tes_state);
726 CTX_INIT(delete_tes_state);
727 CTX_INIT(create_compute_state);
728 CTX_INIT(bind_compute_state);
729 CTX_INIT(delete_compute_state);
730 CTX_INIT(create_vertex_elements_state);
731 CTX_INIT(bind_vertex_elements_state);
732 CTX_INIT(delete_vertex_elements_state);
733 CTX_INIT(set_blend_color);
734 CTX_INIT(set_stencil_ref);
735 CTX_INIT(set_sample_mask);
736 CTX_INIT(set_min_samples);
737 CTX_INIT(set_clip_state);
738 CTX_INIT(set_constant_buffer);
739 CTX_INIT(set_framebuffer_state);
740 CTX_INIT(set_polygon_stipple);
741 CTX_INIT(set_scissor_states);
742 CTX_INIT(set_viewport_states);
743 CTX_INIT(set_sampler_views);
744 CTX_INIT(set_tess_state);
745 CTX_INIT(set_shader_buffers);
746 CTX_INIT(set_shader_images);
747 CTX_INIT(set_vertex_buffers);
748 CTX_INIT(set_index_buffer);
749 CTX_INIT(create_stream_output_target);
750 CTX_INIT(stream_output_target_destroy);
751 CTX_INIT(set_stream_output_targets);
752 CTX_INIT(create_sampler_view);
753 CTX_INIT(sampler_view_destroy);
754 CTX_INIT(create_surface);
755 CTX_INIT(surface_destroy);
756 CTX_INIT(transfer_map);
757 CTX_INIT(transfer_flush_region);
758 CTX_INIT(transfer_unmap);
759 CTX_INIT(transfer_inline_write);
760 CTX_INIT(texture_barrier);
761 CTX_INIT(memory_barrier);
762 /* create_video_codec */
763 /* create_video_buffer */
764 /* create_compute_state */
765 /* bind_compute_state */
766 /* delete_compute_state */
767 /* set_compute_resources */
768 /* set_global_binding */
769 CTX_INIT(get_sample_position);
770 CTX_INIT(invalidate_resource);
771 CTX_INIT(get_device_reset_status);
772 CTX_INIT(dump_debug_state);
773
774 dd_init_draw_functions(dctx);
775
776 dctx->sample_mask = ~0;
777 return &dctx->base;
778 }