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
,
116 galahad_draw_vbo(struct pipe_context
*_pipe
,
117 const struct pipe_draw_info
*info
)
119 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
120 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
122 pipe
->draw_vbo(pipe
, info
);
125 static struct pipe_query
*
126 galahad_create_query(struct pipe_context
*_pipe
,
129 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
130 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
132 if (query_type
== PIPE_QUERY_OCCLUSION_COUNTER
&&
133 !pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_OCCLUSION_QUERY
)) {
134 glhd_error("Occlusion query requested but not supported");
137 if (query_type
== PIPE_QUERY_TIME_ELAPSED
&&
138 !pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_TIMER_QUERY
)) {
139 glhd_error("Timer query requested but not supported");
142 return pipe
->create_query(pipe
,
147 galahad_destroy_query(struct pipe_context
*_pipe
,
148 struct pipe_query
*query
)
150 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
151 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
153 pipe
->destroy_query(pipe
,
158 galahad_begin_query(struct pipe_context
*_pipe
,
159 struct pipe_query
*query
)
161 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
162 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
164 pipe
->begin_query(pipe
,
169 galahad_end_query(struct pipe_context
*_pipe
,
170 struct pipe_query
*query
)
172 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
173 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
175 pipe
->end_query(pipe
,
180 galahad_get_query_result(struct pipe_context
*_pipe
,
181 struct pipe_query
*query
,
185 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
186 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
188 return pipe
->get_query_result(pipe
,
195 galahad_create_blend_state(struct pipe_context
*_pipe
,
196 const struct pipe_blend_state
*blend
)
198 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
199 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
201 if (blend
->logicop_enable
) {
202 if (blend
->rt
[0].blend_enable
) {
203 glhd_warn("Blending enabled for render target 0, but logicops "
208 return pipe
->create_blend_state(pipe
,
213 galahad_bind_blend_state(struct pipe_context
*_pipe
,
216 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
217 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
219 pipe
->bind_blend_state(pipe
,
224 galahad_delete_blend_state(struct pipe_context
*_pipe
,
227 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
228 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
230 pipe
->delete_blend_state(pipe
,
235 galahad_create_sampler_state(struct pipe_context
*_pipe
,
236 const struct pipe_sampler_state
*sampler
)
238 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
239 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
241 return pipe
->create_sampler_state(pipe
,
246 galahad_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
247 unsigned num_samplers
,
250 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
251 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
253 pipe
->bind_fragment_sampler_states(pipe
,
259 galahad_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
260 unsigned num_samplers
,
263 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
264 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
266 pipe
->bind_vertex_sampler_states(pipe
,
272 galahad_delete_sampler_state(struct pipe_context
*_pipe
,
275 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
276 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
278 pipe
->delete_sampler_state(pipe
,
283 galahad_create_rasterizer_state(struct pipe_context
*_pipe
,
284 const struct pipe_rasterizer_state
*rasterizer
)
286 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
287 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
289 if (rasterizer
->point_quad_rasterization
) {
290 if (rasterizer
->point_smooth
) {
291 glhd_warn("Point smoothing requested but ignored");
294 if (rasterizer
->sprite_coord_enable
) {
295 glhd_warn("Point sprites requested but ignored");
299 return pipe
->create_rasterizer_state(pipe
,
304 galahad_bind_rasterizer_state(struct pipe_context
*_pipe
,
307 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
308 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
310 pipe
->bind_rasterizer_state(pipe
,
315 galahad_delete_rasterizer_state(struct pipe_context
*_pipe
,
318 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
319 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
321 pipe
->delete_rasterizer_state(pipe
,
326 galahad_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
327 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
329 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
330 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
332 return pipe
->create_depth_stencil_alpha_state(pipe
,
333 depth_stencil_alpha
);
337 galahad_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
338 void *depth_stencil_alpha
)
340 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
341 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
343 pipe
->bind_depth_stencil_alpha_state(pipe
,
344 depth_stencil_alpha
);
348 galahad_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
349 void *depth_stencil_alpha
)
351 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
352 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
354 pipe
->delete_depth_stencil_alpha_state(pipe
,
355 depth_stencil_alpha
);
359 galahad_create_fs_state(struct pipe_context
*_pipe
,
360 const struct pipe_shader_state
*fs
)
362 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
363 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
365 return pipe
->create_fs_state(pipe
,
370 galahad_bind_fs_state(struct pipe_context
*_pipe
,
373 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
374 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
376 pipe
->bind_fs_state(pipe
,
381 galahad_delete_fs_state(struct pipe_context
*_pipe
,
384 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
385 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
387 pipe
->delete_fs_state(pipe
,
392 galahad_create_vs_state(struct pipe_context
*_pipe
,
393 const struct pipe_shader_state
*vs
)
395 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
396 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
398 return pipe
->create_vs_state(pipe
,
403 galahad_bind_vs_state(struct pipe_context
*_pipe
,
406 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
407 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
409 pipe
->bind_vs_state(pipe
,
414 galahad_delete_vs_state(struct pipe_context
*_pipe
,
417 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
418 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
420 pipe
->delete_vs_state(pipe
,
426 galahad_create_vertex_elements_state(struct pipe_context
*_pipe
,
427 unsigned num_elements
,
428 const struct pipe_vertex_element
*vertex_elements
)
430 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
431 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
433 return pipe
->create_vertex_elements_state(pipe
,
439 galahad_bind_vertex_elements_state(struct pipe_context
*_pipe
,
442 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
443 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
445 pipe
->bind_vertex_elements_state(pipe
,
450 galahad_delete_vertex_elements_state(struct pipe_context
*_pipe
,
453 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
454 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
456 pipe
->delete_vertex_elements_state(pipe
,
461 galahad_set_blend_color(struct pipe_context
*_pipe
,
462 const struct pipe_blend_color
*blend_color
)
464 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
465 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
467 pipe
->set_blend_color(pipe
,
472 galahad_set_stencil_ref(struct pipe_context
*_pipe
,
473 const struct pipe_stencil_ref
*stencil_ref
)
475 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
476 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
478 pipe
->set_stencil_ref(pipe
,
483 galahad_set_clip_state(struct pipe_context
*_pipe
,
484 const struct pipe_clip_state
*clip
)
486 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
487 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
489 pipe
->set_clip_state(pipe
,
494 galahad_set_sample_mask(struct pipe_context
*_pipe
,
495 unsigned sample_mask
)
497 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
498 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
500 pipe
->set_sample_mask(pipe
,
505 galahad_set_constant_buffer(struct pipe_context
*_pipe
,
508 struct pipe_resource
*_resource
)
510 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
511 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
512 struct pipe_resource
*unwrapped_resource
;
513 struct pipe_resource
*resource
= NULL
;
515 /* XXX hmm? unwrap the input state */
517 unwrapped_resource
= galahad_resource_unwrap(_resource
);
518 resource
= unwrapped_resource
;
521 pipe
->set_constant_buffer(pipe
,
528 galahad_set_framebuffer_state(struct pipe_context
*_pipe
,
529 const struct pipe_framebuffer_state
*_state
)
531 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
532 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
533 struct pipe_framebuffer_state unwrapped_state
;
534 struct pipe_framebuffer_state
*state
= NULL
;
537 if (_state
->nr_cbufs
> PIPE_MAX_COLOR_BUFS
) {
538 glhd_error("%d render targets bound, but only %d are permitted by API",
539 _state
->nr_cbufs
, PIPE_MAX_COLOR_BUFS
);
540 } else if (_state
->nr_cbufs
>
541 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
)) {
542 glhd_warn("%d render targets bound, but only %d are supported",
544 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
));
547 /* unwrap the input state */
549 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
550 for(i
= 0; i
< _state
->nr_cbufs
; i
++)
551 unwrapped_state
.cbufs
[i
] = galahad_surface_unwrap(_state
->cbufs
[i
]);
552 for (; i
< PIPE_MAX_COLOR_BUFS
; i
++)
553 unwrapped_state
.cbufs
[i
] = NULL
;
554 unwrapped_state
.zsbuf
= galahad_surface_unwrap(_state
->zsbuf
);
555 state
= &unwrapped_state
;
558 pipe
->set_framebuffer_state(pipe
,
563 galahad_set_polygon_stipple(struct pipe_context
*_pipe
,
564 const struct pipe_poly_stipple
*poly_stipple
)
566 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
567 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
569 pipe
->set_polygon_stipple(pipe
,
574 galahad_set_scissor_state(struct pipe_context
*_pipe
,
575 const struct pipe_scissor_state
*scissor
)
577 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
578 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
580 pipe
->set_scissor_state(pipe
,
585 galahad_set_viewport_state(struct pipe_context
*_pipe
,
586 const struct pipe_viewport_state
*viewport
)
588 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
589 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
591 pipe
->set_viewport_state(pipe
,
596 galahad_set_fragment_sampler_views(struct pipe_context
*_pipe
,
598 struct pipe_sampler_view
**_views
)
600 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
601 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
602 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
603 struct pipe_sampler_view
**views
= NULL
;
607 for (i
= 0; i
< num
; i
++)
608 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
609 for (; i
< PIPE_MAX_SAMPLERS
; i
++)
610 unwrapped_views
[i
] = NULL
;
612 views
= unwrapped_views
;
615 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
619 galahad_set_vertex_sampler_views(struct pipe_context
*_pipe
,
621 struct pipe_sampler_view
**_views
)
623 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
624 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
625 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
626 struct pipe_sampler_view
**views
= NULL
;
630 for (i
= 0; i
< num
; i
++)
631 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
632 for (; i
< PIPE_MAX_VERTEX_SAMPLERS
; i
++)
633 unwrapped_views
[i
] = NULL
;
635 views
= unwrapped_views
;
638 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
642 galahad_set_vertex_buffers(struct pipe_context
*_pipe
,
643 unsigned num_buffers
,
644 const struct pipe_vertex_buffer
*_buffers
)
646 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
647 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
648 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
649 struct pipe_vertex_buffer
*buffers
= NULL
;
653 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
654 for (i
= 0; i
< num_buffers
; i
++)
655 unwrapped_buffers
[i
].buffer
= galahad_resource_unwrap(_buffers
[i
].buffer
);
656 buffers
= unwrapped_buffers
;
659 pipe
->set_vertex_buffers(pipe
,
665 galahad_set_index_buffer(struct pipe_context
*_pipe
,
666 const struct pipe_index_buffer
*_ib
)
668 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
669 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
670 struct pipe_index_buffer unwrapped_ib
, *ib
= NULL
;
673 switch (_ib
->index_size
) {
679 glhd_warn("index buffer %p has unrecognized index size %d",
680 _ib
->buffer
, _ib
->index_size
);
684 else if (_ib
->offset
|| _ib
->index_size
) {
685 glhd_warn("non-indexed state with index offset %d and index size %d",
686 _ib
->offset
, _ib
->index_size
);
691 unwrapped_ib
.buffer
= galahad_resource_unwrap(_ib
->buffer
);
695 pipe
->set_index_buffer(pipe
, ib
);
699 galahad_resource_copy_region(struct pipe_context
*_pipe
,
700 struct pipe_resource
*_dst
,
701 struct pipe_subresource subdst
,
705 struct pipe_resource
*_src
,
706 struct pipe_subresource subsrc
,
713 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
714 struct galahad_resource
*glhd_resource_dst
= galahad_resource(_dst
);
715 struct galahad_resource
*glhd_resource_src
= galahad_resource(_src
);
716 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
717 struct pipe_resource
*dst
= glhd_resource_dst
->resource
;
718 struct pipe_resource
*src
= glhd_resource_src
->resource
;
720 if (_dst
->format
!= _src
->format
) {
721 glhd_warn("Format mismatch: Source is %s, destination is %s",
722 util_format_short_name(_src
->format
),
723 util_format_short_name(_dst
->format
));
726 pipe
->resource_copy_region(pipe
,
742 galahad_clear(struct pipe_context
*_pipe
,
748 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
749 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
759 galahad_clear_render_target(struct pipe_context
*_pipe
,
760 struct pipe_surface
*_dst
,
762 unsigned dstx
, unsigned dsty
,
763 unsigned width
, unsigned height
)
765 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
766 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
767 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
768 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
770 pipe
->clear_render_target(pipe
,
779 galahad_clear_depth_stencil(struct pipe_context
*_pipe
,
780 struct pipe_surface
*_dst
,
781 unsigned clear_flags
,
784 unsigned dstx
, unsigned dsty
,
785 unsigned width
, unsigned height
)
787 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
788 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
789 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
790 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
792 pipe
->clear_depth_stencil(pipe
,
805 galahad_flush(struct pipe_context
*_pipe
,
807 struct pipe_fence_handle
**fence
)
809 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
810 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
818 galahad_is_resource_referenced(struct pipe_context
*_pipe
,
819 struct pipe_resource
*_resource
,
823 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
824 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
825 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
826 struct pipe_resource
*resource
= glhd_resource
->resource
;
828 return pipe
->is_resource_referenced(pipe
,
834 static struct pipe_sampler_view
*
835 galahad_context_create_sampler_view(struct pipe_context
*_pipe
,
836 struct pipe_resource
*_resource
,
837 const struct pipe_sampler_view
*templ
)
839 struct galahad_context
*glhd_context
= galahad_context(_pipe
);
840 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
841 struct pipe_context
*pipe
= glhd_context
->pipe
;
842 struct pipe_resource
*resource
= glhd_resource
->resource
;
843 struct pipe_sampler_view
*result
;
845 result
= pipe
->create_sampler_view(pipe
,
850 return galahad_sampler_view_create(glhd_context
, glhd_resource
, result
);
855 galahad_context_sampler_view_destroy(struct pipe_context
*_pipe
,
856 struct pipe_sampler_view
*_view
)
858 galahad_sampler_view_destroy(galahad_context(_pipe
),
859 galahad_sampler_view(_view
));
862 static struct pipe_transfer
*
863 galahad_context_get_transfer(struct pipe_context
*_context
,
864 struct pipe_resource
*_resource
,
865 struct pipe_subresource sr
,
867 const struct pipe_box
*box
)
869 struct galahad_context
*glhd_context
= galahad_context(_context
);
870 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
871 struct pipe_context
*context
= glhd_context
->pipe
;
872 struct pipe_resource
*resource
= glhd_resource
->resource
;
873 struct pipe_transfer
*result
;
875 result
= context
->get_transfer(context
,
882 return galahad_transfer_create(glhd_context
, glhd_resource
, result
);
887 galahad_context_transfer_destroy(struct pipe_context
*_pipe
,
888 struct pipe_transfer
*_transfer
)
890 galahad_transfer_destroy(galahad_context(_pipe
),
891 galahad_transfer(_transfer
));
895 galahad_context_transfer_map(struct pipe_context
*_context
,
896 struct pipe_transfer
*_transfer
)
898 struct galahad_context
*glhd_context
= galahad_context(_context
);
899 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
900 struct pipe_context
*context
= glhd_context
->pipe
;
901 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
903 return context
->transfer_map(context
,
910 galahad_context_transfer_flush_region(struct pipe_context
*_context
,
911 struct pipe_transfer
*_transfer
,
912 const struct pipe_box
*box
)
914 struct galahad_context
*glhd_context
= galahad_context(_context
);
915 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
916 struct pipe_context
*context
= glhd_context
->pipe
;
917 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
919 context
->transfer_flush_region(context
,
926 galahad_context_transfer_unmap(struct pipe_context
*_context
,
927 struct pipe_transfer
*_transfer
)
929 struct galahad_context
*glhd_context
= galahad_context(_context
);
930 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
931 struct pipe_context
*context
= glhd_context
->pipe
;
932 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
934 context
->transfer_unmap(context
,
940 galahad_context_transfer_inline_write(struct pipe_context
*_context
,
941 struct pipe_resource
*_resource
,
942 struct pipe_subresource sr
,
944 const struct pipe_box
*box
,
947 unsigned slice_stride
)
949 struct galahad_context
*glhd_context
= galahad_context(_context
);
950 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
951 struct pipe_context
*context
= glhd_context
->pipe
;
952 struct pipe_resource
*resource
= glhd_resource
->resource
;
954 context
->transfer_inline_write(context
,
965 struct pipe_context
*
966 galahad_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
968 struct galahad_context
*glhd_pipe
;
969 (void)galahad_screen(_screen
);
971 glhd_pipe
= CALLOC_STRUCT(galahad_context
);
976 glhd_pipe
->base
.winsys
= NULL
;
977 glhd_pipe
->base
.screen
= _screen
;
978 glhd_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
979 glhd_pipe
->base
.draw
= NULL
;
981 glhd_pipe
->base
.destroy
= galahad_destroy
;
982 glhd_pipe
->base
.draw_arrays
= galahad_draw_arrays
;
983 glhd_pipe
->base
.draw_elements
= galahad_draw_elements
;
984 glhd_pipe
->base
.draw_range_elements
= galahad_draw_range_elements
;
985 glhd_pipe
->base
.draw_vbo
= galahad_draw_vbo
;
986 glhd_pipe
->base
.create_query
= galahad_create_query
;
987 glhd_pipe
->base
.destroy_query
= galahad_destroy_query
;
988 glhd_pipe
->base
.begin_query
= galahad_begin_query
;
989 glhd_pipe
->base
.end_query
= galahad_end_query
;
990 glhd_pipe
->base
.get_query_result
= galahad_get_query_result
;
991 glhd_pipe
->base
.create_blend_state
= galahad_create_blend_state
;
992 glhd_pipe
->base
.bind_blend_state
= galahad_bind_blend_state
;
993 glhd_pipe
->base
.delete_blend_state
= galahad_delete_blend_state
;
994 glhd_pipe
->base
.create_sampler_state
= galahad_create_sampler_state
;
995 glhd_pipe
->base
.bind_fragment_sampler_states
= galahad_bind_fragment_sampler_states
;
996 glhd_pipe
->base
.bind_vertex_sampler_states
= galahad_bind_vertex_sampler_states
;
997 glhd_pipe
->base
.delete_sampler_state
= galahad_delete_sampler_state
;
998 glhd_pipe
->base
.create_rasterizer_state
= galahad_create_rasterizer_state
;
999 glhd_pipe
->base
.bind_rasterizer_state
= galahad_bind_rasterizer_state
;
1000 glhd_pipe
->base
.delete_rasterizer_state
= galahad_delete_rasterizer_state
;
1001 glhd_pipe
->base
.create_depth_stencil_alpha_state
= galahad_create_depth_stencil_alpha_state
;
1002 glhd_pipe
->base
.bind_depth_stencil_alpha_state
= galahad_bind_depth_stencil_alpha_state
;
1003 glhd_pipe
->base
.delete_depth_stencil_alpha_state
= galahad_delete_depth_stencil_alpha_state
;
1004 glhd_pipe
->base
.create_fs_state
= galahad_create_fs_state
;
1005 glhd_pipe
->base
.bind_fs_state
= galahad_bind_fs_state
;
1006 glhd_pipe
->base
.delete_fs_state
= galahad_delete_fs_state
;
1007 glhd_pipe
->base
.create_vs_state
= galahad_create_vs_state
;
1008 glhd_pipe
->base
.bind_vs_state
= galahad_bind_vs_state
;
1009 glhd_pipe
->base
.delete_vs_state
= galahad_delete_vs_state
;
1010 glhd_pipe
->base
.create_vertex_elements_state
= galahad_create_vertex_elements_state
;
1011 glhd_pipe
->base
.bind_vertex_elements_state
= galahad_bind_vertex_elements_state
;
1012 glhd_pipe
->base
.delete_vertex_elements_state
= galahad_delete_vertex_elements_state
;
1013 glhd_pipe
->base
.set_blend_color
= galahad_set_blend_color
;
1014 glhd_pipe
->base
.set_stencil_ref
= galahad_set_stencil_ref
;
1015 glhd_pipe
->base
.set_clip_state
= galahad_set_clip_state
;
1016 glhd_pipe
->base
.set_sample_mask
= galahad_set_sample_mask
;
1017 glhd_pipe
->base
.set_constant_buffer
= galahad_set_constant_buffer
;
1018 glhd_pipe
->base
.set_framebuffer_state
= galahad_set_framebuffer_state
;
1019 glhd_pipe
->base
.set_polygon_stipple
= galahad_set_polygon_stipple
;
1020 glhd_pipe
->base
.set_scissor_state
= galahad_set_scissor_state
;
1021 glhd_pipe
->base
.set_viewport_state
= galahad_set_viewport_state
;
1022 glhd_pipe
->base
.set_fragment_sampler_views
= galahad_set_fragment_sampler_views
;
1023 glhd_pipe
->base
.set_vertex_sampler_views
= galahad_set_vertex_sampler_views
;
1024 glhd_pipe
->base
.set_vertex_buffers
= galahad_set_vertex_buffers
;
1025 glhd_pipe
->base
.set_index_buffer
= galahad_set_index_buffer
;
1026 glhd_pipe
->base
.resource_copy_region
= galahad_resource_copy_region
;
1027 glhd_pipe
->base
.clear
= galahad_clear
;
1028 glhd_pipe
->base
.clear_render_target
= galahad_clear_render_target
;
1029 glhd_pipe
->base
.clear_depth_stencil
= galahad_clear_depth_stencil
;
1030 glhd_pipe
->base
.flush
= galahad_flush
;
1031 glhd_pipe
->base
.is_resource_referenced
= galahad_is_resource_referenced
;
1032 glhd_pipe
->base
.create_sampler_view
= galahad_context_create_sampler_view
;
1033 glhd_pipe
->base
.sampler_view_destroy
= galahad_context_sampler_view_destroy
;
1034 glhd_pipe
->base
.get_transfer
= galahad_context_get_transfer
;
1035 glhd_pipe
->base
.transfer_destroy
= galahad_context_transfer_destroy
;
1036 glhd_pipe
->base
.transfer_map
= galahad_context_transfer_map
;
1037 glhd_pipe
->base
.transfer_unmap
= galahad_context_transfer_unmap
;
1038 glhd_pipe
->base
.transfer_flush_region
= galahad_context_transfer_flush_region
;
1039 glhd_pipe
->base
.transfer_inline_write
= galahad_context_transfer_inline_write
;
1041 glhd_pipe
->pipe
= pipe
;
1043 return &glhd_pipe
->base
;