mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 16:50:10 +01:00
zink: combine all surface layout-setting for src/dst into util function
we do a lot of src/dst layout-setting, so ensure that we use the same code everywhere to avoid cases where src==dst and we aren't setting GENERAL layout as we should Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6922>
This commit is contained in:
parent
24f19f409d
commit
e31381ac26
4 changed files with 40 additions and 46 deletions
|
|
@ -31,13 +31,7 @@ blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info)
|
|||
zink_batch_reference_resoure(batch, src);
|
||||
zink_batch_reference_resoure(batch, dst);
|
||||
|
||||
if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
|
||||
zink_resource_barrier(batch->cmdbuf, src, src->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
|
||||
if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
|
||||
zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
zink_resource_setup_transfer_layouts(batch, src, dst);
|
||||
|
||||
VkImageResolve region = {};
|
||||
|
||||
|
|
@ -97,35 +91,7 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
|
|||
zink_batch_reference_resoure(batch, src);
|
||||
zink_batch_reference_resoure(batch, dst);
|
||||
|
||||
if (src == dst) {
|
||||
/* The Vulkan 1.1 specification says the following about valid usage
|
||||
* of vkCmdBlitImage:
|
||||
*
|
||||
* "srcImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
|
||||
* VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL"
|
||||
*
|
||||
* and:
|
||||
*
|
||||
* "dstImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
|
||||
* VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL"
|
||||
*
|
||||
* Since we cant have the same image in two states at the same time,
|
||||
* we're effectively left with VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR or
|
||||
* VK_IMAGE_LAYOUT_GENERAL. And since this isn't a present-related
|
||||
* operation, VK_IMAGE_LAYOUT_GENERAL seems most appropriate.
|
||||
*/
|
||||
if (src->layout != VK_IMAGE_LAYOUT_GENERAL)
|
||||
zink_resource_barrier(batch->cmdbuf, src, src->aspect,
|
||||
VK_IMAGE_LAYOUT_GENERAL);
|
||||
} else {
|
||||
if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
|
||||
zink_resource_barrier(batch->cmdbuf, src, src->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
|
||||
if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
|
||||
zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
zink_resource_setup_transfer_layouts(batch, src, dst);
|
||||
|
||||
VkImageBlit region = {};
|
||||
region.srcSubresource.aspectMask = src->aspect;
|
||||
|
|
|
|||
|
|
@ -962,16 +962,7 @@ zink_resource_copy_region(struct pipe_context *pctx,
|
|||
zink_batch_reference_resoure(batch, src);
|
||||
zink_batch_reference_resoure(batch, dst);
|
||||
|
||||
if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) {
|
||||
zink_resource_barrier(batch->cmdbuf, src, src->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
}
|
||||
|
||||
if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
|
||||
zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
|
||||
zink_resource_setup_transfer_layouts(batch, src, dst);
|
||||
vkCmdCopyImage(batch->cmdbuf, src->image, src->layout,
|
||||
dst->image, dst->layout,
|
||||
1, ®ion);
|
||||
|
|
|
|||
|
|
@ -589,6 +589,40 @@ zink_resource_get_separate_stencil(struct pipe_resource *pres)
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
zink_resource_setup_transfer_layouts(struct zink_batch *batch, struct zink_resource *src, struct zink_resource *dst)
|
||||
{
|
||||
if (src == dst) {
|
||||
/* The Vulkan 1.1 specification says the following about valid usage
|
||||
* of vkCmdBlitImage:
|
||||
*
|
||||
* "srcImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
|
||||
* VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL"
|
||||
*
|
||||
* and:
|
||||
*
|
||||
* "dstImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
|
||||
* VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL"
|
||||
*
|
||||
* Since we cant have the same image in two states at the same time,
|
||||
* we're effectively left with VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR or
|
||||
* VK_IMAGE_LAYOUT_GENERAL. And since this isn't a present-related
|
||||
* operation, VK_IMAGE_LAYOUT_GENERAL seems most appropriate.
|
||||
*/
|
||||
if (src->layout != VK_IMAGE_LAYOUT_GENERAL)
|
||||
zink_resource_barrier(batch->cmdbuf, src, src->aspect,
|
||||
VK_IMAGE_LAYOUT_GENERAL);
|
||||
} else {
|
||||
if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
|
||||
zink_resource_barrier(batch->cmdbuf, src, src->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
|
||||
if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
|
||||
zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zink_get_depth_stencil_resources(struct pipe_resource *res,
|
||||
struct zink_resource **out_z,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
struct pipe_screen;
|
||||
struct sw_displaytarget;
|
||||
struct zink_batch;
|
||||
|
||||
#include "util/u_transfer.h"
|
||||
|
||||
|
|
@ -77,4 +78,6 @@ zink_get_depth_stencil_resources(struct pipe_resource *res,
|
|||
struct zink_resource **out_z,
|
||||
struct zink_resource **out_s);
|
||||
|
||||
void
|
||||
zink_resource_setup_transfer_layouts(struct zink_batch *batch, struct zink_resource *src, struct zink_resource *dst);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue