18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 18:47:06 +01:00

fix(vulkan): a texture image that fails for another reason doesn't turn off host copy for its format

An image to be filled by the host which can't be made is tried again without the host transfer usage, and only when that one
can be made is the format filled through staging buffers from then on. When it can't either (the memory ran out), the texture
fails as before and the format keeps the host copy. The warning says the error logged before it was recovered from.
This commit is contained in:
2026-12-01 16:03:43 +01:00
parent c90113f4d3
commit 02f450c1ab
2 changed files with 14 additions and 8 deletions
+12 -6
View File
@@ -106,8 +106,10 @@ struct job_ticket
std::atomic<bool> taken{false};
};
// the image of a texture. one to be filled by the host (HostCopy) which the driver can't make after all is made to be filled through
// a staging buffer, HostCopy cleared, and so are the next ones of its format
// the image of a texture. one to be filled by the host (HostCopy) which can't be made is tried again to be filled through a staging
// buffer, HostCopy cleared. only when that one can be made is it the host transfer the driver can't do, and the next images of the
// format are filled through staging buffers too; when it can't either, it's something else (the memory ran out) and the format keeps
// the host copy
bool createTextureImage(image &Target, allocator const &Memory, uploader &Uploads, image_desc &Desc, std::string const &Name, bool &HostCopy)
{
if (Target.create(Memory, Desc, Name))
@@ -118,10 +120,14 @@ bool createTextureImage(image &Target, allocator const &Memory, uploader &Upload
{
return false;
}
Uploads.RefuseHostCopy(Desc.format);
HostCopy = false;
Desc.usage &= ~VkImageUsageFlags{VK_IMAGE_USAGE_HOST_TRANSFER_BIT};
return Target.create(Memory, Desc, Name);
if (false == Target.create(Memory, Desc, Name))
{
return false;
}
HostCopy = false;
Uploads.RefuseHostCopy(Desc.format);
return true;
}
} // namespace
@@ -190,7 +196,7 @@ void uploader::RefuseHostCopy(VkFormat Format)
}
if (refused)
{
log_warning(std::format("the textures of format {} are filled through staging buffers: the driver can't make their images to be filled by the host, although it says it can", static_cast<int>(Format)));
log_warning(std::format("the textures of format {} are filled through staging buffers: the driver can't make their images to be filled by the host, although it says it can (the error above, recovered from)", static_cast<int>(Format)));
}
}
+2 -2
View File
@@ -96,8 +96,8 @@ class uploader
// whether an image of the format, of Extent and Mips levels is: the format allows it, the device has memory of its own for such
// images (asked once a format) and the image is within the limits of the format for that use
bool can_host_copy(VkFormat Format, VkExtent3D const &Extent, std::uint32_t Mips) const;
// an image of the format which can_host_copy() allowed couldn't be made: the images of the format are filled through staging
// buffers from now on
// an image of the format which can_host_copy() allowed couldn't be made, and the same one without the host transfer could: the
// images of the format are filled through staging buffers from now on
void RefuseHostCopy(VkFormat Format);
private: