Commit 13c139e7 by Jamie Madill

Support masking out DS feedback loops in RenderTargetCache.

Currently this is a pure refactor and doesn't change any functionality. In a follow-up we can us this bit to mask out DS RTs when Manhattan and other apps render with feedback loops. Bug: angleproject:4517 Change-Id: I80ccd022d90a781506791110d11be195db8cd3e9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2112936Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 0e65abea
......@@ -123,6 +123,11 @@ class FramebufferState final : angle::NonCopyable
bool isDefault() const;
bool hasDepthStencilFeedbackLoop() const
{
return mDepthBufferFeedbackLoop || mStencilBufferFeedbackLoop;
}
private:
const FramebufferAttachment *getWebGLDepthStencilAttachment() const;
const FramebufferAttachment *getWebGLDepthAttachment() const;
......
......@@ -43,7 +43,7 @@ class RenderTargetCache final : angle::NonCopyable
using RenderTargetArray = gl::AttachmentArray<RenderTargetT *>;
const RenderTargetArray &getColors() const;
RenderTargetT *getDepthStencil() const;
RenderTargetT *getDepthStencil(bool allowFeedbackLoop) const;
RenderTargetT *getColorDraw(const gl::FramebufferState &state, size_t colorIndex) const;
RenderTargetT *getColorRead(const gl::FramebufferState &state) const;
......@@ -53,20 +53,18 @@ class RenderTargetCache final : angle::NonCopyable
const gl::FramebufferAttachment *attachment,
RenderTargetT **cachedRenderTarget);
RenderTargetT *mReadRenderTarget;
gl::AttachmentArray<RenderTargetT *> mColorRenderTargets;
RenderTargetT *mReadRenderTarget = nullptr;
gl::AttachmentArray<RenderTargetT *> mColorRenderTargets = {};
// We only support a single Depth/Stencil RenderTarget currently.
RenderTargetT *mDepthStencilRenderTarget;
bool mDepthStencilFeedbackLoop = false;
RenderTargetT *mDepthStencilRenderTarget = nullptr;
};
template <typename RenderTargetT>
RenderTargetCache<RenderTargetT>::RenderTargetCache()
: mReadRenderTarget{nullptr}, mColorRenderTargets{{nullptr}}, mDepthStencilRenderTarget(nullptr)
{}
RenderTargetCache<RenderTargetT>::RenderTargetCache() = default;
template <typename RenderTargetT>
RenderTargetCache<RenderTargetT>::~RenderTargetCache()
{}
RenderTargetCache<RenderTargetT>::~RenderTargetCache() = default;
template <typename RenderTargetT>
angle::Result RenderTargetCache<RenderTargetT>::update(const gl::Context *context,
......@@ -114,9 +112,9 @@ const gl::AttachmentArray<RenderTargetT *> &RenderTargetCache<RenderTargetT>::ge
}
template <typename RenderTargetT>
RenderTargetT *RenderTargetCache<RenderTargetT>::getDepthStencil() const
RenderTargetT *RenderTargetCache<RenderTargetT>::getDepthStencil(bool allowFeedbackLoop) const
{
return mDepthStencilRenderTarget;
return (allowFeedbackLoop || !mDepthStencilFeedbackLoop) ? mDepthStencilRenderTarget : nullptr;
}
template <typename RenderTargetT>
......@@ -149,6 +147,7 @@ angle::Result RenderTargetCache<RenderTargetT>::updateDepthStencilRenderTarget(
const gl::Context *context,
const gl::FramebufferState &state)
{
mDepthStencilFeedbackLoop = state.hasDepthStencilFeedbackLoop();
return updateCachedRenderTarget(context, state.getDepthOrStencilAttachment(),
&mDepthStencilRenderTarget);
}
......
......@@ -420,7 +420,7 @@ RenderTarget11 *Framebuffer11::getFirstRenderTarget() const
}
}
return mRenderTargetCache.getDepthStencil();
return mRenderTargetCache.getDepthStencil(true);
}
} // namespace rx
......@@ -47,7 +47,7 @@ class Framebuffer11 : public FramebufferD3D
}
const RenderTarget11 *getCachedDepthStencilRenderTarget() const
{
return mRenderTargetCache.getDepthStencil();
return mRenderTargetCache.getDepthStencil(true);
}
RenderTarget11 *getFirstRenderTarget() const;
......
......@@ -61,7 +61,7 @@ angle::Result Framebuffer9::clearImpl(const gl::Context *context,
const ClearParameters &clearParams)
{
ANGLE_TRY(mRenderer->applyRenderTarget(context, mRenderTargetCache.getColors()[0],
mRenderTargetCache.getDepthStencil()));
mRenderTargetCache.getDepthStencil(true)));
const gl::State &glState = context->getState();
float nearZ = glState.getNearPlane();
......@@ -72,7 +72,7 @@ angle::Result Framebuffer9::clearImpl(const gl::Context *context,
mRenderer->setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled());
mRenderer->clear(clearParams, mRenderTargetCache.getColors()[0],
mRenderTargetCache.getDepthStencil());
mRenderTargetCache.getDepthStencil(true));
return angle::Result::Continue;
}
......
......@@ -48,7 +48,7 @@ class Framebuffer9 : public FramebufferD3D
const RenderTarget9 *getCachedDepthStencilRenderTarget() const
{
return mRenderTargetCache.getDepthStencil();
return mRenderTargetCache.getDepthStencil(true);
}
private:
......
......@@ -447,7 +447,7 @@ angle::Result FramebufferVk::readPixels(const gl::Context *context,
RenderTargetVk *FramebufferVk::getDepthStencilRenderTarget() const
{
return mRenderTargetCache.getDepthStencil();
return mRenderTargetCache.getDepthStencil(true);
}
RenderTargetVk *FramebufferVk::getColorDrawRenderTarget(size_t colorIndex) const
......@@ -737,7 +737,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
if (blitDepthBuffer || blitStencilBuffer)
{
RenderTargetVk *readRenderTarget = srcFramebufferVk->getDepthStencilRenderTarget();
RenderTargetVk *drawRenderTarget = mRenderTargetCache.getDepthStencil();
RenderTargetVk *drawRenderTarget = mRenderTargetCache.getDepthStencil(true);
params.srcLayer = readRenderTarget->getLayerIndex();
// Multisampled images are not allowed to have mips.
......@@ -947,7 +947,7 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
++attachmentIndexVk;
}
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil();
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil(true);
if (depthStencilRenderTarget)
{
if (invalidateDepthBuffer)
......@@ -983,11 +983,12 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
void FramebufferVk::updateDepthStencilAttachmentSerial(ContextVk *contextVk)
{
if (mRenderTargetCache.getDepthStencil() != nullptr)
RenderTargetVk *depthStencilRT = mRenderTargetCache.getDepthStencil(true);
if (depthStencilRT != nullptr)
{
mCurrentFramebufferDesc.update(
vk::kFramebufferDescDepthStencilIndex,
mRenderTargetCache.getDepthStencil()->getAssignSerial(contextVk));
mCurrentFramebufferDesc.update(vk::kFramebufferDescDepthStencilIndex,
depthStencilRT->getAssignSerial(contextVk));
}
else
{
......@@ -1018,19 +1019,15 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
updateDepthStencilAttachmentSerial(contextVk);
break;
case gl::Framebuffer::DIRTY_BIT_DEPTH_BUFFER_CONTENTS:
ANGLE_TRY(mRenderTargetCache.getDepthStencil()->flushStagedUpdates(contextVk));
ASSERT(mRenderTargetCache.getDepthStencil() != nullptr);
mCurrentFramebufferDesc.update(
vk::kFramebufferDescDepthStencilIndex,
mRenderTargetCache.getDepthStencil()->getAssignSerial(contextVk));
break;
case gl::Framebuffer::DIRTY_BIT_STENCIL_BUFFER_CONTENTS:
ANGLE_TRY(mRenderTargetCache.getDepthStencil()->flushStagedUpdates(contextVk));
ASSERT(mRenderTargetCache.getDepthStencil() != nullptr);
mCurrentFramebufferDesc.update(
vk::kFramebufferDescDepthStencilIndex,
mRenderTargetCache.getDepthStencil()->getAssignSerial(contextVk));
{
RenderTargetVk *depthStencilRT = mRenderTargetCache.getDepthStencil(true);
ASSERT(depthStencilRT != nullptr);
ANGLE_TRY(depthStencilRT->flushStagedUpdates(contextVk));
mCurrentFramebufferDesc.update(vk::kFramebufferDescDepthStencilIndex,
depthStencilRT->getAssignSerial(contextVk));
break;
}
case gl::Framebuffer::DIRTY_BIT_READ_BUFFER:
ANGLE_TRY(mRenderTargetCache.update(context, mState, dirtyBits));
break;
......@@ -1144,7 +1141,7 @@ void FramebufferVk::updateRenderPassDesc()
}
}
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil();
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil(true);
if (depthStencilRenderTarget)
{
mRenderPassDesc.packDepthStencilAttachment(
......@@ -1203,7 +1200,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk, vk::Framebuffe
attachmentsSize = colorRenderTarget->getExtents();
}
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil();
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil(true);
if (depthStencilRenderTarget)
{
const vk::ImageView *imageView = nullptr;
......@@ -1327,7 +1324,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
attachmentClearValues.emplace_back(kUninitializedClearValue);
}
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil();
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil(true);
if (depthStencilRenderTarget)
{
ANGLE_TRY(depthStencilRenderTarget->onDepthStencilDraw(contextVk));
......@@ -1405,7 +1402,7 @@ RenderTargetVk *FramebufferVk::getFirstRenderTarget() const
}
}
return mRenderTargetCache.getDepthStencil();
return mRenderTargetCache.getDepthStencil(true);
}
GLint FramebufferVk::getSamples() const
......
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