1 /**************************************************************************
3 * Copyright 2009 VMware, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
29 * Surface utility functions.
35 #include "pipe/p_defines.h"
36 #include "pipe/p_screen.h"
37 #include "pipe/p_state.h"
39 #include "util/u_format.h"
40 #include "util/u_inlines.h"
41 #include "util/u_rect.h"
42 #include "util/u_surface.h"
43 #include "util/u_pack_color.h"
47 * Initialize a pipe_surface object. 'view' is considered to have
48 * uninitialized contents.
51 u_surface_default_template(struct pipe_surface
*surf
,
52 const struct pipe_resource
*texture
)
54 memset(surf
, 0, sizeof(*surf
));
56 surf
->format
= texture
->format
;
61 * Copy 2D rect from one place to another.
62 * Position and sizes are in pixels.
63 * src_stride may be negative to do vertical flip of pixels from source.
66 util_copy_rect(ubyte
* dst
,
67 enum pipe_format format
,
79 int src_stride_pos
= src_stride
< 0 ? -src_stride
: src_stride
;
80 int blocksize
= util_format_get_blocksize(format
);
81 int blockwidth
= util_format_get_blockwidth(format
);
82 int blockheight
= util_format_get_blockheight(format
);
84 assert(blocksize
> 0);
85 assert(blockwidth
> 0);
86 assert(blockheight
> 0);
90 width
= (width
+ blockwidth
- 1)/blockwidth
;
91 height
= (height
+ blockheight
- 1)/blockheight
;
95 dst
+= dst_x
* blocksize
;
96 src
+= src_x
* blocksize
;
97 dst
+= dst_y
* dst_stride
;
98 src
+= src_y
* src_stride_pos
;
101 if (width
== dst_stride
&& width
== src_stride
)
102 memcpy(dst
, src
, height
* width
);
104 for (i
= 0; i
< height
; i
++) {
105 memcpy(dst
, src
, width
);
114 * Copy 3D box from one place to another.
115 * Position and sizes are in pixels.
118 util_copy_box(ubyte
* dst
,
119 enum pipe_format format
,
120 unsigned dst_stride
, unsigned dst_slice_stride
,
121 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
122 unsigned width
, unsigned height
, unsigned depth
,
124 int src_stride
, unsigned src_slice_stride
,
125 unsigned src_x
, unsigned src_y
, unsigned src_z
)
128 dst
+= dst_z
* dst_slice_stride
;
129 src
+= src_z
* src_slice_stride
;
130 for (z
= 0; z
< depth
; ++z
) {
140 dst
+= dst_slice_stride
;
141 src
+= src_slice_stride
;
147 util_fill_rect(ubyte
* dst
,
148 enum pipe_format format
,
154 union util_color
*uc
)
156 const struct util_format_description
*desc
= util_format_description(format
);
159 int blocksize
= desc
->block
.bits
/ 8;
160 int blockwidth
= desc
->block
.width
;
161 int blockheight
= desc
->block
.height
;
163 assert(blocksize
> 0);
164 assert(blockwidth
> 0);
165 assert(blockheight
> 0);
168 dst_y
/= blockheight
;
169 width
= (width
+ blockwidth
- 1)/blockwidth
;
170 height
= (height
+ blockheight
- 1)/blockheight
;
172 dst
+= dst_x
* blocksize
;
173 dst
+= dst_y
* dst_stride
;
174 width_size
= width
* blocksize
;
178 if(dst_stride
== width_size
)
179 memset(dst
, uc
->ub
, height
* width_size
);
181 for (i
= 0; i
< height
; i
++) {
182 memset(dst
, uc
->ub
, width_size
);
188 for (i
= 0; i
< height
; i
++) {
189 uint16_t *row
= (uint16_t *)dst
;
190 for (j
= 0; j
< width
; j
++)
196 for (i
= 0; i
< height
; i
++) {
197 uint32_t *row
= (uint32_t *)dst
;
198 for (j
= 0; j
< width
; j
++)
204 for (i
= 0; i
< height
; i
++) {
206 for (j
= 0; j
< width
; j
++) {
207 memcpy(row
, uc
, blocksize
);
218 util_fill_box(ubyte
* dst
,
219 enum pipe_format format
,
221 unsigned layer_stride
,
228 union util_color
*uc
)
231 dst
+= z
* layer_stride
;
232 for (layer
= z
; layer
< depth
; layer
++) {
233 util_fill_rect(dst
, format
,
235 x
, y
, width
, height
, uc
);
242 * Fallback function for pipe->resource_copy_region().
243 * We support copying between different formats (including compressed/
244 * uncompressed) if the bytes per block or pixel matches. If copying
245 * compressed -> uncompressed, the dst region is reduced by the block
246 * width, height. If copying uncompressed -> compressed, the dest region
247 * is expanded by the block width, height. See GL_ARB_copy_image.
248 * Note: (X,Y)=(0,0) is always the upper-left corner.
251 util_resource_copy_region(struct pipe_context
*pipe
,
252 struct pipe_resource
*dst
,
254 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
255 struct pipe_resource
*src
,
257 const struct pipe_box
*src_box_in
)
259 struct pipe_transfer
*src_trans
, *dst_trans
;
261 const uint8_t *src_map
;
262 MAYBE_UNUSED
enum pipe_format src_format
;
263 enum pipe_format dst_format
;
264 struct pipe_box src_box
, dst_box
;
265 unsigned src_bs
, dst_bs
, src_bw
, dst_bw
, src_bh
, dst_bh
;
271 assert((src
->target
== PIPE_BUFFER
&& dst
->target
== PIPE_BUFFER
) ||
272 (src
->target
!= PIPE_BUFFER
&& dst
->target
!= PIPE_BUFFER
));
274 src_format
= src
->format
;
275 dst_format
= dst
->format
;
278 src_box
= *src_box_in
;
284 dst_box
.width
= src_box
.width
;
285 dst_box
.height
= src_box
.height
;
286 dst_box
.depth
= src_box
.depth
;
288 src_bs
= util_format_get_blocksize(src_format
);
289 src_bw
= util_format_get_blockwidth(src_format
);
290 src_bh
= util_format_get_blockheight(src_format
);
291 dst_bs
= util_format_get_blocksize(dst_format
);
292 dst_bw
= util_format_get_blockwidth(dst_format
);
293 dst_bh
= util_format_get_blockheight(dst_format
);
295 /* Note: all box positions and sizes are in pixels */
296 if (src_bw
> 1 && dst_bw
== 1) {
297 /* Copy from compressed to uncompressed.
298 * Shrink dest box by the src block size.
300 dst_box
.width
/= src_bw
;
301 dst_box
.height
/= src_bh
;
303 else if (src_bw
== 1 && dst_bw
> 1) {
304 /* Copy from uncompressed to compressed.
305 * Expand dest box by the dest block size.
307 dst_box
.width
*= dst_bw
;
308 dst_box
.height
*= dst_bh
;
311 /* compressed -> compressed or uncompressed -> uncompressed copy */
312 assert(src_bw
== dst_bw
);
313 assert(src_bh
== dst_bh
);
316 assert(src_bs
== dst_bs
);
317 if (src_bs
!= dst_bs
) {
318 /* This can happen if we fail to do format checking before hand.
324 /* check that region boxes are block aligned */
325 assert(src_box
.x
% src_bw
== 0);
326 assert(src_box
.y
% src_bh
== 0);
327 assert(src_box
.width
% src_bw
== 0 ||
328 src_box
.x
+ src_box
.width
== u_minify(src
->width0
, src_level
));
329 assert(src_box
.height
% src_bh
== 0 ||
330 src_box
.y
+ src_box
.height
== u_minify(src
->height0
, src_level
));
331 assert(dst_box
.x
% dst_bw
== 0);
332 assert(dst_box
.y
% dst_bh
== 0);
333 assert(dst_box
.width
% dst_bw
== 0 ||
334 dst_box
.x
+ dst_box
.width
== u_minify(dst
->width0
, dst_level
));
335 assert(dst_box
.height
% dst_bh
== 0 ||
336 dst_box
.y
+ dst_box
.height
== u_minify(dst
->height0
, dst_level
));
338 /* check that region boxes are not out of bounds */
339 assert(src_box
.x
+ src_box
.width
<= u_minify(src
->width0
, src_level
));
340 assert(src_box
.y
+ src_box
.height
<= u_minify(src
->height0
, src_level
));
341 assert(dst_box
.x
+ dst_box
.width
<= u_minify(dst
->width0
, dst_level
));
342 assert(dst_box
.y
+ dst_box
.height
<= u_minify(dst
->height0
, dst_level
));
344 /* check that total number of src, dest bytes match */
345 assert((src_box
.width
/ src_bw
) * (src_box
.height
/ src_bh
) * src_bs
==
346 (dst_box
.width
/ dst_bw
) * (dst_box
.height
/ dst_bh
) * dst_bs
);
348 src_map
= pipe
->transfer_map(pipe
,
352 &src_box
, &src_trans
);
358 dst_map
= pipe
->transfer_map(pipe
,
361 PIPE_TRANSFER_WRITE
|
362 PIPE_TRANSFER_DISCARD_RANGE
, &dst_box
,
369 if (dst
->target
== PIPE_BUFFER
&& src
->target
== PIPE_BUFFER
) {
370 assert(src_box
.height
== 1);
371 assert(src_box
.depth
== 1);
372 memcpy(dst_map
, src_map
, src_box
.width
);
374 util_copy_box(dst_map
,
376 dst_trans
->stride
, dst_trans
->layer_stride
,
378 src_box
.width
, src_box
.height
, src_box
.depth
,
380 src_trans
->stride
, src_trans
->layer_stride
,
384 pipe
->transfer_unmap(pipe
, dst_trans
);
386 pipe
->transfer_unmap(pipe
, src_trans
);
392 util_clear_color_texture_helper(struct pipe_transfer
*dst_trans
,
394 enum pipe_format format
,
395 const union pipe_color_union
*color
,
396 unsigned width
, unsigned height
, unsigned depth
)
400 assert(dst_trans
->stride
> 0);
402 if (util_format_is_pure_integer(format
)) {
404 * We expect int/uint clear values here, though some APIs
405 * might disagree (but in any case util_pack_color()
406 * couldn't handle it)...
408 if (util_format_is_pure_sint(format
)) {
409 util_format_write_4i(format
, color
->i
, 0, &uc
, 0, 0, 0, 1, 1);
411 assert(util_format_is_pure_uint(format
));
412 util_format_write_4ui(format
, color
->ui
, 0, &uc
, 0, 0, 0, 1, 1);
415 util_pack_color(color
->f
, format
, &uc
);
418 util_fill_box(dst_map
, format
,
419 dst_trans
->stride
, dst_trans
->layer_stride
,
420 0, 0, 0, width
, height
, depth
, &uc
);
424 util_clear_color_texture(struct pipe_context
*pipe
,
425 struct pipe_resource
*texture
,
426 enum pipe_format format
,
427 const union pipe_color_union
*color
,
429 unsigned dstx
, unsigned dsty
, unsigned dstz
,
430 unsigned width
, unsigned height
, unsigned depth
)
432 struct pipe_transfer
*dst_trans
;
435 dst_map
= pipe_transfer_map_3d(pipe
,
440 width
, height
, depth
,
445 if (dst_trans
->stride
> 0) {
446 util_clear_color_texture_helper(dst_trans
, dst_map
, format
, color
,
447 width
, height
, depth
);
449 pipe
->transfer_unmap(pipe
, dst_trans
);
453 #define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
457 * Fallback for pipe->clear_render_target() function.
458 * XXX this looks too hackish to be really useful.
459 * cpp > 4 looks like a gross hack at best...
460 * Plus can't use these transfer fallbacks when clearing
461 * multisampled surfaces for instance.
462 * Clears all bound layers.
465 util_clear_render_target(struct pipe_context
*pipe
,
466 struct pipe_surface
*dst
,
467 const union pipe_color_union
*color
,
468 unsigned dstx
, unsigned dsty
,
469 unsigned width
, unsigned height
)
471 struct pipe_transfer
*dst_trans
;
474 assert(dst
->texture
);
478 if (dst
->texture
->target
== PIPE_BUFFER
) {
480 * The fill naturally works on the surface format, however
481 * the transfer uses resource format which is just bytes for buffers.
484 unsigned pixstride
= util_format_get_blocksize(dst
->format
);
485 dx
= (dst
->u
.buf
.first_element
+ dstx
) * pixstride
;
486 w
= width
* pixstride
;
487 dst_map
= pipe_transfer_map(pipe
,
494 util_clear_color_texture_helper(dst_trans
, dst_map
, dst
->format
,
495 color
, width
, height
, 1);
496 pipe
->transfer_unmap(pipe
, dst_trans
);
500 unsigned depth
= dst
->u
.tex
.last_layer
- dst
->u
.tex
.first_layer
+ 1;
501 util_clear_color_texture(pipe
, dst
->texture
, dst
->format
, color
,
502 dst
->u
.tex
.level
, dstx
, dsty
,
503 dst
->u
.tex
.first_layer
, width
, height
, depth
);
508 util_clear_depth_stencil_texture(struct pipe_context
*pipe
,
509 struct pipe_resource
*texture
,
510 enum pipe_format format
,
511 unsigned clear_flags
,
512 uint64_t zstencil
, unsigned level
,
513 unsigned dstx
, unsigned dsty
, unsigned dstz
,
514 unsigned width
, unsigned height
, unsigned depth
)
516 struct pipe_transfer
*dst_trans
;
518 boolean need_rmw
= FALSE
;
521 unsigned i
, j
, layer
;
523 if ((clear_flags
& PIPE_CLEAR_DEPTHSTENCIL
) &&
524 ((clear_flags
& PIPE_CLEAR_DEPTHSTENCIL
) != PIPE_CLEAR_DEPTHSTENCIL
) &&
525 util_format_is_depth_and_stencil(format
))
528 dst_map
= pipe_transfer_map_3d(pipe
,
531 (need_rmw
? PIPE_TRANSFER_READ_WRITE
:
532 PIPE_TRANSFER_WRITE
),
534 width
, height
, depth
, &dst_trans
);
539 dst_stride
= dst_trans
->stride
;
541 assert(dst_trans
->stride
> 0);
543 for (layer
= 0; layer
< depth
; layer
++) {
546 switch (util_format_get_blocksize(format
)) {
548 assert(format
== PIPE_FORMAT_S8_UINT
);
549 if(dst_stride
== width
)
550 memset(dst_map
, (uint8_t) zstencil
, height
* width
);
552 for (i
= 0; i
< height
; i
++) {
553 memset(dst_map
, (uint8_t) zstencil
, width
);
554 dst_map
+= dst_stride
;
559 assert(format
== PIPE_FORMAT_Z16_UNORM
);
560 for (i
= 0; i
< height
; i
++) {
561 uint16_t *row
= (uint16_t *)dst_map
;
562 for (j
= 0; j
< width
; j
++)
563 *row
++ = (uint16_t) zstencil
;
564 dst_map
+= dst_stride
;
569 for (i
= 0; i
< height
; i
++) {
570 uint32_t *row
= (uint32_t *)dst_map
;
571 for (j
= 0; j
< width
; j
++)
572 *row
++ = (uint32_t) zstencil
;
573 dst_map
+= dst_stride
;
578 if (format
== PIPE_FORMAT_Z24_UNORM_S8_UINT
)
579 dst_mask
= 0x00ffffff;
581 assert(format
== PIPE_FORMAT_S8_UINT_Z24_UNORM
);
582 dst_mask
= 0xffffff00;
584 if (clear_flags
& PIPE_CLEAR_DEPTH
)
585 dst_mask
= ~dst_mask
;
586 for (i
= 0; i
< height
; i
++) {
587 uint32_t *row
= (uint32_t *)dst_map
;
588 for (j
= 0; j
< width
; j
++) {
589 uint32_t tmp
= *row
& dst_mask
;
590 *row
++ = tmp
| ((uint32_t) zstencil
& ~dst_mask
);
592 dst_map
+= dst_stride
;
598 for (i
= 0; i
< height
; i
++) {
599 uint64_t *row
= (uint64_t *)dst_map
;
600 for (j
= 0; j
< width
; j
++)
602 dst_map
+= dst_stride
;
608 if (clear_flags
& PIPE_CLEAR_DEPTH
)
609 src_mask
= 0x00000000ffffffffull
;
611 src_mask
= 0x000000ff00000000ull
;
613 for (i
= 0; i
< height
; i
++) {
614 uint64_t *row
= (uint64_t *)dst_map
;
615 for (j
= 0; j
< width
; j
++) {
616 uint64_t tmp
= *row
& ~src_mask
;
617 *row
++ = tmp
| (zstencil
& src_mask
);
619 dst_map
+= dst_stride
;
627 dst_layer
+= dst_trans
->layer_stride
;
630 pipe
->transfer_unmap(pipe
, dst_trans
);
635 util_clear_texture(struct pipe_context
*pipe
,
636 struct pipe_resource
*tex
,
638 const struct pipe_box
*box
,
641 const struct util_format_description
*desc
=
642 util_format_description(tex
->format
);
644 if (level
> tex
->last_level
)
647 if (util_format_is_depth_or_stencil(tex
->format
)) {
653 if (util_format_has_depth(desc
)) {
654 clear
|= PIPE_CLEAR_DEPTH
;
655 desc
->unpack_z_float(&depth
, 0, data
, 0, 1, 1);
658 if (util_format_has_stencil(desc
)) {
659 clear
|= PIPE_CLEAR_STENCIL
;
660 desc
->unpack_s_8uint(&stencil
, 0, data
, 0, 1, 1);
663 zstencil
= util_pack64_z_stencil(tex
->format
, depth
, stencil
);
665 util_clear_depth_stencil_texture(pipe
, tex
, tex
->format
, clear
, zstencil
,
666 level
, box
->x
, box
->y
, box
->z
,
667 box
->width
, box
->height
, box
->depth
);
669 union pipe_color_union color
;
670 if (util_format_is_pure_uint(tex
->format
))
671 desc
->unpack_rgba_uint(color
.ui
, 0, data
, 0, 1, 1);
672 else if (util_format_is_pure_sint(tex
->format
))
673 desc
->unpack_rgba_sint(color
.i
, 0, data
, 0, 1, 1);
675 desc
->unpack_rgba_float(color
.f
, 0, data
, 0, 1, 1);
677 util_clear_color_texture(pipe
, tex
, tex
->format
, &color
, level
,
678 box
->x
, box
->y
, box
->z
,
679 box
->width
, box
->height
, box
->depth
);
685 * Fallback for pipe->clear_stencil() function.
686 * sw fallback doesn't look terribly useful here.
687 * Plus can't use these transfer fallbacks when clearing
688 * multisampled surfaces for instance.
689 * Clears all bound layers.
692 util_clear_depth_stencil(struct pipe_context
*pipe
,
693 struct pipe_surface
*dst
,
694 unsigned clear_flags
,
697 unsigned dstx
, unsigned dsty
,
698 unsigned width
, unsigned height
)
703 assert(dst
->texture
);
707 zstencil
= util_pack64_z_stencil(dst
->format
, depth
, stencil
);
708 max_layer
= dst
->u
.tex
.last_layer
- dst
->u
.tex
.first_layer
;
709 util_clear_depth_stencil_texture(pipe
, dst
->texture
, dst
->format
,
710 clear_flags
, zstencil
, dst
->u
.tex
.level
,
711 dstx
, dsty
, dst
->u
.tex
.first_layer
,
712 width
, height
, max_layer
+ 1);
716 /* Return if the box is totally inside the resource.
719 is_box_inside_resource(const struct pipe_resource
*res
,
720 const struct pipe_box
*box
,
723 unsigned width
= 1, height
= 1, depth
= 1;
725 switch (res
->target
) {
731 case PIPE_TEXTURE_1D
:
732 width
= u_minify(res
->width0
, level
);
736 case PIPE_TEXTURE_2D
:
737 case PIPE_TEXTURE_RECT
:
738 width
= u_minify(res
->width0
, level
);
739 height
= u_minify(res
->height0
, level
);
742 case PIPE_TEXTURE_3D
:
743 width
= u_minify(res
->width0
, level
);
744 height
= u_minify(res
->height0
, level
);
745 depth
= u_minify(res
->depth0
, level
);
747 case PIPE_TEXTURE_CUBE
:
748 width
= u_minify(res
->width0
, level
);
749 height
= u_minify(res
->height0
, level
);
752 case PIPE_TEXTURE_1D_ARRAY
:
753 width
= u_minify(res
->width0
, level
);
755 depth
= res
->array_size
;
757 case PIPE_TEXTURE_2D_ARRAY
:
758 width
= u_minify(res
->width0
, level
);
759 height
= u_minify(res
->height0
, level
);
760 depth
= res
->array_size
;
762 case PIPE_TEXTURE_CUBE_ARRAY
:
763 width
= u_minify(res
->width0
, level
);
764 height
= u_minify(res
->height0
, level
);
765 depth
= res
->array_size
;
766 assert(res
->array_size
% 6 == 0);
768 case PIPE_MAX_TEXTURE_TYPES
:
772 return box
->x
>= 0 &&
773 box
->x
+ box
->width
<= (int) width
&&
775 box
->y
+ box
->height
<= (int) height
&&
777 box
->z
+ box
->depth
<= (int) depth
;
781 get_sample_count(const struct pipe_resource
*res
)
783 return res
->nr_samples
? res
->nr_samples
: 1;
788 * Check if a blit() command can be implemented with a resource_copy_region().
789 * If tight_format_check is true, only allow the resource_copy_region() if
790 * the blit src/dst formats are identical, ignoring the resource formats.
791 * Otherwise, check for format casting and compatibility.
794 util_can_blit_via_copy_region(const struct pipe_blit_info
*blit
,
795 boolean tight_format_check
)
797 const struct util_format_description
*src_desc
, *dst_desc
;
799 src_desc
= util_format_description(blit
->src
.resource
->format
);
800 dst_desc
= util_format_description(blit
->dst
.resource
->format
);
802 if (tight_format_check
) {
803 /* no format conversions allowed */
804 if (blit
->src
.format
!= blit
->dst
.format
) {
809 /* do loose format compatibility checking */
810 if (blit
->src
.resource
->format
!= blit
->src
.format
||
811 blit
->dst
.resource
->format
!= blit
->dst
.format
||
812 !util_is_format_compatible(src_desc
, dst_desc
)) {
817 unsigned mask
= util_format_get_mask(blit
->dst
.format
);
819 /* No masks, no filtering, no scissor, no blending */
820 if ((blit
->mask
& mask
) != mask
||
821 blit
->filter
!= PIPE_TEX_FILTER_NEAREST
||
822 blit
->scissor_enable
||
823 blit
->num_window_rectangles
> 0 ||
828 /* Only the src box can have negative dims for flipping */
829 assert(blit
->dst
.box
.width
>= 1);
830 assert(blit
->dst
.box
.height
>= 1);
831 assert(blit
->dst
.box
.depth
>= 1);
833 /* No scaling or flipping */
834 if (blit
->src
.box
.width
!= blit
->dst
.box
.width
||
835 blit
->src
.box
.height
!= blit
->dst
.box
.height
||
836 blit
->src
.box
.depth
!= blit
->dst
.box
.depth
) {
840 /* No out-of-bounds access. */
841 if (!is_box_inside_resource(blit
->src
.resource
, &blit
->src
.box
,
843 !is_box_inside_resource(blit
->dst
.resource
, &blit
->dst
.box
,
848 /* Sample counts must match. */
849 if (get_sample_count(blit
->src
.resource
) !=
850 get_sample_count(blit
->dst
.resource
)) {
859 * Try to do a blit using resource_copy_region. The function calls
860 * resource_copy_region if the blit description is compatible with it.
862 * It returns TRUE if the blit was done using resource_copy_region.
864 * It returns FALSE otherwise and the caller must fall back to a more generic
865 * codepath for the blit operation. (e.g. by using u_blitter)
868 util_try_blit_via_copy_region(struct pipe_context
*ctx
,
869 const struct pipe_blit_info
*blit
)
871 if (util_can_blit_via_copy_region(blit
, FALSE
)) {
872 ctx
->resource_copy_region(ctx
, blit
->dst
.resource
, blit
->dst
.level
,
873 blit
->dst
.box
.x
, blit
->dst
.box
.y
,
875 blit
->src
.resource
, blit
->src
.level
,