Commit 95c0fae6 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Clear surface images if emulated format

This was done for renderbuffers but was missing for surfaces. Bug: angleproject:2722 Change-Id: I019805d6ca43eef86d2d46e7c72c1013803f2139 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1570149 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3b2c6bfd
...@@ -85,12 +85,8 @@ angle::Result RenderbufferVk::setStorage(const gl::Context *context, ...@@ -85,12 +85,8 @@ angle::Result RenderbufferVk::setStorage(const gl::Context *context,
&mImageView, 0, 1)); &mImageView, 0, 1));
// Clear the renderbuffer if it has emulated channels. // Clear the renderbuffer if it has emulated channels.
if (vkFormat.hasEmulatedChannels()) ANGLE_TRY(mImage->clearIfEmulatedFormat(vk::GetImpl(context), gl::ImageIndex::Make2D(0),
{ vkFormat));
mImage->stageSubresourceEmulatedClear(gl::ImageIndex::Make2D(0),
vkFormat.angleFormat());
ANGLE_TRY(mImage->flushAllStagedUpdates(vk::GetImpl(context)));
}
mRenderTarget.init(mImage, &mImageView, 0, 0, nullptr); mRenderTarget.init(mImage, &mImageView, 0, 0, nullptr);
} }
......
...@@ -109,6 +109,9 @@ angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *display ...@@ -109,6 +109,9 @@ angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *display
ANGLE_TRY(image.initImageView(displayVk, gl::TextureType::_2D, aspect, gl::SwizzleState(), ANGLE_TRY(image.initImageView(displayVk, gl::TextureType::_2D, aspect, gl::SwizzleState(),
&imageView, 0, 1)); &imageView, 0, 1));
// Clear the image if it has emulated channels.
ANGLE_TRY(image.clearIfEmulatedFormat(displayVk, gl::ImageIndex::Make2D(0), vkFormat));
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -568,6 +571,9 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk, ...@@ -568,6 +571,9 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
ANGLE_TRY(member.image.initImageView(displayVk, gl::TextureType::_2D, ANGLE_TRY(member.image.initImageView(displayVk, gl::TextureType::_2D,
VK_IMAGE_ASPECT_COLOR_BIT, gl::SwizzleState(), VK_IMAGE_ASPECT_COLOR_BIT, gl::SwizzleState(),
&member.imageView, 0, 1)); &member.imageView, 0, 1));
// Clear the image if it has emulated channels.
ANGLE_TRY(member.image.clearIfEmulatedFormat(displayVk, gl::ImageIndex::Make2D(0), format));
} }
// Initialize depth/stencil if requested. // Initialize depth/stencil if requested.
...@@ -588,6 +594,10 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk, ...@@ -588,6 +594,10 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
1)); 1));
// We will need to pass depth/stencil image views to the RenderTargetVk in the future. // We will need to pass depth/stencil image views to the RenderTargetVk in the future.
// Clear the image if it has emulated channels.
ANGLE_TRY(mDepthStencilImage.clearIfEmulatedFormat(displayVk, gl::ImageIndex::Make2D(0),
dsFormat));
} }
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -2061,6 +2061,19 @@ void ImageHelper::stageSubresourceEmulatedClear(const gl::ImageIndex &index, ...@@ -2061,6 +2061,19 @@ void ImageHelper::stageSubresourceEmulatedClear(const gl::ImageIndex &index,
stageSubresourceClear(index, format, kEmulatedInitColorValue, kWebGLInitDepthStencilValue); stageSubresourceClear(index, format, kEmulatedInitColorValue, kWebGLInitDepthStencilValue);
} }
angle::Result ImageHelper::clearIfEmulatedFormat(Context *context,
const gl::ImageIndex &index,
const Format &format)
{
if (format.hasEmulatedChannels())
{
stageSubresourceEmulatedClear(index, format.angleFormat());
ANGLE_TRY(flushAllStagedUpdates(context));
}
return angle::Result::Continue;
}
void ImageHelper::stageSubresourceClear(const gl::ImageIndex &index, void ImageHelper::stageSubresourceClear(const gl::ImageIndex &index,
const angle::Format &format, const angle::Format &format,
const VkClearColorValue &colorValue, const VkClearColorValue &colorValue,
......
...@@ -674,6 +674,12 @@ class ImageHelper final : public CommandGraphResource ...@@ -674,6 +674,12 @@ class ImageHelper final : public CommandGraphResource
// values. // values.
void stageSubresourceEmulatedClear(const gl::ImageIndex &index, const angle::Format &format); void stageSubresourceEmulatedClear(const gl::ImageIndex &index, const angle::Format &format);
// If the image has emulated channels, we clear them once so as not to leave garbage on those
// channels.
angle::Result clearIfEmulatedFormat(Context *context,
const gl::ImageIndex &index,
const Format &format);
// This will use the underlying dynamic buffer to allocate some memory to be used as a src or // This will use the underlying dynamic buffer to allocate some memory to be used as a src or
// dst. // dst.
angle::Result allocateStagingMemory(ContextVk *contextVk, angle::Result allocateStagingMemory(ContextVk *contextVk,
......
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