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 return pipe
->create_query(pipe
,
127 galahad_destroy_query(struct pipe_context
*_pipe
,
128 struct pipe_query
*query
)
130 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
131 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
133 pipe
->destroy_query(pipe
,
138 galahad_begin_query(struct pipe_context
*_pipe
,
139 struct pipe_query
*query
)
141 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
142 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
144 pipe
->begin_query(pipe
,
149 galahad_end_query(struct pipe_context
*_pipe
,
150 struct pipe_query
*query
)
152 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
153 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
155 pipe
->end_query(pipe
,
160 galahad_get_query_result(struct pipe_context
*_pipe
,
161 struct pipe_query
*query
,
165 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
166 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
168 return pipe
->get_query_result(pipe
,
175 galahad_create_blend_state(struct pipe_context
*_pipe
,
176 const struct pipe_blend_state
*blend
)
178 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
179 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
181 return pipe
->create_blend_state(pipe
,
186 galahad_bind_blend_state(struct pipe_context
*_pipe
,
189 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
190 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
192 pipe
->bind_blend_state(pipe
,
197 galahad_delete_blend_state(struct pipe_context
*_pipe
,
200 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
201 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
203 pipe
->delete_blend_state(pipe
,
208 galahad_create_sampler_state(struct pipe_context
*_pipe
,
209 const struct pipe_sampler_state
*sampler
)
211 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
212 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
214 return pipe
->create_sampler_state(pipe
,
219 galahad_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
220 unsigned num_samplers
,
223 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
224 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
226 pipe
->bind_fragment_sampler_states(pipe
,
232 galahad_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
233 unsigned num_samplers
,
236 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
237 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
239 pipe
->bind_vertex_sampler_states(pipe
,
245 galahad_delete_sampler_state(struct pipe_context
*_pipe
,
248 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
249 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
251 pipe
->delete_sampler_state(pipe
,
256 galahad_create_rasterizer_state(struct pipe_context
*_pipe
,
257 const struct pipe_rasterizer_state
*rasterizer
)
259 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
260 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
262 return pipe
->create_rasterizer_state(pipe
,
267 galahad_bind_rasterizer_state(struct pipe_context
*_pipe
,
270 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
271 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
273 pipe
->bind_rasterizer_state(pipe
,
278 galahad_delete_rasterizer_state(struct pipe_context
*_pipe
,
281 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
282 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
284 pipe
->delete_rasterizer_state(pipe
,
289 galahad_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
290 const struct pipe_depth_stencil_alpha_state
*depth_stencil_alpha
)
292 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
293 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
295 return pipe
->create_depth_stencil_alpha_state(pipe
,
296 depth_stencil_alpha
);
300 galahad_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
301 void *depth_stencil_alpha
)
303 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
304 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
306 pipe
->bind_depth_stencil_alpha_state(pipe
,
307 depth_stencil_alpha
);
311 galahad_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
312 void *depth_stencil_alpha
)
314 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
315 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
317 pipe
->delete_depth_stencil_alpha_state(pipe
,
318 depth_stencil_alpha
);
322 galahad_create_fs_state(struct pipe_context
*_pipe
,
323 const struct pipe_shader_state
*fs
)
325 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
326 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
328 return pipe
->create_fs_state(pipe
,
333 galahad_bind_fs_state(struct pipe_context
*_pipe
,
336 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
337 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
339 pipe
->bind_fs_state(pipe
,
344 galahad_delete_fs_state(struct pipe_context
*_pipe
,
347 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
348 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
350 pipe
->delete_fs_state(pipe
,
355 galahad_create_vs_state(struct pipe_context
*_pipe
,
356 const struct pipe_shader_state
*vs
)
358 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
359 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
361 return pipe
->create_vs_state(pipe
,
366 galahad_bind_vs_state(struct pipe_context
*_pipe
,
369 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
370 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
372 pipe
->bind_vs_state(pipe
,
377 galahad_delete_vs_state(struct pipe_context
*_pipe
,
380 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
381 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
383 pipe
->delete_vs_state(pipe
,
389 galahad_create_vertex_elements_state(struct pipe_context
*_pipe
,
390 unsigned num_elements
,
391 const struct pipe_vertex_element
*vertex_elements
)
393 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
394 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
396 return pipe
->create_vertex_elements_state(pipe
,
402 galahad_bind_vertex_elements_state(struct pipe_context
*_pipe
,
405 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
406 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
408 pipe
->bind_vertex_elements_state(pipe
,
413 galahad_delete_vertex_elements_state(struct pipe_context
*_pipe
,
416 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
417 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
419 pipe
->delete_vertex_elements_state(pipe
,
424 galahad_set_blend_color(struct pipe_context
*_pipe
,
425 const struct pipe_blend_color
*blend_color
)
427 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
428 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
430 pipe
->set_blend_color(pipe
,
435 galahad_set_stencil_ref(struct pipe_context
*_pipe
,
436 const struct pipe_stencil_ref
*stencil_ref
)
438 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
439 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
441 pipe
->set_stencil_ref(pipe
,
446 galahad_set_clip_state(struct pipe_context
*_pipe
,
447 const struct pipe_clip_state
*clip
)
449 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
450 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
452 pipe
->set_clip_state(pipe
,
457 galahad_set_sample_mask(struct pipe_context
*_pipe
,
458 unsigned sample_mask
)
460 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
461 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
463 pipe
->set_sample_mask(pipe
,
468 galahad_set_constant_buffer(struct pipe_context
*_pipe
,
471 struct pipe_resource
*_resource
)
473 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
474 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
475 struct pipe_resource
*unwrapped_resource
;
476 struct pipe_resource
*resource
= NULL
;
478 /* XXX hmm? unwrap the input state */
480 unwrapped_resource
= galahad_resource_unwrap(_resource
);
481 resource
= unwrapped_resource
;
484 pipe
->set_constant_buffer(pipe
,
491 galahad_set_framebuffer_state(struct pipe_context
*_pipe
,
492 const struct pipe_framebuffer_state
*_state
)
494 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
495 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
496 struct pipe_framebuffer_state unwrapped_state
;
497 struct pipe_framebuffer_state
*state
= NULL
;
500 if (_state
->nr_cbufs
> PIPE_MAX_COLOR_BUFS
) {
501 glhd_error("%d render targets bound, but only %d are permitted by API",
502 _state
->nr_cbufs
, PIPE_MAX_COLOR_BUFS
);
503 } else if (_state
->nr_cbufs
>
504 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
)) {
505 glhd_warn("%d render targets bound, but only %d are supported",
507 pipe
->screen
->get_param(pipe
->screen
, PIPE_CAP_MAX_RENDER_TARGETS
));
510 /* unwrap the input state */
512 memcpy(&unwrapped_state
, _state
, sizeof(unwrapped_state
));
513 for(i
= 0; i
< _state
->nr_cbufs
; i
++)
514 unwrapped_state
.cbufs
[i
] = galahad_surface_unwrap(_state
->cbufs
[i
]);
515 for (; i
< PIPE_MAX_COLOR_BUFS
; i
++)
516 unwrapped_state
.cbufs
[i
] = NULL
;
517 unwrapped_state
.zsbuf
= galahad_surface_unwrap(_state
->zsbuf
);
518 state
= &unwrapped_state
;
521 pipe
->set_framebuffer_state(pipe
,
526 galahad_set_polygon_stipple(struct pipe_context
*_pipe
,
527 const struct pipe_poly_stipple
*poly_stipple
)
529 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
530 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
532 pipe
->set_polygon_stipple(pipe
,
537 galahad_set_scissor_state(struct pipe_context
*_pipe
,
538 const struct pipe_scissor_state
*scissor
)
540 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
541 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
543 pipe
->set_scissor_state(pipe
,
548 galahad_set_viewport_state(struct pipe_context
*_pipe
,
549 const struct pipe_viewport_state
*viewport
)
551 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
552 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
554 pipe
->set_viewport_state(pipe
,
559 galahad_set_fragment_sampler_views(struct pipe_context
*_pipe
,
561 struct pipe_sampler_view
**_views
)
563 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
564 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
565 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_SAMPLERS
];
566 struct pipe_sampler_view
**views
= NULL
;
570 for (i
= 0; i
< num
; i
++)
571 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
572 for (; i
< PIPE_MAX_SAMPLERS
; i
++)
573 unwrapped_views
[i
] = NULL
;
575 views
= unwrapped_views
;
578 pipe
->set_fragment_sampler_views(pipe
, num
, views
);
582 galahad_set_vertex_sampler_views(struct pipe_context
*_pipe
,
584 struct pipe_sampler_view
**_views
)
586 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
587 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
588 struct pipe_sampler_view
*unwrapped_views
[PIPE_MAX_VERTEX_SAMPLERS
];
589 struct pipe_sampler_view
**views
= NULL
;
593 for (i
= 0; i
< num
; i
++)
594 unwrapped_views
[i
] = galahad_sampler_view_unwrap(_views
[i
]);
595 for (; i
< PIPE_MAX_VERTEX_SAMPLERS
; i
++)
596 unwrapped_views
[i
] = NULL
;
598 views
= unwrapped_views
;
601 pipe
->set_vertex_sampler_views(pipe
, num
, views
);
605 galahad_set_vertex_buffers(struct pipe_context
*_pipe
,
606 unsigned num_buffers
,
607 const struct pipe_vertex_buffer
*_buffers
)
609 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
610 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
611 struct pipe_vertex_buffer unwrapped_buffers
[PIPE_MAX_SHADER_INPUTS
];
612 struct pipe_vertex_buffer
*buffers
= NULL
;
616 memcpy(unwrapped_buffers
, _buffers
, num_buffers
* sizeof(*_buffers
));
617 for (i
= 0; i
< num_buffers
; i
++)
618 unwrapped_buffers
[i
].buffer
= galahad_resource_unwrap(_buffers
[i
].buffer
);
619 buffers
= unwrapped_buffers
;
622 pipe
->set_vertex_buffers(pipe
,
627 galahad_resource_copy_region(struct pipe_context
*_pipe
,
628 struct pipe_resource
*_dst
,
629 struct pipe_subresource subdst
,
633 struct pipe_resource
*_src
,
634 struct pipe_subresource subsrc
,
641 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
642 struct galahad_resource
*glhd_resource_dst
= galahad_resource(_dst
);
643 struct galahad_resource
*glhd_resource_src
= galahad_resource(_src
);
644 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
645 struct pipe_resource
*dst
= glhd_resource_dst
->resource
;
646 struct pipe_resource
*src
= glhd_resource_src
->resource
;
648 if (_dst
->format
!= _src
->format
) {
649 glhd_warn("Format mismatch: Source is %s, destination is %s",
650 util_format_short_name(_src
->format
),
651 util_format_short_name(_dst
->format
));
654 pipe
->resource_copy_region(pipe
,
670 galahad_clear(struct pipe_context
*_pipe
,
676 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
677 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
687 galahad_clear_render_target(struct pipe_context
*_pipe
,
688 struct pipe_surface
*_dst
,
690 unsigned dstx
, unsigned dsty
,
691 unsigned width
, unsigned height
)
693 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
694 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
695 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
696 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
698 pipe
->clear_render_target(pipe
,
707 galahad_clear_depth_stencil(struct pipe_context
*_pipe
,
708 struct pipe_surface
*_dst
,
709 unsigned clear_flags
,
712 unsigned dstx
, unsigned dsty
,
713 unsigned width
, unsigned height
)
715 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
716 struct galahad_surface
*glhd_surface_dst
= galahad_surface(_dst
);
717 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
718 struct pipe_surface
*dst
= glhd_surface_dst
->surface
;
720 pipe
->clear_depth_stencil(pipe
,
733 galahad_flush(struct pipe_context
*_pipe
,
735 struct pipe_fence_handle
**fence
)
737 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
738 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
746 galahad_is_resource_referenced(struct pipe_context
*_pipe
,
747 struct pipe_resource
*_resource
,
751 struct galahad_context
*glhd_pipe
= galahad_context(_pipe
);
752 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
753 struct pipe_context
*pipe
= glhd_pipe
->pipe
;
754 struct pipe_resource
*resource
= glhd_resource
->resource
;
756 return pipe
->is_resource_referenced(pipe
,
762 static struct pipe_sampler_view
*
763 galahad_context_create_sampler_view(struct pipe_context
*_pipe
,
764 struct pipe_resource
*_resource
,
765 const struct pipe_sampler_view
*templ
)
767 struct galahad_context
*glhd_context
= galahad_context(_pipe
);
768 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
769 struct pipe_context
*pipe
= glhd_context
->pipe
;
770 struct pipe_resource
*resource
= glhd_resource
->resource
;
771 struct pipe_sampler_view
*result
;
773 result
= pipe
->create_sampler_view(pipe
,
778 return galahad_sampler_view_create(glhd_context
, glhd_resource
, result
);
783 galahad_context_sampler_view_destroy(struct pipe_context
*_pipe
,
784 struct pipe_sampler_view
*_view
)
786 galahad_sampler_view_destroy(galahad_context(_pipe
),
787 galahad_sampler_view(_view
));
790 static struct pipe_transfer
*
791 galahad_context_get_transfer(struct pipe_context
*_context
,
792 struct pipe_resource
*_resource
,
793 struct pipe_subresource sr
,
795 const struct pipe_box
*box
)
797 struct galahad_context
*glhd_context
= galahad_context(_context
);
798 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
799 struct pipe_context
*context
= glhd_context
->pipe
;
800 struct pipe_resource
*resource
= glhd_resource
->resource
;
801 struct pipe_transfer
*result
;
803 result
= context
->get_transfer(context
,
810 return galahad_transfer_create(glhd_context
, glhd_resource
, result
);
815 galahad_context_transfer_destroy(struct pipe_context
*_pipe
,
816 struct pipe_transfer
*_transfer
)
818 galahad_transfer_destroy(galahad_context(_pipe
),
819 galahad_transfer(_transfer
));
823 galahad_context_transfer_map(struct pipe_context
*_context
,
824 struct pipe_transfer
*_transfer
)
826 struct galahad_context
*glhd_context
= galahad_context(_context
);
827 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
828 struct pipe_context
*context
= glhd_context
->pipe
;
829 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
831 return context
->transfer_map(context
,
838 galahad_context_transfer_flush_region(struct pipe_context
*_context
,
839 struct pipe_transfer
*_transfer
,
840 const struct pipe_box
*box
)
842 struct galahad_context
*glhd_context
= galahad_context(_context
);
843 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
844 struct pipe_context
*context
= glhd_context
->pipe
;
845 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
847 context
->transfer_flush_region(context
,
854 galahad_context_transfer_unmap(struct pipe_context
*_context
,
855 struct pipe_transfer
*_transfer
)
857 struct galahad_context
*glhd_context
= galahad_context(_context
);
858 struct galahad_transfer
*glhd_transfer
= galahad_transfer(_transfer
);
859 struct pipe_context
*context
= glhd_context
->pipe
;
860 struct pipe_transfer
*transfer
= glhd_transfer
->transfer
;
862 context
->transfer_unmap(context
,
868 galahad_context_transfer_inline_write(struct pipe_context
*_context
,
869 struct pipe_resource
*_resource
,
870 struct pipe_subresource sr
,
872 const struct pipe_box
*box
,
875 unsigned slice_stride
)
877 struct galahad_context
*glhd_context
= galahad_context(_context
);
878 struct galahad_resource
*glhd_resource
= galahad_resource(_resource
);
879 struct pipe_context
*context
= glhd_context
->pipe
;
880 struct pipe_resource
*resource
= glhd_resource
->resource
;
882 context
->transfer_inline_write(context
,
893 struct pipe_context
*
894 galahad_context_create(struct pipe_screen
*_screen
, struct pipe_context
*pipe
)
896 struct galahad_context
*glhd_pipe
;
897 (void)galahad_screen(_screen
);
899 glhd_pipe
= CALLOC_STRUCT(galahad_context
);
904 glhd_pipe
->base
.winsys
= NULL
;
905 glhd_pipe
->base
.screen
= _screen
;
906 glhd_pipe
->base
.priv
= pipe
->priv
; /* expose wrapped data */
907 glhd_pipe
->base
.draw
= NULL
;
909 glhd_pipe
->base
.destroy
= galahad_destroy
;
910 glhd_pipe
->base
.draw_arrays
= galahad_draw_arrays
;
911 glhd_pipe
->base
.draw_elements
= galahad_draw_elements
;
912 glhd_pipe
->base
.draw_range_elements
= galahad_draw_range_elements
;
913 glhd_pipe
->base
.create_query
= galahad_create_query
;
914 glhd_pipe
->base
.destroy_query
= galahad_destroy_query
;
915 glhd_pipe
->base
.begin_query
= galahad_begin_query
;
916 glhd_pipe
->base
.end_query
= galahad_end_query
;
917 glhd_pipe
->base
.get_query_result
= galahad_get_query_result
;
918 glhd_pipe
->base
.create_blend_state
= galahad_create_blend_state
;
919 glhd_pipe
->base
.bind_blend_state
= galahad_bind_blend_state
;
920 glhd_pipe
->base
.delete_blend_state
= galahad_delete_blend_state
;
921 glhd_pipe
->base
.create_sampler_state
= galahad_create_sampler_state
;
922 glhd_pipe
->base
.bind_fragment_sampler_states
= galahad_bind_fragment_sampler_states
;
923 glhd_pipe
->base
.bind_vertex_sampler_states
= galahad_bind_vertex_sampler_states
;
924 glhd_pipe
->base
.delete_sampler_state
= galahad_delete_sampler_state
;
925 glhd_pipe
->base
.create_rasterizer_state
= galahad_create_rasterizer_state
;
926 glhd_pipe
->base
.bind_rasterizer_state
= galahad_bind_rasterizer_state
;
927 glhd_pipe
->base
.delete_rasterizer_state
= galahad_delete_rasterizer_state
;
928 glhd_pipe
->base
.create_depth_stencil_alpha_state
= galahad_create_depth_stencil_alpha_state
;
929 glhd_pipe
->base
.bind_depth_stencil_alpha_state
= galahad_bind_depth_stencil_alpha_state
;
930 glhd_pipe
->base
.delete_depth_stencil_alpha_state
= galahad_delete_depth_stencil_alpha_state
;
931 glhd_pipe
->base
.create_fs_state
= galahad_create_fs_state
;
932 glhd_pipe
->base
.bind_fs_state
= galahad_bind_fs_state
;
933 glhd_pipe
->base
.delete_fs_state
= galahad_delete_fs_state
;
934 glhd_pipe
->base
.create_vs_state
= galahad_create_vs_state
;
935 glhd_pipe
->base
.bind_vs_state
= galahad_bind_vs_state
;
936 glhd_pipe
->base
.delete_vs_state
= galahad_delete_vs_state
;
937 glhd_pipe
->base
.create_vertex_elements_state
= galahad_create_vertex_elements_state
;
938 glhd_pipe
->base
.bind_vertex_elements_state
= galahad_bind_vertex_elements_state
;
939 glhd_pipe
->base
.delete_vertex_elements_state
= galahad_delete_vertex_elements_state
;
940 glhd_pipe
->base
.set_blend_color
= galahad_set_blend_color
;
941 glhd_pipe
->base
.set_stencil_ref
= galahad_set_stencil_ref
;
942 glhd_pipe
->base
.set_clip_state
= galahad_set_clip_state
;
943 glhd_pipe
->base
.set_sample_mask
= galahad_set_sample_mask
;
944 glhd_pipe
->base
.set_constant_buffer
= galahad_set_constant_buffer
;
945 glhd_pipe
->base
.set_framebuffer_state
= galahad_set_framebuffer_state
;
946 glhd_pipe
->base
.set_polygon_stipple
= galahad_set_polygon_stipple
;
947 glhd_pipe
->base
.set_scissor_state
= galahad_set_scissor_state
;
948 glhd_pipe
->base
.set_viewport_state
= galahad_set_viewport_state
;
949 glhd_pipe
->base
.set_fragment_sampler_views
= galahad_set_fragment_sampler_views
;
950 glhd_pipe
->base
.set_vertex_sampler_views
= galahad_set_vertex_sampler_views
;
951 glhd_pipe
->base
.set_vertex_buffers
= galahad_set_vertex_buffers
;
952 glhd_pipe
->base
.resource_copy_region
= galahad_resource_copy_region
;
953 glhd_pipe
->base
.clear
= galahad_clear
;
954 glhd_pipe
->base
.clear_render_target
= galahad_clear_render_target
;
955 glhd_pipe
->base
.clear_depth_stencil
= galahad_clear_depth_stencil
;
956 glhd_pipe
->base
.flush
= galahad_flush
;
957 glhd_pipe
->base
.is_resource_referenced
= galahad_is_resource_referenced
;
958 glhd_pipe
->base
.create_sampler_view
= galahad_context_create_sampler_view
;
959 glhd_pipe
->base
.sampler_view_destroy
= galahad_context_sampler_view_destroy
;
960 glhd_pipe
->base
.get_transfer
= galahad_context_get_transfer
;
961 glhd_pipe
->base
.transfer_destroy
= galahad_context_transfer_destroy
;
962 glhd_pipe
->base
.transfer_map
= galahad_context_transfer_map
;
963 glhd_pipe
->base
.transfer_unmap
= galahad_context_transfer_unmap
;
964 glhd_pipe
->base
.transfer_flush_region
= galahad_context_transfer_flush_region
;
965 glhd_pipe
->base
.transfer_inline_write
= galahad_context_transfer_inline_write
;
967 glhd_pipe
->pipe
= pipe
;
969 return &glhd_pipe
->base
;