Commit c20b950e by Luc Ferron Committed by Commit Bot

Vulkan: Fix clear of specific mip level was clearing all mip levels

Bug: angleproject:2502 Change-Id: Iffa012dce14584318c4dfd3d9b3a304291c9cebf Reviewed-on: https://chromium-review.googlesource.com/1070666 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 574a6f25
...@@ -210,7 +210,8 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -210,7 +210,8 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex]; RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex];
ASSERT(colorRenderTarget); ASSERT(colorRenderTarget);
vk::ImageHelper *image = colorRenderTarget->getImageForWrite(currentSerial, this); vk::ImageHelper *image = colorRenderTarget->getImageForWrite(currentSerial, this);
image->clearColor(clearColorValue, commandBuffer); GLint mipLevelToClear = (attachment->type() == GL_TEXTURE) ? attachment->mipLevel() : 0;
image->clearColor(clearColorValue, mipLevelToClear, 1, commandBuffer);
} }
return gl::NoError(); return gl::NoError();
......
...@@ -102,7 +102,7 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context, ...@@ -102,7 +102,7 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context,
} }
else else
{ {
mImage.clearColor(kBlackClearColorValue, commandBuffer); mImage.clearColor(kBlackClearColorValue, 0, 1, commandBuffer);
} }
} }
......
...@@ -401,7 +401,7 @@ vk::Error WindowSurfaceVk::initializeImpl(RendererVk *renderer) ...@@ -401,7 +401,7 @@ vk::Error WindowSurfaceVk::initializeImpl(RendererVk *renderer)
gl::SwizzleState(), &member.imageView, 1); gl::SwizzleState(), &member.imageView, 1);
// Set transfer dest layout, and clear the image to black. // Set transfer dest layout, and clear the image to black.
member.image.clearColor(transparentBlack, commandBuffer); member.image.clearColor(transparentBlack, 0, 1, commandBuffer);
ANGLE_TRY(member.imageAcquiredSemaphore.init(device)); ANGLE_TRY(member.imageAcquiredSemaphore.init(device));
ANGLE_TRY(member.commandsCompleteSemaphore.init(device)); ANGLE_TRY(member.commandsCompleteSemaphore.init(device));
......
...@@ -855,7 +855,7 @@ vk::Error TextureVk::initImage(RendererVk *renderer, ...@@ -855,7 +855,7 @@ vk::Error TextureVk::initImage(RendererVk *renderer,
// TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361 // TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361
VkClearColorValue black = {{0, 0, 0, 1.0f}}; VkClearColorValue black = {{0, 0, 0, 1.0f}};
mImage.clearColor(black, commandBuffer); mImage.clearColor(black, 0, levelCount, commandBuffer);
return vk::NoError(); return vk::NoError();
} }
......
...@@ -770,7 +770,10 @@ void ImageHelper::changeLayoutWithStages(VkImageAspectFlags aspectMask, ...@@ -770,7 +770,10 @@ void ImageHelper::changeLayoutWithStages(VkImageAspectFlags aspectMask,
mCurrentLayout = newLayout; mCurrentLayout = newLayout;
} }
void ImageHelper::clearColor(const VkClearColorValue &color, CommandBuffer *commandBuffer) void ImageHelper::clearColor(const VkClearColorValue &color,
uint32_t mipLevel,
uint32_t levelCount,
CommandBuffer *commandBuffer)
{ {
ASSERT(valid()); ASSERT(valid());
...@@ -780,8 +783,8 @@ void ImageHelper::clearColor(const VkClearColorValue &color, CommandBuffer *comm ...@@ -780,8 +783,8 @@ void ImageHelper::clearColor(const VkClearColorValue &color, CommandBuffer *comm
VkImageSubresourceRange range; VkImageSubresourceRange range;
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
range.baseMipLevel = 0; range.baseMipLevel = mipLevel;
range.levelCount = VK_REMAINING_MIP_LEVELS; range.levelCount = levelCount;
range.baseArrayLayer = 0; range.baseArrayLayer = 0;
range.layerCount = mLayerCount; range.layerCount = mLayerCount;
......
...@@ -219,7 +219,10 @@ class ImageHelper final : angle::NonCopyable ...@@ -219,7 +219,10 @@ class ImageHelper final : angle::NonCopyable
VkPipelineStageFlags dstStageMask, VkPipelineStageFlags dstStageMask,
CommandBuffer *commandBuffer); CommandBuffer *commandBuffer);
void clearColor(const VkClearColorValue &color, CommandBuffer *commandBuffer); void clearColor(const VkClearColorValue &color,
uint32_t mipLevel,
uint32_t levelCount,
CommandBuffer *commandBuffer);
void clearDepthStencil(VkImageAspectFlags aspectFlags, void clearDepthStencil(VkImageAspectFlags aspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
......
...@@ -520,9 +520,9 @@ TEST_P(MipmapTest, DISABLED_ThreeLevelsInitData) ...@@ -520,9 +520,9 @@ TEST_P(MipmapTest, DISABLED_ThreeLevelsInitData)
// In particular, on D3D11 Feature Level 9_3 it ensures that both the zero LOD workaround texture AND the 'normal' texture are copied during conversion. // In particular, on D3D11 Feature Level 9_3 it ensures that both the zero LOD workaround texture AND the 'normal' texture are copied during conversion.
TEST_P(MipmapTest, GenerateMipmapFromInitDataThenRender) TEST_P(MipmapTest, GenerateMipmapFromInitDataThenRender)
{ {
// TODO(lucferron): Figure out why we clear all levels when trying to clear level 0. // TODO(lucferron): Figure out why this test is failing only on Intel Linux.
// http://anglebug.com/2502 // http://anglebug.com/2502
ANGLE_SKIP_TEST_IF(IsVulkan()); ANGLE_SKIP_TEST_IF(IsVulkan() && IsIntel());
// Pass in initial data so the texture is blue. // Pass in initial data so the texture is blue.
glBindTexture(GL_TEXTURE_2D, mTexture2D); glBindTexture(GL_TEXTURE_2D, mTexture2D);
...@@ -610,9 +610,9 @@ TEST_P(MipmapTest, GenerateMipmapFromRenderedImage) ...@@ -610,9 +610,9 @@ TEST_P(MipmapTest, GenerateMipmapFromRenderedImage)
// TODO: This test hits a texture rebind bug in the D3D11 renderer. Fix this. // TODO: This test hits a texture rebind bug in the D3D11 renderer. Fix this.
TEST_P(MipmapTest, RenderOntoLevelZeroAfterGenerateMipmap) TEST_P(MipmapTest, RenderOntoLevelZeroAfterGenerateMipmap)
{ {
// TODO(lucferron): Figure out why we clear all levels when trying to clear level 0. // TODO(lucferron): Figure out why this test is failing only on Intel Linux.
// http://anglebug.com/2502 // http://anglebug.com/2502
ANGLE_SKIP_TEST_IF(IsVulkan()); ANGLE_SKIP_TEST_IF(IsVulkan() && IsIntel());
// TODO(geofflang): Figure out why this is broken on AMD OpenGL // TODO(geofflang): Figure out why this is broken on AMD OpenGL
ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL()); ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL());
...@@ -701,8 +701,7 @@ TEST_P(MipmapTest, MipMapGenerationD3D9Bug) ...@@ -701,8 +701,7 @@ TEST_P(MipmapTest, MipMapGenerationD3D9Bug)
// works as expected. It tests enabling/disabling mipmaps, generating mipmaps, and rendering to level zero. // works as expected. It tests enabling/disabling mipmaps, generating mipmaps, and rendering to level zero.
TEST_P(MipmapTest, TextureCubeGeneralLevelZero) TEST_P(MipmapTest, TextureCubeGeneralLevelZero)
{ {
// TODO(lucferron): Implement mipmaps generation for cube textures // TODO(jmadill): Cube map attachments http://anglebug.com/2470
// http://anglebug.com/2502
ANGLE_SKIP_TEST_IF(IsVulkan()); ANGLE_SKIP_TEST_IF(IsVulkan());
glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube); glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
...@@ -743,8 +742,7 @@ TEST_P(MipmapTest, TextureCubeGeneralLevelZero) ...@@ -743,8 +742,7 @@ TEST_P(MipmapTest, TextureCubeGeneralLevelZero)
// This test ensures that rendering to level-zero of a TextureCube works as expected. // This test ensures that rendering to level-zero of a TextureCube works as expected.
TEST_P(MipmapTest, TextureCubeRenderToLevelZero) TEST_P(MipmapTest, TextureCubeRenderToLevelZero)
{ {
// TODO(lucferron): Implement mipmaps generation for cube textures // TODO(jmadill): Cube map attachments http://anglebug.com/2470
// http://anglebug.com/2502
ANGLE_SKIP_TEST_IF(IsVulkan()); ANGLE_SKIP_TEST_IF(IsVulkan());
glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube); glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
......
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