Commit edef895a by Shahbaz Youssefi Committed by Commit Bot

Vulkan: make sure clear value is completely initialized

If clearing only depth or stencil, the other channels contained garbage. Additionally, this removes the clearing of emulated channels. Emulated textures are cleared once, and they don't need to be recleared. Bug: angleproject:2361 Change-Id: I01aa6be116d44f6c0115a1c25322db2e579a7b23 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1553739 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d5ff4fad
......@@ -235,12 +235,8 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
// This function assumes that only enabled attachments are asked to be cleared.
ASSERT((clearColorBuffers & mState.getEnabledDrawBuffers()) == clearColorBuffers);
// Adjust clear behavior based on whether:
//
// - the respective attachments are present: if asked to clear a non-existent attachment, don't
// attempt to clear it.
// - extra clear is necessary: if depth- or stencil-only attachments are emulated with a format
// that has both aspects, clear the emulated aspect.
// Adjust clear behavior based on whether the respective attachments are present; if asked to
// clear a non-existent attachment, don't attempt to clear it.
VkColorComponentFlags colorMaskFlags = contextVk->getClearColorMask();
bool clearColor = clearColorBuffers.any();
......@@ -272,28 +268,6 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
VkClearDepthStencilValue modifiedDepthStencilValue = clearDepthStencilValue;
// If the depth or stencil is being cleared, and the image was originally requested to have a
// single aspect, but it's emulated with a depth/stencil format, clear both aspects, setting the
// other aspect to 0.
if (clearStencil || clearDepth)
{
RenderTargetVk *depthStencil = mRenderTargetCache.getDepthStencil();
const vk::Format &format = depthStencil->getImageFormat();
// GL_DEPTH_COMPONENT24 is always emulated with a format that has stencil.
if (format.angleFormat().stencilBits == 0)
{
clearStencil = true;
modifiedDepthStencilValue.stencil = 0;
}
// GL_STENCIL_INDEX8 may or may not be emulated.
else if (format.angleFormat().depthBits == 0 && format.vkTextureFormat != VK_FORMAT_S8_UINT)
{
clearDepth = true;
modifiedDepthStencilValue.depth = 0;
}
}
// If scissor is enabled, but covers the whole of framebuffer, it can be considered disabled for
// the sake of clear.
bool isScissorTestEffectivelyEnabled =
......@@ -380,7 +354,7 @@ angle::Result FramebufferVk::clearBufferfv(const gl::Context *context,
GLint drawbuffer,
const GLfloat *values)
{
VkClearValue clearValue;
VkClearValue clearValue = {};
bool clearDepth = false;
gl::DrawBufferMask clearColorBuffers;
......@@ -408,7 +382,7 @@ angle::Result FramebufferVk::clearBufferuiv(const gl::Context *context,
GLint drawbuffer,
const GLuint *values)
{
VkClearValue clearValue;
VkClearValue clearValue = {};
gl::DrawBufferMask clearColorBuffers;
clearColorBuffers.set(drawbuffer);
......@@ -427,7 +401,7 @@ angle::Result FramebufferVk::clearBufferiv(const gl::Context *context,
GLint drawbuffer,
const GLint *values)
{
VkClearValue clearValue;
VkClearValue clearValue = {};
bool clearStencil = false;
gl::DrawBufferMask clearColorBuffers;
......@@ -457,7 +431,7 @@ angle::Result FramebufferVk::clearBufferfi(const gl::Context *context,
GLfloat depth,
GLint stencil)
{
VkClearValue clearValue;
VkClearValue clearValue = {};
clearValue.depthStencil.depth = depth;
clearValue.depthStencil.stencil = gl::clamp(stencil, 0, std::numeric_limits<uint8_t>::max());
......
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