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