2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include "tu_private.h"
29 tu_blit_image(struct tu_cmd_buffer
*cmdbuf
,
30 struct tu_image
*src_image
,
31 struct tu_image
*dst_image
,
32 const VkImageBlit
*info
,
35 static const enum a6xx_rotation rotate
[2][2] = {
36 {ROTATE_0
, ROTATE_HFLIP
},
37 {ROTATE_VFLIP
, ROTATE_180
},
39 bool mirror_x
= (info
->srcOffsets
[1].x
< info
->srcOffsets
[0].x
) !=
40 (info
->dstOffsets
[1].x
< info
->dstOffsets
[0].x
);
41 bool mirror_y
= (info
->srcOffsets
[1].y
< info
->srcOffsets
[0].y
) !=
42 (info
->dstOffsets
[1].y
< info
->dstOffsets
[0].y
);
43 bool mirror_z
= (info
->srcOffsets
[1].z
< info
->srcOffsets
[0].z
) !=
44 (info
->dstOffsets
[1].z
< info
->dstOffsets
[0].z
);
47 tu_finishme("blit z mirror\n");
51 if (info
->srcOffsets
[1].z
- info
->srcOffsets
[0].z
!=
52 info
->dstOffsets
[1].z
- info
->dstOffsets
[0].z
) {
53 tu_finishme("blit z filter\n");
56 assert(info
->dstSubresource
.layerCount
== info
->srcSubresource
.layerCount
);
58 struct tu_blit blt
= {
59 .dst
= tu_blit_surf(dst_image
, info
->dstSubresource
, info
->dstOffsets
),
60 .src
= tu_blit_surf(src_image
, info
->srcSubresource
, info
->srcOffsets
),
61 .layers
= MAX2(info
->srcOffsets
[1].z
- info
->srcOffsets
[0].z
,
62 info
->dstSubresource
.layerCount
),
63 .filter
= filter
== VK_FILTER_LINEAR
,
64 .rotation
= rotate
[mirror_y
][mirror_x
],
67 tu_blit(cmdbuf
, &blt
);
71 tu_CmdBlitImage(VkCommandBuffer commandBuffer
,
73 VkImageLayout srcImageLayout
,
75 VkImageLayout destImageLayout
,
77 const VkImageBlit
*pRegions
,
81 TU_FROM_HANDLE(tu_cmd_buffer
, cmdbuf
, commandBuffer
);
82 TU_FROM_HANDLE(tu_image
, src_image
, srcImage
);
83 TU_FROM_HANDLE(tu_image
, dst_image
, destImage
);
85 tu_bo_list_add(&cmdbuf
->bo_list
, src_image
->bo
, MSM_SUBMIT_BO_READ
);
86 tu_bo_list_add(&cmdbuf
->bo_list
, dst_image
->bo
, MSM_SUBMIT_BO_WRITE
);
88 for (uint32_t i
= 0; i
< regionCount
; ++i
) {
89 tu_blit_image(cmdbuf
, src_image
, dst_image
, pRegions
+ i
, filter
);