Commit da958a59 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix clear of non-zero-base-level images

The staged resource updates adjusted their level to take base level into account, but clear updates used a cached unadjusted value. Bug: angleproject:3148 Change-Id: I9a49d5341083b2f870baa1ee6053e54baef35086 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2230786 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent b10f4b94
...@@ -3973,6 +3973,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk, ...@@ -3973,6 +3973,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
if (mBaseLevel > 0) if (mBaseLevel > 0)
{ {
// We need to shift the miplevel in the update to fall into the vkiamge // We need to shift the miplevel in the update to fall into the vkiamge
updateMipLevel -= mBaseLevel;
if (update.updateSource == UpdateSource::Clear) if (update.updateSource == UpdateSource::Clear)
{ {
update.clear.levelIndex -= mBaseLevel; update.clear.levelIndex -= mBaseLevel;
...@@ -4012,6 +4013,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk, ...@@ -4012,6 +4013,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
if (update.updateSource == UpdateSource::Clear) if (update.updateSource == UpdateSource::Clear)
{ {
ASSERT(updateMipLevel == update.clear.levelIndex);
clear(update.clear.aspectFlags, update.clear.value, updateMipLevel, updateBaseLayer, clear(update.clear.aspectFlags, update.clear.value, updateMipLevel, updateBaseLayer,
updateLayerCount, commandBuffer); updateLayerCount, commandBuffer);
} }
......
...@@ -733,6 +733,48 @@ TEST_P(RobustResourceInitTest, DrawWithTexture) ...@@ -733,6 +733,48 @@ TEST_P(RobustResourceInitTest, DrawWithTexture)
checkFramebufferNonZeroPixels(0, 0, 0, 0, GLColor::black); checkFramebufferNonZeroPixels(0, 0, 0, 0, GLColor::black);
} }
// Tests that drawing with an uninitialized mipped texture works as expected.
TEST_P(RobustResourceInitTestES3, DrawWithMippedTexture)
{
ANGLE_SKIP_TEST_IF(!hasGLExtension());
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, kWidth / 2, kHeight / 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, kWidth / 4, kHeight / 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
glTexImage2D(GL_TEXTURE_2D, 3, GL_RGBA, kWidth / 8, kHeight / 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 3);
EXPECT_GL_NO_ERROR();
constexpr char kVS[] =
"attribute vec2 position;\n"
"varying vec2 texCoord;\n"
"void main() {\n"
" gl_Position = vec4(position, 0, 1);\n"
" texCoord = (position * 0.5) + 0.5;\n"
"}";
constexpr char kFS[] =
"precision mediump float;\n"
"varying vec2 texCoord;\n"
"uniform sampler2D tex;\n"
"void main() {\n"
" gl_FragColor = texture2D(tex, texCoord);\n"
"}";
ANGLE_GL_PROGRAM(program, kVS, kFS);
drawQuad(program, "position", 0.5f);
checkFramebufferNonZeroPixels(0, 0, 0, 0, GLColor::black);
}
// Reading a partially initialized texture (texImage2D) should succeed with all uninitialized bytes // Reading a partially initialized texture (texImage2D) should succeed with all uninitialized bytes
// set to 0 and initialized bytes untouched. // set to 0 and initialized bytes untouched.
TEST_P(RobustResourceInitTest, ReadingPartiallyInitializedTexture) TEST_P(RobustResourceInitTest, ReadingPartiallyInitializedTexture)
......
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