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_context.h"
35 #include "rbug_objects.h"
39 rbug_destroy(struct pipe_context
*_pipe
)
41 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
42 struct pipe_context
*pipe
= rb_pipe
->pipe
;
50 rbug_draw_arrays(struct pipe_context
*_pipe
,
55 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
56 struct pipe_context
*pipe
= rb_pipe
->pipe
;
58 pipe
->draw_arrays(pipe
,
65 rbug_draw_elements(struct pipe_context
*_pipe
,
66 struct pipe_resource
*_indexResource
,
73 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
74 struct rbug_resource
*rb_resource
= rbug_resource(_indexResource
);
75 struct pipe_context
*pipe
= rb_pipe
->pipe
;
76 struct pipe_resource
*indexResource
= rb_resource
->resource
;
78 pipe
->draw_elements(pipe
,
88 rbug_draw_range_elements(struct pipe_context
*_pipe
,
89 struct pipe_resource
*_indexResource
,
98 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
99 struct rbug_resource
*rb_resource
= rbug_resource(_indexResource
);
100 struct pipe_context
*pipe
= rb_pipe
->pipe
;
101 struct pipe_resource
*indexResource
= rb_resource
->resource
;
103 pipe
->draw_range_elements(pipe
,
114 static struct pipe_query
*
115 rbug_create_query(struct pipe_context
*_pipe
,
118 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
119 struct pipe_context
*pipe
= rb_pipe
->pipe
;
121 return pipe
->create_query(pipe
,
126 rbug_destroy_query(struct pipe_context
*_pipe
,
127 struct pipe_query
*query
)
129 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
130 struct pipe_context
*pipe
= rb_pipe
->pipe
;
132 pipe
->destroy_query(pipe
,
137 rbug_begin_query(struct pipe_context
*_pipe
,
138 struct pipe_query
*query
)
140 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
141 struct pipe_context
*pipe
= rb_pipe
->pipe
;
143 pipe
->begin_query(pipe
,
148 rbug_end_query(struct pipe_context
*_pipe
,
149 struct pipe_query
*query
)
151 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
152 struct pipe_context
*pipe
= rb_pipe
->pipe
;
154 pipe
->end_query(pipe
,
159 rbug_get_query_result(struct pipe_context
*_pipe
,
160 struct pipe_query
*query
,
164 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
165 struct pipe_context
*pipe
= rb_pipe
->pipe
;
167 return pipe
->get_query_result(pipe
,
174 rbug_create_blend_state(struct pipe_context
*_pipe
,
175 const struct pipe_blend_state
*blend
)
177 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
178 struct pipe_context
*pipe
= rb_pipe
->pipe
;
180 return pipe
->create_blend_state(pipe
,
185 rbug_bind_blend_state(struct pipe_context
*_pipe
,
188 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
189 struct pipe_context
*pipe
= rb_pipe
->pipe
;
191 pipe
->bind_blend_state(pipe
,
196 rbug_delete_blend_state(struct pipe_context
*_pipe
,
199 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
200 struct pipe_context
*pipe
= rb_pipe
->pipe
;
202 pipe
->delete_blend_state(pipe
,
207 rbug_create_sampler_state(struct pipe_context
*_pipe
,
208 const struct pipe_sampler_state
*sampler
)
210 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
211 struct pipe_context
*pipe
= rb_pipe
->pipe
;
213 return pipe
->create_sampler_state(pipe
,
218 rbug_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
219 unsigned num_samplers
,
222 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
223 struct pipe_context
*pipe
= rb_pipe
->pipe
;
225 pipe
->bind_fragment_sampler_states(pipe
,
231 rbug_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
232 unsigned num_samplers
,
235 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
236 struct pipe_context
*pipe
= rb_pipe
->pipe
;
238 pipe
->bind_vertex_sampler_states(pipe
,
244 rbug_delete_sampler_state(struct pipe_context
*_pipe
,
247 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
248 struct pipe_context
*pipe
= rb_pipe
->pipe
;
250 pipe
->delete_sampler_state(pipe
,
255 rbug_create_rasterizer_state(struct pipe_context
*_pipe
,
256 const struct pipe_rasterizer_state
*rasterizer
)
258 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
259 struct pipe_context
*pipe
= rb_pipe
->pipe
;
261 return pipe
->create_rasterizer_state(pipe
,
266 rbug_bind_rasterizer_state(struct pipe_context
*_pipe
,
269 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
270 struct pipe_context
*pipe
= rb_pipe
->pipe
;
272 pipe
->bind_rasterizer_state(pipe
,
277 rbug_delete_rasterizer_state(struct pipe_context
*_pipe
,
280 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
281 struct pipe_context
*pipe
= rb_pipe
->pipe
;
283 pipe
->delete_rasterizer_state(pipe
,
288 rbug_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
289 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
291 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
292 struct pipe_context
*pipe
= rb_pipe
->pipe
;
294 return pipe
->create_depth_stencil_alpha_state(pipe
,
295 depth_stencil_alpha
);
299 rbug_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
300 void *depth_stencil_alpha
)
302 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
303 struct pipe_context
*pipe
= rb_pipe
->pipe
;
305 pipe
->bind_depth_stencil_alpha_state(pipe
,
306 depth_stencil_alpha
);
310 rbug_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
311 void *depth_stencil_alpha
)
313 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
314 struct pipe_context
*pipe
= rb_pipe
->pipe
;
316 pipe
->delete_depth_stencil_alpha_state(pipe
,
317 depth_stencil_alpha
);
321 rbug_create_fs_state(struct pipe_context
*_pipe
,
322 const struct pipe_shader_state
*state
)
324 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
325 struct pipe_context
*pipe
= rb_pipe
->pipe
;
328 result
= pipe
->create_fs_state(pipe
, state
);
332 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_FRAGMENT
);
336 rbug_bind_fs_state(struct pipe_context
*_pipe
,
339 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
340 struct pipe_context
*pipe
= rb_pipe
->pipe
;
343 fs
= rbug_shader_unwrap(_fs
);
344 rb_pipe
->curr
.fs
= rbug_shader(_fs
);
345 pipe
->bind_fs_state(pipe
,
350 rbug_delete_fs_state(struct pipe_context
*_pipe
,
353 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
354 struct rbug_shader
*rb_shader
= rbug_shader(_fs
);
356 rbug_shader_destroy(rb_pipe
, rb_shader
);
360 rbug_create_vs_state(struct pipe_context
*_pipe
,
361 const struct pipe_shader_state
*state
)
363 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
364 struct pipe_context
*pipe
= rb_pipe
->pipe
;
367 result
= pipe
->create_vs_state(pipe
, state
);
371 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_VERTEX
);
375 rbug_bind_vs_state(struct pipe_context
*_pipe
,
378 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
379 struct pipe_context
*pipe
= rb_pipe
->pipe
;
382 vs
= rbug_shader_unwrap(_vs
);
383 rb_pipe
->curr
.vs
= rbug_shader(_vs
);
384 pipe
->bind_vs_state(pipe
,
389 rbug_delete_vs_state(struct pipe_context
*_pipe
,
392 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
393 struct rbug_shader
*rb_shader
= rbug_shader(_vs
);
395 rbug_shader_destroy(rb_pipe
, rb_shader
);
399 rbug_create_gs_state(struct pipe_context
*_pipe
,
400 const struct pipe_shader_state
*state
)
402 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
403 struct pipe_context
*pipe
= rb_pipe
->pipe
;
406 result
= pipe
->create_gs_state(pipe
, state
);
410 return rbug_shader_create(rb_pipe
, state
, result
, RBUG_SHADER_GEOM
);
414 rbug_bind_gs_state(struct pipe_context
*_pipe
,
417 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
418 struct pipe_context
*pipe
= rb_pipe
->pipe
;
421 gs
= rbug_shader_unwrap(_gs
);
422 rb_pipe
->curr
.gs
= rbug_shader(_gs
);
423 pipe
->bind_gs_state(pipe
,
428 rbug_delete_gs_state(struct pipe_context
*_pipe
,
431 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
432 struct rbug_shader
*rb_shader
= rbug_shader(_gs
);
434 rbug_shader_destroy(rb_pipe
, rb_shader
);
438 rbug_create_vertex_elements_state(struct pipe_context
*_pipe
,
439 unsigned num_elements
,
440 const struct pipe_vertex_element
*vertex_elements
)
442 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
443 struct pipe_context
*pipe
= rb_pipe
->pipe
;
445 return pipe
->create_vertex_elements_state(pipe
,
451 rbug_bind_vertex_elements_state(struct pipe_context
*_pipe
,
454 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
455 struct pipe_context
*pipe
= rb_pipe
->pipe
;
457 pipe
->bind_vertex_elements_state(pipe
,
462 rbug_delete_vertex_elements_state(struct pipe_context
*_pipe
,
465 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
466 struct pipe_context
*pipe
= rb_pipe
->pipe
;
468 pipe
->delete_vertex_elements_state(pipe
,
473 rbug_set_blend_color(struct pipe_context
*_pipe
,
474 const struct pipe_blend_color
*blend_color
)
476 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
477 struct pipe_context
*pipe
= rb_pipe
->pipe
;
479 pipe
->set_blend_color(pipe
,
484 rbug_set_stencil_ref(struct pipe_context
*_pipe
,
485 const struct pipe_stencil_ref
*stencil_ref
)
487 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
488 struct pipe_context
*pipe
= rb_pipe
->pipe
;
490 pipe
->set_stencil_ref(pipe
,
495 rbug_set_clip_state(struct pipe_context
*_pipe
,
496 const struct pipe_clip_state
*clip
)
498 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
499 struct pipe_context
*pipe
= rb_pipe
->pipe
;
501 pipe
->set_clip_state(pipe
,
506 rbug_set_constant_buffer(struct pipe_context
*_pipe
,
509 struct pipe_resource
*_resource
)
511 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
512 struct pipe_context
*pipe
= rb_pipe
->pipe
;
513 struct pipe_resource
*unwrapped_resource
;
514 struct pipe_resource
*resource
= NULL
;
516 /* XXX hmm? unwrap the input state */
518 unwrapped_resource
= rbug_resource_unwrap(_resource
);
519 resource
= unwrapped_resource
;
522 pipe
->set_constant_buffer(pipe
,
529 rbug_set_framebuffer_state(struct pipe_context
*_pipe
,
530 const struct pipe_framebuffer_state
*_state
)
532 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
533 struct pipe_context
*pipe
= rb_pipe
->pipe
;
534 struct pipe_framebuffer_state unwrapped_state
;
535 struct pipe_framebuffer_state
*state
= NULL
;
538 /* unwrap the input state */
540 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
541 for(i
= 0; i
< _state
->nr_cbufs
; i
++)
542 unwrapped_state
.cbufs
[i
] = rbug_surface_unwrap(_state
->cbufs
[i
]);
543 for (; i
< PIPE_MAX_COLOR_BUFS
; i
++)
544 unwrapped_state
.cbufs
[i
] = NULL
;
545 unwrapped_state
.zsbuf
= rbug_surface_unwrap(_state
->zsbuf
);
546 state
= &unwrapped_state
;
549 pipe
->set_framebuffer_state(pipe
,
554 rbug_set_polygon_stipple(struct pipe_context
*_pipe
,
555 const struct pipe_poly_stipple
*poly_stipple
)
557 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
558 struct pipe_context
*pipe
= rb_pipe
->pipe
;
560 pipe
->set_polygon_stipple(pipe
,
565 rbug_set_scissor_state(struct pipe_context
*_pipe
,
566 const struct pipe_scissor_state
*scissor
)
568 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
569 struct pipe_context
*pipe
= rb_pipe
->pipe
;
571 pipe
->set_scissor_state(pipe
,
576 rbug_set_viewport_state(struct pipe_context
*_pipe
,
577 const struct pipe_viewport_state
*viewport
)
579 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
580 struct pipe_context
*pipe
= rb_pipe
->pipe
;
582 pipe
->set_viewport_state(pipe
,
587 rbug_set_fragment_sampler_views(struct pipe_context
*_pipe
,
589 struct pipe_sampler_view
**_views
)
591 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
592 struct pipe_context
*pipe
= rb_pipe
->pipe
;
593 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
594 struct pipe_sampler_view
**views
= NULL
;
598 for (i
= 0; i
< num
; i
++)
599 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
600 for (; i
< PIPE_MAX_SAMPLERS
; i
++)
601 unwrapped_views
[i
] = NULL
;
603 views
= unwrapped_views
;
606 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
610 rbug_set_vertex_sampler_views(struct pipe_context
*_pipe
,
612 struct pipe_sampler_view
**_views
)
614 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
615 struct pipe_context
*pipe
= rb_pipe
->pipe
;
616 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
617 struct pipe_sampler_view
**views
= NULL
;
621 for (i
= 0; i
< num
; i
++)
622 unwrapped_views
[i
] = rbug_sampler_view_unwrap(_views
[i
]);
623 for (; i
< PIPE_MAX_VERTEX_SAMPLERS
; i
++)
624 unwrapped_views
[i
] = NULL
;
626 views
= unwrapped_views
;
629 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
633 rbug_set_vertex_buffers(struct pipe_context
*_pipe
,
634 unsigned num_buffers
,
635 const struct pipe_vertex_buffer
*_buffers
)
637 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
638 struct pipe_context
*pipe
= rb_pipe
->pipe
;
639 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
640 struct pipe_vertex_buffer
*buffers
= NULL
;
644 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
645 for (i
= 0; i
< num_buffers
; i
++)
646 unwrapped_buffers
[i
].buffer
= rbug_resource_unwrap(_buffers
[i
].buffer
);
647 buffers
= unwrapped_buffers
;
650 pipe
->set_vertex_buffers(pipe
,
655 rbug_surface_copy(struct pipe_context
*_pipe
,
656 struct pipe_surface
*_dst
,
659 struct pipe_surface
*_src
,
665 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
666 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
667 struct rbug_surface
*rb_surface_src
= rbug_surface(_src
);
668 struct pipe_context
*pipe
= rb_pipe
->pipe
;
669 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
670 struct pipe_surface
*src
= rb_surface_src
->surface
;
672 pipe
->surface_copy(pipe
,
684 rbug_surface_fill(struct pipe_context
*_pipe
,
685 struct pipe_surface
*_dst
,
692 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
693 struct rbug_surface
*rb_surface_dst
= rbug_surface(_dst
);
694 struct pipe_context
*pipe
= rb_pipe
->pipe
;
695 struct pipe_surface
*dst
= rb_surface_dst
->surface
;
697 pipe
->surface_fill(pipe
,
707 rbug_clear(struct pipe_context
*_pipe
,
713 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
714 struct pipe_context
*pipe
= rb_pipe
->pipe
;
724 rbug_flush(struct pipe_context
*_pipe
,
726 struct pipe_fence_handle
**fence
)
728 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
729 struct pipe_context
*pipe
= rb_pipe
->pipe
;
737 rbug_is_resource_referenced(struct pipe_context
*_pipe
,
738 struct pipe_resource
*_resource
,
742 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
743 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
744 struct pipe_context
*pipe
= rb_pipe
->pipe
;
745 struct pipe_resource
*resource
= rb_resource
->resource
;
747 return pipe
->is_resource_referenced(pipe
,
753 static struct pipe_sampler_view
*
754 rbug_context_create_sampler_view(struct pipe_context
*_pipe
,
755 struct pipe_resource
*_resource
,
756 const struct pipe_sampler_view
*templ
)
758 struct rbug_context
*rb_pipe
= rbug_context(_pipe
);
759 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
760 struct pipe_context
*pipe
= rb_pipe
->pipe
;
761 struct pipe_resource
*resource
= rb_resource
->resource
;
762 struct pipe_sampler_view
*result
;
764 result
= pipe
->create_sampler_view(pipe
,
769 return rbug_sampler_view_create(rb_pipe
, rb_resource
, result
);
774 rbug_context_sampler_view_destroy(struct pipe_context
*_pipe
,
775 struct pipe_sampler_view
*_view
)
777 rbug_sampler_view_destroy(rbug_context(_pipe
),
778 rbug_sampler_view(_view
));
781 static struct pipe_transfer
*
782 rbug_context_get_transfer(struct pipe_context
*_context
,
783 struct pipe_resource
*_resource
,
784 struct pipe_subresource sr
,
786 const struct pipe_box
*box
)
788 struct rbug_context
*rb_pipe
= rbug_context(_context
);
789 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
790 struct pipe_context
*context
= rb_pipe
->pipe
;
791 struct pipe_resource
*resource
= rb_resource
->resource
;
792 struct pipe_transfer
*result
;
794 result
= context
->get_transfer(context
,
801 return rbug_transfer_create(rb_pipe
, rb_resource
, result
);
806 rbug_context_transfer_destroy(struct pipe_context
*_pipe
,
807 struct pipe_transfer
*_transfer
)
809 rbug_transfer_destroy(rbug_context(_pipe
),
810 rbug_transfer(_transfer
));
814 rbug_context_transfer_map(struct pipe_context
*_context
,
815 struct pipe_transfer
*_transfer
)
817 struct rbug_context
*rb_pipe
= rbug_context(_context
);
818 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
819 struct pipe_context
*context
= rb_pipe
->pipe
;
820 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
822 return context
->transfer_map(context
,
829 rbug_context_transfer_flush_region(struct pipe_context
*_context
,
830 struct pipe_transfer
*_transfer
,
831 const struct pipe_box
*box
)
833 struct rbug_context
*rb_pipe
= rbug_context(_context
);
834 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
835 struct pipe_context
*context
= rb_pipe
->pipe
;
836 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
838 context
->transfer_flush_region(context
,
845 rbug_context_transfer_unmap(struct pipe_context
*_context
,
846 struct pipe_transfer
*_transfer
)
848 struct rbug_context
*rb_pipe
= rbug_context(_context
);
849 struct rbug_transfer
*rb_transfer
= rbug_transfer(_transfer
);
850 struct pipe_context
*context
= rb_pipe
->pipe
;
851 struct pipe_transfer
*transfer
= rb_transfer
->transfer
;
853 context
->transfer_unmap(context
,
859 rbug_context_transfer_inline_write(struct pipe_context
*_context
,
860 struct pipe_resource
*_resource
,
861 struct pipe_subresource sr
,
863 const struct pipe_box
*box
,
866 unsigned slice_stride
)
868 struct rbug_context
*rb_pipe
= rbug_context(_context
);
869 struct rbug_resource
*rb_resource
= rbug_resource(_resource
);
870 struct pipe_context
*context
= rb_pipe
->pipe
;
871 struct pipe_resource
*resource
= rb_resource
->resource
;
873 context
->transfer_inline_write(context
,
884 struct pipe_context
*
885 rbug_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
887 struct rbug_context
*rb_pipe
;
888 struct rbug_screen
*rb_screen
= rbug_screen(_screen
);
893 rb_pipe
= CALLOC_STRUCT(rbug_context
);
897 pipe_mutex_init(rb_pipe
->draw_mutex
);
898 pipe_condvar_init(rb_pipe
->draw_cond
);
899 pipe_mutex_init(rb_pipe
->call_mutex
);
900 pipe_mutex_init(rb_pipe
->list_mutex
);
901 make_empty_list(&rb_pipe
->shaders
);
903 rb_pipe
->base
.winsys
= NULL
;
904 rb_pipe
->base
.screen
= _screen
;
905 rb_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
906 rb_pipe
->base
.draw
= NULL
;
908 rb_pipe
->base
.destroy
= rbug_destroy
;
909 rb_pipe
->base
.draw_arrays
= rbug_draw_arrays
;
910 rb_pipe
->base
.draw_elements
= rbug_draw_elements
;
911 rb_pipe
->base
.draw_range_elements
= rbug_draw_range_elements
;
912 rb_pipe
->base
.create_query
= rbug_create_query
;
913 rb_pipe
->base
.destroy_query
= rbug_destroy_query
;
914 rb_pipe
->base
.begin_query
= rbug_begin_query
;
915 rb_pipe
->base
.end_query
= rbug_end_query
;
916 rb_pipe
->base
.get_query_result
= rbug_get_query_result
;
917 rb_pipe
->base
.create_blend_state
= rbug_create_blend_state
;
918 rb_pipe
->base
.bind_blend_state
= rbug_bind_blend_state
;
919 rb_pipe
->base
.delete_blend_state
= rbug_delete_blend_state
;
920 rb_pipe
->base
.create_sampler_state
= rbug_create_sampler_state
;
921 rb_pipe
->base
.bind_fragment_sampler_states
= rbug_bind_fragment_sampler_states
;
922 rb_pipe
->base
.bind_vertex_sampler_states
= rbug_bind_vertex_sampler_states
;
923 rb_pipe
->base
.delete_sampler_state
= rbug_delete_sampler_state
;
924 rb_pipe
->base
.create_rasterizer_state
= rbug_create_rasterizer_state
;
925 rb_pipe
->base
.bind_rasterizer_state
= rbug_bind_rasterizer_state
;
926 rb_pipe
->base
.delete_rasterizer_state
= rbug_delete_rasterizer_state
;
927 rb_pipe
->base
.create_depth_stencil_alpha_state
= rbug_create_depth_stencil_alpha_state
;
928 rb_pipe
->base
.bind_depth_stencil_alpha_state
= rbug_bind_depth_stencil_alpha_state
;
929 rb_pipe
->base
.delete_depth_stencil_alpha_state
= rbug_delete_depth_stencil_alpha_state
;
930 rb_pipe
->base
.create_fs_state
= rbug_create_fs_state
;
931 rb_pipe
->base
.bind_fs_state
= rbug_bind_fs_state
;
932 rb_pipe
->base
.delete_fs_state
= rbug_delete_fs_state
;
933 rb_pipe
->base
.create_vs_state
= rbug_create_vs_state
;
934 rb_pipe
->base
.bind_vs_state
= rbug_bind_vs_state
;
935 rb_pipe
->base
.delete_vs_state
= rbug_delete_vs_state
;
936 rb_pipe
->base
.create_gs_state
= rbug_create_gs_state
;
937 rb_pipe
->base
.bind_gs_state
= rbug_bind_gs_state
;
938 rb_pipe
->base
.delete_gs_state
= rbug_delete_gs_state
;
939 rb_pipe
->base
.create_vertex_elements_state
= rbug_create_vertex_elements_state
;
940 rb_pipe
->base
.bind_vertex_elements_state
= rbug_bind_vertex_elements_state
;
941 rb_pipe
->base
.delete_vertex_elements_state
= rbug_delete_vertex_elements_state
;
942 rb_pipe
->base
.set_blend_color
= rbug_set_blend_color
;
943 rb_pipe
->base
.set_stencil_ref
= rbug_set_stencil_ref
;
944 rb_pipe
->base
.set_clip_state
= rbug_set_clip_state
;
945 rb_pipe
->base
.set_constant_buffer
= rbug_set_constant_buffer
;
946 rb_pipe
->base
.set_framebuffer_state
= rbug_set_framebuffer_state
;
947 rb_pipe
->base
.set_polygon_stipple
= rbug_set_polygon_stipple
;
948 rb_pipe
->base
.set_scissor_state
= rbug_set_scissor_state
;
949 rb_pipe
->base
.set_viewport_state
= rbug_set_viewport_state
;
950 rb_pipe
->base
.set_fragment_sampler_views
= rbug_set_fragment_sampler_views
;
951 rb_pipe
->base
.set_vertex_sampler_views
= rbug_set_vertex_sampler_views
;
952 rb_pipe
->base
.set_vertex_buffers
= rbug_set_vertex_buffers
;
953 rb_pipe
->base
.surface_copy
= rbug_surface_copy
;
954 rb_pipe
->base
.surface_fill
= rbug_surface_fill
;
955 rb_pipe
->base
.clear
= rbug_clear
;
956 rb_pipe
->base
.flush
= rbug_flush
;
957 rb_pipe
->base
.is_resource_referenced
= rbug_is_resource_referenced
;
958 rb_pipe
->base
.create_sampler_view
= rbug_context_create_sampler_view
;
959 rb_pipe
->base
.sampler_view_destroy
= rbug_context_sampler_view_destroy
;
960 rb_pipe
->base
.get_transfer
= rbug_context_get_transfer
;
961 rb_pipe
->base
.transfer_destroy
= rbug_context_transfer_destroy
;
962 rb_pipe
->base
.transfer_map
= rbug_context_transfer_map
;
963 rb_pipe
->base
.transfer_unmap
= rbug_context_transfer_unmap
;
964 rb_pipe
->base
.transfer_flush_region
= rbug_context_transfer_flush_region
;
965 rb_pipe
->base
.transfer_inline_write
= rbug_context_transfer_inline_write
;
967 rb_pipe
->pipe
= pipe
;
969 rbug_screen_add_to_list(rb_screen
, contexts
, rb_pipe
);
971 return &rb_pipe
->base
;