Commit 71e7a5a6 by Charlie Lao Committed by Commit Bot

Vulkan: Move mAttachedColorBufferMask to FramebufferState

This moves the bit mask of attached color buffer to front end. No function change is expected. Bug: b/167301719 Change-Id: I4eec3a419560b91875260b812a036ceaaeb6b5bb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2410790Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
parent d8b037d6
......@@ -292,6 +292,7 @@ FramebufferState::FramebufferState(rx::Serial serial)
mFramebufferSerial(serial),
mLabel(),
mColorAttachments(1),
mColorAttachmentsMask(0),
mDrawBufferStates(1, GL_BACK),
mReadBufferState(GL_BACK),
mDrawBufferTypeMask(),
......@@ -312,6 +313,7 @@ FramebufferState::FramebufferState(const Caps &caps, FramebufferID id, rx::Seria
mFramebufferSerial(serial),
mLabel(),
mColorAttachments(caps.maxColorAttachments),
mColorAttachmentsMask(0),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
mDrawBufferTypeMask(),
......@@ -1788,6 +1790,8 @@ void Framebuffer::setAttachmentImpl(const Context *context,
updateAttachment(context, &mState.mColorAttachments[0], DIRTY_BIT_COLOR_ATTACHMENT_0,
&mDirtyColorAttachmentBindings[0], type, binding, textureIndex,
resource, numViews, baseViewIndex, isMultiview, samples);
mState.mColorAttachmentsMask.set(0);
break;
default:
......@@ -1802,11 +1806,13 @@ void Framebuffer::setAttachmentImpl(const Context *context,
if (!resource)
{
mFloat32ColorAttachmentBits.reset(colorIndex);
mState.mColorAttachmentsMask.reset(colorIndex);
}
else
{
updateFloat32ColorAttachmentBits(
colorIndex, resource->getAttachmentFormat(binding, textureIndex).info);
mState.mColorAttachmentsMask.set(colorIndex);
}
bool enabled = (type != GL_NONE && getDrawBufferState(colorIndex) != GL_NONE);
......
......@@ -79,6 +79,7 @@ class FramebufferState final : angle::NonCopyable
{
return mColorAttachments;
}
const DrawBufferMask getColorAttachmentsMask() const { return mColorAttachmentsMask; }
bool attachmentsHaveSameDimensions() const;
bool hasSeparateDepthAndStencilAttachments() const;
......@@ -137,6 +138,9 @@ class FramebufferState final : angle::NonCopyable
FramebufferAttachment mDepthAttachment;
FramebufferAttachment mStencilAttachment;
// Tracks all the color buffers attached to this FramebufferDesc
gl::DrawBufferMask mColorAttachmentsMask;
std::vector<GLenum> mDrawBufferStates;
GLenum mReadBufferState;
DrawBufferMask mEnabledDrawBuffers;
......
......@@ -1477,7 +1477,7 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
{
// Set the appropriate storeOp for attachments.
vk::PackedAttachmentIndex colorIndexVk(0);
for (size_t colorIndexGL : mAttachedColorBufferMask)
for (size_t colorIndexGL : mState.getColorAttachmentsMask())
{
if (mState.getEnabledDrawBuffers()[colorIndexGL] &&
invalidateColorBuffers.test(colorIndexGL))
......@@ -1584,12 +1584,10 @@ angle::Result FramebufferVk::updateColorAttachment(const gl::Context *context,
if (enabledColor)
{
mCurrentFramebufferDesc.updateColor(colorIndexGL, renderTarget->getDrawSubresourceSerial());
mAttachedColorBufferMask.set(colorIndexGL);
}
else
{
mCurrentFramebufferDesc.updateColor(colorIndexGL, vk::kInvalidImageViewSubresourceSerial);
mAttachedColorBufferMask.reset(colorIndexGL);
}
if (enabledResolve)
......@@ -1797,10 +1795,11 @@ void FramebufferVk::updateRenderPassDesc()
mRenderPassDesc.setSamples(getSamples());
// Color attachments.
const auto &colorRenderTargets = mRenderTargetCache.getColors();
for (size_t colorIndexGL = 0; colorIndexGL < mAttachedColorBufferMask.size(); ++colorIndexGL)
const auto &colorRenderTargets = mRenderTargetCache.getColors();
const gl::DrawBufferMask colorAttachmentMask = mState.getColorAttachmentsMask();
for (size_t colorIndexGL = 0; colorIndexGL < colorAttachmentMask.size(); ++colorIndexGL)
{
if (mAttachedColorBufferMask[colorIndexGL])
if (colorAttachmentMask[colorIndexGL])
{
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
ASSERT(colorRenderTarget);
......@@ -1874,7 +1873,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk,
// Color attachments.
const auto &colorRenderTargets = mRenderTargetCache.getColors();
for (size_t colorIndexGL : mAttachedColorBufferMask)
for (size_t colorIndexGL : mState.getColorAttachmentsMask())
{
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
ASSERT(colorRenderTarget);
......@@ -1914,7 +1913,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk,
else
{
// This Framebuffer owns all of the ImageViews, including its own resolve ImageViews.
for (size_t colorIndexGL : mAttachedColorBufferMask)
for (size_t colorIndexGL : mState.getColorAttachmentsMask())
{
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
ASSERT(colorRenderTarget);
......@@ -2119,7 +2118,7 @@ void FramebufferVk::clearWithLoadOp(ContextVk *contextVk,
ASSERT(commands.getCommandBuffer().empty());
vk::PackedAttachmentIndex colorIndexVk(0);
for (size_t colorIndexGL : mAttachedColorBufferMask)
for (size_t colorIndexGL : mState.getColorAttachmentsMask())
{
if (mState.getEnabledDrawBuffers()[colorIndexGL] && clearColorBuffers[colorIndexGL])
{
......@@ -2234,7 +2233,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
// Color attachments.
const auto &colorRenderTargets = mRenderTargetCache.getColors();
vk::PackedAttachmentIndex colorIndexVk(0);
for (size_t colorIndexGL : mAttachedColorBufferMask)
for (size_t colorIndexGL : mState.getColorAttachmentsMask())
{
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
ASSERT(colorRenderTarget);
......@@ -2377,7 +2376,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
// Transition the images to the correct layout (through onColorDraw) after the
// resolve-to-multisampled copies are done.
for (size_t colorIndexGL : mAttachedColorBufferMask)
for (size_t colorIndexGL : mState.getColorAttachmentsMask())
{
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
colorRenderTarget->onColorDraw(contextVk);
......
......@@ -250,8 +250,6 @@ class FramebufferVk : public FramebufferImpl
vk::FramebufferDesc mCurrentFramebufferDesc;
std::unordered_map<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache;
// Tracks all the color buffers attached to this FramebufferDesc
gl::DrawBufferMask mAttachedColorBufferMask;
vk::ClearValuesArray mDeferredClears;
};
......
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