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 pipe_condvar_wait(rb_pipe
->draw_cond
, rb_pipe
->draw_mutex
);
106 rbug_draw_vbo(struct pipe_context
*_pipe
, const struct pipe_draw_info
*info
)
108 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
109 struct pipe_context
*pipe
= rb_pipe
->pipe
;
111 pipe_mutex_lock(rb_pipe
->draw_mutex
);
112 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_BEFORE
);
114 pipe
->draw_vbo(pipe
, info
);
116 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_AFTER
);
117 pipe_mutex_unlock(rb_pipe
->draw_mutex
);
120 static struct pipe_query
*
121 rbug_create_query(struct pipe_context
*_pipe
,
124 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
125 struct pipe_context
*pipe
= rb_pipe
->pipe
;
127 return pipe
->create_query(pipe
,
132 rbug_destroy_query(struct pipe_context
*_pipe
,
133 struct pipe_query
*query
)
135 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
136 struct pipe_context
*pipe
= rb_pipe
->pipe
;
138 pipe
->destroy_query(pipe
,
143 rbug_begin_query(struct pipe_context
*_pipe
,
144 struct pipe_query
*query
)
146 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
147 struct pipe_context
*pipe
= rb_pipe
->pipe
;
149 pipe
->begin_query(pipe
,
154 rbug_end_query(struct pipe_context
*_pipe
,
155 struct pipe_query
*query
)
157 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
158 struct pipe_context
*pipe
= rb_pipe
->pipe
;
160 pipe
->end_query(pipe
,
165 rbug_get_query_result(struct pipe_context
*_pipe
,
166 struct pipe_query
*query
,
170 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
171 struct pipe_context
*pipe
= rb_pipe
->pipe
;
173 return pipe
->get_query_result(pipe
,
180 rbug_create_blend_state(struct pipe_context
*_pipe
,
181 const struct pipe_blend_state
*blend
)
183 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
184 struct pipe_context
*pipe
= rb_pipe
->pipe
;
186 return pipe
->create_blend_state(pipe
,
191 rbug_bind_blend_state(struct pipe_context
*_pipe
,
194 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
195 struct pipe_context
*pipe
= rb_pipe
->pipe
;
197 pipe
->bind_blend_state(pipe
,
202 rbug_delete_blend_state(struct pipe_context
*_pipe
,
205 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
206 struct pipe_context
*pipe
= rb_pipe
->pipe
;
208 pipe
->delete_blend_state(pipe
,
213 rbug_create_sampler_state(struct pipe_context
*_pipe
,
214 const struct pipe_sampler_state
*sampler
)
216 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
217 struct pipe_context
*pipe
= rb_pipe
->pipe
;
219 return pipe
->create_sampler_state(pipe
,
224 rbug_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
225 unsigned num_samplers
,
228 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
229 struct pipe_context
*pipe
= rb_pipe
->pipe
;
231 pipe
->bind_fragment_sampler_states(pipe
,
237 rbug_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
238 unsigned num_samplers
,
241 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
242 struct pipe_context
*pipe
= rb_pipe
->pipe
;
244 pipe
->bind_vertex_sampler_states(pipe
,
250 rbug_delete_sampler_state(struct pipe_context
*_pipe
,
253 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
254 struct pipe_context
*pipe
= rb_pipe
->pipe
;
256 pipe
->delete_sampler_state(pipe
,
261 rbug_create_rasterizer_state(struct pipe_context
*_pipe
,
262 const struct pipe_rasterizer_state
*rasterizer
)
264 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
265 struct pipe_context
*pipe
= rb_pipe
->pipe
;
267 return pipe
->create_rasterizer_state(pipe
,
272 rbug_bind_rasterizer_state(struct pipe_context
*_pipe
,
275 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
276 struct pipe_context
*pipe
= rb_pipe
->pipe
;
278 pipe
->bind_rasterizer_state(pipe
,
283 rbug_delete_rasterizer_state(struct pipe_context
*_pipe
,
286 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
287 struct pipe_context
*pipe
= rb_pipe
->pipe
;
289 pipe
->delete_rasterizer_state(pipe
,
294 rbug_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
295 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
297 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
298 struct pipe_context
*pipe
= rb_pipe
->pipe
;
300 return pipe
->create_depth_stencil_alpha_state(pipe
,
301 depth_stencil_alpha
);
305 rbug_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
306 void *depth_stencil_alpha
)
308 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
309 struct pipe_context
*pipe
= rb_pipe
->pipe
;
311 pipe
->bind_depth_stencil_alpha_state(pipe
,
312 depth_stencil_alpha
);
316 rbug_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
317 void *depth_stencil_alpha
)
319 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
320 struct pipe_context
*pipe
= rb_pipe
->pipe
;
322 pipe
->delete_depth_stencil_alpha_state(pipe
,
323 depth_stencil_alpha
);
327 rbug_create_fs_state(struct pipe_context
*_pipe
,
328 const struct pipe_shader_state
*state
)
330 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
331 struct pipe_context
*pipe
= rb_pipe
->pipe
;
334 result
= pipe
->create_fs_state(pipe
, state
);
338 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_FRAGMENT
);
342 rbug_bind_fs_state(struct pipe_context
*_pipe
,
345 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
346 struct pipe_context
*pipe
= rb_pipe
->pipe
;
349 fs
= rbug_shader_unwrap(_fs
);
350 rb_pipe
->curr
.fs
= rbug_shader(_fs
);
351 pipe
->bind_fs_state(pipe
,
356 rbug_delete_fs_state(struct pipe_context
*_pipe
,
359 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
360 struct rbug_shader
*rb_shader
= rbug_shader(_fs
);
362 rbug_shader_destroy(rb_pipe
, rb_shader
);
366 rbug_create_vs_state(struct pipe_context
*_pipe
,
367 const struct pipe_shader_state
*state
)
369 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
370 struct pipe_context
*pipe
= rb_pipe
->pipe
;
373 result
= pipe
->create_vs_state(pipe
, state
);
377 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_VERTEX
);
381 rbug_bind_vs_state(struct pipe_context
*_pipe
,
384 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
385 struct pipe_context
*pipe
= rb_pipe
->pipe
;
388 vs
= rbug_shader_unwrap(_vs
);
389 rb_pipe
->curr
.vs
= rbug_shader(_vs
);
390 pipe
->bind_vs_state(pipe
,
395 rbug_delete_vs_state(struct pipe_context
*_pipe
,
398 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
399 struct rbug_shader
*rb_shader
= rbug_shader(_vs
);
401 rbug_shader_destroy(rb_pipe
, rb_shader
);
405 rbug_create_gs_state(struct pipe_context
*_pipe
,
406 const struct pipe_shader_state
*state
)
408 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
409 struct pipe_context
*pipe
= rb_pipe
->pipe
;
412 result
= pipe
->create_gs_state(pipe
, state
);
416 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_GEOM
);
420 rbug_bind_gs_state(struct pipe_context
*_pipe
,
423 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
424 struct pipe_context
*pipe
= rb_pipe
->pipe
;
427 gs
= rbug_shader_unwrap(_gs
);
428 rb_pipe
->curr
.gs
= rbug_shader(_gs
);
429 pipe
->bind_gs_state(pipe
,
434 rbug_delete_gs_state(struct pipe_context
*_pipe
,
437 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
438 struct rbug_shader
*rb_shader
= rbug_shader(_gs
);
440 rbug_shader_destroy(rb_pipe
, rb_shader
);
444 rbug_create_vertex_elements_state(struct pipe_context
*_pipe
,
445 unsigned num_elements
,
446 const struct pipe_vertex_element
*vertex_elements
)
448 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
449 struct pipe_context
*pipe
= rb_pipe
->pipe
;
451 return pipe
->create_vertex_elements_state(pipe
,
457 rbug_bind_vertex_elements_state(struct pipe_context
*_pipe
,
460 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
461 struct pipe_context
*pipe
= rb_pipe
->pipe
;
463 pipe
->bind_vertex_elements_state(pipe
,
468 rbug_delete_vertex_elements_state(struct pipe_context
*_pipe
,
471 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
472 struct pipe_context
*pipe
= rb_pipe
->pipe
;
474 pipe
->delete_vertex_elements_state(pipe
,
479 rbug_set_blend_color(struct pipe_context
*_pipe
,
480 const struct pipe_blend_color
*blend_color
)
482 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
483 struct pipe_context
*pipe
= rb_pipe
->pipe
;
485 pipe
->set_blend_color(pipe
,
490 rbug_set_stencil_ref(struct pipe_context
*_pipe
,
491 const struct pipe_stencil_ref
*stencil_ref
)
493 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
494 struct pipe_context
*pipe
= rb_pipe
->pipe
;
496 pipe
->set_stencil_ref(pipe
,
501 rbug_set_clip_state(struct pipe_context
*_pipe
,
502 const struct pipe_clip_state
*clip
)
504 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
505 struct pipe_context
*pipe
= rb_pipe
->pipe
;
507 pipe
->set_clip_state(pipe
,
512 rbug_set_constant_buffer(struct pipe_context
*_pipe
,
515 struct pipe_resource
*_resource
)
517 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
518 struct pipe_context
*pipe
= rb_pipe
->pipe
;
519 struct pipe_resource
*unwrapped_resource
;
520 struct pipe_resource
*resource
= NULL
;
522 /* XXX hmm? unwrap the input state */
524 unwrapped_resource
= rbug_resource_unwrap(_resource
);
525 resource
= unwrapped_resource
;
528 pipe
->set_constant_buffer(pipe
,
535 rbug_set_framebuffer_state(struct pipe_context
*_pipe
,
536 const struct pipe_framebuffer_state
*_state
)
538 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
539 struct pipe_context
*pipe
= rb_pipe
->pipe
;
540 struct pipe_framebuffer_state unwrapped_state
;
541 struct pipe_framebuffer_state
*state
= NULL
;
544 rb_pipe
->curr
.nr_cbufs
= 0;
545 memset(rb_pipe
->curr
.cbufs
, 0, sizeof(rb_pipe
->curr
.cbufs
));
547 /* unwrap the input state */
549 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
551 rb_pipe
->curr
.nr_cbufs
= _state
->nr_cbufs
;
552 for(i
= 0; i
< _state
->nr_cbufs
; i
++) {
553 unwrapped_state
.cbufs
[i
] = rbug_surface_unwrap(_state
->cbufs
[i
]);
554 if (_state
->cbufs
[i
])
555 rb_pipe
->curr
.cbufs
[i
] = rbug_resource(_state
->cbufs
[i
]->texture
);
557 unwrapped_state
.zsbuf
= rbug_surface_unwrap(_state
->zsbuf
);
558 state
= &unwrapped_state
;
561 pipe
->set_framebuffer_state(pipe
,
566 rbug_set_polygon_stipple(struct pipe_context
*_pipe
,
567 const struct pipe_poly_stipple
*poly_stipple
)
569 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
570 struct pipe_context
*pipe
= rb_pipe
->pipe
;
572 pipe
->set_polygon_stipple(pipe
,
577 rbug_set_scissor_state(struct pipe_context
*_pipe
,
578 const struct pipe_scissor_state
*scissor
)
580 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
581 struct pipe_context
*pipe
= rb_pipe
->pipe
;
583 pipe
->set_scissor_state(pipe
,
588 rbug_set_viewport_state(struct pipe_context
*_pipe
,
589 const struct pipe_viewport_state
*viewport
)
591 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
592 struct pipe_context
*pipe
= rb_pipe
->pipe
;
594 pipe
->set_viewport_state(pipe
,
599 rbug_set_fragment_sampler_views(struct pipe_context
*_pipe
,
601 struct pipe_sampler_view
**_views
)
603 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
604 struct pipe_context
*pipe
= rb_pipe
->pipe
;
605 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
606 struct pipe_sampler_view
**views
= NULL
;
609 rb_pipe
->curr
.num_fs_views
= 0;
610 memset(rb_pipe
->curr
.fs_views
, 0, sizeof(rb_pipe
->curr
.fs_views
));
611 memset(rb_pipe
->curr
.fs_texs
, 0, sizeof(rb_pipe
->curr
.fs_texs
));
612 memset(unwrapped_views
, 0, sizeof(unwrapped_views
));
615 rb_pipe
->curr
.num_fs_views
= num
;
616 for (i
= 0; i
< num
; i
++) {
617 rb_pipe
->curr
.fs_views
[i
] = rbug_sampler_view(_views
[i
]);
618 rb_pipe
->curr
.fs_texs
[i
] = rbug_resource(_views
[i
] ? _views
[i
]->texture
: NULL
);
619 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
621 views
= unwrapped_views
;
624 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
628 rbug_set_vertex_sampler_views(struct pipe_context
*_pipe
,
630 struct pipe_sampler_view
**_views
)
632 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
633 struct pipe_context
*pipe
= rb_pipe
->pipe
;
634 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
635 struct pipe_sampler_view
**views
= NULL
;
638 rb_pipe
->curr
.num_vs_views
= 0;
639 memset(rb_pipe
->curr
.vs_views
, 0, sizeof(rb_pipe
->curr
.vs_views
));
640 memset(rb_pipe
->curr
.vs_texs
, 0, sizeof(rb_pipe
->curr
.vs_texs
));
641 memset(unwrapped_views
, 0, sizeof(unwrapped_views
));
644 rb_pipe
->curr
.num_vs_views
= num
;
645 for (i
= 0; i
< num
; i
++) {
646 rb_pipe
->curr
.vs_views
[i
] = rbug_sampler_view(_views
[i
]);
647 rb_pipe
->curr
.vs_texs
[i
] = rbug_resource(_views
[i
]->texture
);
648 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
650 views
= unwrapped_views
;
653 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
657 rbug_set_vertex_buffers(struct pipe_context
*_pipe
,
658 unsigned num_buffers
,
659 const struct pipe_vertex_buffer
*_buffers
)
661 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
662 struct pipe_context
*pipe
= rb_pipe
->pipe
;
663 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
664 struct pipe_vertex_buffer
*buffers
= NULL
;
668 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
669 for (i
= 0; i
< num_buffers
; i
++)
670 unwrapped_buffers
[i
].buffer
= rbug_resource_unwrap(_buffers
[i
].buffer
);
671 buffers
= unwrapped_buffers
;
674 pipe
->set_vertex_buffers(pipe
,
680 rbug_set_index_buffer(struct pipe_context
*_pipe
,
681 const struct pipe_index_buffer
*_ib
)
683 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
684 struct pipe_context
*pipe
= rb_pipe
->pipe
;
685 struct pipe_index_buffer unwrapped_ib
, *ib
= NULL
;
689 unwrapped_ib
.buffer
= rbug_resource_unwrap(_ib
->buffer
);
693 pipe
->set_index_buffer(pipe
, ib
);
697 rbug_set_sample_mask(struct pipe_context
*_pipe
,
698 unsigned sample_mask
)
700 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
701 struct pipe_context
*pipe
= rb_pipe
->pipe
;
703 pipe
->set_sample_mask(pipe
, sample_mask
);
707 rbug_resource_copy_region(struct pipe_context
*_pipe
,
708 struct pipe_resource
*_dst
,
709 struct pipe_subresource subdst
,
713 struct pipe_resource
*_src
,
714 struct pipe_subresource subsrc
,
721 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
722 struct rbug_resource
*rb_resource_dst
= rbug_resource(_dst
);
723 struct rbug_resource
*rb_resource_src
= rbug_resource(_src
);
724 struct pipe_context
*pipe
= rb_pipe
->pipe
;
725 struct pipe_resource
*dst
= rb_resource_dst
->resource
;
726 struct pipe_resource
*src
= rb_resource_src
->resource
;
728 pipe
->resource_copy_region(pipe
,
744 rbug_clear(struct pipe_context
*_pipe
,
750 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
751 struct pipe_context
*pipe
= rb_pipe
->pipe
;
761 rbug_clear_render_target(struct pipe_context
*_pipe
,
762 struct pipe_surface
*_dst
,
764 unsigned dstx
, unsigned dsty
,
765 unsigned width
, unsigned height
)
767 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
768 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
769 struct pipe_context
*pipe
= rb_pipe
->pipe
;
770 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
772 pipe
->clear_render_target(pipe
,
782 rbug_clear_depth_stencil(struct pipe_context
*_pipe
,
783 struct pipe_surface
*_dst
,
784 unsigned clear_flags
,
787 unsigned dstx
, unsigned dsty
,
788 unsigned width
, unsigned height
)
790 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
791 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
792 struct pipe_context
*pipe
= rb_pipe
->pipe
;
793 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
795 pipe
->clear_depth_stencil(pipe
,
807 rbug_flush(struct pipe_context
*_pipe
,
809 struct pipe_fence_handle
**fence
)
811 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
812 struct pipe_context
*pipe
= rb_pipe
->pipe
;
820 rbug_is_resource_referenced(struct pipe_context
*_pipe
,
821 struct pipe_resource
*_resource
,
825 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
826 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
827 struct pipe_context
*pipe
= rb_pipe
->pipe
;
828 struct pipe_resource
*resource
= rb_resource
->resource
;
830 return pipe
->is_resource_referenced(pipe
,
836 static struct pipe_sampler_view
*
837 rbug_context_create_sampler_view(struct pipe_context
*_pipe
,
838 struct pipe_resource
*_resource
,
839 const struct pipe_sampler_view
*templ
)
841 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
842 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
843 struct pipe_context
*pipe
= rb_pipe
->pipe
;
844 struct pipe_resource
*resource
= rb_resource
->resource
;
845 struct pipe_sampler_view
*result
;
847 result
= pipe
->create_sampler_view(pipe
,
852 return rbug_sampler_view_create(rb_pipe
, rb_resource
, result
);
857 rbug_context_sampler_view_destroy(struct pipe_context
*_pipe
,
858 struct pipe_sampler_view
*_view
)
860 rbug_sampler_view_destroy(rbug_context(_pipe
),
861 rbug_sampler_view(_view
));
864 static struct pipe_transfer
*
865 rbug_context_get_transfer(struct pipe_context
*_context
,
866 struct pipe_resource
*_resource
,
867 struct pipe_subresource sr
,
869 const struct pipe_box
*box
)
871 struct rbug_context
*rb_pipe
= rbug_context(_context
);
872 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
873 struct pipe_context
*context
= rb_pipe
->pipe
;
874 struct pipe_resource
*resource
= rb_resource
->resource
;
875 struct pipe_transfer
*result
;
877 result
= context
->get_transfer(context
,
884 return rbug_transfer_create(rb_pipe
, rb_resource
, result
);
889 rbug_context_transfer_destroy(struct pipe_context
*_pipe
,
890 struct pipe_transfer
*_transfer
)
892 rbug_transfer_destroy(rbug_context(_pipe
),
893 rbug_transfer(_transfer
));
897 rbug_context_transfer_map(struct pipe_context
*_context
,
898 struct pipe_transfer
*_transfer
)
900 struct rbug_context
*rb_pipe
= rbug_context(_context
);
901 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
902 struct pipe_context
*context
= rb_pipe
->pipe
;
903 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
905 return context
->transfer_map(context
,
912 rbug_context_transfer_flush_region(struct pipe_context
*_context
,
913 struct pipe_transfer
*_transfer
,
914 const struct pipe_box
*box
)
916 struct rbug_context
*rb_pipe
= rbug_context(_context
);
917 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
918 struct pipe_context
*context
= rb_pipe
->pipe
;
919 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
921 context
->transfer_flush_region(context
,
928 rbug_context_transfer_unmap(struct pipe_context
*_context
,
929 struct pipe_transfer
*_transfer
)
931 struct rbug_context
*rb_pipe
= rbug_context(_context
);
932 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
933 struct pipe_context
*context
= rb_pipe
->pipe
;
934 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
936 context
->transfer_unmap(context
,
942 rbug_context_transfer_inline_write(struct pipe_context
*_context
,
943 struct pipe_resource
*_resource
,
944 struct pipe_subresource sr
,
946 const struct pipe_box
*box
,
949 unsigned slice_stride
)
951 struct rbug_context
*rb_pipe
= rbug_context(_context
);
952 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
953 struct pipe_context
*context
= rb_pipe
->pipe
;
954 struct pipe_resource
*resource
= rb_resource
->resource
;
956 context
->transfer_inline_write(context
,
967 struct pipe_context
*
968 rbug_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
970 struct rbug_context
*rb_pipe
;
971 struct rbug_screen
*rb_screen
= rbug_screen(_screen
);
976 rb_pipe
= CALLOC_STRUCT(rbug_context
);
980 pipe_mutex_init(rb_pipe
->draw_mutex
);
981 pipe_condvar_init(rb_pipe
->draw_cond
);
982 pipe_mutex_init(rb_pipe
->call_mutex
);
983 pipe_mutex_init(rb_pipe
->list_mutex
);
984 make_empty_list(&rb_pipe
->shaders
);
986 rb_pipe
->base
.winsys
= NULL
;
987 rb_pipe
->base
.screen
= _screen
;
988 rb_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
989 rb_pipe
->base
.draw
= NULL
;
991 rb_pipe
->base
.destroy
= rbug_destroy
;
992 rb_pipe
->base
.draw_vbo
= rbug_draw_vbo
;
993 rb_pipe
->base
.create_query
= rbug_create_query
;
994 rb_pipe
->base
.destroy_query
= rbug_destroy_query
;
995 rb_pipe
->base
.begin_query
= rbug_begin_query
;
996 rb_pipe
->base
.end_query
= rbug_end_query
;
997 rb_pipe
->base
.get_query_result
= rbug_get_query_result
;
998 rb_pipe
->base
.create_blend_state
= rbug_create_blend_state
;
999 rb_pipe
->base
.bind_blend_state
= rbug_bind_blend_state
;
1000 rb_pipe
->base
.delete_blend_state
= rbug_delete_blend_state
;
1001 rb_pipe
->base
.create_sampler_state
= rbug_create_sampler_state
;
1002 rb_pipe
->base
.bind_fragment_sampler_states
= rbug_bind_fragment_sampler_states
;
1003 rb_pipe
->base
.bind_vertex_sampler_states
= rbug_bind_vertex_sampler_states
;
1004 rb_pipe
->base
.delete_sampler_state
= rbug_delete_sampler_state
;
1005 rb_pipe
->base
.create_rasterizer_state
= rbug_create_rasterizer_state
;
1006 rb_pipe
->base
.bind_rasterizer_state
= rbug_bind_rasterizer_state
;
1007 rb_pipe
->base
.delete_rasterizer_state
= rbug_delete_rasterizer_state
;
1008 rb_pipe
->base
.create_depth_stencil_alpha_state
= rbug_create_depth_stencil_alpha_state
;
1009 rb_pipe
->base
.bind_depth_stencil_alpha_state
= rbug_bind_depth_stencil_alpha_state
;
1010 rb_pipe
->base
.delete_depth_stencil_alpha_state
= rbug_delete_depth_stencil_alpha_state
;
1011 rb_pipe
->base
.create_fs_state
= rbug_create_fs_state
;
1012 rb_pipe
->base
.bind_fs_state
= rbug_bind_fs_state
;
1013 rb_pipe
->base
.delete_fs_state
= rbug_delete_fs_state
;
1014 rb_pipe
->base
.create_vs_state
= rbug_create_vs_state
;
1015 rb_pipe
->base
.bind_vs_state
= rbug_bind_vs_state
;
1016 rb_pipe
->base
.delete_vs_state
= rbug_delete_vs_state
;
1017 rb_pipe
->base
.create_gs_state
= rbug_create_gs_state
;
1018 rb_pipe
->base
.bind_gs_state
= rbug_bind_gs_state
;
1019 rb_pipe
->base
.delete_gs_state
= rbug_delete_gs_state
;
1020 rb_pipe
->base
.create_vertex_elements_state
= rbug_create_vertex_elements_state
;
1021 rb_pipe
->base
.bind_vertex_elements_state
= rbug_bind_vertex_elements_state
;
1022 rb_pipe
->base
.delete_vertex_elements_state
= rbug_delete_vertex_elements_state
;
1023 rb_pipe
->base
.set_blend_color
= rbug_set_blend_color
;
1024 rb_pipe
->base
.set_stencil_ref
= rbug_set_stencil_ref
;
1025 rb_pipe
->base
.set_clip_state
= rbug_set_clip_state
;
1026 rb_pipe
->base
.set_constant_buffer
= rbug_set_constant_buffer
;
1027 rb_pipe
->base
.set_framebuffer_state
= rbug_set_framebuffer_state
;
1028 rb_pipe
->base
.set_polygon_stipple
= rbug_set_polygon_stipple
;
1029 rb_pipe
->base
.set_scissor_state
= rbug_set_scissor_state
;
1030 rb_pipe
->base
.set_viewport_state
= rbug_set_viewport_state
;
1031 rb_pipe
->base
.set_fragment_sampler_views
= rbug_set_fragment_sampler_views
;
1032 rb_pipe
->base
.set_vertex_sampler_views
= rbug_set_vertex_sampler_views
;
1033 rb_pipe
->base
.set_vertex_buffers
= rbug_set_vertex_buffers
;
1034 rb_pipe
->base
.set_index_buffer
= rbug_set_index_buffer
;
1035 rb_pipe
->base
.set_sample_mask
= rbug_set_sample_mask
;
1036 rb_pipe
->base
.resource_copy_region
= rbug_resource_copy_region
;
1037 rb_pipe
->base
.clear
= rbug_clear
;
1038 rb_pipe
->base
.clear_render_target
= rbug_clear_render_target
;
1039 rb_pipe
->base
.clear_depth_stencil
= rbug_clear_depth_stencil
;
1040 rb_pipe
->base
.flush
= rbug_flush
;
1041 rb_pipe
->base
.is_resource_referenced
= rbug_is_resource_referenced
;
1042 rb_pipe
->base
.create_sampler_view
= rbug_context_create_sampler_view
;
1043 rb_pipe
->base
.sampler_view_destroy
= rbug_context_sampler_view_destroy
;
1044 rb_pipe
->base
.get_transfer
= rbug_context_get_transfer
;
1045 rb_pipe
->base
.transfer_destroy
= rbug_context_transfer_destroy
;
1046 rb_pipe
->base
.transfer_map
= rbug_context_transfer_map
;
1047 rb_pipe
->base
.transfer_unmap
= rbug_context_transfer_unmap
;
1048 rb_pipe
->base
.transfer_flush_region
= rbug_context_transfer_flush_region
;
1049 rb_pipe
->base
.transfer_inline_write
= rbug_context_transfer_inline_write
;
1051 rb_pipe
->pipe
= pipe
;
1053 rbug_screen_add_to_list(rb_screen
, contexts
, rb_pipe
);
1055 return &rb_pipe
->base
;