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 pipe
->bind_fragment_sampler_states(pipe
,
194 galahad_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
195 unsigned num_samplers
,
198 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
199 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
201 pipe
->bind_vertex_sampler_states(pipe
,
207 galahad_delete_sampler_state(struct pipe_context
*_pipe
,
210 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
211 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
213 pipe
->delete_sampler_state(pipe
,
218 galahad_create_rasterizer_state(struct pipe_context
*_pipe
,
219 const struct pipe_rasterizer_state
*rasterizer
)
221 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
222 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
224 if (rasterizer
->point_quad_rasterization
) {
225 if (rasterizer
->point_smooth
) {
226 glhd_warn("Point smoothing requested but ignored");
229 if (rasterizer
->sprite_coord_enable
) {
230 glhd_warn("Point sprites requested but ignored");
234 return pipe
->create_rasterizer_state(pipe
,
239 galahad_bind_rasterizer_state(struct pipe_context
*_pipe
,
242 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
243 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
245 pipe
->bind_rasterizer_state(pipe
,
250 galahad_delete_rasterizer_state(struct pipe_context
*_pipe
,
253 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
254 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
256 pipe
->delete_rasterizer_state(pipe
,
261 galahad_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
262 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
264 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
265 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
267 return pipe
->create_depth_stencil_alpha_state(pipe
,
268 depth_stencil_alpha
);
272 galahad_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
273 void *depth_stencil_alpha
)
275 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
276 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
278 pipe
->bind_depth_stencil_alpha_state(pipe
,
279 depth_stencil_alpha
);
283 galahad_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
284 void *depth_stencil_alpha
)
286 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
287 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
289 pipe
->delete_depth_stencil_alpha_state(pipe
,
290 depth_stencil_alpha
);
294 galahad_create_fs_state(struct pipe_context
*_pipe
,
295 const struct pipe_shader_state
*fs
)
297 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
298 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
300 return pipe
->create_fs_state(pipe
,
305 galahad_bind_fs_state(struct pipe_context
*_pipe
,
308 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
309 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
311 pipe
->bind_fs_state(pipe
,
316 galahad_delete_fs_state(struct pipe_context
*_pipe
,
319 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
320 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
322 pipe
->delete_fs_state(pipe
,
327 galahad_create_vs_state(struct pipe_context
*_pipe
,
328 const struct pipe_shader_state
*vs
)
330 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
331 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
333 return pipe
->create_vs_state(pipe
,
338 galahad_bind_vs_state(struct pipe_context
*_pipe
,
341 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
342 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
344 pipe
->bind_vs_state(pipe
,
349 galahad_delete_vs_state(struct pipe_context
*_pipe
,
352 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
353 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
355 pipe
->delete_vs_state(pipe
,
361 galahad_create_vertex_elements_state(struct pipe_context
*_pipe
,
362 unsigned num_elements
,
363 const struct pipe_vertex_element
*vertex_elements
)
365 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
366 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
368 return pipe
->create_vertex_elements_state(pipe
,
374 galahad_bind_vertex_elements_state(struct pipe_context
*_pipe
,
377 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
378 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
380 pipe
->bind_vertex_elements_state(pipe
,
385 galahad_delete_vertex_elements_state(struct pipe_context
*_pipe
,
388 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
389 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
391 pipe
->delete_vertex_elements_state(pipe
,
396 galahad_set_blend_color(struct pipe_context
*_pipe
,
397 const struct pipe_blend_color
*blend_color
)
399 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
400 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
402 pipe
->set_blend_color(pipe
,
407 galahad_set_stencil_ref(struct pipe_context
*_pipe
,
408 const struct pipe_stencil_ref
*stencil_ref
)
410 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
411 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
413 pipe
->set_stencil_ref(pipe
,
418 galahad_set_clip_state(struct pipe_context
*_pipe
,
419 const struct pipe_clip_state
*clip
)
421 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
422 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
424 pipe
->set_clip_state(pipe
,
429 galahad_set_sample_mask(struct pipe_context
*_pipe
,
430 unsigned sample_mask
)
432 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
433 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
435 pipe
->set_sample_mask(pipe
,
440 galahad_set_constant_buffer(struct pipe_context
*_pipe
,
443 struct pipe_resource
*_resource
)
445 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
446 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
447 struct pipe_resource
*unwrapped_resource
;
448 struct pipe_resource
*resource
= NULL
;
450 /* XXX hmm? unwrap the input state */
452 unwrapped_resource
= galahad_resource_unwrap(_resource
);
453 resource
= unwrapped_resource
;
456 pipe
->set_constant_buffer(pipe
,
463 galahad_set_framebuffer_state(struct pipe_context
*_pipe
,
464 const struct pipe_framebuffer_state
*_state
)
466 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
467 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
468 struct pipe_framebuffer_state unwrapped_state
;
469 struct pipe_framebuffer_state
*state
= NULL
;
472 if (_state
->nr_cbufs
> PIPE_MAX_COLOR_BUFS
) {
473 glhd_error("%d render targets bound, but only %d are permitted by API",
474 _state
->nr_cbufs
, PIPE_MAX_COLOR_BUFS
);
475 } else if (_state
->nr_cbufs
>
476 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
)) {
477 glhd_warn("%d render targets bound, but only %d are supported",
479 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
));
482 /* unwrap the input state */
484 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
485 for(i
= 0; i
< _state
->nr_cbufs
; i
++)
486 unwrapped_state
.cbufs
[i
] = galahad_surface_unwrap(_state
->cbufs
[i
]);
487 for (; i
< PIPE_MAX_COLOR_BUFS
; i
++)
488 unwrapped_state
.cbufs
[i
] = NULL
;
489 unwrapped_state
.zsbuf
= galahad_surface_unwrap(_state
->zsbuf
);
490 state
= &unwrapped_state
;
493 pipe
->set_framebuffer_state(pipe
,
498 galahad_set_polygon_stipple(struct pipe_context
*_pipe
,
499 const struct pipe_poly_stipple
*poly_stipple
)
501 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
502 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
504 pipe
->set_polygon_stipple(pipe
,
509 galahad_set_scissor_state(struct pipe_context
*_pipe
,
510 const struct pipe_scissor_state
*scissor
)
512 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
513 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
515 pipe
->set_scissor_state(pipe
,
520 galahad_set_viewport_state(struct pipe_context
*_pipe
,
521 const struct pipe_viewport_state
*viewport
)
523 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
524 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
526 pipe
->set_viewport_state(pipe
,
531 galahad_set_fragment_sampler_views(struct pipe_context
*_pipe
,
533 struct pipe_sampler_view
**_views
)
535 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
536 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
537 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
538 struct pipe_sampler_view
**views
= NULL
;
542 for (i
= 0; i
< num
; i
++)
543 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
544 for (; i
< PIPE_MAX_SAMPLERS
; i
++)
545 unwrapped_views
[i
] = NULL
;
547 views
= unwrapped_views
;
550 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
554 galahad_set_vertex_sampler_views(struct pipe_context
*_pipe
,
556 struct pipe_sampler_view
**_views
)
558 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
559 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
560 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
561 struct pipe_sampler_view
**views
= NULL
;
565 for (i
= 0; i
< num
; i
++)
566 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
567 for (; i
< PIPE_MAX_VERTEX_SAMPLERS
; i
++)
568 unwrapped_views
[i
] = NULL
;
570 views
= unwrapped_views
;
573 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
577 galahad_set_vertex_buffers(struct pipe_context
*_pipe
,
578 unsigned num_buffers
,
579 const struct pipe_vertex_buffer
*_buffers
)
581 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
582 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
583 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
584 struct pipe_vertex_buffer
*buffers
= NULL
;
588 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
589 for (i
= 0; i
< num_buffers
; i
++)
590 unwrapped_buffers
[i
].buffer
= galahad_resource_unwrap(_buffers
[i
].buffer
);
591 buffers
= unwrapped_buffers
;
594 pipe
->set_vertex_buffers(pipe
,
600 galahad_set_index_buffer(struct pipe_context
*_pipe
,
601 const struct pipe_index_buffer
*_ib
)
603 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
604 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
605 struct pipe_index_buffer unwrapped_ib
, *ib
= NULL
;
608 switch (_ib
->index_size
) {
614 glhd_warn("index buffer %p has unrecognized index size %d",
615 _ib
->buffer
, _ib
->index_size
);
619 else if (_ib
->offset
|| _ib
->index_size
) {
620 glhd_warn("non-indexed state with index offset %d and index size %d",
621 _ib
->offset
, _ib
->index_size
);
626 unwrapped_ib
.buffer
= galahad_resource_unwrap(_ib
->buffer
);
630 pipe
->set_index_buffer(pipe
, ib
);
634 galahad_resource_copy_region(struct pipe_context
*_pipe
,
635 struct pipe_resource
*_dst
,
636 struct pipe_subresource subdst
,
640 struct pipe_resource
*_src
,
641 struct pipe_subresource subsrc
,
648 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
649 struct galahad_resource
*glhd_resource_dst
= galahad_resource(_dst
);
650 struct galahad_resource
*glhd_resource_src
= galahad_resource(_src
);
651 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
652 struct pipe_resource
*dst
= glhd_resource_dst
->resource
;
653 struct pipe_resource
*src
= glhd_resource_src
->resource
;
655 if (_dst
->format
!= _src
->format
) {
656 glhd_warn("Format mismatch: Source is %s, destination is %s",
657 util_format_short_name(_src
->format
),
658 util_format_short_name(_dst
->format
));
661 pipe
->resource_copy_region(pipe
,
677 galahad_clear(struct pipe_context
*_pipe
,
683 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
684 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
694 galahad_clear_render_target(struct pipe_context
*_pipe
,
695 struct pipe_surface
*_dst
,
697 unsigned dstx
, unsigned dsty
,
698 unsigned width
, unsigned height
)
700 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
701 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
702 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
703 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
705 pipe
->clear_render_target(pipe
,
714 galahad_clear_depth_stencil(struct pipe_context
*_pipe
,
715 struct pipe_surface
*_dst
,
716 unsigned clear_flags
,
719 unsigned dstx
, unsigned dsty
,
720 unsigned width
, unsigned height
)
722 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
723 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
724 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
725 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
727 pipe
->clear_depth_stencil(pipe
,
740 galahad_flush(struct pipe_context
*_pipe
,
742 struct pipe_fence_handle
**fence
)
744 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
745 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
753 galahad_is_resource_referenced(struct pipe_context
*_pipe
,
754 struct pipe_resource
*_resource
,
758 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
759 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
760 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
761 struct pipe_resource
*resource
= glhd_resource
->resource
;
763 return pipe
->is_resource_referenced(pipe
,
769 static struct pipe_sampler_view
*
770 galahad_context_create_sampler_view(struct pipe_context
*_pipe
,
771 struct pipe_resource
*_resource
,
772 const struct pipe_sampler_view
*templ
)
774 struct galahad_context
*glhd_context
= galahad_context(_pipe
);
775 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
776 struct pipe_context
*pipe
= glhd_context
->pipe
;
777 struct pipe_resource
*resource
= glhd_resource
->resource
;
778 struct pipe_sampler_view
*result
;
780 result
= pipe
->create_sampler_view(pipe
,
785 return galahad_sampler_view_create(glhd_context
, glhd_resource
, result
);
790 galahad_context_sampler_view_destroy(struct pipe_context
*_pipe
,
791 struct pipe_sampler_view
*_view
)
793 galahad_sampler_view_destroy(galahad_context(_pipe
),
794 galahad_sampler_view(_view
));
797 static struct pipe_transfer
*
798 galahad_context_get_transfer(struct pipe_context
*_context
,
799 struct pipe_resource
*_resource
,
800 struct pipe_subresource sr
,
802 const struct pipe_box
*box
)
804 struct galahad_context
*glhd_context
= galahad_context(_context
);
805 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
806 struct pipe_context
*context
= glhd_context
->pipe
;
807 struct pipe_resource
*resource
= glhd_resource
->resource
;
808 struct pipe_transfer
*result
;
810 result
= context
->get_transfer(context
,
817 return galahad_transfer_create(glhd_context
, glhd_resource
, result
);
822 galahad_context_transfer_destroy(struct pipe_context
*_pipe
,
823 struct pipe_transfer
*_transfer
)
825 galahad_transfer_destroy(galahad_context(_pipe
),
826 galahad_transfer(_transfer
));
830 galahad_context_transfer_map(struct pipe_context
*_context
,
831 struct pipe_transfer
*_transfer
)
833 struct galahad_context
*glhd_context
= galahad_context(_context
);
834 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
835 struct pipe_context
*context
= glhd_context
->pipe
;
836 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
838 return context
->transfer_map(context
,
845 galahad_context_transfer_flush_region(struct pipe_context
*_context
,
846 struct pipe_transfer
*_transfer
,
847 const struct pipe_box
*box
)
849 struct galahad_context
*glhd_context
= galahad_context(_context
);
850 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
851 struct pipe_context
*context
= glhd_context
->pipe
;
852 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
854 context
->transfer_flush_region(context
,
861 galahad_context_transfer_unmap(struct pipe_context
*_context
,
862 struct pipe_transfer
*_transfer
)
864 struct galahad_context
*glhd_context
= galahad_context(_context
);
865 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
866 struct pipe_context
*context
= glhd_context
->pipe
;
867 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
869 context
->transfer_unmap(context
,
875 galahad_context_transfer_inline_write(struct pipe_context
*_context
,
876 struct pipe_resource
*_resource
,
877 struct pipe_subresource sr
,
879 const struct pipe_box
*box
,
882 unsigned slice_stride
)
884 struct galahad_context
*glhd_context
= galahad_context(_context
);
885 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
886 struct pipe_context
*context
= glhd_context
->pipe
;
887 struct pipe_resource
*resource
= glhd_resource
->resource
;
889 context
->transfer_inline_write(context
,
900 struct pipe_context
*
901 galahad_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
903 struct galahad_context
*glhd_pipe
;
904 (void)galahad_screen(_screen
);
906 glhd_pipe
= CALLOC_STRUCT(galahad_context
);
911 glhd_pipe
->base
.winsys
= NULL
;
912 glhd_pipe
->base
.screen
= _screen
;
913 glhd_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
914 glhd_pipe
->base
.draw
= NULL
;
916 glhd_pipe
->base
.destroy
= galahad_destroy
;
917 glhd_pipe
->base
.draw_vbo
= galahad_draw_vbo
;
918 glhd_pipe
->base
.create_query
= galahad_create_query
;
919 glhd_pipe
->base
.destroy_query
= galahad_destroy_query
;
920 glhd_pipe
->base
.begin_query
= galahad_begin_query
;
921 glhd_pipe
->base
.end_query
= galahad_end_query
;
922 glhd_pipe
->base
.get_query_result
= galahad_get_query_result
;
923 glhd_pipe
->base
.create_blend_state
= galahad_create_blend_state
;
924 glhd_pipe
->base
.bind_blend_state
= galahad_bind_blend_state
;
925 glhd_pipe
->base
.delete_blend_state
= galahad_delete_blend_state
;
926 glhd_pipe
->base
.create_sampler_state
= galahad_create_sampler_state
;
927 glhd_pipe
->base
.bind_fragment_sampler_states
= galahad_bind_fragment_sampler_states
;
928 glhd_pipe
->base
.bind_vertex_sampler_states
= galahad_bind_vertex_sampler_states
;
929 glhd_pipe
->base
.delete_sampler_state
= galahad_delete_sampler_state
;
930 glhd_pipe
->base
.create_rasterizer_state
= galahad_create_rasterizer_state
;
931 glhd_pipe
->base
.bind_rasterizer_state
= galahad_bind_rasterizer_state
;
932 glhd_pipe
->base
.delete_rasterizer_state
= galahad_delete_rasterizer_state
;
933 glhd_pipe
->base
.create_depth_stencil_alpha_state
= galahad_create_depth_stencil_alpha_state
;
934 glhd_pipe
->base
.bind_depth_stencil_alpha_state
= galahad_bind_depth_stencil_alpha_state
;
935 glhd_pipe
->base
.delete_depth_stencil_alpha_state
= galahad_delete_depth_stencil_alpha_state
;
936 glhd_pipe
->base
.create_fs_state
= galahad_create_fs_state
;
937 glhd_pipe
->base
.bind_fs_state
= galahad_bind_fs_state
;
938 glhd_pipe
->base
.delete_fs_state
= galahad_delete_fs_state
;
939 glhd_pipe
->base
.create_vs_state
= galahad_create_vs_state
;
940 glhd_pipe
->base
.bind_vs_state
= galahad_bind_vs_state
;
941 glhd_pipe
->base
.delete_vs_state
= galahad_delete_vs_state
;
942 glhd_pipe
->base
.create_vertex_elements_state
= galahad_create_vertex_elements_state
;
943 glhd_pipe
->base
.bind_vertex_elements_state
= galahad_bind_vertex_elements_state
;
944 glhd_pipe
->base
.delete_vertex_elements_state
= galahad_delete_vertex_elements_state
;
945 glhd_pipe
->base
.set_blend_color
= galahad_set_blend_color
;
946 glhd_pipe
->base
.set_stencil_ref
= galahad_set_stencil_ref
;
947 glhd_pipe
->base
.set_clip_state
= galahad_set_clip_state
;
948 glhd_pipe
->base
.set_sample_mask
= galahad_set_sample_mask
;
949 glhd_pipe
->base
.set_constant_buffer
= galahad_set_constant_buffer
;
950 glhd_pipe
->base
.set_framebuffer_state
= galahad_set_framebuffer_state
;
951 glhd_pipe
->base
.set_polygon_stipple
= galahad_set_polygon_stipple
;
952 glhd_pipe
->base
.set_scissor_state
= galahad_set_scissor_state
;
953 glhd_pipe
->base
.set_viewport_state
= galahad_set_viewport_state
;
954 glhd_pipe
->base
.set_fragment_sampler_views
= galahad_set_fragment_sampler_views
;
955 glhd_pipe
->base
.set_vertex_sampler_views
= galahad_set_vertex_sampler_views
;
956 glhd_pipe
->base
.set_vertex_buffers
= galahad_set_vertex_buffers
;
957 glhd_pipe
->base
.set_index_buffer
= galahad_set_index_buffer
;
958 glhd_pipe
->base
.resource_copy_region
= galahad_resource_copy_region
;
959 glhd_pipe
->base
.clear
= galahad_clear
;
960 glhd_pipe
->base
.clear_render_target
= galahad_clear_render_target
;
961 glhd_pipe
->base
.clear_depth_stencil
= galahad_clear_depth_stencil
;
962 glhd_pipe
->base
.flush
= galahad_flush
;
963 glhd_pipe
->base
.is_resource_referenced
= galahad_is_resource_referenced
;
964 glhd_pipe
->base
.create_sampler_view
= galahad_context_create_sampler_view
;
965 glhd_pipe
->base
.sampler_view_destroy
= galahad_context_sampler_view_destroy
;
966 glhd_pipe
->base
.get_transfer
= galahad_context_get_transfer
;
967 glhd_pipe
->base
.transfer_destroy
= galahad_context_transfer_destroy
;
968 glhd_pipe
->base
.transfer_map
= galahad_context_transfer_map
;
969 glhd_pipe
->base
.transfer_unmap
= galahad_context_transfer_unmap
;
970 glhd_pipe
->base
.transfer_flush_region
= galahad_context_transfer_flush_region
;
971 glhd_pipe
->base
.transfer_inline_write
= galahad_context_transfer_inline_write
;
973 glhd_pipe
->pipe
= pipe
;
975 return &glhd_pipe
->base
;