1 /**********************************************************
2 * Copyright 2008-2017 VMware, Inc. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 **********************************************************/
26 #include "svga_context.h"
27 #include "svga_debug.h"
29 #include "svga_format.h"
30 #include "svga_resource_buffer.h"
31 #include "svga_resource_texture.h"
32 #include "svga_surface.h"
34 //#include "util/u_blit_sw.h"
35 #include "util/u_format.h"
36 #include "util/u_surface.h"
38 #define FILE_DEBUG_FLAG DEBUG_BLIT
42 * Build a struct pipe_blit_info object from the arguments used by the
43 * pipe::resource_copy_region() function.
46 build_blit_info(struct pipe_resource
*dst_tex
,
51 struct pipe_resource
*src_tex
,
53 const struct pipe_box
*src_box
,
54 struct pipe_blit_info
*blit
)
56 memset(blit
, 0, sizeof(*blit
));
58 blit
->src
.format
= src_tex
->format
;
59 blit
->dst
.format
= dst_tex
->format
;
61 blit
->mask
= util_format_get_mask(blit
->dst
.format
);
62 blit
->filter
= PIPE_TEX_FILTER_NEAREST
;
63 blit
->src
.resource
= src_tex
;
64 blit
->src
.level
= src_level
;
65 blit
->dst
.resource
= dst_tex
;
66 blit
->dst
.level
= dst_level
;
67 blit
->src
.box
= *src_box
;
68 u_box_3d(dst_x
, dst_y
, dst_z
, src_box
->width
, src_box
->height
,
69 src_box
->depth
, &blit
->dst
.box
);
74 * Copy an image between textures with the vgpu10 CopyRegion command.
77 copy_region_vgpu10(struct svga_context
*svga
, struct pipe_resource
*src_tex
,
78 unsigned src_x
, unsigned src_y
, unsigned src_z
,
79 unsigned src_level
, unsigned src_face
,
80 struct pipe_resource
*dst_tex
,
81 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
82 unsigned dst_level
, unsigned dst_face
,
83 unsigned width
, unsigned height
, unsigned depth
)
86 uint32 srcSubResource
, dstSubResource
;
87 struct svga_texture
*dtex
, *stex
;
90 stex
= svga_texture(src_tex
);
91 dtex
= svga_texture(dst_tex
);
93 svga_surfaces_flush(svga
);
105 srcSubResource
= src_face
* (src_tex
->last_level
+ 1) + src_level
;
106 dstSubResource
= dst_face
* (dst_tex
->last_level
+ 1) + dst_level
;
108 ret
= SVGA3D_vgpu10_PredCopyRegion(svga
->swc
,
109 dtex
->handle
, dstSubResource
,
110 stex
->handle
, srcSubResource
, &box
);
111 if (ret
!= PIPE_OK
) {
112 svga_context_flush(svga
, NULL
);
113 ret
= SVGA3D_vgpu10_PredCopyRegion(svga
->swc
,
114 dtex
->handle
, dstSubResource
,
115 stex
->handle
, srcSubResource
, &box
);
116 assert(ret
== PIPE_OK
);
119 /* Mark the texture subresource as defined. */
120 svga_define_texture_level(dtex
, dst_face
, dst_level
);
122 /* Mark the texture subresource as rendered-to. */
123 svga_set_texture_rendered_to(dtex
, dst_face
, dst_level
);
128 * Fallback to the copy region utility which uses map/memcpy for the copy
131 copy_region_fallback(struct svga_context
*svga
,
132 struct pipe_resource
*dst_tex
, unsigned dst_level
,
133 unsigned dstx
, unsigned dsty
, unsigned dstz
,
134 struct pipe_resource
*src_tex
, unsigned src_level
,
135 const struct pipe_box
*src_box
)
137 struct svga_winsys_screen
*sws
= svga_screen(svga
->pipe
.screen
)->sws
;
139 SVGA_STATS_TIME_PUSH(sws
, SVGA_STATS_TIME_COPYREGIONFALLBACK
);
140 util_resource_copy_region(&svga
->pipe
, dst_tex
, dst_level
, dstx
,
141 dsty
, dstz
, src_tex
, src_level
, src_box
);
142 SVGA_STATS_TIME_POP(sws
);
148 * For some texture types, we need to move the z (slice) coordinate
149 * to the layer value. For example, to select the z=3 slice of a 2D ARRAY
150 * texture, we need to use layer=3 and set z=0.
153 adjust_z_layer(enum pipe_texture_target target
,
154 int z_in
, unsigned *layer_out
, unsigned *z_out
)
156 if (target
== PIPE_TEXTURE_CUBE
||
157 target
== PIPE_TEXTURE_2D_ARRAY
||
158 target
== PIPE_TEXTURE_1D_ARRAY
) {
170 * Are the given SVGA3D formats compatible, in terms of vgpu10's
171 * PredCopyRegion() command?
174 formats_compatible(const struct svga_screen
*ss
,
175 SVGA3dSurfaceFormat src_svga_fmt
,
176 SVGA3dSurfaceFormat dst_svga_fmt
)
178 src_svga_fmt
= svga_typeless_format(src_svga_fmt
);
179 dst_svga_fmt
= svga_typeless_format(dst_svga_fmt
);
181 return src_svga_fmt
== dst_svga_fmt
;
186 * Check whether the blending is enabled or not
189 is_blending_enabled(struct svga_context
*svga
,
190 const struct pipe_blit_info
*blit
)
192 bool blend_enable
= false;
194 if (svga
->curr
.blend
) {
195 if (svga
->curr
.blend
->independent_blend_enable
) {
196 for (i
= 0; i
< PIPE_MAX_COLOR_BUFS
; i
++) {
197 if (svga
->curr
.framebuffer
.cbufs
[i
]->texture
== blit
->dst
.resource
) {
198 if (svga
->curr
.blend
->rt
[i
].blend_enable
) {
206 if (svga
->curr
.blend
->rt
[0].blend_enable
)
215 * If GL_FRAMEBUFFER_SRGB is enabled, then output colorspace is
216 * expected to be sRGB if blending is not enabled.
217 * If GL_FRAMEBUFFER_SRGB is disabled, then we can use
218 * copy_region_vgpu10()
219 * Following table basically tells when copy_region_vgpu10 can be
220 * used if GL_FRAMEBUFFER_SRGB is enabled.
221 * ______________________________________________________________
222 * | src fmt | dst_fmt | blending |Can use |
223 * | | | |copy_region |
224 * ______________________________________________________________
225 * | linear | linear | N | Y |
226 * | linear | linear | Y | Y |
227 * | linear | sRGB | N | N |
228 * | linear | sRGB | Y | Y |
229 * | sRGB | linear | N | N |
230 * | sRGB | linear | Y | N |
231 * | sRGB | sRGB | N | Y |
232 * | sRGB | sRGB | Y | N |
233 * ______________________________________________________________
237 check_blending_and_srgb_cond(struct svga_context
*svga
,
238 const struct pipe_blit_info
*blit
)
240 enum pipe_format sFmt
= blit
->src
.format
;
241 enum pipe_format dFmt
= blit
->dst
.format
;
243 if (is_blending_enabled(svga
, blit
)) {
244 if (!util_format_is_srgb(blit
->src
.format
))
248 if (util_format_is_srgb(sFmt
) && util_format_is_srgb(dFmt
))
250 else if (!util_format_is_srgb(sFmt
)){
251 if (!util_format_is_srgb(dFmt
))
255 * State tracker converts all sRGB src blit format
256 * to linear if GL_FRAMEBUFFER_SRGB is disabled.
257 * So if src resource format is sRGB and
258 * blit format is linear then it means,
259 * GL_FRAMEBUFFER_SRGB is disabled. In this case also
260 * we can use copy_region_vgpu10().
263 if (util_format_is_srgb(blit
->src
.resource
->format
))
272 * Do common checks for svga surface copy.
275 can_blit_via_svga_copy_region(struct svga_context
*svga
,
276 const struct pipe_blit_info
*blit_info
)
278 if (!util_can_blit_via_copy_region(blit_info
, FALSE
) &&
279 !util_can_blit_via_copy_region(blit_info
, TRUE
))
282 /* For depth+stencil formats, copy with mask != PIPE_MASK_ZS is not
285 if (util_format_is_depth_and_stencil(blit_info
->src
.format
) &&
286 blit_info
->mask
!= (PIPE_MASK_ZS
))
289 return check_blending_and_srgb_cond(svga
, blit_info
);
294 * The state tracker implements some resource copies with blits (for
295 * GL_ARB_copy_image). This function checks if we should really do the blit
296 * with a VGPU10 CopyRegion command or software fallback (for incompatible
300 can_blit_via_copy_region_vgpu10(struct svga_context
*svga
,
301 const struct pipe_blit_info
*blit_info
)
303 struct svga_texture
*dtex
, *stex
;
305 /* can't copy between different resource types */
306 if (svga_resource_type(blit_info
->src
.resource
->target
) !=
307 svga_resource_type(blit_info
->dst
.resource
->target
))
310 stex
= svga_texture(blit_info
->src
.resource
);
311 dtex
= svga_texture(blit_info
->dst
.resource
);
313 if (!svga_have_vgpu10(svga
))
316 if (stex
->handle
== dtex
->handle
)
319 return formats_compatible(svga_screen(svga
->pipe
.screen
),
326 * Check whether we can blit using the surface_copy command.
329 can_blit_via_surface_copy(struct svga_context
*svga
,
330 const struct pipe_blit_info
*blit_info
)
332 struct svga_texture
*dtex
, *stex
;
334 if (svga
->render_condition
&& blit_info
->render_condition_enable
)
337 /* can't copy between different resource types */
338 if (svga_resource_type(blit_info
->src
.resource
->target
) !=
339 svga_resource_type(blit_info
->dst
.resource
->target
))
342 stex
= svga_texture(blit_info
->src
.resource
);
343 dtex
= svga_texture(blit_info
->dst
.resource
);
345 if (stex
->handle
== dtex
->handle
)
349 * This is what we've been using before, but it can probably be
350 * relaxed. The device checks are less stringent.
352 return (stex
->b
.b
.format
== dtex
->b
.b
.format
);
357 * Try region copy using one of the region copy commands
360 try_copy_region(struct svga_context
*svga
,
361 const struct pipe_blit_info
*blit
)
363 unsigned src_face
, src_z
, dst_face
, dst_z
;
365 if (!can_blit_via_svga_copy_region(svga
, blit
))
368 adjust_z_layer(blit
->src
.resource
->target
, blit
->src
.box
.z
,
371 adjust_z_layer(blit
->dst
.resource
->target
, blit
->dst
.box
.z
,
374 if (can_blit_via_copy_region_vgpu10(svga
, blit
)) {
375 svga_toggle_render_condition(svga
, blit
->render_condition_enable
, FALSE
);
377 copy_region_vgpu10(svga
,
379 blit
->src
.box
.x
, blit
->src
.box
.y
, src_z
,
380 blit
->src
.level
, src_face
,
382 blit
->dst
.box
.x
, blit
->dst
.box
.y
, dst_z
,
383 blit
->dst
.level
, dst_face
,
384 blit
->src
.box
.width
, blit
->src
.box
.height
,
385 blit
->src
.box
.depth
);
387 svga_toggle_render_condition(svga
, blit
->render_condition_enable
, TRUE
);
392 if (can_blit_via_surface_copy(svga
, blit
)) {
393 struct svga_texture
*stex
= svga_texture(blit
->src
.resource
);
394 struct svga_texture
*dtex
= svga_texture(blit
->dst
.resource
);
396 svga_surfaces_flush(svga
);
398 svga_texture_copy_handle(svga
,
400 blit
->src
.box
.x
, blit
->src
.box
.y
, src_z
,
401 blit
->src
.level
, src_face
,
403 blit
->dst
.box
.x
, blit
->dst
.box
.y
, dst_z
,
404 blit
->dst
.level
, dst_face
,
405 blit
->src
.box
.width
, blit
->src
.box
.height
,
406 blit
->src
.box
.depth
);
408 svga_define_texture_level(dtex
, dst_face
, blit
->dst
.level
);
409 svga_set_texture_rendered_to(dtex
, dst_face
, blit
->dst
.level
);
418 * A helper function to determine if the specified view format
419 * is compatible with the surface format.
420 * It is compatible if the view format is the same as the surface format,
421 * or the associated svga format for the surface is a typeless format, or
422 * the view format is an adjusted format for BGRX/BGRA resource.
425 is_view_format_compatible(enum pipe_format surf_fmt
,
426 SVGA3dSurfaceFormat surf_svga_fmt
,
427 enum pipe_format view_fmt
)
429 if (surf_fmt
== view_fmt
|| svga_format_is_typeless(surf_svga_fmt
))
432 if ((surf_fmt
== PIPE_FORMAT_B8G8R8X8_UNORM
&&
433 view_fmt
== PIPE_FORMAT_B8G8R8A8_UNORM
) ||
434 (surf_fmt
== PIPE_FORMAT_B8G8R8A8_UNORM
&&
435 view_fmt
== PIPE_FORMAT_B8G8R8X8_UNORM
))
443 * Try issuing a quad blit.
446 try_blit(struct svga_context
*svga
, const struct pipe_blit_info
*blit_info
)
448 struct svga_winsys_screen
*sws
= svga_screen(svga
->pipe
.screen
)->sws
;
449 struct pipe_resource
*src
= blit_info
->src
.resource
;
450 struct pipe_resource
*dst
= blit_info
->dst
.resource
;
451 struct pipe_resource
*newSrc
= NULL
;
452 struct pipe_resource
*newDst
= NULL
;
453 bool can_create_src_view
;
454 bool can_create_dst_view
;
456 struct pipe_blit_info blit
= *blit_info
;
458 SVGA_STATS_TIME_PUSH(sws
, SVGA_STATS_TIME_BLITBLITTER
);
461 * If format is srgb and blend is enabled then color values need
462 * to be converted into linear format.
464 if (is_blending_enabled(svga
, &blit
))
465 blit
.src
.format
= util_format_linear(blit
.src
.format
);
467 /* Check if we can create shader resource view and
468 * render target view for the quad blitter to work
470 can_create_src_view
=
471 is_view_format_compatible(src
->format
, svga_texture(src
)->key
.format
,
474 can_create_dst_view
=
475 is_view_format_compatible(dst
->format
, svga_texture(dst
)->key
.format
,
478 if ((blit
.mask
& PIPE_MASK_S
) ||
479 ((!can_create_dst_view
|| !can_create_src_view
)
480 && !svga_have_vgpu10(svga
))) {
481 /* Can't do stencil blits with textured quad blitter */
482 debug_warn_once("using software stencil blit");
487 if (!util_blitter_is_blit_supported(svga
->blitter
, &blit
)) {
488 debug_printf("svga: blit unsupported %s -> %s\n",
489 util_format_short_name(blit
.src
.resource
->format
),
490 util_format_short_name(blit
.dst
.resource
->format
));
495 /* XXX turn off occlusion and streamout queries */
497 util_blitter_save_vertex_buffer_slot(svga
->blitter
, svga
->curr
.vb
);
498 util_blitter_save_vertex_elements(svga
->blitter
, (void*)svga
->curr
.velems
);
499 util_blitter_save_vertex_shader(svga
->blitter
, svga
->curr
.vs
);
500 util_blitter_save_geometry_shader(svga
->blitter
, svga
->curr
.user_gs
);
501 util_blitter_save_so_targets(svga
->blitter
, svga
->num_so_targets
,
502 (struct pipe_stream_output_target
**)svga
->so_targets
);
503 util_blitter_save_rasterizer(svga
->blitter
, (void*)svga
->curr
.rast
);
504 util_blitter_save_viewport(svga
->blitter
, &svga
->curr
.viewport
);
505 util_blitter_save_scissor(svga
->blitter
, &svga
->curr
.scissor
);
506 util_blitter_save_fragment_shader(svga
->blitter
, svga
->curr
.fs
);
507 util_blitter_save_blend(svga
->blitter
, (void*)svga
->curr
.blend
);
508 util_blitter_save_depth_stencil_alpha(svga
->blitter
,
509 (void*)svga
->curr
.depth
);
510 util_blitter_save_stencil_ref(svga
->blitter
, &svga
->curr
.stencil_ref
);
511 util_blitter_save_sample_mask(svga
->blitter
, svga
->curr
.sample_mask
);
512 util_blitter_save_framebuffer(svga
->blitter
, &svga
->curr
.framebuffer
);
513 util_blitter_save_fragment_sampler_states(svga
->blitter
,
514 svga
->curr
.num_samplers
[PIPE_SHADER_FRAGMENT
],
515 (void**)svga
->curr
.sampler
[PIPE_SHADER_FRAGMENT
]);
516 util_blitter_save_fragment_sampler_views(svga
->blitter
,
517 svga
->curr
.num_sampler_views
[PIPE_SHADER_FRAGMENT
],
518 svga
->curr
.sampler_views
[PIPE_SHADER_FRAGMENT
]);
520 if (!can_create_src_view
) {
521 struct pipe_resource
template;
522 struct pipe_blit_info copy_region_blit
;
525 * If the source blit format is not compatible with the source resource
526 * format, we will not be able to create a shader resource view.
527 * In order to avoid falling back to software blit, we'll create
528 * a new resource in the blit format, and use DXCopyResource to
529 * copy from the original format to the new format. The new
530 * resource will be used for the blit in util_blitter_blit().
533 template.format
= blit
.src
.format
;
534 newSrc
= svga_texture_create(svga
->pipe
.screen
, &template);
535 if (newSrc
== NULL
) {
536 debug_printf("svga_blit: fails to create temporary src\n");
541 /* increment the mksStats for blitter with extra copy */
542 SVGA_STATS_COUNT_INC(sws
, SVGA_STATS_COUNT_BLITBLITTERCOPY
);
543 build_blit_info(newSrc
,
544 blit
.src
.level
, blit
.src
.box
.x
,
545 blit
.src
.box
.y
, blit
.src
.box
.z
,
547 blit
.src
.level
, &blit
.src
.box
,
549 if (!try_copy_region(svga
, ©_region_blit
)) {
554 blit
.src
.resource
= newSrc
;
557 if (!can_create_dst_view
) {
558 struct pipe_resource
template;
561 * If the destination blit format is not compatible with the destination
562 * resource format, we will not be able to create a render target view.
563 * In order to avoid falling back to software blit, we'll create
564 * a new resource in the blit format, and use DXPredCopyRegion
565 * after the blit to copy from the blit format back to the resource
569 template.format
= blit
.dst
.format
;
570 newDst
= svga_texture_create(svga
->pipe
.screen
, &template);
571 if (newDst
== NULL
) {
572 debug_printf("svga_blit: fails to create temporary dst\n");
577 blit
.dst
.resource
= newDst
;
580 svga_toggle_render_condition(svga
, blit
.render_condition_enable
, FALSE
);
582 util_blitter_blit(svga
->blitter
, &blit
);
584 svga_toggle_render_condition(svga
, blit
.render_condition_enable
, TRUE
);
586 if (blit
.dst
.resource
!= dst
) {
587 struct pipe_blit_info copy_region_blit
;
589 /* increment the mksStats for blitter with extra copy */
590 SVGA_STATS_COUNT_INC(sws
, SVGA_STATS_COUNT_BLITBLITTERCOPY
);
593 * A temporary resource was created for the blit, we need to
594 * copy from the temporary resource back to the original destination.
596 build_blit_info(blit
.dst
.resource
,
597 blit
.dst
.level
, blit
.dst
.box
.x
,
598 blit
.dst
.box
.y
, blit
.dst
.box
.z
,
600 blit
.dst
.level
, &blit
.dst
.box
,
602 if (!try_copy_region(svga
, ©_region_blit
)) {
609 /* unreference the temporary resources if needed */
610 pipe_resource_reference(&newDst
, NULL
);
611 pipe_resource_reference(&newSrc
, NULL
);
613 SVGA_STATS_TIME_POP(sws
); /* SVGA_STATS_TIME_BLITBLITTER */
621 * Try a cpu copy_region fallback.
624 try_cpu_copy_region(struct svga_context
*svga
,
625 const struct pipe_blit_info
*blit
)
627 if (util_can_blit_via_copy_region(blit
, TRUE
) ||
628 util_can_blit_via_copy_region(blit
, FALSE
)) {
630 if (svga
->render_condition
&& blit
->render_condition_enable
) {
631 debug_warning("CPU copy_region doesn't support "
632 "conditional rendering.\n");
636 copy_region_fallback(svga
, blit
->dst
.resource
,
638 blit
->dst
.box
.x
, blit
->dst
.box
.y
,
639 blit
->dst
.box
.z
, blit
->src
.resource
,
640 blit
->src
.level
, &blit
->src
.box
);
649 * The pipe::blit member.
652 svga_blit(struct pipe_context
*pipe
,
653 const struct pipe_blit_info
*blit
)
655 struct svga_context
*svga
= svga_context(pipe
);
656 struct svga_winsys_screen
*sws
= svga_screen(pipe
->screen
)->sws
;
658 if (!svga_have_vgpu10(svga
) &&
659 blit
->src
.resource
->nr_samples
> 1 &&
660 blit
->dst
.resource
->nr_samples
<= 1 &&
661 !util_format_is_depth_or_stencil(blit
->src
.resource
->format
) &&
662 !util_format_is_pure_integer(blit
->src
.resource
->format
)) {
663 debug_printf("svga: color resolve unimplemented\n");
667 SVGA_STATS_TIME_PUSH(sws
, SVGA_STATS_TIME_BLIT
);
669 if (try_copy_region(svga
, blit
))
672 if (try_blit(svga
, blit
))
675 if (!try_cpu_copy_region(svga
, blit
))
676 debug_printf("svga: Blit failed.\n");
679 SVGA_STATS_TIME_POP(sws
); /* SVGA_STATS_TIME_BLIT */
685 * The pipe::resource_copy_region member.
688 svga_resource_copy_region(struct pipe_context
*pipe
,
689 struct pipe_resource
*dst_tex
,
691 unsigned dstx
, unsigned dsty
, unsigned dstz
,
692 struct pipe_resource
*src_tex
,
694 const struct pipe_box
*src_box
)
696 struct svga_context
*svga
= svga_context(pipe
);
697 struct svga_winsys_screen
*sws
= svga_screen(svga
->pipe
.screen
)->sws
;
699 SVGA_STATS_TIME_PUSH(sws
, SVGA_STATS_TIME_COPYREGION
);
701 if (dst_tex
->target
== PIPE_BUFFER
&& src_tex
->target
== PIPE_BUFFER
) {
702 /* can't copy within the same buffer, unfortunately */
703 if (svga_have_vgpu10(svga
) && src_tex
!= dst_tex
) {
705 struct svga_winsys_surface
*src_surf
;
706 struct svga_winsys_surface
*dst_surf
;
707 struct svga_buffer
*dbuffer
= svga_buffer(dst_tex
);
709 src_surf
= svga_buffer_handle(svga
, src_tex
);
710 dst_surf
= svga_buffer_handle(svga
, dst_tex
);
712 ret
= SVGA3D_vgpu10_BufferCopy(svga
->swc
, src_surf
, dst_surf
,
713 src_box
->x
, dstx
, src_box
->width
);
714 if (ret
!= PIPE_OK
) {
715 svga_context_flush(svga
, NULL
);
716 ret
= SVGA3D_vgpu10_BufferCopy(svga
->swc
, src_surf
, dst_surf
,
717 src_box
->x
, dstx
, src_box
->width
);
718 assert(ret
== PIPE_OK
);
721 dbuffer
->dirty
= TRUE
;
724 /* use map/memcpy fallback */
725 copy_region_fallback(svga
, dst_tex
, dst_level
, dstx
,
726 dsty
, dstz
, src_tex
, src_level
, src_box
);
729 struct pipe_blit_info blit
;
731 build_blit_info(dst_tex
, dst_level
, dstx
, dsty
, dstz
,
732 src_tex
, src_level
, src_box
, &blit
);
734 if (try_copy_region(svga
, &blit
))
737 /* Blits are format-converting which is not what we want, so perform a
738 * strict format-check.
739 * FIXME: Need to figure out why srgb blits (tf2) and
740 * 3D blits (piglit) are broken here. Perhaps we set up the
741 * struct pipe_blit_info incorrectly.
743 if (src_tex
->format
== dst_tex
->format
&&
744 !util_format_is_srgb(src_tex
->format
) &&
745 svga_resource_type(src_tex
->target
) != SVGA3D_RESOURCE_TEXTURE3D
&&
746 try_blit(svga
, &blit
))
749 copy_region_fallback(svga
, dst_tex
, dst_level
, dstx
, dsty
, dstz
,
750 src_tex
, src_level
, src_box
);
754 SVGA_STATS_TIME_POP(sws
);
760 * The pipe::flush_resource member.
763 svga_flush_resource(struct pipe_context
*pipe
,
764 struct pipe_resource
*resource
)
770 * Setup the pipe blit, resource_copy_region and flush_resource members.
773 svga_init_blit_functions(struct svga_context
*svga
)
775 svga
->pipe
.resource_copy_region
= svga_resource_copy_region
;
776 svga
->pipe
.blit
= svga_blit
;
777 svga
->pipe
.flush_resource
= svga_flush_resource
;