mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 22:13:25 -10:00
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 <[email protected]> Reviewed-by: Jamie Madill <[email protected]> Reviewed-by: Cody Northrop <[email protected]>
This commit is contained in:
1 parent
b10f4b94aa
commit
da958a59ea
2 files changed
+44
No files matched your search
@@ -3973,6 +3973,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
|
||||
if (mBaseLevel > 0)
|
||||
{
|
||||
// We need to shift the miplevel in the update to fall into the vkiamge
|
||||
updateMipLevel -= mBaseLevel;
|
||||
if (update.updateSource == UpdateSource::Clear)
|
||||
{
|
||||
update.clear.levelIndex -= mBaseLevel;
|
||||
@@ -4012,6 +4013,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
|
||||
|
||||
if (update.updateSource == UpdateSource::Clear)
|
||||
{
|
||||
ASSERT(updateMipLevel == update.clear.levelIndex);
|
||||
clear(update.clear.aspectFlags, update.clear.value, updateMipLevel, updateBaseLayer,
|
||||
updateLayerCount, commandBuffer);
|
||||
}
|
||||
|
||||
@@ -733,6 +733,48 @@ TEST_P(RobustResourceInitTest, DrawWithTexture)
|
||||
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
|
||||
// set to 0 and initialized bytes untouched.
|
||||
TEST_P(RobustResourceInitTest, ReadingPartiallyInitializedTexture)
|
||||
|
||||
Reference in new issue
Block a user