1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "pipe/p_context.h"
30 #include "util/u_memory.h"
31 #include "util/u_inlines.h"
32 #include "util/u_simple_list.h"
34 #include "rbug/rbug_context.h"
36 #include "rbug_context.h"
37 #include "rbug_objects.h"
41 rbug_destroy(struct pipe_context
*_pipe
)
43 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
44 struct pipe_context
*pipe
= rb_pipe
->pipe
;
52 rbug_draw_block_locked(struct rbug_context
*rb_pipe
, int flag
)
55 if (rb_pipe
->draw_blocker
& flag
) {
56 rb_pipe
->draw_blocked
|= flag
;
57 } else if ((rb_pipe
->draw_rule
.blocker
& flag
) &&
58 (rb_pipe
->draw_blocker
& RBUG_BLOCK_RULE
)) {
60 boolean block
= FALSE
;
61 debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__
,
62 (void *) rb_pipe
->draw_rule
.fs
, (void *) rb_pipe
->curr
.fs
,
63 (void *) rb_pipe
->draw_rule
.vs
, (void *) rb_pipe
->curr
.vs
,
64 (void *) rb_pipe
->draw_rule
.surf
, 0,
65 (void *) rb_pipe
->draw_rule
.texture
, 0);
66 if (rb_pipe
->draw_rule
.fs
&&
67 rb_pipe
->draw_rule
.fs
== rb_pipe
->curr
.fs
)
69 if (rb_pipe
->draw_rule
.vs
&&
70 rb_pipe
->draw_rule
.vs
== rb_pipe
->curr
.vs
)
72 if (rb_pipe
->draw_rule
.surf
&&
73 rb_pipe
->draw_rule
.surf
== rb_pipe
->curr
.zsbuf
)
75 if (rb_pipe
->draw_rule
.surf
)
76 for (k
= 0; k
< rb_pipe
->curr
.nr_cbufs
; k
++)
77 if (rb_pipe
->draw_rule
.surf
== rb_pipe
->curr
.cbufs
[k
])
79 if (rb_pipe
->draw_rule
.texture
) {
80 for (k
= 0; k
< rb_pipe
->curr
.num_fs_views
; k
++)
81 if (rb_pipe
->draw_rule
.texture
== rb_pipe
->curr
.fs_texs
[k
])
83 for (k
= 0; k
< rb_pipe
->curr
.num_vs_views
; k
++) {
84 if (rb_pipe
->draw_rule
.texture
== rb_pipe
->curr
.vs_texs
[k
]) {
91 rb_pipe
->draw_blocked
|= (flag
| RBUG_BLOCK_RULE
);
94 if (rb_pipe
->draw_blocked
)
95 rbug_notify_draw_blocked(rb_pipe
);
97 /* wait for rbug to clear the blocked flag */
98 while (rb_pipe
->draw_blocked
& flag
) {
99 rb_pipe
->draw_blocked
|= flag
;
100 #ifdef PIPE_THREAD_HAVE_CONDVAR
101 pipe_condvar_wait(rb_pipe
->draw_cond
, rb_pipe
->draw_mutex
);
103 pipe_mutex_unlock(rb_pipe
->draw_mutex
);
104 #ifdef PIPE_SUBSYSTEM_WINDOWS_USER
107 pipe_mutex_lock(rb_pipe
->draw_mutex
);
114 rbug_draw_arrays(struct pipe_context
*_pipe
,
119 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
120 struct pipe_context
*pipe
= rb_pipe
->pipe
;
122 pipe_mutex_lock(rb_pipe
->draw_mutex
);
123 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_BEFORE
);
125 pipe
->draw_arrays(pipe
,
130 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_AFTER
);
131 pipe_mutex_unlock(rb_pipe
->draw_mutex
);
135 rbug_draw_elements(struct pipe_context
*_pipe
,
136 struct pipe_resource
*_indexResource
,
143 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
144 struct rbug_resource
*rb_resource
= rbug_resource(_indexResource
);
145 struct pipe_context
*pipe
= rb_pipe
->pipe
;
146 struct pipe_resource
*indexResource
= rb_resource
->resource
;
148 pipe_mutex_lock(rb_pipe
->draw_mutex
);
149 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_BEFORE
);
151 pipe
->draw_elements(pipe
,
159 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_AFTER
);
160 pipe_mutex_unlock(rb_pipe
->draw_mutex
);
164 rbug_draw_range_elements(struct pipe_context
*_pipe
,
165 struct pipe_resource
*_indexResource
,
174 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
175 struct rbug_resource
*rb_resource
= rbug_resource(_indexResource
);
176 struct pipe_context
*pipe
= rb_pipe
->pipe
;
177 struct pipe_resource
*indexResource
= rb_resource
->resource
;
179 pipe_mutex_lock(rb_pipe
->draw_mutex
);
180 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_BEFORE
);
182 pipe
->draw_range_elements(pipe
,
192 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_AFTER
);
193 pipe_mutex_unlock(rb_pipe
->draw_mutex
);
196 static struct pipe_query
*
197 rbug_create_query(struct pipe_context
*_pipe
,
200 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
201 struct pipe_context
*pipe
= rb_pipe
->pipe
;
203 return pipe
->create_query(pipe
,
208 rbug_destroy_query(struct pipe_context
*_pipe
,
209 struct pipe_query
*query
)
211 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
212 struct pipe_context
*pipe
= rb_pipe
->pipe
;
214 pipe
->destroy_query(pipe
,
219 rbug_begin_query(struct pipe_context
*_pipe
,
220 struct pipe_query
*query
)
222 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
223 struct pipe_context
*pipe
= rb_pipe
->pipe
;
225 pipe
->begin_query(pipe
,
230 rbug_end_query(struct pipe_context
*_pipe
,
231 struct pipe_query
*query
)
233 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
234 struct pipe_context
*pipe
= rb_pipe
->pipe
;
236 pipe
->end_query(pipe
,
241 rbug_get_query_result(struct pipe_context
*_pipe
,
242 struct pipe_query
*query
,
246 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
247 struct pipe_context
*pipe
= rb_pipe
->pipe
;
249 return pipe
->get_query_result(pipe
,
256 rbug_create_blend_state(struct pipe_context
*_pipe
,
257 const struct pipe_blend_state
*blend
)
259 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
260 struct pipe_context
*pipe
= rb_pipe
->pipe
;
262 return pipe
->create_blend_state(pipe
,
267 rbug_bind_blend_state(struct pipe_context
*_pipe
,
270 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
271 struct pipe_context
*pipe
= rb_pipe
->pipe
;
273 pipe
->bind_blend_state(pipe
,
278 rbug_delete_blend_state(struct pipe_context
*_pipe
,
281 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
282 struct pipe_context
*pipe
= rb_pipe
->pipe
;
284 pipe
->delete_blend_state(pipe
,
289 rbug_create_sampler_state(struct pipe_context
*_pipe
,
290 const struct pipe_sampler_state
*sampler
)
292 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
293 struct pipe_context
*pipe
= rb_pipe
->pipe
;
295 return pipe
->create_sampler_state(pipe
,
300 rbug_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
301 unsigned num_samplers
,
304 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
305 struct pipe_context
*pipe
= rb_pipe
->pipe
;
307 pipe
->bind_fragment_sampler_states(pipe
,
313 rbug_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
314 unsigned num_samplers
,
317 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
318 struct pipe_context
*pipe
= rb_pipe
->pipe
;
320 pipe
->bind_vertex_sampler_states(pipe
,
326 rbug_delete_sampler_state(struct pipe_context
*_pipe
,
329 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
330 struct pipe_context
*pipe
= rb_pipe
->pipe
;
332 pipe
->delete_sampler_state(pipe
,
337 rbug_create_rasterizer_state(struct pipe_context
*_pipe
,
338 const struct pipe_rasterizer_state
*rasterizer
)
340 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
341 struct pipe_context
*pipe
= rb_pipe
->pipe
;
343 return pipe
->create_rasterizer_state(pipe
,
348 rbug_bind_rasterizer_state(struct pipe_context
*_pipe
,
351 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
352 struct pipe_context
*pipe
= rb_pipe
->pipe
;
354 pipe
->bind_rasterizer_state(pipe
,
359 rbug_delete_rasterizer_state(struct pipe_context
*_pipe
,
362 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
363 struct pipe_context
*pipe
= rb_pipe
->pipe
;
365 pipe
->delete_rasterizer_state(pipe
,
370 rbug_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
371 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
373 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
374 struct pipe_context
*pipe
= rb_pipe
->pipe
;
376 return pipe
->create_depth_stencil_alpha_state(pipe
,
377 depth_stencil_alpha
);
381 rbug_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
382 void *depth_stencil_alpha
)
384 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
385 struct pipe_context
*pipe
= rb_pipe
->pipe
;
387 pipe
->bind_depth_stencil_alpha_state(pipe
,
388 depth_stencil_alpha
);
392 rbug_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
393 void *depth_stencil_alpha
)
395 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
396 struct pipe_context
*pipe
= rb_pipe
->pipe
;
398 pipe
->delete_depth_stencil_alpha_state(pipe
,
399 depth_stencil_alpha
);
403 rbug_create_fs_state(struct pipe_context
*_pipe
,
404 const struct pipe_shader_state
*state
)
406 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
407 struct pipe_context
*pipe
= rb_pipe
->pipe
;
410 result
= pipe
->create_fs_state(pipe
, state
);
414 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_FRAGMENT
);
418 rbug_bind_fs_state(struct pipe_context
*_pipe
,
421 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
422 struct pipe_context
*pipe
= rb_pipe
->pipe
;
425 fs
= rbug_shader_unwrap(_fs
);
426 rb_pipe
->curr
.fs
= rbug_shader(_fs
);
427 pipe
->bind_fs_state(pipe
,
432 rbug_delete_fs_state(struct pipe_context
*_pipe
,
435 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
436 struct rbug_shader
*rb_shader
= rbug_shader(_fs
);
438 rbug_shader_destroy(rb_pipe
, rb_shader
);
442 rbug_create_vs_state(struct pipe_context
*_pipe
,
443 const struct pipe_shader_state
*state
)
445 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
446 struct pipe_context
*pipe
= rb_pipe
->pipe
;
449 result
= pipe
->create_vs_state(pipe
, state
);
453 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_VERTEX
);
457 rbug_bind_vs_state(struct pipe_context
*_pipe
,
460 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
461 struct pipe_context
*pipe
= rb_pipe
->pipe
;
464 vs
= rbug_shader_unwrap(_vs
);
465 rb_pipe
->curr
.vs
= rbug_shader(_vs
);
466 pipe
->bind_vs_state(pipe
,
471 rbug_delete_vs_state(struct pipe_context
*_pipe
,
474 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
475 struct rbug_shader
*rb_shader
= rbug_shader(_vs
);
477 rbug_shader_destroy(rb_pipe
, rb_shader
);
481 rbug_create_gs_state(struct pipe_context
*_pipe
,
482 const struct pipe_shader_state
*state
)
484 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
485 struct pipe_context
*pipe
= rb_pipe
->pipe
;
488 result
= pipe
->create_gs_state(pipe
, state
);
492 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_GEOM
);
496 rbug_bind_gs_state(struct pipe_context
*_pipe
,
499 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
500 struct pipe_context
*pipe
= rb_pipe
->pipe
;
503 gs
= rbug_shader_unwrap(_gs
);
504 rb_pipe
->curr
.gs
= rbug_shader(_gs
);
505 pipe
->bind_gs_state(pipe
,
510 rbug_delete_gs_state(struct pipe_context
*_pipe
,
513 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
514 struct rbug_shader
*rb_shader
= rbug_shader(_gs
);
516 rbug_shader_destroy(rb_pipe
, rb_shader
);
520 rbug_create_vertex_elements_state(struct pipe_context
*_pipe
,
521 unsigned num_elements
,
522 const struct pipe_vertex_element
*vertex_elements
)
524 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
525 struct pipe_context
*pipe
= rb_pipe
->pipe
;
527 return pipe
->create_vertex_elements_state(pipe
,
533 rbug_bind_vertex_elements_state(struct pipe_context
*_pipe
,
536 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
537 struct pipe_context
*pipe
= rb_pipe
->pipe
;
539 pipe
->bind_vertex_elements_state(pipe
,
544 rbug_delete_vertex_elements_state(struct pipe_context
*_pipe
,
547 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
548 struct pipe_context
*pipe
= rb_pipe
->pipe
;
550 pipe
->delete_vertex_elements_state(pipe
,
555 rbug_set_blend_color(struct pipe_context
*_pipe
,
556 const struct pipe_blend_color
*blend_color
)
558 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
559 struct pipe_context
*pipe
= rb_pipe
->pipe
;
561 pipe
->set_blend_color(pipe
,
566 rbug_set_stencil_ref(struct pipe_context
*_pipe
,
567 const struct pipe_stencil_ref
*stencil_ref
)
569 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
570 struct pipe_context
*pipe
= rb_pipe
->pipe
;
572 pipe
->set_stencil_ref(pipe
,
577 rbug_set_clip_state(struct pipe_context
*_pipe
,
578 const struct pipe_clip_state
*clip
)
580 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
581 struct pipe_context
*pipe
= rb_pipe
->pipe
;
583 pipe
->set_clip_state(pipe
,
588 rbug_set_constant_buffer(struct pipe_context
*_pipe
,
591 struct pipe_resource
*_resource
)
593 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
594 struct pipe_context
*pipe
= rb_pipe
->pipe
;
595 struct pipe_resource
*unwrapped_resource
;
596 struct pipe_resource
*resource
= NULL
;
598 /* XXX hmm? unwrap the input state */
600 unwrapped_resource
= rbug_resource_unwrap(_resource
);
601 resource
= unwrapped_resource
;
604 pipe
->set_constant_buffer(pipe
,
611 rbug_set_framebuffer_state(struct pipe_context
*_pipe
,
612 const struct pipe_framebuffer_state
*_state
)
614 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
615 struct pipe_context
*pipe
= rb_pipe
->pipe
;
616 struct pipe_framebuffer_state unwrapped_state
;
617 struct pipe_framebuffer_state
*state
= NULL
;
620 rb_pipe
->curr
.nr_cbufs
= 0;
621 memset(rb_pipe
->curr
.cbufs
, 0, sizeof(rb_pipe
->curr
.cbufs
));
623 /* unwrap the input state */
625 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
627 rb_pipe
->curr
.nr_cbufs
= _state
->nr_cbufs
;
628 for(i
= 0; i
< _state
->nr_cbufs
; i
++) {
629 unwrapped_state
.cbufs
[i
] = rbug_surface_unwrap(_state
->cbufs
[i
]);
630 if (_state
->cbufs
[i
])
631 rb_pipe
->curr
.cbufs
[i
] = rbug_resource(_state
->cbufs
[i
]->texture
);
633 unwrapped_state
.zsbuf
= rbug_surface_unwrap(_state
->zsbuf
);
634 state
= &unwrapped_state
;
637 pipe
->set_framebuffer_state(pipe
,
642 rbug_set_polygon_stipple(struct pipe_context
*_pipe
,
643 const struct pipe_poly_stipple
*poly_stipple
)
645 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
646 struct pipe_context
*pipe
= rb_pipe
->pipe
;
648 pipe
->set_polygon_stipple(pipe
,
653 rbug_set_scissor_state(struct pipe_context
*_pipe
,
654 const struct pipe_scissor_state
*scissor
)
656 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
657 struct pipe_context
*pipe
= rb_pipe
->pipe
;
659 pipe
->set_scissor_state(pipe
,
664 rbug_set_viewport_state(struct pipe_context
*_pipe
,
665 const struct pipe_viewport_state
*viewport
)
667 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
668 struct pipe_context
*pipe
= rb_pipe
->pipe
;
670 pipe
->set_viewport_state(pipe
,
675 rbug_set_fragment_sampler_views(struct pipe_context
*_pipe
,
677 struct pipe_sampler_view
**_views
)
679 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
680 struct pipe_context
*pipe
= rb_pipe
->pipe
;
681 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
682 struct pipe_sampler_view
**views
= NULL
;
685 rb_pipe
->curr
.num_fs_views
= 0;
686 memset(rb_pipe
->curr
.fs_views
, 0, sizeof(rb_pipe
->curr
.fs_views
));
687 memset(rb_pipe
->curr
.fs_texs
, 0, sizeof(rb_pipe
->curr
.fs_texs
));
688 memset(unwrapped_views
, 0, sizeof(unwrapped_views
));
691 rb_pipe
->curr
.num_fs_views
= num
;
692 for (i
= 0; i
< num
; i
++) {
693 rb_pipe
->curr
.fs_views
[i
] = rbug_sampler_view(_views
[i
]);
694 rb_pipe
->curr
.fs_texs
[i
] = rbug_resource(_views
[i
] ? _views
[i
]->texture
: NULL
);
695 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
697 views
= unwrapped_views
;
700 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
704 rbug_set_vertex_sampler_views(struct pipe_context
*_pipe
,
706 struct pipe_sampler_view
**_views
)
708 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
709 struct pipe_context
*pipe
= rb_pipe
->pipe
;
710 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
711 struct pipe_sampler_view
**views
= NULL
;
714 rb_pipe
->curr
.num_vs_views
= 0;
715 memset(rb_pipe
->curr
.vs_views
, 0, sizeof(rb_pipe
->curr
.vs_views
));
716 memset(rb_pipe
->curr
.vs_texs
, 0, sizeof(rb_pipe
->curr
.vs_texs
));
717 memset(unwrapped_views
, 0, sizeof(unwrapped_views
));
720 rb_pipe
->curr
.num_vs_views
= num
;
721 for (i
= 0; i
< num
; i
++) {
722 rb_pipe
->curr
.vs_views
[i
] = rbug_sampler_view(_views
[i
]);
723 rb_pipe
->curr
.vs_texs
[i
] = rbug_resource(_views
[i
]->texture
);
724 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
726 views
= unwrapped_views
;
729 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
733 rbug_set_vertex_buffers(struct pipe_context
*_pipe
,
734 unsigned num_buffers
,
735 const struct pipe_vertex_buffer
*_buffers
)
737 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
738 struct pipe_context
*pipe
= rb_pipe
->pipe
;
739 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
740 struct pipe_vertex_buffer
*buffers
= NULL
;
744 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
745 for (i
= 0; i
< num_buffers
; i
++)
746 unwrapped_buffers
[i
].buffer
= rbug_resource_unwrap(_buffers
[i
].buffer
);
747 buffers
= unwrapped_buffers
;
750 pipe
->set_vertex_buffers(pipe
,
755 rbug_surface_copy(struct pipe_context
*_pipe
,
756 struct pipe_surface
*_dst
,
759 struct pipe_surface
*_src
,
765 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
766 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
767 struct rbug_surface
*rb_surface_src
= rbug_surface(_src
);
768 struct pipe_context
*pipe
= rb_pipe
->pipe
;
769 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
770 struct pipe_surface
*src
= rb_surface_src
->surface
;
772 pipe
->surface_copy(pipe
,
784 rbug_surface_fill(struct pipe_context
*_pipe
,
785 struct pipe_surface
*_dst
,
792 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
793 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
794 struct pipe_context
*pipe
= rb_pipe
->pipe
;
795 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
797 pipe
->surface_fill(pipe
,
807 rbug_clear(struct pipe_context
*_pipe
,
813 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
814 struct pipe_context
*pipe
= rb_pipe
->pipe
;
824 rbug_flush(struct pipe_context
*_pipe
,
826 struct pipe_fence_handle
**fence
)
828 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
829 struct pipe_context
*pipe
= rb_pipe
->pipe
;
837 rbug_is_resource_referenced(struct pipe_context
*_pipe
,
838 struct pipe_resource
*_resource
,
842 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
843 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
844 struct pipe_context
*pipe
= rb_pipe
->pipe
;
845 struct pipe_resource
*resource
= rb_resource
->resource
;
847 return pipe
->is_resource_referenced(pipe
,
853 static struct pipe_sampler_view
*
854 rbug_context_create_sampler_view(struct pipe_context
*_pipe
,
855 struct pipe_resource
*_resource
,
856 const struct pipe_sampler_view
*templ
)
858 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
859 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
860 struct pipe_context
*pipe
= rb_pipe
->pipe
;
861 struct pipe_resource
*resource
= rb_resource
->resource
;
862 struct pipe_sampler_view
*result
;
864 result
= pipe
->create_sampler_view(pipe
,
869 return rbug_sampler_view_create(rb_pipe
, rb_resource
, result
);
874 rbug_context_sampler_view_destroy(struct pipe_context
*_pipe
,
875 struct pipe_sampler_view
*_view
)
877 rbug_sampler_view_destroy(rbug_context(_pipe
),
878 rbug_sampler_view(_view
));
881 static struct pipe_transfer
*
882 rbug_context_get_transfer(struct pipe_context
*_context
,
883 struct pipe_resource
*_resource
,
884 struct pipe_subresource sr
,
886 const struct pipe_box
*box
)
888 struct rbug_context
*rb_pipe
= rbug_context(_context
);
889 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
890 struct pipe_context
*context
= rb_pipe
->pipe
;
891 struct pipe_resource
*resource
= rb_resource
->resource
;
892 struct pipe_transfer
*result
;
894 result
= context
->get_transfer(context
,
901 return rbug_transfer_create(rb_pipe
, rb_resource
, result
);
906 rbug_context_transfer_destroy(struct pipe_context
*_pipe
,
907 struct pipe_transfer
*_transfer
)
909 rbug_transfer_destroy(rbug_context(_pipe
),
910 rbug_transfer(_transfer
));
914 rbug_context_transfer_map(struct pipe_context
*_context
,
915 struct pipe_transfer
*_transfer
)
917 struct rbug_context
*rb_pipe
= rbug_context(_context
);
918 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
919 struct pipe_context
*context
= rb_pipe
->pipe
;
920 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
922 return context
->transfer_map(context
,
929 rbug_context_transfer_flush_region(struct pipe_context
*_context
,
930 struct pipe_transfer
*_transfer
,
931 const struct pipe_box
*box
)
933 struct rbug_context
*rb_pipe
= rbug_context(_context
);
934 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
935 struct pipe_context
*context
= rb_pipe
->pipe
;
936 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
938 context
->transfer_flush_region(context
,
945 rbug_context_transfer_unmap(struct pipe_context
*_context
,
946 struct pipe_transfer
*_transfer
)
948 struct rbug_context
*rb_pipe
= rbug_context(_context
);
949 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
950 struct pipe_context
*context
= rb_pipe
->pipe
;
951 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
953 context
->transfer_unmap(context
,
959 rbug_context_transfer_inline_write(struct pipe_context
*_context
,
960 struct pipe_resource
*_resource
,
961 struct pipe_subresource sr
,
963 const struct pipe_box
*box
,
966 unsigned slice_stride
)
968 struct rbug_context
*rb_pipe
= rbug_context(_context
);
969 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
970 struct pipe_context
*context
= rb_pipe
->pipe
;
971 struct pipe_resource
*resource
= rb_resource
->resource
;
973 context
->transfer_inline_write(context
,
984 struct pipe_context
*
985 rbug_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
987 struct rbug_context
*rb_pipe
;
988 struct rbug_screen
*rb_screen
= rbug_screen(_screen
);
993 rb_pipe
= CALLOC_STRUCT(rbug_context
);
997 pipe_mutex_init(rb_pipe
->draw_mutex
);
998 pipe_condvar_init(rb_pipe
->draw_cond
);
999 pipe_mutex_init(rb_pipe
->call_mutex
);
1000 pipe_mutex_init(rb_pipe
->list_mutex
);
1001 make_empty_list(&rb_pipe
->shaders
);
1003 rb_pipe
->base
.winsys
= NULL
;
1004 rb_pipe
->base
.screen
= _screen
;
1005 rb_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
1006 rb_pipe
->base
.draw
= NULL
;
1008 rb_pipe
->base
.destroy
= rbug_destroy
;
1009 rb_pipe
->base
.draw_arrays
= rbug_draw_arrays
;
1010 rb_pipe
->base
.draw_elements
= rbug_draw_elements
;
1011 rb_pipe
->base
.draw_range_elements
= rbug_draw_range_elements
;
1012 rb_pipe
->base
.create_query
= rbug_create_query
;
1013 rb_pipe
->base
.destroy_query
= rbug_destroy_query
;
1014 rb_pipe
->base
.begin_query
= rbug_begin_query
;
1015 rb_pipe
->base
.end_query
= rbug_end_query
;
1016 rb_pipe
->base
.get_query_result
= rbug_get_query_result
;
1017 rb_pipe
->base
.create_blend_state
= rbug_create_blend_state
;
1018 rb_pipe
->base
.bind_blend_state
= rbug_bind_blend_state
;
1019 rb_pipe
->base
.delete_blend_state
= rbug_delete_blend_state
;
1020 rb_pipe
->base
.create_sampler_state
= rbug_create_sampler_state
;
1021 rb_pipe
->base
.bind_fragment_sampler_states
= rbug_bind_fragment_sampler_states
;
1022 rb_pipe
->base
.bind_vertex_sampler_states
= rbug_bind_vertex_sampler_states
;
1023 rb_pipe
->base
.delete_sampler_state
= rbug_delete_sampler_state
;
1024 rb_pipe
->base
.create_rasterizer_state
= rbug_create_rasterizer_state
;
1025 rb_pipe
->base
.bind_rasterizer_state
= rbug_bind_rasterizer_state
;
1026 rb_pipe
->base
.delete_rasterizer_state
= rbug_delete_rasterizer_state
;
1027 rb_pipe
->base
.create_depth_stencil_alpha_state
= rbug_create_depth_stencil_alpha_state
;
1028 rb_pipe
->base
.bind_depth_stencil_alpha_state
= rbug_bind_depth_stencil_alpha_state
;
1029 rb_pipe
->base
.delete_depth_stencil_alpha_state
= rbug_delete_depth_stencil_alpha_state
;
1030 rb_pipe
->base
.create_fs_state
= rbug_create_fs_state
;
1031 rb_pipe
->base
.bind_fs_state
= rbug_bind_fs_state
;
1032 rb_pipe
->base
.delete_fs_state
= rbug_delete_fs_state
;
1033 rb_pipe
->base
.create_vs_state
= rbug_create_vs_state
;
1034 rb_pipe
->base
.bind_vs_state
= rbug_bind_vs_state
;
1035 rb_pipe
->base
.delete_vs_state
= rbug_delete_vs_state
;
1036 rb_pipe
->base
.create_gs_state
= rbug_create_gs_state
;
1037 rb_pipe
->base
.bind_gs_state
= rbug_bind_gs_state
;
1038 rb_pipe
->base
.delete_gs_state
= rbug_delete_gs_state
;
1039 rb_pipe
->base
.create_vertex_elements_state
= rbug_create_vertex_elements_state
;
1040 rb_pipe
->base
.bind_vertex_elements_state
= rbug_bind_vertex_elements_state
;
1041 rb_pipe
->base
.delete_vertex_elements_state
= rbug_delete_vertex_elements_state
;
1042 rb_pipe
->base
.set_blend_color
= rbug_set_blend_color
;
1043 rb_pipe
->base
.set_stencil_ref
= rbug_set_stencil_ref
;
1044 rb_pipe
->base
.set_clip_state
= rbug_set_clip_state
;
1045 rb_pipe
->base
.set_constant_buffer
= rbug_set_constant_buffer
;
1046 rb_pipe
->base
.set_framebuffer_state
= rbug_set_framebuffer_state
;
1047 rb_pipe
->base
.set_polygon_stipple
= rbug_set_polygon_stipple
;
1048 rb_pipe
->base
.set_scissor_state
= rbug_set_scissor_state
;
1049 rb_pipe
->base
.set_viewport_state
= rbug_set_viewport_state
;
1050 rb_pipe
->base
.set_fragment_sampler_views
= rbug_set_fragment_sampler_views
;
1051 rb_pipe
->base
.set_vertex_sampler_views
= rbug_set_vertex_sampler_views
;
1052 rb_pipe
->base
.set_vertex_buffers
= rbug_set_vertex_buffers
;
1053 rb_pipe
->base
.surface_copy
= rbug_surface_copy
;
1054 rb_pipe
->base
.surface_fill
= rbug_surface_fill
;
1055 rb_pipe
->base
.clear
= rbug_clear
;
1056 rb_pipe
->base
.flush
= rbug_flush
;
1057 rb_pipe
->base
.is_resource_referenced
= rbug_is_resource_referenced
;
1058 rb_pipe
->base
.create_sampler_view
= rbug_context_create_sampler_view
;
1059 rb_pipe
->base
.sampler_view_destroy
= rbug_context_sampler_view_destroy
;
1060 rb_pipe
->base
.get_transfer
= rbug_context_get_transfer
;
1061 rb_pipe
->base
.transfer_destroy
= rbug_context_transfer_destroy
;
1062 rb_pipe
->base
.transfer_map
= rbug_context_transfer_map
;
1063 rb_pipe
->base
.transfer_unmap
= rbug_context_transfer_unmap
;
1064 rb_pipe
->base
.transfer_flush_region
= rbug_context_transfer_flush_region
;
1065 rb_pipe
->base
.transfer_inline_write
= rbug_context_transfer_inline_write
;
1067 rb_pipe
->pipe
= pipe
;
1069 rbug_screen_add_to_list(rb_screen
, contexts
, rb_pipe
);
1071 return &rb_pipe
->base
;