version-detect AMD unreliable image memory requirements needing padding

* From driver 2.0.33 (18.5.2) onwards, the image memory requirements don't vary
  randomly so don't need any padding.
* It should only be applied also for the AMD binary driver.
This commit is contained in:
baldurk
2019-01-03 17:25:36 +00:00
parent 50a5f05fe4
commit e13f0e882a
3 changed files with 13 additions and 2 deletions
+4
View File
@@ -738,6 +738,10 @@ VkDriverInfo::VkDriverInfo(const VkPhysicalDeviceProperties &physProps)
if(Major() < 1)
texelFetchBrokenDriver = true;
// driver 18.5.2 which is vulkan version >= 2.0.33 contains the fix
if(physProps.driverVersion < VK_MAKE_VERSION(2, 0, 33))
unreliableImgMemReqs = true;
}
#endif
+6
View File
@@ -192,6 +192,11 @@ public:
// A workaround for a couple of bugs, removing texelFetch use from shaders.
// It means broken functionality but at least no instant crashes
bool TexelFetchBrokenDriver() { return texelFetchBrokenDriver; }
// Older AMD driver versions could sometimes cause image memory requirements to vary randomly
// between identical images. This means the memory required at capture could be less than at
// replay. To counteract this, on drivers with this issue we pad out the memory requirements
// enough to account for the change
bool UnreliableImageMemoryRequirements() { return unreliableImgMemReqs; }
// another workaround, on some AMD driver versions creating an MSAA image with STORAGE_BIT
// causes graphical corruption trying to sample from it. We workaround it by preventing the
// MSAA <-> Array pipelines from creating, which removes the STORAGE_BIT and skips the copies.
@@ -207,6 +212,7 @@ private:
uint32_t m_Major, m_Minor, m_Patch;
bool texelFetchBrokenDriver = false;
bool unreliableImgMemReqs = false;
bool amdStorageMSAABrokenDriver = false;
bool qualcommLeakingUBOOffsets = false;
};
@@ -284,7 +284,7 @@ void WrappedVulkan::vkGetImageMemoryRequirements(VkDevice device, VkImage image,
// allow for this. The variability isn't quite clear, but for now we assume aligning size to
// alignment * 4 should be sufficient (adding on a fixed padding won't help the problem as it
// won't remove the variability, nor will adding then aligning for the same reason).
if(GetDriverVersion().Vendor() == GPUVendor::AMD && pMemoryRequirements->size > 0)
if(GetDriverInfo().UnreliableImageMemoryRequirements() && pMemoryRequirements->size > 0)
{
VkMemoryRequirements &memreq = *pMemoryRequirements;
@@ -376,7 +376,8 @@ void WrappedVulkan::vkGetImageMemoryRequirements2(VkDevice device,
// allow for this. The variability isn't quite clear, but for now we assume aligning size to
// alignment * 4 should be sufficient (adding on a fixed padding won't help the problem as it
// won't remove the variability, nor will adding then aligning for the same reason).
if(GetDriverVersion().Vendor() == GPUVendor::AMD && pMemoryRequirements->memoryRequirements.size > 0)
if(GetDriverInfo().UnreliableImageMemoryRequirements() &&
pMemoryRequirements->memoryRequirements.size > 0)
{
VkMemoryRequirements &memreq = pMemoryRequirements->memoryRequirements;