Commit 175227ba by Tobin Ehlis Committed by Commit Bot

Vulkan:FramebufferVk cache draw buffer handling

Dirty draw buffers are causing cache clears on Manhattan. Instead of clearing out the entire FramebufferVk cache when draw buffers are dirty, reset the cache signature and regenerate it. This change also contains a fix to make sure that we're not generating serials for a draw buffer that's disabled. Thanks Jamie Madill! Bug: angleproject:4442 Change-Id: I0d48a2d6d95e74898a11bdde0fedbce77c82a3a3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2091862Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent a2f9ad39
...@@ -1037,9 +1037,18 @@ angle::Result FramebufferVk::syncState(const gl::Context *context, ...@@ -1037,9 +1037,18 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
case gl::Framebuffer::DIRTY_BIT_READ_BUFFER: case gl::Framebuffer::DIRTY_BIT_READ_BUFFER:
ANGLE_TRY(mRenderTargetCache.update(context, mState, dirtyBits)); ANGLE_TRY(mRenderTargetCache.update(context, mState, dirtyBits));
break; break;
case gl::Framebuffer::DIRTY_BIT_DRAW_BUFFERS:
// Force update of serial for enabled draw buffers
mCurrentFramebufferDesc.reset();
for (size_t colorIndexGL : mState.getEnabledDrawBuffers())
{
mCurrentFramebufferDesc.update(
static_cast<uint32_t>(colorIndexGL),
mRenderTargetCache.getColors()[colorIndexGL]->getAssignSerial(contextVk));
}
break;
case gl::Framebuffer::DIRTY_BIT_DEFAULT_WIDTH: case gl::Framebuffer::DIRTY_BIT_DEFAULT_WIDTH:
case gl::Framebuffer::DIRTY_BIT_DEFAULT_HEIGHT: case gl::Framebuffer::DIRTY_BIT_DEFAULT_HEIGHT:
case gl::Framebuffer::DIRTY_BIT_DRAW_BUFFERS:
case gl::Framebuffer::DIRTY_BIT_DEFAULT_SAMPLES: case gl::Framebuffer::DIRTY_BIT_DEFAULT_SAMPLES:
case gl::Framebuffer::DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS: case gl::Framebuffer::DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS:
// Invalidate the cache. If we have performance critical code hitting this path we // Invalidate the cache. If we have performance critical code hitting this path we
...@@ -1054,7 +1063,8 @@ angle::Result FramebufferVk::syncState(const gl::Context *context, ...@@ -1054,7 +1063,8 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
size_t colorIndexGL = static_cast<size_t>( size_t colorIndexGL = static_cast<size_t>(
dirtyBit - gl::Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0); dirtyBit - gl::Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0);
ANGLE_TRY(updateColorAttachment(context, colorIndexGL)); ANGLE_TRY(updateColorAttachment(context, colorIndexGL));
if (mRenderTargetCache.getColors()[colorIndexGL] != nullptr) if (mRenderTargetCache.getColors()[colorIndexGL] != nullptr &&
mState.getEnabledDrawBuffers()[colorIndexGL])
{ {
mCurrentFramebufferDesc.update( mCurrentFramebufferDesc.update(
static_cast<uint32_t>(colorIndexGL), static_cast<uint32_t>(colorIndexGL),
......
...@@ -1647,7 +1647,7 @@ bool TextureDescriptorDesc::operator==(const TextureDescriptorDesc &other) const ...@@ -1647,7 +1647,7 @@ bool TextureDescriptorDesc::operator==(const TextureDescriptorDesc &other) const
FramebufferDesc::FramebufferDesc() FramebufferDesc::FramebufferDesc()
{ {
clearSerials(); reset();
} }
FramebufferDesc::~FramebufferDesc() = default; FramebufferDesc::~FramebufferDesc() = default;
...@@ -1666,7 +1666,7 @@ size_t FramebufferDesc::hash() const ...@@ -1666,7 +1666,7 @@ size_t FramebufferDesc::hash() const
sizeof(AttachmentSerial) * kMaxFramebufferAttachments); sizeof(AttachmentSerial) * kMaxFramebufferAttachments);
} }
void FramebufferDesc::clearSerials() void FramebufferDesc::reset()
{ {
memset(&mSerials, 0, sizeof(AttachmentSerial) * kMaxFramebufferAttachments); memset(&mSerials, 0, sizeof(AttachmentSerial) * kMaxFramebufferAttachments);
} }
......
...@@ -748,11 +748,11 @@ class FramebufferDesc ...@@ -748,11 +748,11 @@ class FramebufferDesc
void update(uint32_t index, AttachmentSerial serial); void update(uint32_t index, AttachmentSerial serial);
size_t hash() const; size_t hash() const;
void reset();
bool operator==(const FramebufferDesc &other) const; bool operator==(const FramebufferDesc &other) const;
private: private:
void clearSerials();
gl::AttachmentArray<AttachmentSerial> mSerials; gl::AttachmentArray<AttachmentSerial> mSerials;
}; };
} // namespace vk } // namespace vk
......
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