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
;
46 remove_from_list(&rb_pipe
->list
);
53 rbug_draw_block_locked(struct rbug_context
*rb_pipe
, int flag
)
56 if (rb_pipe
->draw_blocker
& flag
) {
57 rb_pipe
->draw_blocked
|= flag
;
58 } else if ((rb_pipe
->draw_rule
.blocker
& flag
) &&
59 (rb_pipe
->draw_blocker
& RBUG_BLOCK_RULE
)) {
61 boolean block
= FALSE
;
62 debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__
,
63 (void *) rb_pipe
->draw_rule
.fs
, (void *) rb_pipe
->curr
.fs
,
64 (void *) rb_pipe
->draw_rule
.vs
, (void *) rb_pipe
->curr
.vs
,
65 (void *) rb_pipe
->draw_rule
.surf
, 0,
66 (void *) rb_pipe
->draw_rule
.texture
, 0);
67 if (rb_pipe
->draw_rule
.fs
&&
68 rb_pipe
->draw_rule
.fs
== rb_pipe
->curr
.fs
)
70 if (rb_pipe
->draw_rule
.vs
&&
71 rb_pipe
->draw_rule
.vs
== rb_pipe
->curr
.vs
)
73 if (rb_pipe
->draw_rule
.surf
&&
74 rb_pipe
->draw_rule
.surf
== rb_pipe
->curr
.zsbuf
)
76 if (rb_pipe
->draw_rule
.surf
)
77 for (k
= 0; k
< rb_pipe
->curr
.nr_cbufs
; k
++)
78 if (rb_pipe
->draw_rule
.surf
== rb_pipe
->curr
.cbufs
[k
])
80 if (rb_pipe
->draw_rule
.texture
) {
81 for (k
= 0; k
< rb_pipe
->curr
.num_fs_views
; k
++)
82 if (rb_pipe
->draw_rule
.texture
== rb_pipe
->curr
.fs_texs
[k
])
84 for (k
= 0; k
< rb_pipe
->curr
.num_vs_views
; k
++) {
85 if (rb_pipe
->draw_rule
.texture
== rb_pipe
->curr
.vs_texs
[k
]) {
92 rb_pipe
->draw_blocked
|= (flag
| RBUG_BLOCK_RULE
);
95 if (rb_pipe
->draw_blocked
)
96 rbug_notify_draw_blocked(rb_pipe
);
98 /* wait for rbug to clear the blocked flag */
99 while (rb_pipe
->draw_blocked
& flag
) {
100 rb_pipe
->draw_blocked
|= flag
;
101 pipe_condvar_wait(rb_pipe
->draw_cond
, rb_pipe
->draw_mutex
);
107 rbug_draw_vbo(struct pipe_context
*_pipe
, const struct pipe_draw_info
*info
)
109 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
110 struct pipe_context
*pipe
= rb_pipe
->pipe
;
112 pipe_mutex_lock(rb_pipe
->draw_mutex
);
113 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_BEFORE
);
115 pipe
->draw_vbo(pipe
, info
);
117 rbug_draw_block_locked(rb_pipe
, RBUG_BLOCK_AFTER
);
118 pipe_mutex_unlock(rb_pipe
->draw_mutex
);
121 static struct pipe_query
*
122 rbug_create_query(struct pipe_context
*_pipe
,
125 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
126 struct pipe_context
*pipe
= rb_pipe
->pipe
;
128 return pipe
->create_query(pipe
,
133 rbug_destroy_query(struct pipe_context
*_pipe
,
134 struct pipe_query
*query
)
136 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
137 struct pipe_context
*pipe
= rb_pipe
->pipe
;
139 pipe
->destroy_query(pipe
,
144 rbug_begin_query(struct pipe_context
*_pipe
,
145 struct pipe_query
*query
)
147 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
148 struct pipe_context
*pipe
= rb_pipe
->pipe
;
150 pipe
->begin_query(pipe
,
155 rbug_end_query(struct pipe_context
*_pipe
,
156 struct pipe_query
*query
)
158 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
159 struct pipe_context
*pipe
= rb_pipe
->pipe
;
161 pipe
->end_query(pipe
,
166 rbug_get_query_result(struct pipe_context
*_pipe
,
167 struct pipe_query
*query
,
171 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
172 struct pipe_context
*pipe
= rb_pipe
->pipe
;
174 return pipe
->get_query_result(pipe
,
181 rbug_create_blend_state(struct pipe_context
*_pipe
,
182 const struct pipe_blend_state
*blend
)
184 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
185 struct pipe_context
*pipe
= rb_pipe
->pipe
;
187 return pipe
->create_blend_state(pipe
,
192 rbug_bind_blend_state(struct pipe_context
*_pipe
,
195 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
196 struct pipe_context
*pipe
= rb_pipe
->pipe
;
198 pipe
->bind_blend_state(pipe
,
203 rbug_delete_blend_state(struct pipe_context
*_pipe
,
206 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
207 struct pipe_context
*pipe
= rb_pipe
->pipe
;
209 pipe
->delete_blend_state(pipe
,
214 rbug_create_sampler_state(struct pipe_context
*_pipe
,
215 const struct pipe_sampler_state
*sampler
)
217 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
218 struct pipe_context
*pipe
= rb_pipe
->pipe
;
220 return pipe
->create_sampler_state(pipe
,
225 rbug_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
226 unsigned num_samplers
,
229 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
230 struct pipe_context
*pipe
= rb_pipe
->pipe
;
232 pipe
->bind_fragment_sampler_states(pipe
,
238 rbug_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
239 unsigned num_samplers
,
242 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
243 struct pipe_context
*pipe
= rb_pipe
->pipe
;
245 pipe
->bind_vertex_sampler_states(pipe
,
251 rbug_delete_sampler_state(struct pipe_context
*_pipe
,
254 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
255 struct pipe_context
*pipe
= rb_pipe
->pipe
;
257 pipe
->delete_sampler_state(pipe
,
262 rbug_create_rasterizer_state(struct pipe_context
*_pipe
,
263 const struct pipe_rasterizer_state
*rasterizer
)
265 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
266 struct pipe_context
*pipe
= rb_pipe
->pipe
;
268 return pipe
->create_rasterizer_state(pipe
,
273 rbug_bind_rasterizer_state(struct pipe_context
*_pipe
,
276 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
277 struct pipe_context
*pipe
= rb_pipe
->pipe
;
279 pipe
->bind_rasterizer_state(pipe
,
284 rbug_delete_rasterizer_state(struct pipe_context
*_pipe
,
287 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
288 struct pipe_context
*pipe
= rb_pipe
->pipe
;
290 pipe
->delete_rasterizer_state(pipe
,
295 rbug_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
296 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
298 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
299 struct pipe_context
*pipe
= rb_pipe
->pipe
;
301 return pipe
->create_depth_stencil_alpha_state(pipe
,
302 depth_stencil_alpha
);
306 rbug_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
307 void *depth_stencil_alpha
)
309 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
310 struct pipe_context
*pipe
= rb_pipe
->pipe
;
312 pipe
->bind_depth_stencil_alpha_state(pipe
,
313 depth_stencil_alpha
);
317 rbug_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
318 void *depth_stencil_alpha
)
320 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
321 struct pipe_context
*pipe
= rb_pipe
->pipe
;
323 pipe
->delete_depth_stencil_alpha_state(pipe
,
324 depth_stencil_alpha
);
328 rbug_create_fs_state(struct pipe_context
*_pipe
,
329 const struct pipe_shader_state
*state
)
331 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
332 struct pipe_context
*pipe
= rb_pipe
->pipe
;
335 result
= pipe
->create_fs_state(pipe
, state
);
339 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_FRAGMENT
);
343 rbug_bind_fs_state(struct pipe_context
*_pipe
,
346 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
347 struct pipe_context
*pipe
= rb_pipe
->pipe
;
350 fs
= rbug_shader_unwrap(_fs
);
351 rb_pipe
->curr
.fs
= rbug_shader(_fs
);
352 pipe
->bind_fs_state(pipe
,
357 rbug_delete_fs_state(struct pipe_context
*_pipe
,
360 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
361 struct rbug_shader
*rb_shader
= rbug_shader(_fs
);
363 rbug_shader_destroy(rb_pipe
, rb_shader
);
367 rbug_create_vs_state(struct pipe_context
*_pipe
,
368 const struct pipe_shader_state
*state
)
370 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
371 struct pipe_context
*pipe
= rb_pipe
->pipe
;
374 result
= pipe
->create_vs_state(pipe
, state
);
378 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_VERTEX
);
382 rbug_bind_vs_state(struct pipe_context
*_pipe
,
385 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
386 struct pipe_context
*pipe
= rb_pipe
->pipe
;
389 vs
= rbug_shader_unwrap(_vs
);
390 rb_pipe
->curr
.vs
= rbug_shader(_vs
);
391 pipe
->bind_vs_state(pipe
,
396 rbug_delete_vs_state(struct pipe_context
*_pipe
,
399 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
400 struct rbug_shader
*rb_shader
= rbug_shader(_vs
);
402 rbug_shader_destroy(rb_pipe
, rb_shader
);
406 rbug_create_gs_state(struct pipe_context
*_pipe
,
407 const struct pipe_shader_state
*state
)
409 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
410 struct pipe_context
*pipe
= rb_pipe
->pipe
;
413 result
= pipe
->create_gs_state(pipe
, state
);
417 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_GEOM
);
421 rbug_bind_gs_state(struct pipe_context
*_pipe
,
424 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
425 struct pipe_context
*pipe
= rb_pipe
->pipe
;
428 gs
= rbug_shader_unwrap(_gs
);
429 rb_pipe
->curr
.gs
= rbug_shader(_gs
);
430 pipe
->bind_gs_state(pipe
,
435 rbug_delete_gs_state(struct pipe_context
*_pipe
,
438 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
439 struct rbug_shader
*rb_shader
= rbug_shader(_gs
);
441 rbug_shader_destroy(rb_pipe
, rb_shader
);
445 rbug_create_vertex_elements_state(struct pipe_context
*_pipe
,
446 unsigned num_elements
,
447 const struct pipe_vertex_element
*vertex_elements
)
449 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
450 struct pipe_context
*pipe
= rb_pipe
->pipe
;
452 return pipe
->create_vertex_elements_state(pipe
,
458 rbug_bind_vertex_elements_state(struct pipe_context
*_pipe
,
461 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
462 struct pipe_context
*pipe
= rb_pipe
->pipe
;
464 pipe
->bind_vertex_elements_state(pipe
,
469 rbug_delete_vertex_elements_state(struct pipe_context
*_pipe
,
472 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
473 struct pipe_context
*pipe
= rb_pipe
->pipe
;
475 pipe
->delete_vertex_elements_state(pipe
,
480 rbug_set_blend_color(struct pipe_context
*_pipe
,
481 const struct pipe_blend_color
*blend_color
)
483 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
484 struct pipe_context
*pipe
= rb_pipe
->pipe
;
486 pipe
->set_blend_color(pipe
,
491 rbug_set_stencil_ref(struct pipe_context
*_pipe
,
492 const struct pipe_stencil_ref
*stencil_ref
)
494 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
495 struct pipe_context
*pipe
= rb_pipe
->pipe
;
497 pipe
->set_stencil_ref(pipe
,
502 rbug_set_clip_state(struct pipe_context
*_pipe
,
503 const struct pipe_clip_state
*clip
)
505 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
506 struct pipe_context
*pipe
= rb_pipe
->pipe
;
508 pipe
->set_clip_state(pipe
,
513 rbug_set_constant_buffer(struct pipe_context
*_pipe
,
516 struct pipe_resource
*_resource
)
518 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
519 struct pipe_context
*pipe
= rb_pipe
->pipe
;
520 struct pipe_resource
*unwrapped_resource
;
521 struct pipe_resource
*resource
= NULL
;
523 /* XXX hmm? unwrap the input state */
525 unwrapped_resource
= rbug_resource_unwrap(_resource
);
526 resource
= unwrapped_resource
;
529 pipe
->set_constant_buffer(pipe
,
536 rbug_set_framebuffer_state(struct pipe_context
*_pipe
,
537 const struct pipe_framebuffer_state
*_state
)
539 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
540 struct pipe_context
*pipe
= rb_pipe
->pipe
;
541 struct pipe_framebuffer_state unwrapped_state
;
542 struct pipe_framebuffer_state
*state
= NULL
;
545 rb_pipe
->curr
.nr_cbufs
= 0;
546 memset(rb_pipe
->curr
.cbufs
, 0, sizeof(rb_pipe
->curr
.cbufs
));
548 /* unwrap the input state */
550 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
552 rb_pipe
->curr
.nr_cbufs
= _state
->nr_cbufs
;
553 for(i
= 0; i
< _state
->nr_cbufs
; i
++) {
554 unwrapped_state
.cbufs
[i
] = rbug_surface_unwrap(_state
->cbufs
[i
]);
555 if (_state
->cbufs
[i
])
556 rb_pipe
->curr
.cbufs
[i
] = rbug_resource(_state
->cbufs
[i
]->texture
);
558 unwrapped_state
.zsbuf
= rbug_surface_unwrap(_state
->zsbuf
);
559 state
= &unwrapped_state
;
562 pipe
->set_framebuffer_state(pipe
,
567 rbug_set_polygon_stipple(struct pipe_context
*_pipe
,
568 const struct pipe_poly_stipple
*poly_stipple
)
570 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
571 struct pipe_context
*pipe
= rb_pipe
->pipe
;
573 pipe
->set_polygon_stipple(pipe
,
578 rbug_set_scissor_state(struct pipe_context
*_pipe
,
579 const struct pipe_scissor_state
*scissor
)
581 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
582 struct pipe_context
*pipe
= rb_pipe
->pipe
;
584 pipe
->set_scissor_state(pipe
,
589 rbug_set_viewport_state(struct pipe_context
*_pipe
,
590 const struct pipe_viewport_state
*viewport
)
592 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
593 struct pipe_context
*pipe
= rb_pipe
->pipe
;
595 pipe
->set_viewport_state(pipe
,
600 rbug_set_fragment_sampler_views(struct pipe_context
*_pipe
,
602 struct pipe_sampler_view
**_views
)
604 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
605 struct pipe_context
*pipe
= rb_pipe
->pipe
;
606 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
607 struct pipe_sampler_view
**views
= NULL
;
610 rb_pipe
->curr
.num_fs_views
= 0;
611 memset(rb_pipe
->curr
.fs_views
, 0, sizeof(rb_pipe
->curr
.fs_views
));
612 memset(rb_pipe
->curr
.fs_texs
, 0, sizeof(rb_pipe
->curr
.fs_texs
));
613 memset(unwrapped_views
, 0, sizeof(unwrapped_views
));
616 rb_pipe
->curr
.num_fs_views
= num
;
617 for (i
= 0; i
< num
; i
++) {
618 rb_pipe
->curr
.fs_views
[i
] = rbug_sampler_view(_views
[i
]);
619 rb_pipe
->curr
.fs_texs
[i
] = rbug_resource(_views
[i
] ? _views
[i
]->texture
: NULL
);
620 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
622 views
= unwrapped_views
;
625 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
629 rbug_set_vertex_sampler_views(struct pipe_context
*_pipe
,
631 struct pipe_sampler_view
**_views
)
633 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
634 struct pipe_context
*pipe
= rb_pipe
->pipe
;
635 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
636 struct pipe_sampler_view
**views
= NULL
;
639 rb_pipe
->curr
.num_vs_views
= 0;
640 memset(rb_pipe
->curr
.vs_views
, 0, sizeof(rb_pipe
->curr
.vs_views
));
641 memset(rb_pipe
->curr
.vs_texs
, 0, sizeof(rb_pipe
->curr
.vs_texs
));
642 memset(unwrapped_views
, 0, sizeof(unwrapped_views
));
645 rb_pipe
->curr
.num_vs_views
= num
;
646 for (i
= 0; i
< num
; i
++) {
647 rb_pipe
->curr
.vs_views
[i
] = rbug_sampler_view(_views
[i
]);
648 rb_pipe
->curr
.vs_texs
[i
] = rbug_resource(_views
[i
]->texture
);
649 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
651 views
= unwrapped_views
;
654 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
658 rbug_set_vertex_buffers(struct pipe_context
*_pipe
,
659 unsigned num_buffers
,
660 const struct pipe_vertex_buffer
*_buffers
)
662 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
663 struct pipe_context
*pipe
= rb_pipe
->pipe
;
664 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
665 struct pipe_vertex_buffer
*buffers
= NULL
;
669 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
670 for (i
= 0; i
< num_buffers
; i
++)
671 unwrapped_buffers
[i
].buffer
= rbug_resource_unwrap(_buffers
[i
].buffer
);
672 buffers
= unwrapped_buffers
;
675 pipe
->set_vertex_buffers(pipe
,
681 rbug_set_index_buffer(struct pipe_context
*_pipe
,
682 const struct pipe_index_buffer
*_ib
)
684 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
685 struct pipe_context
*pipe
= rb_pipe
->pipe
;
686 struct pipe_index_buffer unwrapped_ib
, *ib
= NULL
;
690 unwrapped_ib
.buffer
= rbug_resource_unwrap(_ib
->buffer
);
694 pipe
->set_index_buffer(pipe
, ib
);
698 rbug_set_sample_mask(struct pipe_context
*_pipe
,
699 unsigned sample_mask
)
701 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
702 struct pipe_context
*pipe
= rb_pipe
->pipe
;
704 pipe
->set_sample_mask(pipe
, sample_mask
);
708 rbug_resource_copy_region(struct pipe_context
*_pipe
,
709 struct pipe_resource
*_dst
,
710 struct pipe_subresource subdst
,
714 struct pipe_resource
*_src
,
715 struct pipe_subresource subsrc
,
722 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
723 struct rbug_resource
*rb_resource_dst
= rbug_resource(_dst
);
724 struct rbug_resource
*rb_resource_src
= rbug_resource(_src
);
725 struct pipe_context
*pipe
= rb_pipe
->pipe
;
726 struct pipe_resource
*dst
= rb_resource_dst
->resource
;
727 struct pipe_resource
*src
= rb_resource_src
->resource
;
729 pipe
->resource_copy_region(pipe
,
745 rbug_clear(struct pipe_context
*_pipe
,
751 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
752 struct pipe_context
*pipe
= rb_pipe
->pipe
;
762 rbug_clear_render_target(struct pipe_context
*_pipe
,
763 struct pipe_surface
*_dst
,
765 unsigned dstx
, unsigned dsty
,
766 unsigned width
, unsigned height
)
768 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
769 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
770 struct pipe_context
*pipe
= rb_pipe
->pipe
;
771 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
773 pipe
->clear_render_target(pipe
,
783 rbug_clear_depth_stencil(struct pipe_context
*_pipe
,
784 struct pipe_surface
*_dst
,
785 unsigned clear_flags
,
788 unsigned dstx
, unsigned dsty
,
789 unsigned width
, unsigned height
)
791 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
792 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
793 struct pipe_context
*pipe
= rb_pipe
->pipe
;
794 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
796 pipe
->clear_depth_stencil(pipe
,
808 rbug_flush(struct pipe_context
*_pipe
,
810 struct pipe_fence_handle
**fence
)
812 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
813 struct pipe_context
*pipe
= rb_pipe
->pipe
;
821 rbug_is_resource_referenced(struct pipe_context
*_pipe
,
822 struct pipe_resource
*_resource
,
826 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
827 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
828 struct pipe_context
*pipe
= rb_pipe
->pipe
;
829 struct pipe_resource
*resource
= rb_resource
->resource
;
831 return pipe
->is_resource_referenced(pipe
,
837 static struct pipe_sampler_view
*
838 rbug_context_create_sampler_view(struct pipe_context
*_pipe
,
839 struct pipe_resource
*_resource
,
840 const struct pipe_sampler_view
*templ
)
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
;
846 struct pipe_sampler_view
*result
;
848 result
= pipe
->create_sampler_view(pipe
,
853 return rbug_sampler_view_create(rb_pipe
, rb_resource
, result
);
858 rbug_context_sampler_view_destroy(struct pipe_context
*_pipe
,
859 struct pipe_sampler_view
*_view
)
861 rbug_sampler_view_destroy(rbug_context(_pipe
),
862 rbug_sampler_view(_view
));
865 static struct pipe_transfer
*
866 rbug_context_get_transfer(struct pipe_context
*_context
,
867 struct pipe_resource
*_resource
,
868 struct pipe_subresource sr
,
870 const struct pipe_box
*box
)
872 struct rbug_context
*rb_pipe
= rbug_context(_context
);
873 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
874 struct pipe_context
*context
= rb_pipe
->pipe
;
875 struct pipe_resource
*resource
= rb_resource
->resource
;
876 struct pipe_transfer
*result
;
878 result
= context
->get_transfer(context
,
885 return rbug_transfer_create(rb_pipe
, rb_resource
, result
);
890 rbug_context_transfer_destroy(struct pipe_context
*_pipe
,
891 struct pipe_transfer
*_transfer
)
893 rbug_transfer_destroy(rbug_context(_pipe
),
894 rbug_transfer(_transfer
));
898 rbug_context_transfer_map(struct pipe_context
*_context
,
899 struct pipe_transfer
*_transfer
)
901 struct rbug_context
*rb_pipe
= rbug_context(_context
);
902 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
903 struct pipe_context
*context
= rb_pipe
->pipe
;
904 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
906 return context
->transfer_map(context
,
913 rbug_context_transfer_flush_region(struct pipe_context
*_context
,
914 struct pipe_transfer
*_transfer
,
915 const struct pipe_box
*box
)
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 context
->transfer_flush_region(context
,
929 rbug_context_transfer_unmap(struct pipe_context
*_context
,
930 struct pipe_transfer
*_transfer
)
932 struct rbug_context
*rb_pipe
= rbug_context(_context
);
933 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
934 struct pipe_context
*context
= rb_pipe
->pipe
;
935 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
937 context
->transfer_unmap(context
,
943 rbug_context_transfer_inline_write(struct pipe_context
*_context
,
944 struct pipe_resource
*_resource
,
945 struct pipe_subresource sr
,
947 const struct pipe_box
*box
,
950 unsigned slice_stride
)
952 struct rbug_context
*rb_pipe
= rbug_context(_context
);
953 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
954 struct pipe_context
*context
= rb_pipe
->pipe
;
955 struct pipe_resource
*resource
= rb_resource
->resource
;
957 context
->transfer_inline_write(context
,
968 struct pipe_context
*
969 rbug_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
971 struct rbug_context
*rb_pipe
;
972 struct rbug_screen
*rb_screen
= rbug_screen(_screen
);
977 rb_pipe
= CALLOC_STRUCT(rbug_context
);
981 pipe_mutex_init(rb_pipe
->draw_mutex
);
982 pipe_condvar_init(rb_pipe
->draw_cond
);
983 pipe_mutex_init(rb_pipe
->call_mutex
);
984 pipe_mutex_init(rb_pipe
->list_mutex
);
985 make_empty_list(&rb_pipe
->shaders
);
987 rb_pipe
->base
.winsys
= NULL
;
988 rb_pipe
->base
.screen
= _screen
;
989 rb_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
990 rb_pipe
->base
.draw
= NULL
;
992 rb_pipe
->base
.destroy
= rbug_destroy
;
993 rb_pipe
->base
.draw_vbo
= rbug_draw_vbo
;
994 rb_pipe
->base
.create_query
= rbug_create_query
;
995 rb_pipe
->base
.destroy_query
= rbug_destroy_query
;
996 rb_pipe
->base
.begin_query
= rbug_begin_query
;
997 rb_pipe
->base
.end_query
= rbug_end_query
;
998 rb_pipe
->base
.get_query_result
= rbug_get_query_result
;
999 rb_pipe
->base
.create_blend_state
= rbug_create_blend_state
;
1000 rb_pipe
->base
.bind_blend_state
= rbug_bind_blend_state
;
1001 rb_pipe
->base
.delete_blend_state
= rbug_delete_blend_state
;
1002 rb_pipe
->base
.create_sampler_state
= rbug_create_sampler_state
;
1003 rb_pipe
->base
.bind_fragment_sampler_states
= rbug_bind_fragment_sampler_states
;
1004 rb_pipe
->base
.bind_vertex_sampler_states
= rbug_bind_vertex_sampler_states
;
1005 rb_pipe
->base
.delete_sampler_state
= rbug_delete_sampler_state
;
1006 rb_pipe
->base
.create_rasterizer_state
= rbug_create_rasterizer_state
;
1007 rb_pipe
->base
.bind_rasterizer_state
= rbug_bind_rasterizer_state
;
1008 rb_pipe
->base
.delete_rasterizer_state
= rbug_delete_rasterizer_state
;
1009 rb_pipe
->base
.create_depth_stencil_alpha_state
= rbug_create_depth_stencil_alpha_state
;
1010 rb_pipe
->base
.bind_depth_stencil_alpha_state
= rbug_bind_depth_stencil_alpha_state
;
1011 rb_pipe
->base
.delete_depth_stencil_alpha_state
= rbug_delete_depth_stencil_alpha_state
;
1012 rb_pipe
->base
.create_fs_state
= rbug_create_fs_state
;
1013 rb_pipe
->base
.bind_fs_state
= rbug_bind_fs_state
;
1014 rb_pipe
->base
.delete_fs_state
= rbug_delete_fs_state
;
1015 rb_pipe
->base
.create_vs_state
= rbug_create_vs_state
;
1016 rb_pipe
->base
.bind_vs_state
= rbug_bind_vs_state
;
1017 rb_pipe
->base
.delete_vs_state
= rbug_delete_vs_state
;
1018 rb_pipe
->base
.create_gs_state
= rbug_create_gs_state
;
1019 rb_pipe
->base
.bind_gs_state
= rbug_bind_gs_state
;
1020 rb_pipe
->base
.delete_gs_state
= rbug_delete_gs_state
;
1021 rb_pipe
->base
.create_vertex_elements_state
= rbug_create_vertex_elements_state
;
1022 rb_pipe
->base
.bind_vertex_elements_state
= rbug_bind_vertex_elements_state
;
1023 rb_pipe
->base
.delete_vertex_elements_state
= rbug_delete_vertex_elements_state
;
1024 rb_pipe
->base
.set_blend_color
= rbug_set_blend_color
;
1025 rb_pipe
->base
.set_stencil_ref
= rbug_set_stencil_ref
;
1026 rb_pipe
->base
.set_clip_state
= rbug_set_clip_state
;
1027 rb_pipe
->base
.set_constant_buffer
= rbug_set_constant_buffer
;
1028 rb_pipe
->base
.set_framebuffer_state
= rbug_set_framebuffer_state
;
1029 rb_pipe
->base
.set_polygon_stipple
= rbug_set_polygon_stipple
;
1030 rb_pipe
->base
.set_scissor_state
= rbug_set_scissor_state
;
1031 rb_pipe
->base
.set_viewport_state
= rbug_set_viewport_state
;
1032 rb_pipe
->base
.set_fragment_sampler_views
= rbug_set_fragment_sampler_views
;
1033 rb_pipe
->base
.set_vertex_sampler_views
= rbug_set_vertex_sampler_views
;
1034 rb_pipe
->base
.set_vertex_buffers
= rbug_set_vertex_buffers
;
1035 rb_pipe
->base
.set_index_buffer
= rbug_set_index_buffer
;
1036 rb_pipe
->base
.set_sample_mask
= rbug_set_sample_mask
;
1037 rb_pipe
->base
.resource_copy_region
= rbug_resource_copy_region
;
1038 rb_pipe
->base
.clear
= rbug_clear
;
1039 rb_pipe
->base
.clear_render_target
= rbug_clear_render_target
;
1040 rb_pipe
->base
.clear_depth_stencil
= rbug_clear_depth_stencil
;
1041 rb_pipe
->base
.flush
= rbug_flush
;
1042 rb_pipe
->base
.is_resource_referenced
= rbug_is_resource_referenced
;
1043 rb_pipe
->base
.create_sampler_view
= rbug_context_create_sampler_view
;
1044 rb_pipe
->base
.sampler_view_destroy
= rbug_context_sampler_view_destroy
;
1045 rb_pipe
->base
.get_transfer
= rbug_context_get_transfer
;
1046 rb_pipe
->base
.transfer_destroy
= rbug_context_transfer_destroy
;
1047 rb_pipe
->base
.transfer_map
= rbug_context_transfer_map
;
1048 rb_pipe
->base
.transfer_unmap
= rbug_context_transfer_unmap
;
1049 rb_pipe
->base
.transfer_flush_region
= rbug_context_transfer_flush_region
;
1050 rb_pipe
->base
.transfer_inline_write
= rbug_context_transfer_inline_write
;
1052 rb_pipe
->pipe
= pipe
;
1054 rbug_screen_add_to_list(rb_screen
, contexts
, rb_pipe
);
1056 return &rb_pipe
->base
;