Vulkan: Use VK_EXT_multisampled_render_to_single_sampled

Previously, the GOOGLEX version was used. The EXT version is favored
now.

Bug: angleproject:4836
Change-Id: Ie41d750b0729f0b3a14d1937fbf2dd386b65dd59
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3857993
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Charlie Lao <cclao@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi 2022-08-25 20:19:02 -04:00 коммит произвёл Angle LUCI CQ
Родитель 9aeb6311a0
Коммит ff46a03a89
6 изменённых файлов: 122 добавлений и 57 удалений

Просмотреть файл

@ -28,14 +28,14 @@
# define VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_GOOGLEX \
((VkStructureType)(1000376001))
typedef struct VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGoogleX
typedef struct VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGOOGLEX
{
VkStructureType sType;
const void *pNext;
VkBool32 multisampledRenderToSingleSampled;
} VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGoogleX;
} VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGOOGLEX;
typedef struct VkMultisampledRenderToSingleSampledInfoGoogleX
typedef struct VkMultisampledRenderToSingleSampledInfoGOOGLEX
{
VkStructureType sType;
const void *pNext;
@ -43,7 +43,7 @@ typedef struct VkMultisampledRenderToSingleSampledInfoGoogleX
VkSampleCountFlagBits rasterizationSamples;
VkResolveModeFlagBits depthResolveMode;
VkResolveModeFlagBits stencilResolveMode;
} VkMultisampledRenderToSingleSampledInfoGoogleX;
} VkMultisampledRenderToSingleSampledInfoGOOGLEX;
#endif /* VK_GOOGLEX_multisampled_render_to_single_sampled */
#if !defined(ANGLE_SHARED_LIBVULKAN)

Просмотреть файл

@ -85,7 +85,8 @@ angle::Result RenderbufferVk::setStorageImpl(const gl::Context *context,
const bool isRenderToTexture = mode == gl::MultisamplingMode::MultisampledRenderToTexture;
const bool hasRenderToTextureEXT =
renderer->getFeatures().supportsMultisampledRenderToSingleSampled.enabled;
renderer->getFeatures().supportsMultisampledRenderToSingleSampled.enabled ||
renderer->getFeatures().supportsMultisampledRenderToSingleSampledGOOGLEX.enabled;
// Transfer and sampled usage are used for various utilities such as readback or blit.
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
@ -107,6 +108,13 @@ angle::Result RenderbufferVk::setStorageImpl(const gl::Context *context,
usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
}
VkImageCreateFlags createFlags = vk::kVkImageCreateFlagsNone;
if (isRenderToTexture &&
renderer->getFeatures().supportsMultisampledRenderToSingleSampled.enabled)
{
createFlags |= VK_IMAGE_CREATE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_BIT_EXT;
}
const uint32_t imageSamples = isRenderToTexture ? 1 : samples;
bool robustInit = contextVk->isRobustResourceInitEnabled();
@ -114,8 +122,8 @@ angle::Result RenderbufferVk::setStorageImpl(const gl::Context *context,
VkExtent3D extents = {static_cast<uint32_t>(width), static_cast<uint32_t>(height), 1u};
ANGLE_TRY(mImage->initExternal(contextVk, gl::TextureType::_2D, extents,
format.getIntendedFormatID(), textureFormatID, imageSamples,
usage, vk::kVkImageCreateFlagsNone, vk::ImageLayout::Undefined,
nullptr, gl::LevelIndex(0), 1, 1, robustInit, false));
usage, createFlags, vk::ImageLayout::Undefined, nullptr,
gl::LevelIndex(0), 1, 1, robustInit, false));
VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
ANGLE_TRY(mImage->initMemory(contextVk, false, renderer->getMemoryProperties(), flags));

Просмотреть файл

@ -1940,6 +1940,10 @@ void RendererVk::queryDeviceExtensionFeatures(const vk::ExtensionNameList &devic
mMultisampledRenderToSingleSampledFeatures = {};
mMultisampledRenderToSingleSampledFeatures.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_EXT;
mMultisampledRenderToSingleSampledFeaturesGOOGLEX = {};
mMultisampledRenderToSingleSampledFeaturesGOOGLEX.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_GOOGLEX;
mImage2dViewOf3dFeatures = {};
@ -2083,11 +2087,16 @@ void RendererVk::queryDeviceExtensionFeatures(const vk::ExtensionNameList &devic
}
// Query multisampled render to single-sampled features
if (ExtensionFound(VK_GOOGLEX_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME,
if (ExtensionFound(VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME,
deviceExtensionNames))
{
vk::AddToPNextChain(&deviceFeatures, &mMultisampledRenderToSingleSampledFeatures);
}
else if (ExtensionFound(VK_GOOGLEX_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME,
deviceExtensionNames))
{
vk::AddToPNextChain(&deviceFeatures, &mMultisampledRenderToSingleSampledFeaturesGOOGLEX);
}
if (ExtensionFound(VK_EXT_IMAGE_2D_VIEW_OF_3D_EXTENSION_NAME, deviceExtensionNames))
{
@ -2204,6 +2213,7 @@ void RendererVk::queryDeviceExtensionFeatures(const vk::ExtensionNameList &devic
mShaderFloat16Int8Features.pNext = nullptr;
mDepthStencilResolveProperties.pNext = nullptr;
mMultisampledRenderToSingleSampledFeatures.pNext = nullptr;
mMultisampledRenderToSingleSampledFeaturesGOOGLEX.pNext = nullptr;
mImage2dViewOf3dFeatures.pNext = nullptr;
mMultiviewFeatures.pNext = nullptr;
mMultiviewProperties.pNext = nullptr;
@ -2587,10 +2597,18 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
if (getFeatures().supportsMultisampledRenderToSingleSampled.enabled)
{
mEnabledDeviceExtensions.push_back(
VK_GOOGLEX_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME);
VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME);
vk::AddToPNextChain(&mEnabledFeatures, &mMultisampledRenderToSingleSampledFeatures);
}
if (getFeatures().supportsMultisampledRenderToSingleSampledGOOGLEX.enabled)
{
ASSERT(!getFeatures().supportsMultisampledRenderToSingleSampled.enabled);
mEnabledDeviceExtensions.push_back(
VK_GOOGLEX_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME);
vk::AddToPNextChain(&mEnabledFeatures, &mMultisampledRenderToSingleSampledFeaturesGOOGLEX);
}
if (getFeatures().supportsMultiview.enabled)
{
// OVR_multiview disallows multiview with geometry and tessellation, so don't request these
@ -3481,6 +3499,14 @@ void RendererVk::initFeatures(DisplayVk *displayVk,
mMultisampledRenderToSingleSampledFeatures.multisampledRenderToSingleSampled ==
VK_TRUE);
ANGLE_FEATURE_CONDITION(
&mFeatures, supportsMultisampledRenderToSingleSampledGOOGLEX,
!mFeatures.supportsMultisampledRenderToSingleSampled.enabled &&
mFeatures.supportsRenderpass2.enabled &&
mFeatures.supportsDepthStencilResolve.enabled &&
mMultisampledRenderToSingleSampledFeaturesGOOGLEX.multisampledRenderToSingleSampled ==
VK_TRUE);
ANGLE_FEATURE_CONDITION(&mFeatures, supportsImage2dViewOf3d,
mImage2dViewOf3dFeatures.image2DViewOf3D == VK_TRUE &&
mImage2dViewOf3dFeatures.sampler2DViewOf3D == VK_TRUE);
@ -3641,8 +3667,10 @@ void RendererVk::initFeatures(DisplayVk *displayVk,
const bool supportsIndependentDepthStencilResolve =
mFeatures.supportsDepthStencilResolve.enabled &&
mDepthStencilResolveProperties.independentResolveNone == VK_TRUE;
ANGLE_FEATURE_CONDITION(&mFeatures, enableMultisampledRenderToTexture,
ANGLE_FEATURE_CONDITION(
&mFeatures, enableMultisampledRenderToTexture,
mFeatures.supportsMultisampledRenderToSingleSampled.enabled ||
mFeatures.supportsMultisampledRenderToSingleSampledGOOGLEX.enabled ||
(supportsIndependentDepthStencilResolve && !isSwiftShader &&
!(IsWindows() && (isIntel || isAMD))));

Просмотреть файл

@ -694,7 +694,9 @@ class RendererVk : angle::NonCopyable
VkPhysicalDeviceExternalMemoryHostPropertiesEXT mExternalMemoryHostProperties;
VkPhysicalDeviceShaderFloat16Int8FeaturesKHR mShaderFloat16Int8Features;
VkPhysicalDeviceDepthStencilResolvePropertiesKHR mDepthStencilResolveProperties;
VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGoogleX
VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGOOGLEX
mMultisampledRenderToSingleSampledFeaturesGOOGLEX;
VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT
mMultisampledRenderToSingleSampledFeatures;
VkPhysicalDeviceImage2DViewOf3DFeaturesEXT mImage2dViewOf3dFeatures;
VkPhysicalDeviceMultiviewFeatures mMultiviewFeatures;

Просмотреть файл

@ -2434,7 +2434,8 @@ angle::Result TextureVk::getAttachmentRenderTarget(const gl::Context *context,
}
const bool hasRenderToTextureEXT =
contextVk->getFeatures().supportsMultisampledRenderToSingleSampled.enabled;
contextVk->getFeatures().supportsMultisampledRenderToSingleSampled.enabled ||
contextVk->getFeatures().supportsMultisampledRenderToSingleSampledGOOGLEX.enabled;
// If samples > 1 here, we have a singlesampled texture that's being multisampled rendered to.
// In this case, create a multisampled image that is otherwise identical to the single sampled
@ -3166,6 +3167,13 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
{
mImageCreateFlags |= VK_IMAGE_CREATE_PROTECTED_BIT;
}
if (mOwnsImage && samples == 1 &&
contextVk->getFeatures().supportsMultisampledRenderToSingleSampled.enabled)
{
// Conservatively add the MSRTSS flag, because any texture might end up as an MSRTT
// attachment.
mImageCreateFlags |= VK_IMAGE_CREATE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_BIT_EXT;
}
ANGLE_TRY(mImage->initExternal(
contextVk, mState.getType(), vkExtent, intendedImageFormatID, actualImageFormatID, samples,

Просмотреть файл

@ -791,13 +791,23 @@ angle::Result CreateRenderPass2(Context *context,
multiviewInfo.pViewMasks[subpass], &subpassDescriptions[subpass]);
}
VkMultisampledRenderToSingleSampledInfoGoogleX renderToTextureInfo = {};
renderToTextureInfo.sType =
VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_GOOGLEX;
renderToTextureInfo.multisampledRenderToSingleSampledEnable = true;
renderToTextureInfo.rasterizationSamples = gl_vk::GetSamples(renderToTextureSamples);
renderToTextureInfo.depthResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
renderToTextureInfo.stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
VkSubpassDescriptionDepthStencilResolve msrtssResolve = {};
msrtssResolve.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE;
msrtssResolve.depthResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
msrtssResolve.stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
VkMultisampledRenderToSingleSampledInfoEXT msrtss = {};
msrtss.sType = VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_EXT;
msrtss.pNext = &msrtssResolve;
msrtss.multisampledRenderToSingleSampledEnable = true;
msrtss.rasterizationSamples = gl_vk::GetSamples(renderToTextureSamples);
VkMultisampledRenderToSingleSampledInfoGOOGLEX msrtssGOOGLEX = {};
msrtssGOOGLEX.sType = VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_GOOGLEX;
msrtssGOOGLEX.multisampledRenderToSingleSampledEnable = true;
msrtssGOOGLEX.rasterizationSamples = msrtss.rasterizationSamples;
msrtssGOOGLEX.depthResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
msrtssGOOGLEX.stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
// Append the depth/stencil resolve attachment to the pNext chain of last subpass, if any.
if (depthStencilResolve.pDepthStencilResolveAttachment != nullptr)
@ -810,10 +820,18 @@ angle::Result CreateRenderPass2(Context *context,
RendererVk *renderer = context->getRenderer();
ASSERT(isRenderToTextureThroughExtension);
ASSERT(renderer->getFeatures().supportsMultisampledRenderToSingleSampled.enabled);
ASSERT(renderer->getFeatures().supportsMultisampledRenderToSingleSampled.enabled ||
renderer->getFeatures().supportsMultisampledRenderToSingleSampledGOOGLEX.enabled);
ASSERT(subpassDescriptions.size() == 1);
subpassDescriptions.back().pNext = &renderToTextureInfo;
if (renderer->getFeatures().supportsMultisampledRenderToSingleSampled.enabled)
{
subpassDescriptions.back().pNext = &msrtss;
}
else
{
subpassDescriptions.back().pNext = &msrtssGOOGLEX;
}
}
// Convert subpass dependencies to VkSubpassDependency2.
@ -1017,7 +1035,8 @@ angle::Result InitializeRenderPassFromDesc(ContextVk *contextVk,
const bool needInputAttachments = desc.hasFramebufferFetch();
const bool isRenderToTextureThroughExtension =
desc.isRenderToTexture() &&
contextVk->getFeatures().supportsMultisampledRenderToSingleSampled.enabled;
(contextVk->getFeatures().supportsMultisampledRenderToSingleSampled.enabled ||
contextVk->getFeatures().supportsMultisampledRenderToSingleSampledGOOGLEX.enabled);
const bool isRenderToTextureThroughEmulation =
desc.isRenderToTexture() && !isRenderToTextureThroughExtension;