1 /**************************************************************************
3 * Copyright 2009 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"
31 #include "util/u_format.h"
32 #include "util/u_memory.h"
33 #include "util/u_inlines.h"
35 #include "glhd_context.h"
36 #include "glhd_objects.h"
40 galahad_destroy(struct pipe_context
*_pipe
)
42 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
43 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
51 galahad_draw_arrays(struct pipe_context
*_pipe
,
56 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
57 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
59 pipe
->draw_arrays(pipe
,
66 galahad_draw_elements(struct pipe_context
*_pipe
,
67 struct pipe_resource
*_indexResource
,
74 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
75 struct galahad_resource
*glhd_resource
= galahad_resource(_indexResource
);
76 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
77 struct pipe_resource
*indexResource
= glhd_resource
->resource
;
79 pipe
->draw_elements(pipe
,
89 galahad_draw_range_elements(struct pipe_context
*_pipe
,
90 struct pipe_resource
*_indexResource
,
99 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
100 struct galahad_resource
*glhd_resource
= galahad_resource(_indexResource
);
101 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
102 struct pipe_resource
*indexResource
= glhd_resource
->resource
;
104 pipe
->draw_range_elements(pipe
,
115 static struct pipe_query
*
116 galahad_create_query(struct pipe_context
*_pipe
,
119 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
120 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
122 if (query_type
== PIPE_QUERY_OCCLUSION_COUNTER
&&
123 !pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_OCCLUSION_QUERY
)) {
124 glhd_error("Occlusion query requested but not supported");
127 if (query_type
== PIPE_QUERY_TIME_ELAPSED
&&
128 !pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_TIMER_QUERY
)) {
129 glhd_error("Timer query requested but not supported");
132 return pipe
->create_query(pipe
,
137 galahad_destroy_query(struct pipe_context
*_pipe
,
138 struct pipe_query
*query
)
140 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
141 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
143 pipe
->destroy_query(pipe
,
148 galahad_begin_query(struct pipe_context
*_pipe
,
149 struct pipe_query
*query
)
151 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
152 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
154 pipe
->begin_query(pipe
,
159 galahad_end_query(struct pipe_context
*_pipe
,
160 struct pipe_query
*query
)
162 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
163 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
165 pipe
->end_query(pipe
,
170 galahad_get_query_result(struct pipe_context
*_pipe
,
171 struct pipe_query
*query
,
175 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
176 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
178 return pipe
->get_query_result(pipe
,
185 galahad_create_blend_state(struct pipe_context
*_pipe
,
186 const struct pipe_blend_state
*blend
)
188 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
189 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
191 if (blend
->logicop_enable
) {
192 if (blend
->rt
[0].blend_enable
) {
193 glhd_warn("Blending enabled for render target 0, but logicops "
198 return pipe
->create_blend_state(pipe
,
203 galahad_bind_blend_state(struct pipe_context
*_pipe
,
206 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
207 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
209 pipe
->bind_blend_state(pipe
,
214 galahad_delete_blend_state(struct pipe_context
*_pipe
,
217 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
218 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
220 pipe
->delete_blend_state(pipe
,
225 galahad_create_sampler_state(struct pipe_context
*_pipe
,
226 const struct pipe_sampler_state
*sampler
)
228 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
229 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
231 return pipe
->create_sampler_state(pipe
,
236 galahad_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
237 unsigned num_samplers
,
240 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
241 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
243 pipe
->bind_fragment_sampler_states(pipe
,
249 galahad_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
250 unsigned num_samplers
,
253 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
254 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
256 pipe
->bind_vertex_sampler_states(pipe
,
262 galahad_delete_sampler_state(struct pipe_context
*_pipe
,
265 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
266 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
268 pipe
->delete_sampler_state(pipe
,
273 galahad_create_rasterizer_state(struct pipe_context
*_pipe
,
274 const struct pipe_rasterizer_state
*rasterizer
)
276 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
277 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
279 if (rasterizer
->point_quad_rasterization
) {
280 if (rasterizer
->point_smooth
) {
281 glhd_warn("Point smoothing requested but ignored");
284 if (rasterizer
->sprite_coord_enable
) {
285 glhd_warn("Point sprites requested but ignored");
289 return pipe
->create_rasterizer_state(pipe
,
294 galahad_bind_rasterizer_state(struct pipe_context
*_pipe
,
297 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
298 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
300 pipe
->bind_rasterizer_state(pipe
,
305 galahad_delete_rasterizer_state(struct pipe_context
*_pipe
,
308 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
309 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
311 pipe
->delete_rasterizer_state(pipe
,
316 galahad_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
317 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
319 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
320 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
322 return pipe
->create_depth_stencil_alpha_state(pipe
,
323 depth_stencil_alpha
);
327 galahad_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
328 void *depth_stencil_alpha
)
330 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
331 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
333 pipe
->bind_depth_stencil_alpha_state(pipe
,
334 depth_stencil_alpha
);
338 galahad_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
339 void *depth_stencil_alpha
)
341 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
342 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
344 pipe
->delete_depth_stencil_alpha_state(pipe
,
345 depth_stencil_alpha
);
349 galahad_create_fs_state(struct pipe_context
*_pipe
,
350 const struct pipe_shader_state
*fs
)
352 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
353 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
355 return pipe
->create_fs_state(pipe
,
360 galahad_bind_fs_state(struct pipe_context
*_pipe
,
363 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
364 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
366 pipe
->bind_fs_state(pipe
,
371 galahad_delete_fs_state(struct pipe_context
*_pipe
,
374 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
375 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
377 pipe
->delete_fs_state(pipe
,
382 galahad_create_vs_state(struct pipe_context
*_pipe
,
383 const struct pipe_shader_state
*vs
)
385 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
386 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
388 return pipe
->create_vs_state(pipe
,
393 galahad_bind_vs_state(struct pipe_context
*_pipe
,
396 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
397 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
399 pipe
->bind_vs_state(pipe
,
404 galahad_delete_vs_state(struct pipe_context
*_pipe
,
407 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
408 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
410 pipe
->delete_vs_state(pipe
,
416 galahad_create_vertex_elements_state(struct pipe_context
*_pipe
,
417 unsigned num_elements
,
418 const struct pipe_vertex_element
*vertex_elements
)
420 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
421 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
423 return pipe
->create_vertex_elements_state(pipe
,
429 galahad_bind_vertex_elements_state(struct pipe_context
*_pipe
,
432 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
433 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
435 pipe
->bind_vertex_elements_state(pipe
,
440 galahad_delete_vertex_elements_state(struct pipe_context
*_pipe
,
443 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
444 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
446 pipe
->delete_vertex_elements_state(pipe
,
451 galahad_set_blend_color(struct pipe_context
*_pipe
,
452 const struct pipe_blend_color
*blend_color
)
454 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
455 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
457 pipe
->set_blend_color(pipe
,
462 galahad_set_stencil_ref(struct pipe_context
*_pipe
,
463 const struct pipe_stencil_ref
*stencil_ref
)
465 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
466 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
468 pipe
->set_stencil_ref(pipe
,
473 galahad_set_clip_state(struct pipe_context
*_pipe
,
474 const struct pipe_clip_state
*clip
)
476 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
477 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
479 pipe
->set_clip_state(pipe
,
484 galahad_set_sample_mask(struct pipe_context
*_pipe
,
485 unsigned sample_mask
)
487 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
488 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
490 pipe
->set_sample_mask(pipe
,
495 galahad_set_constant_buffer(struct pipe_context
*_pipe
,
498 struct pipe_resource
*_resource
)
500 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
501 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
502 struct pipe_resource
*unwrapped_resource
;
503 struct pipe_resource
*resource
= NULL
;
505 /* XXX hmm? unwrap the input state */
507 unwrapped_resource
= galahad_resource_unwrap(_resource
);
508 resource
= unwrapped_resource
;
511 pipe
->set_constant_buffer(pipe
,
518 galahad_set_framebuffer_state(struct pipe_context
*_pipe
,
519 const struct pipe_framebuffer_state
*_state
)
521 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
522 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
523 struct pipe_framebuffer_state unwrapped_state
;
524 struct pipe_framebuffer_state
*state
= NULL
;
527 if (_state
->nr_cbufs
> PIPE_MAX_COLOR_BUFS
) {
528 glhd_error("%d render targets bound, but only %d are permitted by API",
529 _state
->nr_cbufs
, PIPE_MAX_COLOR_BUFS
);
530 } else if (_state
->nr_cbufs
>
531 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
)) {
532 glhd_warn("%d render targets bound, but only %d are supported",
534 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
));
537 /* unwrap the input state */
539 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
540 for(i
= 0; i
< _state
->nr_cbufs
; i
++)
541 unwrapped_state
.cbufs
[i
] = galahad_surface_unwrap(_state
->cbufs
[i
]);
542 for (; i
< PIPE_MAX_COLOR_BUFS
; i
++)
543 unwrapped_state
.cbufs
[i
] = NULL
;
544 unwrapped_state
.zsbuf
= galahad_surface_unwrap(_state
->zsbuf
);
545 state
= &unwrapped_state
;
548 pipe
->set_framebuffer_state(pipe
,
553 galahad_set_polygon_stipple(struct pipe_context
*_pipe
,
554 const struct pipe_poly_stipple
*poly_stipple
)
556 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
557 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
559 pipe
->set_polygon_stipple(pipe
,
564 galahad_set_scissor_state(struct pipe_context
*_pipe
,
565 const struct pipe_scissor_state
*scissor
)
567 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
568 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
570 pipe
->set_scissor_state(pipe
,
575 galahad_set_viewport_state(struct pipe_context
*_pipe
,
576 const struct pipe_viewport_state
*viewport
)
578 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
579 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
581 pipe
->set_viewport_state(pipe
,
586 galahad_set_fragment_sampler_views(struct pipe_context
*_pipe
,
588 struct pipe_sampler_view
**_views
)
590 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
591 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
592 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
593 struct pipe_sampler_view
**views
= NULL
;
597 for (i
= 0; i
< num
; i
++)
598 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
599 for (; i
< PIPE_MAX_SAMPLERS
; i
++)
600 unwrapped_views
[i
] = NULL
;
602 views
= unwrapped_views
;
605 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
609 galahad_set_vertex_sampler_views(struct pipe_context
*_pipe
,
611 struct pipe_sampler_view
**_views
)
613 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
614 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
615 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
616 struct pipe_sampler_view
**views
= NULL
;
620 for (i
= 0; i
< num
; i
++)
621 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
622 for (; i
< PIPE_MAX_VERTEX_SAMPLERS
; i
++)
623 unwrapped_views
[i
] = NULL
;
625 views
= unwrapped_views
;
628 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
632 galahad_set_vertex_buffers(struct pipe_context
*_pipe
,
633 unsigned num_buffers
,
634 const struct pipe_vertex_buffer
*_buffers
)
636 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
637 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
638 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
639 struct pipe_vertex_buffer
*buffers
= NULL
;
643 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
644 for (i
= 0; i
< num_buffers
; i
++)
645 unwrapped_buffers
[i
].buffer
= galahad_resource_unwrap(_buffers
[i
].buffer
);
646 buffers
= unwrapped_buffers
;
649 pipe
->set_vertex_buffers(pipe
,
654 galahad_resource_copy_region(struct pipe_context
*_pipe
,
655 struct pipe_resource
*_dst
,
656 struct pipe_subresource subdst
,
660 struct pipe_resource
*_src
,
661 struct pipe_subresource subsrc
,
668 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
669 struct galahad_resource
*glhd_resource_dst
= galahad_resource(_dst
);
670 struct galahad_resource
*glhd_resource_src
= galahad_resource(_src
);
671 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
672 struct pipe_resource
*dst
= glhd_resource_dst
->resource
;
673 struct pipe_resource
*src
= glhd_resource_src
->resource
;
675 if (_dst
->format
!= _src
->format
) {
676 glhd_warn("Format mismatch: Source is %s, destination is %s",
677 util_format_short_name(_src
->format
),
678 util_format_short_name(_dst
->format
));
681 pipe
->resource_copy_region(pipe
,
697 galahad_clear(struct pipe_context
*_pipe
,
703 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
704 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
714 galahad_clear_render_target(struct pipe_context
*_pipe
,
715 struct pipe_surface
*_dst
,
717 unsigned dstx
, unsigned dsty
,
718 unsigned width
, unsigned height
)
720 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
721 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
722 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
723 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
725 pipe
->clear_render_target(pipe
,
734 galahad_clear_depth_stencil(struct pipe_context
*_pipe
,
735 struct pipe_surface
*_dst
,
736 unsigned clear_flags
,
739 unsigned dstx
, unsigned dsty
,
740 unsigned width
, unsigned height
)
742 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
743 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
744 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
745 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
747 pipe
->clear_depth_stencil(pipe
,
760 galahad_flush(struct pipe_context
*_pipe
,
762 struct pipe_fence_handle
**fence
)
764 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
765 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
773 galahad_is_resource_referenced(struct pipe_context
*_pipe
,
774 struct pipe_resource
*_resource
,
778 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
779 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
780 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
781 struct pipe_resource
*resource
= glhd_resource
->resource
;
783 return pipe
->is_resource_referenced(pipe
,
789 static struct pipe_sampler_view
*
790 galahad_context_create_sampler_view(struct pipe_context
*_pipe
,
791 struct pipe_resource
*_resource
,
792 const struct pipe_sampler_view
*templ
)
794 struct galahad_context
*glhd_context
= galahad_context(_pipe
);
795 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
796 struct pipe_context
*pipe
= glhd_context
->pipe
;
797 struct pipe_resource
*resource
= glhd_resource
->resource
;
798 struct pipe_sampler_view
*result
;
800 result
= pipe
->create_sampler_view(pipe
,
805 return galahad_sampler_view_create(glhd_context
, glhd_resource
, result
);
810 galahad_context_sampler_view_destroy(struct pipe_context
*_pipe
,
811 struct pipe_sampler_view
*_view
)
813 galahad_sampler_view_destroy(galahad_context(_pipe
),
814 galahad_sampler_view(_view
));
817 static struct pipe_transfer
*
818 galahad_context_get_transfer(struct pipe_context
*_context
,
819 struct pipe_resource
*_resource
,
820 struct pipe_subresource sr
,
822 const struct pipe_box
*box
)
824 struct galahad_context
*glhd_context
= galahad_context(_context
);
825 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
826 struct pipe_context
*context
= glhd_context
->pipe
;
827 struct pipe_resource
*resource
= glhd_resource
->resource
;
828 struct pipe_transfer
*result
;
830 result
= context
->get_transfer(context
,
837 return galahad_transfer_create(glhd_context
, glhd_resource
, result
);
842 galahad_context_transfer_destroy(struct pipe_context
*_pipe
,
843 struct pipe_transfer
*_transfer
)
845 galahad_transfer_destroy(galahad_context(_pipe
),
846 galahad_transfer(_transfer
));
850 galahad_context_transfer_map(struct pipe_context
*_context
,
851 struct pipe_transfer
*_transfer
)
853 struct galahad_context
*glhd_context
= galahad_context(_context
);
854 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
855 struct pipe_context
*context
= glhd_context
->pipe
;
856 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
858 return context
->transfer_map(context
,
865 galahad_context_transfer_flush_region(struct pipe_context
*_context
,
866 struct pipe_transfer
*_transfer
,
867 const struct pipe_box
*box
)
869 struct galahad_context
*glhd_context
= galahad_context(_context
);
870 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
871 struct pipe_context
*context
= glhd_context
->pipe
;
872 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
874 context
->transfer_flush_region(context
,
881 galahad_context_transfer_unmap(struct pipe_context
*_context
,
882 struct pipe_transfer
*_transfer
)
884 struct galahad_context
*glhd_context
= galahad_context(_context
);
885 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
886 struct pipe_context
*context
= glhd_context
->pipe
;
887 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
889 context
->transfer_unmap(context
,
895 galahad_context_transfer_inline_write(struct pipe_context
*_context
,
896 struct pipe_resource
*_resource
,
897 struct pipe_subresource sr
,
899 const struct pipe_box
*box
,
902 unsigned slice_stride
)
904 struct galahad_context
*glhd_context
= galahad_context(_context
);
905 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
906 struct pipe_context
*context
= glhd_context
->pipe
;
907 struct pipe_resource
*resource
= glhd_resource
->resource
;
909 context
->transfer_inline_write(context
,
920 struct pipe_context
*
921 galahad_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
923 struct galahad_context
*glhd_pipe
;
924 (void)galahad_screen(_screen
);
926 glhd_pipe
= CALLOC_STRUCT(galahad_context
);
931 glhd_pipe
->base
.winsys
= NULL
;
932 glhd_pipe
->base
.screen
= _screen
;
933 glhd_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
934 glhd_pipe
->base
.draw
= NULL
;
936 glhd_pipe
->base
.destroy
= galahad_destroy
;
937 glhd_pipe
->base
.draw_arrays
= galahad_draw_arrays
;
938 glhd_pipe
->base
.draw_elements
= galahad_draw_elements
;
939 glhd_pipe
->base
.draw_range_elements
= galahad_draw_range_elements
;
940 glhd_pipe
->base
.create_query
= galahad_create_query
;
941 glhd_pipe
->base
.destroy_query
= galahad_destroy_query
;
942 glhd_pipe
->base
.begin_query
= galahad_begin_query
;
943 glhd_pipe
->base
.end_query
= galahad_end_query
;
944 glhd_pipe
->base
.get_query_result
= galahad_get_query_result
;
945 glhd_pipe
->base
.create_blend_state
= galahad_create_blend_state
;
946 glhd_pipe
->base
.bind_blend_state
= galahad_bind_blend_state
;
947 glhd_pipe
->base
.delete_blend_state
= galahad_delete_blend_state
;
948 glhd_pipe
->base
.create_sampler_state
= galahad_create_sampler_state
;
949 glhd_pipe
->base
.bind_fragment_sampler_states
= galahad_bind_fragment_sampler_states
;
950 glhd_pipe
->base
.bind_vertex_sampler_states
= galahad_bind_vertex_sampler_states
;
951 glhd_pipe
->base
.delete_sampler_state
= galahad_delete_sampler_state
;
952 glhd_pipe
->base
.create_rasterizer_state
= galahad_create_rasterizer_state
;
953 glhd_pipe
->base
.bind_rasterizer_state
= galahad_bind_rasterizer_state
;
954 glhd_pipe
->base
.delete_rasterizer_state
= galahad_delete_rasterizer_state
;
955 glhd_pipe
->base
.create_depth_stencil_alpha_state
= galahad_create_depth_stencil_alpha_state
;
956 glhd_pipe
->base
.bind_depth_stencil_alpha_state
= galahad_bind_depth_stencil_alpha_state
;
957 glhd_pipe
->base
.delete_depth_stencil_alpha_state
= galahad_delete_depth_stencil_alpha_state
;
958 glhd_pipe
->base
.create_fs_state
= galahad_create_fs_state
;
959 glhd_pipe
->base
.bind_fs_state
= galahad_bind_fs_state
;
960 glhd_pipe
->base
.delete_fs_state
= galahad_delete_fs_state
;
961 glhd_pipe
->base
.create_vs_state
= galahad_create_vs_state
;
962 glhd_pipe
->base
.bind_vs_state
= galahad_bind_vs_state
;
963 glhd_pipe
->base
.delete_vs_state
= galahad_delete_vs_state
;
964 glhd_pipe
->base
.create_vertex_elements_state
= galahad_create_vertex_elements_state
;
965 glhd_pipe
->base
.bind_vertex_elements_state
= galahad_bind_vertex_elements_state
;
966 glhd_pipe
->base
.delete_vertex_elements_state
= galahad_delete_vertex_elements_state
;
967 glhd_pipe
->base
.set_blend_color
= galahad_set_blend_color
;
968 glhd_pipe
->base
.set_stencil_ref
= galahad_set_stencil_ref
;
969 glhd_pipe
->base
.set_clip_state
= galahad_set_clip_state
;
970 glhd_pipe
->base
.set_sample_mask
= galahad_set_sample_mask
;
971 glhd_pipe
->base
.set_constant_buffer
= galahad_set_constant_buffer
;
972 glhd_pipe
->base
.set_framebuffer_state
= galahad_set_framebuffer_state
;
973 glhd_pipe
->base
.set_polygon_stipple
= galahad_set_polygon_stipple
;
974 glhd_pipe
->base
.set_scissor_state
= galahad_set_scissor_state
;
975 glhd_pipe
->base
.set_viewport_state
= galahad_set_viewport_state
;
976 glhd_pipe
->base
.set_fragment_sampler_views
= galahad_set_fragment_sampler_views
;
977 glhd_pipe
->base
.set_vertex_sampler_views
= galahad_set_vertex_sampler_views
;
978 glhd_pipe
->base
.set_vertex_buffers
= galahad_set_vertex_buffers
;
979 glhd_pipe
->base
.resource_copy_region
= galahad_resource_copy_region
;
980 glhd_pipe
->base
.clear
= galahad_clear
;
981 glhd_pipe
->base
.clear_render_target
= galahad_clear_render_target
;
982 glhd_pipe
->base
.clear_depth_stencil
= galahad_clear_depth_stencil
;
983 glhd_pipe
->base
.flush
= galahad_flush
;
984 glhd_pipe
->base
.is_resource_referenced
= galahad_is_resource_referenced
;
985 glhd_pipe
->base
.create_sampler_view
= galahad_context_create_sampler_view
;
986 glhd_pipe
->base
.sampler_view_destroy
= galahad_context_sampler_view_destroy
;
987 glhd_pipe
->base
.get_transfer
= galahad_context_get_transfer
;
988 glhd_pipe
->base
.transfer_destroy
= galahad_context_transfer_destroy
;
989 glhd_pipe
->base
.transfer_map
= galahad_context_transfer_map
;
990 glhd_pipe
->base
.transfer_unmap
= galahad_context_transfer_unmap
;
991 glhd_pipe
->base
.transfer_flush_region
= galahad_context_transfer_flush_region
;
992 glhd_pipe
->base
.transfer_inline_write
= galahad_context_transfer_inline_write
;
994 glhd_pipe
->pipe
= pipe
;
996 return &glhd_pipe
->base
;