Commit cf63d872 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Use mipmap hint when generating mipmaps

If the application asks for GL_FASTEST, this uses VK_FILTER_NEAREST instead of VK_FILTER_LINEAR. Bug: angleproject:4551 Change-Id: I6c10758104bd63dd477ea853a3b0464665f371ed Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2279132Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 45c22722
......@@ -1438,6 +1438,11 @@ void State::setGenerateMipmapHint(GLenum hint)
mDirtyBits.set(DIRTY_BIT_EXTENDED);
}
GLenum State::getGenerateMipmapHint() const
{
return mGenerateMipmapHint;
}
void State::setTextureFilteringHint(GLenum hint)
{
mTextureFilteringHint = hint;
......
......@@ -262,6 +262,7 @@ class State : angle::NonCopyable
// Hint setters
void setGenerateMipmapHint(GLenum hint);
GLenum getGenerateMipmapHint() const;
void setTextureFilteringHint(GLenum hint);
GLenum getTextureFilteringHint() const;
void setFragmentShaderDerivativeHint(GLenum hint);
......
......@@ -3272,6 +3272,12 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
barrier.subresourceRange.layerCount = mLayerCount;
barrier.subresourceRange.levelCount = 1;
const bool formatSupportsLinearFiltering = contextVk->getRenderer()->hasImageFormatFeatureBits(
getFormat().vkImageFormat, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
const bool hintFastest = contextVk->getState().getGenerateMipmapHint() == GL_FASTEST;
const VkFilter filter =
formatSupportsLinearFiltering && !hintFastest ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
for (uint32_t mipLevel = 1; mipLevel <= maxLevel; mipLevel++)
{
int32_t nextMipWidth = std::max<int32_t>(1, mipWidth >> 1);
......@@ -3305,13 +3311,8 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
mipHeight = nextMipHeight;
mipDepth = nextMipDepth;
bool formatSupportsLinearFiltering = contextVk->getRenderer()->hasImageFormatFeatureBits(
getFormat().vkImageFormat, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
commandBuffer->blitImage(
mImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit,
formatSupportsLinearFiltering ? VK_FILTER_LINEAR : VK_FILTER_NEAREST);
commandBuffer->blitImage(mImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, filter);
}
// Transition the last mip level to the same layout as all the other ones, so we can declare
......
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