Force linear images to be dirty on creation on vulkan

* This is necessary for e.g. the cube demo where it can create the image as
  LINEAR in HOST_VISIBLE memory and then the image never gets dirtied, so we
  don't properly create initial contents for it - instead only fetching the
  underlying memory which is not technically legal.
This commit is contained in:
baldurk
2019-06-26 12:23:44 +01:00
parent 2b7bcccbc6
commit 05282a3bdf
@@ -1627,6 +1627,8 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo *
bool isSparse = (pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) != 0;
bool isLinear = (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR);
bool isExternal = false;
const VkBaseInStructure *next = (const VkBaseInStructure *)pCreateInfo->pNext;
@@ -1647,7 +1649,12 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo *
// sparse and external images are considered dirty from creation. For sparse images this is
// so that we can serialise the tracked page table, for external images this is so we can be
// sure to fetch their contents even if we don't see any writes.
if(isSparse || isExternal)
//
// We also dirty linear images since we may not get another chance - if they are bound to
// host-visible memory they may only be updated via memory maps, and we want to be sure to
// correctly copy their initial contents out rather than relying on memory contents (which may
// not be valid to map from/into if the image isn't in GENERAL layout).
if(isSparse || isExternal || isLinear)
{
GetResourceManager()->MarkDirtyResource(id);