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, ...@@ -235,12 +235,8 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
// This function assumes that only enabled attachments are asked to be cleared. // This function assumes that only enabled attachments are asked to be cleared.
ASSERT((clearColorBuffers & mState.getEnabledDrawBuffers()) == clearColorBuffers); ASSERT((clearColorBuffers & mState.getEnabledDrawBuffers()) == clearColorBuffers);
// Adjust clear behavior based on whether: // 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.
// - 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.
VkColorComponentFlags colorMaskFlags = contextVk->getClearColorMask(); VkColorComponentFlags colorMaskFlags = contextVk->getClearColorMask();
bool clearColor = clearColorBuffers.any(); bool clearColor = clearColorBuffers.any();
...@@ -272,28 +268,6 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -272,28 +268,6 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
VkClearDepthStencilValue modifiedDepthStencilValue = clearDepthStencilValue; 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 // If scissor is enabled, but covers the whole of framebuffer, it can be considered disabled for
// the sake of clear. // the sake of clear.
bool isScissorTestEffectivelyEnabled = bool isScissorTestEffectivelyEnabled =
...@@ -380,7 +354,7 @@ angle::Result FramebufferVk::clearBufferfv(const gl::Context *context, ...@@ -380,7 +354,7 @@ angle::Result FramebufferVk::clearBufferfv(const gl::Context *context,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) const GLfloat *values)
{ {
VkClearValue clearValue; VkClearValue clearValue = {};
bool clearDepth = false; bool clearDepth = false;
gl::DrawBufferMask clearColorBuffers; gl::DrawBufferMask clearColorBuffers;
...@@ -408,7 +382,7 @@ angle::Result FramebufferVk::clearBufferuiv(const gl::Context *context, ...@@ -408,7 +382,7 @@ angle::Result FramebufferVk::clearBufferuiv(const gl::Context *context,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) const GLuint *values)
{ {
VkClearValue clearValue; VkClearValue clearValue = {};
gl::DrawBufferMask clearColorBuffers; gl::DrawBufferMask clearColorBuffers;
clearColorBuffers.set(drawbuffer); clearColorBuffers.set(drawbuffer);
...@@ -427,7 +401,7 @@ angle::Result FramebufferVk::clearBufferiv(const gl::Context *context, ...@@ -427,7 +401,7 @@ angle::Result FramebufferVk::clearBufferiv(const gl::Context *context,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) const GLint *values)
{ {
VkClearValue clearValue; VkClearValue clearValue = {};
bool clearStencil = false; bool clearStencil = false;
gl::DrawBufferMask clearColorBuffers; gl::DrawBufferMask clearColorBuffers;
...@@ -457,7 +431,7 @@ angle::Result FramebufferVk::clearBufferfi(const gl::Context *context, ...@@ -457,7 +431,7 @@ angle::Result FramebufferVk::clearBufferfi(const gl::Context *context,
GLfloat depth, GLfloat depth,
GLint stencil) GLint stencil)
{ {
VkClearValue clearValue; VkClearValue clearValue = {};
clearValue.depthStencil.depth = depth; clearValue.depthStencil.depth = depth;
clearValue.depthStencil.stencil = gl::clamp(stencil, 0, std::numeric_limits<uint8_t>::max()); 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