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_vbo(struct pipe_context
*_pipe
,
52 const struct pipe_draw_info
*info
)
54 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
55 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
57 pipe
->draw_vbo(pipe
, info
);
60 static struct pipe_query
*
61 galahad_create_query(struct pipe_context
*_pipe
,
64 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
65 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
67 if (query_type
== PIPE_QUERY_OCCLUSION_COUNTER
&&
68 !pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_OCCLUSION_QUERY
)) {
69 glhd_error("Occlusion query requested but not supported");
72 if (query_type
== PIPE_QUERY_TIME_ELAPSED
&&
73 !pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_TIMER_QUERY
)) {
74 glhd_error("Timer query requested but not supported");
77 return pipe
->create_query(pipe
,
82 galahad_destroy_query(struct pipe_context
*_pipe
,
83 struct pipe_query
*query
)
85 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
86 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
88 pipe
->destroy_query(pipe
,
93 galahad_begin_query(struct pipe_context
*_pipe
,
94 struct pipe_query
*query
)
96 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
97 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
99 pipe
->begin_query(pipe
,
104 galahad_end_query(struct pipe_context
*_pipe
,
105 struct pipe_query
*query
)
107 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
108 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
110 pipe
->end_query(pipe
,
115 galahad_get_query_result(struct pipe_context
*_pipe
,
116 struct pipe_query
*query
,
120 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
121 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
123 return pipe
->get_query_result(pipe
,
130 galahad_create_blend_state(struct pipe_context
*_pipe
,
131 const struct pipe_blend_state
*blend
)
133 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
134 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
136 if (blend
->logicop_enable
) {
137 if (blend
->rt
[0].blend_enable
) {
138 glhd_warn("Blending enabled for render target 0, but logicops "
143 return pipe
->create_blend_state(pipe
,
148 galahad_bind_blend_state(struct pipe_context
*_pipe
,
151 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
152 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
154 pipe
->bind_blend_state(pipe
,
159 galahad_delete_blend_state(struct pipe_context
*_pipe
,
162 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
163 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
165 pipe
->delete_blend_state(pipe
,
170 galahad_create_sampler_state(struct pipe_context
*_pipe
,
171 const struct pipe_sampler_state
*sampler
)
173 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
174 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
176 return pipe
->create_sampler_state(pipe
,
181 galahad_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
182 unsigned num_samplers
,
185 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
186 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
188 if (num_samplers
> PIPE_MAX_SAMPLERS
) {
189 glhd_error("%u fragment samplers requested, "
190 "but only %u are permitted by API",
191 num_samplers
, PIPE_MAX_SAMPLERS
);
194 pipe
->bind_fragment_sampler_states(pipe
,
200 galahad_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
201 unsigned num_samplers
,
204 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
205 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
207 if (num_samplers
> PIPE_MAX_VERTEX_SAMPLERS
) {
208 glhd_error("%u vertex samplers requested, "
209 "but only %u are permitted by API",
210 num_samplers
, PIPE_MAX_VERTEX_SAMPLERS
);
213 pipe
->bind_vertex_sampler_states(pipe
,
219 galahad_delete_sampler_state(struct pipe_context
*_pipe
,
222 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
223 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
225 pipe
->delete_sampler_state(pipe
,
230 galahad_create_rasterizer_state(struct pipe_context
*_pipe
,
231 const struct pipe_rasterizer_state
*rasterizer
)
233 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
234 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
236 if (rasterizer
->point_quad_rasterization
) {
237 if (rasterizer
->point_smooth
) {
238 glhd_warn("Point smoothing requested but ignored");
241 if (rasterizer
->sprite_coord_enable
) {
242 glhd_warn("Point sprites requested but ignored");
246 return pipe
->create_rasterizer_state(pipe
,
251 galahad_bind_rasterizer_state(struct pipe_context
*_pipe
,
254 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
255 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
257 pipe
->bind_rasterizer_state(pipe
,
262 galahad_delete_rasterizer_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_rasterizer_state(pipe
,
273 galahad_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
274 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
276 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
277 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
279 return pipe
->create_depth_stencil_alpha_state(pipe
,
280 depth_stencil_alpha
);
284 galahad_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
285 void *depth_stencil_alpha
)
287 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
288 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
290 pipe
->bind_depth_stencil_alpha_state(pipe
,
291 depth_stencil_alpha
);
295 galahad_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
296 void *depth_stencil_alpha
)
298 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
299 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
301 pipe
->delete_depth_stencil_alpha_state(pipe
,
302 depth_stencil_alpha
);
306 galahad_create_fs_state(struct pipe_context
*_pipe
,
307 const struct pipe_shader_state
*fs
)
309 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
310 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
312 return pipe
->create_fs_state(pipe
,
317 galahad_bind_fs_state(struct pipe_context
*_pipe
,
320 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
321 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
323 pipe
->bind_fs_state(pipe
,
328 galahad_delete_fs_state(struct pipe_context
*_pipe
,
331 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
332 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
334 pipe
->delete_fs_state(pipe
,
339 galahad_create_vs_state(struct pipe_context
*_pipe
,
340 const struct pipe_shader_state
*vs
)
342 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
343 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
345 return pipe
->create_vs_state(pipe
,
350 galahad_bind_vs_state(struct pipe_context
*_pipe
,
353 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
354 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
356 pipe
->bind_vs_state(pipe
,
361 galahad_delete_vs_state(struct pipe_context
*_pipe
,
364 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
365 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
367 pipe
->delete_vs_state(pipe
,
373 galahad_create_vertex_elements_state(struct pipe_context
*_pipe
,
374 unsigned num_elements
,
375 const struct pipe_vertex_element
*vertex_elements
)
377 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
378 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
380 return pipe
->create_vertex_elements_state(pipe
,
386 galahad_bind_vertex_elements_state(struct pipe_context
*_pipe
,
389 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
390 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
392 pipe
->bind_vertex_elements_state(pipe
,
397 galahad_delete_vertex_elements_state(struct pipe_context
*_pipe
,
400 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
401 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
403 pipe
->delete_vertex_elements_state(pipe
,
408 galahad_set_blend_color(struct pipe_context
*_pipe
,
409 const struct pipe_blend_color
*blend_color
)
411 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
412 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
414 pipe
->set_blend_color(pipe
,
419 galahad_set_stencil_ref(struct pipe_context
*_pipe
,
420 const struct pipe_stencil_ref
*stencil_ref
)
422 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
423 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
425 pipe
->set_stencil_ref(pipe
,
430 galahad_set_clip_state(struct pipe_context
*_pipe
,
431 const struct pipe_clip_state
*clip
)
433 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
434 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
436 pipe
->set_clip_state(pipe
,
441 galahad_set_sample_mask(struct pipe_context
*_pipe
,
442 unsigned sample_mask
)
444 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
445 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
447 pipe
->set_sample_mask(pipe
,
452 galahad_set_constant_buffer(struct pipe_context
*_pipe
,
455 struct pipe_resource
*_resource
)
457 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
458 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
459 struct pipe_resource
*unwrapped_resource
;
460 struct pipe_resource
*resource
= NULL
;
462 if (shader
>= PIPE_SHADER_TYPES
) {
463 glhd_error("Unknown shader type %u", shader
);
468 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_CONST_BUFFERS
)) {
469 glhd_error("Access to constant buffer %u requested, "
470 "but only %d are supported",
472 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_CONST_BUFFERS
));
475 /* XXX hmm? unwrap the input state */
477 unwrapped_resource
= galahad_resource_unwrap(_resource
);
478 resource
= unwrapped_resource
;
481 pipe
->set_constant_buffer(pipe
,
488 galahad_set_framebuffer_state(struct pipe_context
*_pipe
,
489 const struct pipe_framebuffer_state
*_state
)
491 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
492 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
493 struct pipe_framebuffer_state unwrapped_state
;
494 struct pipe_framebuffer_state
*state
= NULL
;
497 if (_state
->nr_cbufs
> PIPE_MAX_COLOR_BUFS
) {
498 glhd_error("%d render targets bound, but only %d are permitted by API",
499 _state
->nr_cbufs
, PIPE_MAX_COLOR_BUFS
);
500 } else if (_state
->nr_cbufs
>
501 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
)) {
502 glhd_warn("%d render targets bound, but only %d are supported",
504 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
));
507 /* unwrap the input state */
509 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
510 for(i
= 0; i
< _state
->nr_cbufs
; i
++)
511 unwrapped_state
.cbufs
[i
] = galahad_surface_unwrap(_state
->cbufs
[i
]);
512 for (; i
< PIPE_MAX_COLOR_BUFS
; i
++)
513 unwrapped_state
.cbufs
[i
] = NULL
;
514 unwrapped_state
.zsbuf
= galahad_surface_unwrap(_state
->zsbuf
);
515 state
= &unwrapped_state
;
518 pipe
->set_framebuffer_state(pipe
,
523 galahad_set_polygon_stipple(struct pipe_context
*_pipe
,
524 const struct pipe_poly_stipple
*poly_stipple
)
526 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
527 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
529 pipe
->set_polygon_stipple(pipe
,
534 galahad_set_scissor_state(struct pipe_context
*_pipe
,
535 const struct pipe_scissor_state
*scissor
)
537 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
538 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
540 pipe
->set_scissor_state(pipe
,
545 galahad_set_viewport_state(struct pipe_context
*_pipe
,
546 const struct pipe_viewport_state
*viewport
)
548 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
549 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
551 pipe
->set_viewport_state(pipe
,
556 galahad_set_fragment_sampler_views(struct pipe_context
*_pipe
,
558 struct pipe_sampler_view
**_views
)
560 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
561 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
562 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
563 struct pipe_sampler_view
**views
= NULL
;
567 for (i
= 0; i
< num
; i
++)
568 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
569 for (; i
< PIPE_MAX_SAMPLERS
; i
++)
570 unwrapped_views
[i
] = NULL
;
572 views
= unwrapped_views
;
575 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
579 galahad_set_vertex_sampler_views(struct pipe_context
*_pipe
,
581 struct pipe_sampler_view
**_views
)
583 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
584 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
585 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
586 struct pipe_sampler_view
**views
= NULL
;
590 for (i
= 0; i
< num
; i
++)
591 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
592 for (; i
< PIPE_MAX_VERTEX_SAMPLERS
; i
++)
593 unwrapped_views
[i
] = NULL
;
595 views
= unwrapped_views
;
598 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
602 galahad_set_vertex_buffers(struct pipe_context
*_pipe
,
603 unsigned num_buffers
,
604 const struct pipe_vertex_buffer
*_buffers
)
606 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
607 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
608 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
609 struct pipe_vertex_buffer
*buffers
= NULL
;
613 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
614 for (i
= 0; i
< num_buffers
; i
++)
615 unwrapped_buffers
[i
].buffer
= galahad_resource_unwrap(_buffers
[i
].buffer
);
616 buffers
= unwrapped_buffers
;
619 pipe
->set_vertex_buffers(pipe
,
625 galahad_set_index_buffer(struct pipe_context
*_pipe
,
626 const struct pipe_index_buffer
*_ib
)
628 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
629 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
630 struct pipe_index_buffer unwrapped_ib
, *ib
= NULL
;
633 switch (_ib
->index_size
) {
639 glhd_warn("index buffer %p has unrecognized index size %d",
640 _ib
->buffer
, _ib
->index_size
);
644 else if (_ib
->offset
|| _ib
->index_size
) {
645 glhd_warn("non-indexed state with index offset %d and index size %d",
646 _ib
->offset
, _ib
->index_size
);
651 unwrapped_ib
.buffer
= galahad_resource_unwrap(_ib
->buffer
);
655 pipe
->set_index_buffer(pipe
, ib
);
659 galahad_resource_copy_region(struct pipe_context
*_pipe
,
660 struct pipe_resource
*_dst
,
661 struct pipe_subresource subdst
,
665 struct pipe_resource
*_src
,
666 struct pipe_subresource subsrc
,
673 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
674 struct galahad_resource
*glhd_resource_dst
= galahad_resource(_dst
);
675 struct galahad_resource
*glhd_resource_src
= galahad_resource(_src
);
676 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
677 struct pipe_resource
*dst
= glhd_resource_dst
->resource
;
678 struct pipe_resource
*src
= glhd_resource_src
->resource
;
680 if (_dst
->format
!= _src
->format
) {
681 glhd_warn("Format mismatch: Source is %s, destination is %s",
682 util_format_short_name(_src
->format
),
683 util_format_short_name(_dst
->format
));
686 pipe
->resource_copy_region(pipe
,
702 galahad_clear(struct pipe_context
*_pipe
,
708 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
709 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
719 galahad_clear_render_target(struct pipe_context
*_pipe
,
720 struct pipe_surface
*_dst
,
722 unsigned dstx
, unsigned dsty
,
723 unsigned width
, unsigned height
)
725 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
726 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
727 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
728 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
730 pipe
->clear_render_target(pipe
,
739 galahad_clear_depth_stencil(struct pipe_context
*_pipe
,
740 struct pipe_surface
*_dst
,
741 unsigned clear_flags
,
744 unsigned dstx
, unsigned dsty
,
745 unsigned width
, unsigned height
)
747 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
748 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
749 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
750 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
752 pipe
->clear_depth_stencil(pipe
,
765 galahad_flush(struct pipe_context
*_pipe
,
767 struct pipe_fence_handle
**fence
)
769 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
770 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
778 galahad_is_resource_referenced(struct pipe_context
*_pipe
,
779 struct pipe_resource
*_resource
,
783 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
784 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
785 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
786 struct pipe_resource
*resource
= glhd_resource
->resource
;
788 return pipe
->is_resource_referenced(pipe
,
794 static struct pipe_sampler_view
*
795 galahad_context_create_sampler_view(struct pipe_context
*_pipe
,
796 struct pipe_resource
*_resource
,
797 const struct pipe_sampler_view
*templ
)
799 struct galahad_context
*glhd_context
= galahad_context(_pipe
);
800 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
801 struct pipe_context
*pipe
= glhd_context
->pipe
;
802 struct pipe_resource
*resource
= glhd_resource
->resource
;
803 struct pipe_sampler_view
*result
;
805 result
= pipe
->create_sampler_view(pipe
,
810 return galahad_sampler_view_create(glhd_context
, glhd_resource
, result
);
815 galahad_context_sampler_view_destroy(struct pipe_context
*_pipe
,
816 struct pipe_sampler_view
*_view
)
818 galahad_sampler_view_destroy(galahad_context(_pipe
),
819 galahad_sampler_view(_view
));
822 static struct pipe_transfer
*
823 galahad_context_get_transfer(struct pipe_context
*_context
,
824 struct pipe_resource
*_resource
,
825 struct pipe_subresource sr
,
827 const struct pipe_box
*box
)
829 struct galahad_context
*glhd_context
= galahad_context(_context
);
830 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
831 struct pipe_context
*context
= glhd_context
->pipe
;
832 struct pipe_resource
*resource
= glhd_resource
->resource
;
833 struct pipe_transfer
*result
;
835 result
= context
->get_transfer(context
,
842 return galahad_transfer_create(glhd_context
, glhd_resource
, result
);
847 galahad_context_transfer_destroy(struct pipe_context
*_pipe
,
848 struct pipe_transfer
*_transfer
)
850 galahad_transfer_destroy(galahad_context(_pipe
),
851 galahad_transfer(_transfer
));
855 galahad_context_transfer_map(struct pipe_context
*_context
,
856 struct pipe_transfer
*_transfer
)
858 struct galahad_context
*glhd_context
= galahad_context(_context
);
859 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
860 struct pipe_context
*context
= glhd_context
->pipe
;
861 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
863 return context
->transfer_map(context
,
870 galahad_context_transfer_flush_region(struct pipe_context
*_context
,
871 struct pipe_transfer
*_transfer
,
872 const struct pipe_box
*box
)
874 struct galahad_context
*glhd_context
= galahad_context(_context
);
875 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
876 struct pipe_context
*context
= glhd_context
->pipe
;
877 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
879 context
->transfer_flush_region(context
,
886 galahad_context_transfer_unmap(struct pipe_context
*_context
,
887 struct pipe_transfer
*_transfer
)
889 struct galahad_context
*glhd_context
= galahad_context(_context
);
890 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
891 struct pipe_context
*context
= glhd_context
->pipe
;
892 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
894 context
->transfer_unmap(context
,
900 galahad_context_transfer_inline_write(struct pipe_context
*_context
,
901 struct pipe_resource
*_resource
,
902 struct pipe_subresource sr
,
904 const struct pipe_box
*box
,
907 unsigned slice_stride
)
909 struct galahad_context
*glhd_context
= galahad_context(_context
);
910 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
911 struct pipe_context
*context
= glhd_context
->pipe
;
912 struct pipe_resource
*resource
= glhd_resource
->resource
;
914 context
->transfer_inline_write(context
,
925 struct pipe_context
*
926 galahad_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
928 struct galahad_context
*glhd_pipe
;
929 (void)galahad_screen(_screen
);
931 glhd_pipe
= CALLOC_STRUCT(galahad_context
);
936 glhd_pipe
->base
.winsys
= NULL
;
937 glhd_pipe
->base
.screen
= _screen
;
938 glhd_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
939 glhd_pipe
->base
.draw
= NULL
;
941 glhd_pipe
->base
.destroy
= galahad_destroy
;
942 glhd_pipe
->base
.draw_vbo
= galahad_draw_vbo
;
943 glhd_pipe
->base
.create_query
= galahad_create_query
;
944 glhd_pipe
->base
.destroy_query
= galahad_destroy_query
;
945 glhd_pipe
->base
.begin_query
= galahad_begin_query
;
946 glhd_pipe
->base
.end_query
= galahad_end_query
;
947 glhd_pipe
->base
.get_query_result
= galahad_get_query_result
;
948 glhd_pipe
->base
.create_blend_state
= galahad_create_blend_state
;
949 glhd_pipe
->base
.bind_blend_state
= galahad_bind_blend_state
;
950 glhd_pipe
->base
.delete_blend_state
= galahad_delete_blend_state
;
951 glhd_pipe
->base
.create_sampler_state
= galahad_create_sampler_state
;
952 glhd_pipe
->base
.bind_fragment_sampler_states
= galahad_bind_fragment_sampler_states
;
953 glhd_pipe
->base
.bind_vertex_sampler_states
= galahad_bind_vertex_sampler_states
;
954 glhd_pipe
->base
.delete_sampler_state
= galahad_delete_sampler_state
;
955 glhd_pipe
->base
.create_rasterizer_state
= galahad_create_rasterizer_state
;
956 glhd_pipe
->base
.bind_rasterizer_state
= galahad_bind_rasterizer_state
;
957 glhd_pipe
->base
.delete_rasterizer_state
= galahad_delete_rasterizer_state
;
958 glhd_pipe
->base
.create_depth_stencil_alpha_state
= galahad_create_depth_stencil_alpha_state
;
959 glhd_pipe
->base
.bind_depth_stencil_alpha_state
= galahad_bind_depth_stencil_alpha_state
;
960 glhd_pipe
->base
.delete_depth_stencil_alpha_state
= galahad_delete_depth_stencil_alpha_state
;
961 glhd_pipe
->base
.create_fs_state
= galahad_create_fs_state
;
962 glhd_pipe
->base
.bind_fs_state
= galahad_bind_fs_state
;
963 glhd_pipe
->base
.delete_fs_state
= galahad_delete_fs_state
;
964 glhd_pipe
->base
.create_vs_state
= galahad_create_vs_state
;
965 glhd_pipe
->base
.bind_vs_state
= galahad_bind_vs_state
;
966 glhd_pipe
->base
.delete_vs_state
= galahad_delete_vs_state
;
967 glhd_pipe
->base
.create_vertex_elements_state
= galahad_create_vertex_elements_state
;
968 glhd_pipe
->base
.bind_vertex_elements_state
= galahad_bind_vertex_elements_state
;
969 glhd_pipe
->base
.delete_vertex_elements_state
= galahad_delete_vertex_elements_state
;
970 glhd_pipe
->base
.set_blend_color
= galahad_set_blend_color
;
971 glhd_pipe
->base
.set_stencil_ref
= galahad_set_stencil_ref
;
972 glhd_pipe
->base
.set_clip_state
= galahad_set_clip_state
;
973 glhd_pipe
->base
.set_sample_mask
= galahad_set_sample_mask
;
974 glhd_pipe
->base
.set_constant_buffer
= galahad_set_constant_buffer
;
975 glhd_pipe
->base
.set_framebuffer_state
= galahad_set_framebuffer_state
;
976 glhd_pipe
->base
.set_polygon_stipple
= galahad_set_polygon_stipple
;
977 glhd_pipe
->base
.set_scissor_state
= galahad_set_scissor_state
;
978 glhd_pipe
->base
.set_viewport_state
= galahad_set_viewport_state
;
979 glhd_pipe
->base
.set_fragment_sampler_views
= galahad_set_fragment_sampler_views
;
980 glhd_pipe
->base
.set_vertex_sampler_views
= galahad_set_vertex_sampler_views
;
981 glhd_pipe
->base
.set_vertex_buffers
= galahad_set_vertex_buffers
;
982 glhd_pipe
->base
.set_index_buffer
= galahad_set_index_buffer
;
983 glhd_pipe
->base
.resource_copy_region
= galahad_resource_copy_region
;
984 glhd_pipe
->base
.clear
= galahad_clear
;
985 glhd_pipe
->base
.clear_render_target
= galahad_clear_render_target
;
986 glhd_pipe
->base
.clear_depth_stencil
= galahad_clear_depth_stencil
;
987 glhd_pipe
->base
.flush
= galahad_flush
;
988 glhd_pipe
->base
.is_resource_referenced
= galahad_is_resource_referenced
;
989 glhd_pipe
->base
.create_sampler_view
= galahad_context_create_sampler_view
;
990 glhd_pipe
->base
.sampler_view_destroy
= galahad_context_sampler_view_destroy
;
991 glhd_pipe
->base
.get_transfer
= galahad_context_get_transfer
;
992 glhd_pipe
->base
.transfer_destroy
= galahad_context_transfer_destroy
;
993 glhd_pipe
->base
.transfer_map
= galahad_context_transfer_map
;
994 glhd_pipe
->base
.transfer_unmap
= galahad_context_transfer_unmap
;
995 glhd_pipe
->base
.transfer_flush_region
= galahad_context_transfer_flush_region
;
996 glhd_pipe
->base
.transfer_inline_write
= galahad_context_transfer_inline_write
;
998 glhd_pipe
->pipe
= pipe
;
1000 glhd_warn("Created context %p", glhd_pipe
);
1002 return &glhd_pipe
->base
;