Vulkan: Fix format properties queries
When querying format properties (in vk::GetFormatProperties), the
mandatory feature support table was consulted to check whether a number
of texture features are present. If so, the entry from that table was
returned. The goal had been to speed up initialization by not issuing
device queries if possible.
That is, when vk::GetFormatProperties was called on a format, if it
supported that select few texture features, the VkFormatProperties entry
from the mandatory table would be returned.
However, that function found its way to other uses (such as querying
buffer format properties, or other image properties beyond the select
few). As a result, when the VkFormatProperties from the mandatory table
was returned, actual support for these other features was often not
tested and assumed false (unless they happened to be mandatory as well).
This commit reworks the format feature query functions such that the
specific features to be tested are provided when querying the format
properties. The mandatory table is consulted as before, and if the
entry doesn't contain those features, the device is queried and the
results cached.
Bug: angleproject:2958
Change-Id: I28d046eb63c3bd5173468aa4cb3e4c63c83e67b1
Reviewed-on: https://chromium-review.googlesource.com/c/1357152
Reviewed-by: Tobin Ehlis <tobine@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 13a4129..7b0eb74 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -49,23 +49,16 @@
return ClipRectangle(area, renderTargetRect, rectOut);
}
-bool HasSrcAndDstBlitProperties(const VkPhysicalDevice &physicalDevice,
+bool HasSrcAndDstBlitProperties(RendererVk *renderer,
RenderTargetVk *srcRenderTarget,
RenderTargetVk *dstRenderTarget)
{
- VkFormatProperties drawImageProperties;
- vk::GetFormatProperties(physicalDevice, srcRenderTarget->getImageFormat().vkTextureFormat,
- &drawImageProperties);
-
- VkFormatProperties readImageProperties;
- vk::GetFormatProperties(physicalDevice, dstRenderTarget->getImageFormat().vkTextureFormat,
- &readImageProperties);
+ const VkFormat srcFormat = srcRenderTarget->getImageFormat().vkTextureFormat;
+ const VkFormat dstFormat = dstRenderTarget->getImageFormat().vkTextureFormat;
// Verifies if the draw and read images have the necessary prerequisites for blitting.
- return (IsMaskFlagSet<VkFormatFeatureFlags>(drawImageProperties.optimalTilingFeatures,
- VK_FORMAT_FEATURE_BLIT_DST_BIT) &&
- IsMaskFlagSet<VkFormatFeatureFlags>(readImageProperties.optimalTilingFeatures,
- VK_FORMAT_FEATURE_BLIT_SRC_BIT));
+ return renderer->hasTextureFormatFeatureBits(srcFormat, VK_FORMAT_FEATURE_BLIT_SRC_BIT) &&
+ renderer->hasTextureFormatFeatureBits(dstFormat, VK_FORMAT_FEATURE_BLIT_DST_BIT);
}
// Special rules apply to VkBufferImageCopy with depth/stencil. The components are tightly packed
@@ -577,8 +570,7 @@
{
RenderTargetVk *drawRenderTarget = mRenderTargetCache.getColors()[colorAttachment];
ASSERT(drawRenderTarget);
- ASSERT(HasSrcAndDstBlitProperties(renderer->getPhysicalDevice(), readRenderTarget,
- drawRenderTarget));
+ ASSERT(HasSrcAndDstBlitProperties(renderer, readRenderTarget, drawRenderTarget));
gl::Rectangle drawRenderTargetRect;
if (!ClipToRenderTarget(drawRect, drawRenderTarget, &drawRenderTargetRect))
@@ -615,8 +607,7 @@
ASSERT(readRenderTargetRect == drawRenderTargetRect);
ASSERT(filter == GL_NEAREST);
- if (HasSrcAndDstBlitProperties(renderer->getPhysicalDevice(), readRenderTarget,
- drawRenderTarget))
+ if (HasSrcAndDstBlitProperties(renderer, readRenderTarget, drawRenderTarget))
{
ANGLE_TRY(blitWithCommand(contextVk, readRenderTargetRect, drawRenderTargetRect,
readRenderTarget, drawRenderTarget, filter, false,