Commit f6fb6da8 by Khushal Committed by Commit Bot

Revert "Feedback Loop Redesign 2/3: Track bound FBOs in Texture."

This reverts commit 699bcde0. Reason for revert: Breaking GLES2WebGLDecoderPassthroughTest.DrawArraysInstancedANGLEEnablement. Here is a sample build : https://ci.chromium.org/p/chromium/builders/ci/Win10%20FYI%20x64%20Release%20%28NVIDIA%29/4240 Original change's description: > Feedback Loop Redesign 2/3: Track bound FBOs in Texture. > > Currently we track feedback loops by counting the times a Texture is > bound as a sampler or image in a particular context. This is a bit > tricky because Texture bindings change frequently. Relative to the > number of times we need to check for a feedback loop this causes excess > overhead. > > Usually Framebuffers have a low number of Textures bound (in many cases > just 1). And Textures aren't usually bound to many different FBOs. So > instead of counting the number of times a Texture is bound as a sampler > or image we will track the Framebuffers that the Texture is bound to. > > This CL adds a small vector class to gl::Texture which tracks all the > Framebufer Serials of its bound Framebuffers. We can use this set to > quickly check if there's any potential feedback loop between the a FBO > and this Texture. > > We also update the feedback loop check to use this new method. We will > be able to remove the old counting method when we switch the Vulkan > feedback loop handling to use the new tracking in this CL. > > Bug: angleproject:4500 > Bug: angleproject:4959 > Change-Id: I84a2f0ed8480d1da63d5879e0e56a8be4af4e735 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2358850 > Reviewed-by: Tobin Ehlis <tobine@google.com> > Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> > Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> > Commit-Queue: Jamie Madill <jmadill@chromium.org> TBR=tobine@google.com,courtneygo@google.com,jonahr@google.com,jmadill@chromium.org Change-Id: Ica795036895652add37ac8ed319031f9d5a321ac No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:4500 Bug: angleproject:4959 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2365077Reviewed-by: 's avatarKhushal <khushalsagar@chromium.org> Commit-Queue: Khushal <khushalsagar@chromium.org>
parent 0f33d01e
......@@ -796,19 +796,19 @@ void Framebuffer::onDestroy(const Context *context)
{
if (isDefault())
{
mState.mDefaultFramebufferReadAttachment.detach(context, mState.mFramebufferSerial);
mState.mDefaultFramebufferReadAttachment.detach(context);
mState.mDefaultFramebufferReadAttachmentInitialized = false;
}
for (auto &attachment : mState.mColorAttachments)
{
attachment.detach(context, mState.mFramebufferSerial);
attachment.detach(context);
}
mState.mDepthAttachment.detach(context, mState.mFramebufferSerial);
mState.mStencilAttachment.detach(context, mState.mFramebufferSerial);
mState.mWebGLDepthAttachment.detach(context, mState.mFramebufferSerial);
mState.mWebGLStencilAttachment.detach(context, mState.mFramebufferSerial);
mState.mWebGLDepthStencilAttachment.detach(context, mState.mFramebufferSerial);
mState.mDepthAttachment.detach(context);
mState.mStencilAttachment.detach(context);
mState.mWebGLDepthAttachment.detach(context);
mState.mWebGLStencilAttachment.detach(context);
mState.mWebGLDepthStencilAttachment.detach(context);
mImpl->destroy(context);
}
......@@ -819,7 +819,7 @@ void Framebuffer::setReadSurface(const Context *context, egl::Surface *readSurfa
mState.mDefaultFramebufferReadAttachment.attach(
context, GL_FRAMEBUFFER_DEFAULT, GL_BACK, ImageIndex(), readSurface,
FramebufferAttachment::kDefaultNumViews, FramebufferAttachment::kDefaultBaseViewIndex,
false, FramebufferAttachment::kDefaultRenderToTextureSamples, mState.mFramebufferSerial);
false, FramebufferAttachment::kDefaultRenderToTextureSamples);
mDirtyBits.set(DIRTY_BIT_READ_BUFFER);
}
......@@ -1674,21 +1674,19 @@ void Framebuffer::setAttachment(const Context *context,
{
case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT:
mState.mWebGLDepthStencilAttachment.attach(
context, type, binding, textureIndex, resource, numViews, baseViewIndex,
isMultiview, samples, mState.mFramebufferSerial);
mState.mWebGLDepthStencilAttachment.attach(context, type, binding, textureIndex,
resource, numViews, baseViewIndex,
isMultiview, samples);
break;
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT:
mState.mWebGLDepthAttachment.attach(context, type, binding, textureIndex, resource,
numViews, baseViewIndex, isMultiview, samples,
mState.mFramebufferSerial);
numViews, baseViewIndex, isMultiview, samples);
break;
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT:
mState.mWebGLStencilAttachment.attach(context, type, binding, textureIndex, resource,
numViews, baseViewIndex, isMultiview, samples,
mState.mFramebufferSerial);
numViews, baseViewIndex, isMultiview, samples);
break;
default:
setAttachmentImpl(context, type, binding, textureIndex, resource, numViews,
......@@ -1871,7 +1869,7 @@ void Framebuffer::updateAttachment(const Context *context,
GLsizei samples)
{
attachment->attach(context, type, binding, textureIndex, resource, numViews, baseViewIndex,
isMultiview, samples, mState.mFramebufferSerial);
isMultiview, samples);
mDirtyBits.set(dirtyBit);
mState.mResourceNeedsInit.set(dirtyBit, attachment->initState() == InitState::MayNeedInit);
onDirtyBinding->bind(resource);
......@@ -1969,31 +1967,6 @@ FramebufferAttachment *Framebuffer::getAttachmentFromSubjectIndex(angle::Subject
}
}
bool Framebuffer::formsRenderingFeedbackLoopWith(const Context *context) const
{
const State &glState = context->getState();
const ProgramExecutable *executable = glState.getProgramExecutable();
ASSERT(executable);
const ActiveTextureMask &activeTextures = executable->getActiveSamplersMask();
const ActiveTextureTypeArray &textureTypes = executable->getActiveSamplerTypes();
for (size_t textureIndex : activeTextures)
{
unsigned int uintIndex = static_cast<unsigned int>(textureIndex);
Texture *texture = glState.getSamplerTexture(uintIndex, textureTypes[textureIndex]);
const Sampler *sampler = glState.getSampler(uintIndex);
if (texture && texture->isSamplerComplete(context, sampler) &&
texture->isBoundToFramebuffer(mState.mFramebufferSerial))
{
// TODO(jmadill): Subresource check. http://anglebug.com/4500
return true;
}
}
return false;
}
bool Framebuffer::formsCopyingFeedbackLoopWith(TextureID copyTextureID,
GLint copyTextureLevel,
GLint copyTextureLayer) const
......
......@@ -171,7 +171,6 @@ class FramebufferState final : angle::NonCopyable
bool mWebGLDepthStencilConsistent;
// Tracks rendering feedback loops.
// TODO(jmadill): Remove. http://anglebug.com/4500
DrawBufferMask mDrawBufferFeedbackLoops;
bool mDepthBufferFeedbackLoop;
bool mStencilBufferFeedbackLoop;
......@@ -410,10 +409,7 @@ class Framebuffer final : public angle::ObserverInterface,
// Observer implementation
void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
// TODO(jmadill): Remove. http://anglebug.com/4500
bool hasRenderingFeedbackLoop() const { return mState.mHasRenderingFeedbackLoop; }
bool formsRenderingFeedbackLoopWith(const Context *context) const;
bool formsCopyingFeedbackLoopWith(TextureID copyTextureID,
GLint copyTextureLevel,
GLint copyTextureLayer) const;
......
......@@ -60,12 +60,11 @@ FramebufferAttachment::FramebufferAttachment(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource,
rx::Serial framebufferSerial)
FramebufferAttachmentObject *resource)
: mResource(nullptr)
{
attach(context, type, binding, textureIndex, resource, kDefaultNumViews, kDefaultBaseViewIndex,
false, kDefaultRenderToTextureSamples, framebufferSerial);
false, kDefaultRenderToTextureSamples);
}
FramebufferAttachment::FramebufferAttachment(FramebufferAttachment &&other)
......@@ -91,12 +90,12 @@ FramebufferAttachment::~FramebufferAttachment()
ASSERT(!isAttached());
}
void FramebufferAttachment::detach(const Context *context, rx::Serial framebufferSerial)
void FramebufferAttachment::detach(const Context *context)
{
mType = GL_NONE;
if (mResource != nullptr)
{
mResource->onDetach(context, framebufferSerial);
mResource->onDetach(context);
mResource = nullptr;
}
mNumViews = kDefaultNumViews;
......@@ -115,12 +114,11 @@ void FramebufferAttachment::attach(const Context *context,
GLsizei numViews,
GLuint baseViewIndex,
bool isMultiview,
GLsizei samples,
rx::Serial framebufferSerial)
GLsizei samples)
{
if (resource == nullptr)
{
detach(context, framebufferSerial);
detach(context);
return;
}
......@@ -130,11 +128,11 @@ void FramebufferAttachment::attach(const Context *context,
mBaseViewIndex = baseViewIndex;
mIsMultiview = isMultiview;
mRenderToTextureSamples = samples;
resource->onAttach(context, framebufferSerial);
resource->onAttach(context);
if (mResource != nullptr)
{
mResource->onDetach(context, framebufferSerial);
mResource->onDetach(context);
}
mResource = resource;
......
......@@ -64,15 +64,14 @@ class FramebufferAttachment final
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource,
rx::Serial framebufferSerial);
FramebufferAttachmentObject *resource);
FramebufferAttachment(FramebufferAttachment &&other);
FramebufferAttachment &operator=(FramebufferAttachment &&other);
~FramebufferAttachment();
void detach(const Context *context, rx::Serial framebufferSerial);
void detach(const Context *context);
void attach(const Context *context,
GLenum type,
GLenum binding,
......@@ -81,8 +80,7 @@ class FramebufferAttachment final
GLsizei numViews,
GLuint baseViewIndex,
bool isMultiview,
GLsizei samples,
rx::Serial framebufferSerial);
GLsizei samples);
// Helper methods
GLuint getRedSize() const;
......@@ -210,9 +208,9 @@ class FramebufferAttachmentObject : public angle::Subject, public angle::Observe
GLenum binding,
const ImageIndex &imageIndex) const = 0;
virtual void onAttach(const Context *context, rx::Serial framebufferSerial) = 0;
virtual void onDetach(const Context *context, rx::Serial framebufferSerial) = 0;
virtual GLuint getId() const = 0;
virtual void onAttach(const Context *context) = 0;
virtual void onDetach(const Context *context) = 0;
virtual GLuint getId() const = 0;
// These are used for robust resource initialization.
virtual InitState initState(const ImageIndex &imageIndex) const = 0;
......
......@@ -193,9 +193,9 @@ bool ExternalImageSibling::isTextureable(const gl::Context *context) const
return mImplementation->isTexturable(context);
}
void ExternalImageSibling::onAttach(const gl::Context *context, rx::Serial framebufferSerial) {}
void ExternalImageSibling::onAttach(const gl::Context *context) {}
void ExternalImageSibling::onDetach(const gl::Context *context, rx::Serial framebufferSerial) {}
void ExternalImageSibling::onDetach(const gl::Context *context) {}
GLuint ExternalImageSibling::getId() const
{
......
......@@ -98,8 +98,8 @@ class ExternalImageSibling : public ImageSibling
const gl::ImageIndex &imageIndex) const override;
bool isTextureable(const gl::Context *context) const;
void onAttach(const gl::Context *context, rx::Serial framebufferSerial) override;
void onDetach(const gl::Context *context, rx::Serial framebufferSerial) override;
void onAttach(const gl::Context *context) override;
void onDetach(const gl::Context *context) override;
GLuint getId() const override;
gl::InitState initState(const gl::ImageIndex &imageIndex) const override;
......
......@@ -234,12 +234,12 @@ GLint Renderbuffer::getMemorySize() const
return size.ValueOrDefault(std::numeric_limits<GLint>::max());
}
void Renderbuffer::onAttach(const Context *context, rx::Serial framebufferSerial)
void Renderbuffer::onAttach(const Context *context)
{
addRef();
}
void Renderbuffer::onDetach(const Context *context, rx::Serial framebufferSerial)
void Renderbuffer::onDetach(const Context *context)
{
release(context);
}
......
......@@ -110,8 +110,8 @@ class Renderbuffer final : public RefCountObject<RenderbufferID>,
GLenum binding,
const ImageIndex &imageIndex) const override;
void onAttach(const Context *context, rx::Serial framebufferSerial) override;
void onDetach(const Context *context, rx::Serial framebufferSerial) override;
void onAttach(const Context *context) override;
void onDetach(const Context *context) override;
GLuint getId() const override;
InitState initState(const ImageIndex &imageIndex) const override;
......
......@@ -143,8 +143,8 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
GLenum binding,
const gl::ImageIndex &imageIndex) const override;
void onAttach(const gl::Context *context, rx::Serial framebufferSerial) override {}
void onDetach(const gl::Context *context, rx::Serial framebufferSerial) override {}
void onAttach(const gl::Context *context) override {}
void onDetach(const gl::Context *context) override {}
GLuint getId() const override;
bool flexibleSurfaceCompatibilityRequested() const
......
......@@ -1774,20 +1774,13 @@ GLenum Texture::getGenerateMipmapHint() const
return mState.getGenerateMipmapHint();
}
void Texture::onAttach(const Context *context, rx::Serial framebufferSerial)
void Texture::onAttach(const Context *context)
{
addRef();
// Duplicates allowed for multiple attachment points. See the comment in the header.
mBoundFramebufferSerials.push_back(framebufferSerial);
}
void Texture::onDetach(const Context *context, rx::Serial framebufferSerial)
void Texture::onDetach(const Context *context)
{
// Erase first instance. If there are multiple bindings, leave the others.
ASSERT(isBoundToFramebuffer(framebufferSerial));
mBoundFramebufferSerials.remove_and_permute(framebufferSerial);
release(context);
}
......
......@@ -146,8 +146,6 @@ class TextureState final : private angle::NonCopyable
GLenum getUsage() const { return mUsage; }
GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; }
bool isStencilMode() const { return mDepthStencilTextureMode == GL_STENCIL_INDEX; }
// TODO(jmadill): Remove. http://anglebug.com/4500
bool isBoundAsSamplerTexture(ContextID contextID) const
{
return getBindingCount(contextID).samplerBindingCount > 0;
......@@ -547,8 +545,8 @@ class Texture final : public RefCountObject<TextureID>,
void setGenerateMipmapHint(GLenum generate);
GLenum getGenerateMipmapHint() const;
void onAttach(const Context *context, rx::Serial framebufferSerial) override;
void onDetach(const Context *context, rx::Serial framebufferSerial) override;
void onAttach(const Context *context) override;
void onDetach(const Context *context) override;
// Used specifically for FramebufferAttachmentObject.
GLuint getId() const override;
......@@ -561,17 +559,6 @@ class Texture final : public RefCountObject<TextureID>,
InitState initState() const { return mState.mInitState; }
void setInitState(const ImageIndex &imageIndex, InitState initState) override;
bool isBoundToFramebuffer(rx::Serial framebufferSerial) const
{
for (size_t index = 0; index < mBoundFramebufferSerials.size(); ++index)
{
if (mBoundFramebufferSerials[index] == framebufferSerial)
return true;
}
return false;
}
enum DirtyBitType
{
// Sampler state
......@@ -656,14 +643,6 @@ class Texture final : public RefCountObject<TextureID>,
egl::Surface *mBoundSurface;
egl::Stream *mBoundStream;
// We track all the serials of the Framebuffers this texture is attached to. Note that this
// allows duplicates because different ranges of a Texture can be bound to the same Framebuffer.
// For the purposes of depth-stencil loops, a simple "isBound" check works fine. For color
// attachment Feedback Loop checks we then need to check further to see when a Texture is bound
// to mulitple bindings that the bindings don't overlap.
static constexpr uint32_t kFastFramebufferSerialCount = 8;
angle::FastVector<rx::Serial, kFastFramebufferSerialCount> mBoundFramebufferSerials;
struct SamplerCompletenessCache
{
SamplerCompletenessCache();
......
......@@ -362,18 +362,19 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const gl:
// it to be attached to a new binding point.
if (mDummyAttachment.isAttached())
{
mDummyAttachment.detach(context, Serial());
mDummyAttachment.detach(context);
}
gl::Texture *dummyTex = nullptr;
// TODO(jmadill): Handle error if dummy texture can't be created.
// TODO(Jamie): Handle error if dummy texture can't be created.
(void)mRenderer->getIncompleteTexture(context, gl::TextureType::_2D, &dummyTex);
if (dummyTex)
{
gl::ImageIndex index = gl::ImageIndex::Make2D(0);
mDummyAttachment = gl::FramebufferAttachment(
context, GL_TEXTURE, GL_COLOR_ATTACHMENT0_EXT + activeProgramLocation, index,
dummyTex, Serial());
dummyTex);
colorAttachmentsForRender.push_back(&mDummyAttachment);
}
}
......@@ -389,7 +390,7 @@ void FramebufferD3D::destroy(const gl::Context *context)
{
if (mDummyAttachment.isAttached())
{
mDummyAttachment.detach(context, Serial());
mDummyAttachment.detach(context);
}
}
......
......@@ -3005,7 +3005,7 @@ const char *ValidateDrawStates(const Context *context)
}
// Detect rendering feedback loops for WebGL.
if (framebuffer->formsRenderingFeedbackLoopWith(context))
if (framebuffer->hasRenderingFeedbackLoop())
{
return kFeedbackLoop;
}
......
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