Commit 065c2329 by Geoff Lang Committed by Commit Bot

Reland "Vulkan: Add features to modify sampling parameters"

This reverts commit a51b57fa. Original change's description: > Revert "Vulkan: Add features to modify sampling parameters" > > Bug: b/167404532 > Change-Id: Iae19dfe165074e8c01216312bddd744c4fb504a4 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2510012 > Commit-Queue: Geoff Lang <geofflang@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> Bug: b/167404532 Change-Id: I2c756b8eb0f61701ef6e33275e557bc199a4d3b4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2815259Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent c2d1a464
...@@ -423,6 +423,28 @@ struct FeaturesVk : FeatureSetBase ...@@ -423,6 +423,28 @@ struct FeaturesVk : FeatureSetBase
"Works around a bug on platforms which destroy oldSwapchain in vkCreateSwapchainKHR.", "Works around a bug on platforms which destroy oldSwapchain in vkCreateSwapchainKHR.",
&members, "http://anglebug.com/5061"}; &members, "http://anglebug.com/5061"};
// Allow forcing an LOD offset on all sampling operations for performance comparisons. ANGLE is
// non-conformant if this feature is enabled.
std::array<angle::Feature, 4> forceTextureLODOffset = {
angle::Feature{"force_texture_lod_offset_1", angle::FeatureCategory::VulkanWorkarounds,
"Increase the minimum texture level-of-detail by 1 when sampling.",
&members},
angle::Feature{"force_texture_lod_offset_2", angle::FeatureCategory::VulkanWorkarounds,
"Increase the minimum texture level-of-detail by 2 when sampling.",
&members},
angle::Feature{"force_texture_lod_offset_3", angle::FeatureCategory::VulkanWorkarounds,
"Increase the minimum texture level-of-detail by 3 when sampling.",
&members},
angle::Feature{"force_texture_lod_offset_4", angle::FeatureCategory::VulkanWorkarounds,
"Increase the minimum texture level-of-detail by 4 when sampling.",
&members},
};
// Translate non-nearest filtering modes to nearest for all samplers for performance
// comparisons. ANGLE is non-conformant if this feature is enabled.
Feature forceNearestFiltering = {"force_nearest_filtering", FeatureCategory::VulkanWorkarounds,
"Force nearest filtering when sampling.", &members};
// Translate non-nearest mip filtering modes to nearest mip for all samplers for performance // Translate non-nearest mip filtering modes to nearest mip for all samplers for performance
// comparisons. ANGLE is non-conformant if this feature is enabled. // comparisons. ANGLE is non-conformant if this feature is enabled.
Feature forceNearestMipFiltering = {"forceNearestMipFiltering", Feature forceNearestMipFiltering = {"forceNearestMipFiltering",
......
...@@ -2338,6 +2338,14 @@ void RendererVk::initFeatures(DisplayVk *displayVk, ...@@ -2338,6 +2338,14 @@ void RendererVk::initFeatures(DisplayVk *displayVk,
// Android mistakenly destroys the old swapchain when creating a new one. // Android mistakenly destroys the old swapchain when creating a new one.
ANGLE_FEATURE_CONDITION(&mFeatures, waitIdleBeforeSwapchainRecreation, IsAndroid() && isARM); ANGLE_FEATURE_CONDITION(&mFeatures, waitIdleBeforeSwapchainRecreation, IsAndroid() && isARM);
for (size_t lodOffsetFeatureIdx = 0;
lodOffsetFeatureIdx < mFeatures.forceTextureLODOffset.size(); lodOffsetFeatureIdx++)
{
ANGLE_FEATURE_CONDITION(&mFeatures, forceTextureLODOffset[lodOffsetFeatureIdx], false);
}
ANGLE_FEATURE_CONDITION(&mFeatures, forceNearestFiltering, false);
ANGLE_FEATURE_CONDITION(&mFeatures, forceNearestMipFiltering, false);
ANGLE_FEATURE_CONDITION( ANGLE_FEATURE_CONDITION(
&mFeatures, preferDrawClearOverVkCmdClearAttachments, &mFeatures, preferDrawClearOverVkCmdClearAttachments,
IsPixel2(mPhysicalDeviceProperties.vendorID, mPhysicalDeviceProperties.deviceID)); IsPixel2(mPhysicalDeviceProperties.vendorID, mPhysicalDeviceProperties.deviceID));
......
...@@ -3184,6 +3184,16 @@ void SamplerDesc::update(const angle::FeaturesVk &featuresVk, ...@@ -3184,6 +3184,16 @@ void SamplerDesc::update(const angle::FeaturesVk &featuresVk,
uint64_t externalFormat) uint64_t externalFormat)
{ {
mMipLodBias = 0.0f; mMipLodBias = 0.0f;
for (size_t lodOffsetFeatureIdx = 0;
lodOffsetFeatureIdx < featuresVk.forceTextureLODOffset.size(); lodOffsetFeatureIdx++)
{
if (featuresVk.forceTextureLODOffset[lodOffsetFeatureIdx].enabled)
{
// Make sure only one forceTextureLODOffset feature is set.
ASSERT(mMipLodBias == 0.0f);
mMipLodBias = static_cast<float>(lodOffsetFeatureIdx + 1);
}
}
mMaxAnisotropy = samplerState.getMaxAnisotropy(); mMaxAnisotropy = samplerState.getMaxAnisotropy();
mMinLod = samplerState.getMinLod(); mMinLod = samplerState.getMinLod();
...@@ -3205,6 +3215,15 @@ void SamplerDesc::update(const angle::FeaturesVk &featuresVk, ...@@ -3205,6 +3215,15 @@ void SamplerDesc::update(const angle::FeaturesVk &featuresVk,
GLenum magFilter = samplerState.getMagFilter(); GLenum magFilter = samplerState.getMagFilter();
GLenum minFilter = samplerState.getMinFilter(); GLenum minFilter = samplerState.getMinFilter();
if (featuresVk.forceNearestFiltering.enabled)
{
magFilter = gl::ConvertToNearestFilterMode(magFilter);
minFilter = gl::ConvertToNearestFilterMode(minFilter);
}
if (featuresVk.forceNearestMipFiltering.enabled)
{
minFilter = gl::ConvertToNearestMipFilterMode(minFilter);
}
SetBitField(mMagFilter, gl_vk::GetFilter(magFilter)); SetBitField(mMagFilter, gl_vk::GetFilter(magFilter));
SetBitField(mMinFilter, gl_vk::GetFilter(minFilter)); SetBitField(mMinFilter, gl_vk::GetFilter(minFilter));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment