зеркало из https://github.com/AvaloniaUI/angle.git
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:
Родитель
9aeb6311a0
Коммит
ff46a03a89
|
@ -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))
|
||||
{
|
||||
|
@ -2190,38 +2199,39 @@ void RendererVk::queryDeviceExtensionFeatures(const vk::ExtensionNameList &devic
|
|||
vkGetPhysicalDeviceProperties2KHR(mPhysicalDevice, &deviceProperties);
|
||||
|
||||
// Clean up pNext chains
|
||||
mLineRasterizationFeatures.pNext = nullptr;
|
||||
mMemoryReportFeatures.pNext = nullptr;
|
||||
mProvokingVertexFeatures.pNext = nullptr;
|
||||
mVertexAttributeDivisorFeatures.pNext = nullptr;
|
||||
mVertexAttributeDivisorProperties.pNext = nullptr;
|
||||
mTransformFeedbackFeatures.pNext = nullptr;
|
||||
mIndexTypeUint8Features.pNext = nullptr;
|
||||
mSubgroupProperties.pNext = nullptr;
|
||||
mSubgroupExtendedTypesFeatures.pNext = nullptr;
|
||||
mExternalMemoryHostProperties.pNext = nullptr;
|
||||
mCustomBorderColorFeatures.pNext = nullptr;
|
||||
mShaderFloat16Int8Features.pNext = nullptr;
|
||||
mDepthStencilResolveProperties.pNext = nullptr;
|
||||
mMultisampledRenderToSingleSampledFeatures.pNext = nullptr;
|
||||
mImage2dViewOf3dFeatures.pNext = nullptr;
|
||||
mMultiviewFeatures.pNext = nullptr;
|
||||
mMultiviewProperties.pNext = nullptr;
|
||||
mDriverProperties.pNext = nullptr;
|
||||
mSamplerYcbcrConversionFeatures.pNext = nullptr;
|
||||
mProtectedMemoryFeatures.pNext = nullptr;
|
||||
mProtectedMemoryProperties.pNext = nullptr;
|
||||
mHostQueryResetFeatures.pNext = nullptr;
|
||||
mDepthClipControlFeatures.pNext = nullptr;
|
||||
mPrimitivesGeneratedQueryFeatures.pNext = nullptr;
|
||||
mPrimitiveTopologyListRestartFeatures.pNext = nullptr;
|
||||
mBlendOperationAdvancedFeatures.pNext = nullptr;
|
||||
mPipelineCreationCacheControlFeatures.pNext = nullptr;
|
||||
mExtendedDynamicStateFeatures.pNext = nullptr;
|
||||
mExtendedDynamicState2Features.pNext = nullptr;
|
||||
mFragmentShadingRateFeatures.pNext = nullptr;
|
||||
mFragmentShaderInterlockFeatures.pNext = nullptr;
|
||||
mImagelessFramebufferFeatures.pNext = nullptr;
|
||||
mLineRasterizationFeatures.pNext = nullptr;
|
||||
mMemoryReportFeatures.pNext = nullptr;
|
||||
mProvokingVertexFeatures.pNext = nullptr;
|
||||
mVertexAttributeDivisorFeatures.pNext = nullptr;
|
||||
mVertexAttributeDivisorProperties.pNext = nullptr;
|
||||
mTransformFeedbackFeatures.pNext = nullptr;
|
||||
mIndexTypeUint8Features.pNext = nullptr;
|
||||
mSubgroupProperties.pNext = nullptr;
|
||||
mSubgroupExtendedTypesFeatures.pNext = nullptr;
|
||||
mExternalMemoryHostProperties.pNext = nullptr;
|
||||
mCustomBorderColorFeatures.pNext = nullptr;
|
||||
mShaderFloat16Int8Features.pNext = nullptr;
|
||||
mDepthStencilResolveProperties.pNext = nullptr;
|
||||
mMultisampledRenderToSingleSampledFeatures.pNext = nullptr;
|
||||
mMultisampledRenderToSingleSampledFeaturesGOOGLEX.pNext = nullptr;
|
||||
mImage2dViewOf3dFeatures.pNext = nullptr;
|
||||
mMultiviewFeatures.pNext = nullptr;
|
||||
mMultiviewProperties.pNext = nullptr;
|
||||
mDriverProperties.pNext = nullptr;
|
||||
mSamplerYcbcrConversionFeatures.pNext = nullptr;
|
||||
mProtectedMemoryFeatures.pNext = nullptr;
|
||||
mProtectedMemoryProperties.pNext = nullptr;
|
||||
mHostQueryResetFeatures.pNext = nullptr;
|
||||
mDepthClipControlFeatures.pNext = nullptr;
|
||||
mPrimitivesGeneratedQueryFeatures.pNext = nullptr;
|
||||
mPrimitiveTopologyListRestartFeatures.pNext = nullptr;
|
||||
mBlendOperationAdvancedFeatures.pNext = nullptr;
|
||||
mPipelineCreationCacheControlFeatures.pNext = nullptr;
|
||||
mExtendedDynamicStateFeatures.pNext = nullptr;
|
||||
mExtendedDynamicState2Features.pNext = nullptr;
|
||||
mFragmentShadingRateFeatures.pNext = nullptr;
|
||||
mFragmentShaderInterlockFeatures.pNext = nullptr;
|
||||
mImagelessFramebufferFeatures.pNext = nullptr;
|
||||
}
|
||||
|
||||
angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex)
|
||||
|
@ -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,10 +3667,12 @@ void RendererVk::initFeatures(DisplayVk *displayVk,
|
|||
const bool supportsIndependentDepthStencilResolve =
|
||||
mFeatures.supportsDepthStencilResolve.enabled &&
|
||||
mDepthStencilResolveProperties.independentResolveNone == VK_TRUE;
|
||||
ANGLE_FEATURE_CONDITION(&mFeatures, enableMultisampledRenderToTexture,
|
||||
mFeatures.supportsMultisampledRenderToSingleSampled.enabled ||
|
||||
(supportsIndependentDepthStencilResolve && !isSwiftShader &&
|
||||
!(IsWindows() && (isIntel || isAMD))));
|
||||
ANGLE_FEATURE_CONDITION(
|
||||
&mFeatures, enableMultisampledRenderToTexture,
|
||||
mFeatures.supportsMultisampledRenderToSingleSampled.enabled ||
|
||||
mFeatures.supportsMultisampledRenderToSingleSampledGOOGLEX.enabled ||
|
||||
(supportsIndependentDepthStencilResolve && !isSwiftShader &&
|
||||
!(IsWindows() && (isIntel || isAMD))));
|
||||
|
||||
// Currently we enable cube map arrays based on the imageCubeArray Vk feature.
|
||||
// TODO: Check device caps for full cube map array support. http://anglebug.com/5143
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче