Commit 124f78c2 by Jamie Madill Committed by Commit Bot

Remove gl::Context parameter from Observer functions.

It was only used in exactly one instance in VertexArray. Instead we can cache a bool and avoid needing to pass it around. Will make signaling dirty easier in the Vulkan back-end. Bug: angleproject:3539 Change-Id: Ia570aec051a24a5280df49edc4345c54022b46ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1663838Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 81b6acfb
...@@ -94,7 +94,7 @@ angle::Result Buffer::bufferData(Context *context, ...@@ -94,7 +94,7 @@ angle::Result Buffer::bufferData(Context *context,
mState.mSize = size; mState.mSize = size;
// Notify when storage changes. // Notify when storage changes.
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -111,7 +111,7 @@ angle::Result Buffer::bufferSubData(const Context *context, ...@@ -111,7 +111,7 @@ angle::Result Buffer::bufferSubData(const Context *context,
static_cast<unsigned int>(size)); static_cast<unsigned int>(size));
// Notify when data changes. // Notify when data changes.
onStateChange(context, angle::SubjectMessage::ContentsChanged); onStateChange(angle::SubjectMessage::ContentsChanged);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -129,7 +129,7 @@ angle::Result Buffer::copyBufferSubData(const Context *context, ...@@ -129,7 +129,7 @@ angle::Result Buffer::copyBufferSubData(const Context *context,
static_cast<unsigned int>(size)); static_cast<unsigned int>(size));
// Notify when data changes. // Notify when data changes.
onStateChange(context, angle::SubjectMessage::ContentsChanged); onStateChange(angle::SubjectMessage::ContentsChanged);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -151,7 +151,7 @@ angle::Result Buffer::map(const Context *context, GLenum access) ...@@ -151,7 +151,7 @@ angle::Result Buffer::map(const Context *context, GLenum access)
mIndexRangeCache.clear(); mIndexRangeCache.clear();
// Notify when state changes. // Notify when state changes.
onStateChange(context, angle::SubjectMessage::SubjectMapped); onStateChange(angle::SubjectMessage::SubjectMapped);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -185,7 +185,7 @@ angle::Result Buffer::mapRange(const Context *context, ...@@ -185,7 +185,7 @@ angle::Result Buffer::mapRange(const Context *context,
} }
// Notify when state changes. // Notify when state changes.
onStateChange(context, angle::SubjectMessage::SubjectMapped); onStateChange(angle::SubjectMessage::SubjectMapped);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -205,25 +205,25 @@ angle::Result Buffer::unmap(const Context *context, GLboolean *result) ...@@ -205,25 +205,25 @@ angle::Result Buffer::unmap(const Context *context, GLboolean *result)
mState.mAccessFlags = 0; mState.mAccessFlags = 0;
// Notify when data changes. // Notify when data changes.
onStateChange(context, angle::SubjectMessage::SubjectUnmapped); onStateChange(angle::SubjectMessage::SubjectUnmapped);
return angle::Result::Continue; return angle::Result::Continue;
} }
void Buffer::onTransformFeedback(const Context *context) void Buffer::onTransformFeedback()
{ {
mIndexRangeCache.clear(); mIndexRangeCache.clear();
// Notify when data changes. // Notify when data changes.
onStateChange(context, angle::SubjectMessage::ContentsChanged); onStateChange(angle::SubjectMessage::ContentsChanged);
} }
void Buffer::onPixelPack(const Context *context) void Buffer::onPixelPack()
{ {
mIndexRangeCache.clear(); mIndexRangeCache.clear();
// Notify when data changes. // Notify when data changes.
onStateChange(context, angle::SubjectMessage::ContentsChanged); onStateChange(angle::SubjectMessage::ContentsChanged);
} }
angle::Result Buffer::getIndexRange(const gl::Context *context, angle::Result Buffer::getIndexRange(const gl::Context *context,
...@@ -266,7 +266,7 @@ void Buffer::onTFBindingChanged(const Context *context, bool bound, bool indexed ...@@ -266,7 +266,7 @@ void Buffer::onTFBindingChanged(const Context *context, bool bound, bool indexed
ASSERT(bound || mState.mTransformFeedbackIndexedBindingCount > 0); ASSERT(bound || mState.mTransformFeedbackIndexedBindingCount > 0);
mState.mTransformFeedbackIndexedBindingCount += bound ? 1 : -1; mState.mTransformFeedbackIndexedBindingCount += bound ? 1 : -1;
onStateChange(context, angle::SubjectMessage::BindingChanged); onStateChange(angle::SubjectMessage::BindingChanged);
} }
else else
{ {
...@@ -274,13 +274,11 @@ void Buffer::onTFBindingChanged(const Context *context, bool bound, bool indexed ...@@ -274,13 +274,11 @@ void Buffer::onTFBindingChanged(const Context *context, bool bound, bool indexed
} }
} }
void Buffer::onSubjectStateChange(const gl::Context *context, void Buffer::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message)
angle::SubjectIndex index,
angle::SubjectMessage message)
{ {
// Pass it along! // Pass it along!
ASSERT(index == kImplementationSubjectIndex); ASSERT(index == kImplementationSubjectIndex);
ASSERT(message == angle::SubjectMessage::SubjectChanged); ASSERT(message == angle::SubjectMessage::SubjectChanged);
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
} }
} // namespace gl } // namespace gl
...@@ -99,8 +99,8 @@ class Buffer final : public RefCountObject, ...@@ -99,8 +99,8 @@ class Buffer final : public RefCountObject,
angle::Result unmap(const Context *context, GLboolean *result); angle::Result unmap(const Context *context, GLboolean *result);
// These are called when another operation changes Buffer data. // These are called when another operation changes Buffer data.
void onTransformFeedback(const Context *context); void onTransformFeedback();
void onPixelPack(const Context *context); void onPixelPack();
angle::Result getIndexRange(const gl::Context *context, angle::Result getIndexRange(const gl::Context *context,
DrawElementsType type, DrawElementsType type,
...@@ -139,9 +139,7 @@ class Buffer final : public RefCountObject, ...@@ -139,9 +139,7 @@ class Buffer final : public RefCountObject,
void onNonTFBindingChanged(int incr) { mState.mBindingCount += incr; } void onNonTFBindingChanged(int incr) { mState.mBindingCount += incr; }
// angle::ObserverInterface implementation. // angle::ObserverInterface implementation.
void onSubjectStateChange(const gl::Context *context, void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
angle::SubjectIndex index,
angle::SubjectMessage message) override;
private: private:
BufferState mState; BufferState mState;
......
...@@ -2685,6 +2685,7 @@ VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) ...@@ -2685,6 +2685,7 @@ VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle)
vertexArray = vertexArray =
new VertexArray(mImplementation.get(), vertexArrayHandle, new VertexArray(mImplementation.get(), vertexArrayHandle,
mState.mCaps.maxVertexAttributes, mState.mCaps.maxVertexAttribBindings); mState.mCaps.maxVertexAttributes, mState.mCaps.maxVertexAttribBindings);
vertexArray->setBufferAccessValidationEnabled(mBufferAccessValidationEnabled);
mVertexArrayMap.assign(vertexArrayHandle, vertexArray); mVertexArrayMap.assign(vertexArrayHandle, vertexArray);
} }
...@@ -3105,16 +3106,16 @@ void Context::requestExtension(const char *name) ...@@ -3105,16 +3106,16 @@ void Context::requestExtension(const char *name)
// Invalidate all textures and framebuffer. Some extensions make new formats renderable or // Invalidate all textures and framebuffer. Some extensions make new formats renderable or
// sampleable. // sampleable.
mState.mTextureManager->signalAllTexturesDirty(this); mState.mTextureManager->signalAllTexturesDirty();
for (auto &zeroTexture : mZeroTextures) for (auto &zeroTexture : mZeroTextures)
{ {
if (zeroTexture.get() != nullptr) if (zeroTexture.get() != nullptr)
{ {
zeroTexture->signalDirtyStorage(this, InitState::Initialized); zeroTexture->signalDirtyStorage(InitState::Initialized);
} }
} }
mState.mFramebufferManager->invalidateFramebufferComplenessCache(this); mState.mFramebufferManager->invalidateFramebufferComplenessCache();
} }
size_t Context::getRequestableExtensionStringCount() const size_t Context::getRequestableExtensionStringCount() const
...@@ -3477,9 +3478,14 @@ void Context::updateCaps() ...@@ -3477,9 +3478,14 @@ void Context::updateCaps()
// We need to validate buffer bounds if we are in a WebGL or robust access context and the // We need to validate buffer bounds if we are in a WebGL or robust access context and the
// back-end does not support robust buffer access behaviour. // back-end does not support robust buffer access behaviour.
if (!mSupportedExtensions.robustBufferAccessBehavior && (mState.isWebGL() || mRobustAccess)) mBufferAccessValidationEnabled =
(!mSupportedExtensions.robustBufferAccessBehavior && (mState.isWebGL() || mRobustAccess));
// Cache this in the VertexArrays. They need to check it in state change notifications.
for (auto vaoIter : mVertexArrayMap)
{ {
mBufferAccessValidationEnabled = true; VertexArray *vao = vaoIter.second;
vao->setBufferAccessValidationEnabled(mBufferAccessValidationEnabled);
} }
// Reinitialize state cache after extension changes. // Reinitialize state cache after extension changes.
...@@ -8165,9 +8171,7 @@ bool Context::isGLES1() const ...@@ -8165,9 +8171,7 @@ bool Context::isGLES1() const
return mState.getClientVersion() < Version(2, 0); return mState.getClientVersion() < Version(2, 0);
} }
void Context::onSubjectStateChange(const Context *context, void Context::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message)
angle::SubjectIndex index,
angle::SubjectMessage message)
{ {
switch (index) switch (index)
{ {
......
...@@ -499,9 +499,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -499,9 +499,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
const StateCache &getStateCache() const { return mStateCache; } const StateCache &getStateCache() const { return mStateCache; }
StateCache &getStateCache() { return mStateCache; } StateCache &getStateCache() { return mStateCache; }
void onSubjectStateChange(const Context *context, void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
angle::SubjectIndex index,
angle::SubjectMessage message) override;
void onSamplerUniformChange(size_t textureUnitIndex); void onSamplerUniformChange(size_t textureUnitIndex);
......
...@@ -953,13 +953,13 @@ bool Framebuffer::usingExtendedDrawBuffers() const ...@@ -953,13 +953,13 @@ bool Framebuffer::usingExtendedDrawBuffers() const
return false; return false;
} }
void Framebuffer::invalidateCompletenessCache(const Context *context) void Framebuffer::invalidateCompletenessCache()
{ {
if (mState.mId != 0) if (mState.mId != 0)
{ {
mCachedStatus.reset(); mCachedStatus.reset();
} }
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Framebuffer::checkStatusImpl(const Context *context) GLenum Framebuffer::checkStatusImpl(const Context *context)
...@@ -1507,7 +1507,7 @@ angle::Result Framebuffer::readPixels(const Context *context, ...@@ -1507,7 +1507,7 @@ angle::Result Framebuffer::readPixels(const Context *context,
Buffer *unpackBuffer = context->getState().getTargetBuffer(BufferBinding::PixelUnpack); Buffer *unpackBuffer = context->getState().getTargetBuffer(BufferBinding::PixelUnpack);
if (unpackBuffer) if (unpackBuffer)
{ {
unpackBuffer->onPixelPack(context); unpackBuffer->onPixelPack();
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -1830,7 +1830,7 @@ void Framebuffer::updateAttachment(const Context *context, ...@@ -1830,7 +1830,7 @@ void Framebuffer::updateAttachment(const Context *context,
mState.mResourceNeedsInit.set(dirtyBit, attachment->initState() == InitState::MayNeedInit); mState.mResourceNeedsInit.set(dirtyBit, attachment->initState() == InitState::MayNeedInit);
onDirtyBinding->bind(resource); onDirtyBinding->bind(resource);
invalidateCompletenessCache(context); invalidateCompletenessCache();
} }
void Framebuffer::resetAttachment(const Context *context, GLenum binding) void Framebuffer::resetAttachment(const Context *context, GLenum binding)
...@@ -1850,9 +1850,7 @@ angle::Result Framebuffer::syncState(const Context *context) ...@@ -1850,9 +1850,7 @@ angle::Result Framebuffer::syncState(const Context *context)
return angle::Result::Continue; return angle::Result::Continue;
} }
void Framebuffer::onSubjectStateChange(const Context *context, void Framebuffer::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message)
angle::SubjectIndex index,
angle::SubjectMessage message)
{ {
if (message != angle::SubjectMessage::SubjectChanged) if (message != angle::SubjectMessage::SubjectChanged)
{ {
...@@ -1860,7 +1858,7 @@ void Framebuffer::onSubjectStateChange(const Context *context, ...@@ -1860,7 +1858,7 @@ void Framebuffer::onSubjectStateChange(const Context *context,
if (message == angle::SubjectMessage::ContentsChanged) if (message == angle::SubjectMessage::ContentsChanged)
{ {
mDirtyBits.set(DIRTY_BIT_COLOR_BUFFER_CONTENTS_0 + index); mDirtyBits.set(DIRTY_BIT_COLOR_BUFFER_CONTENTS_0 + index);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
return; return;
} }
...@@ -1872,7 +1870,7 @@ void Framebuffer::onSubjectStateChange(const Context *context, ...@@ -1872,7 +1870,7 @@ void Framebuffer::onSubjectStateChange(const Context *context,
ASSERT(!mDirtyBitsGuard.valid() || mDirtyBitsGuard.value().test(index)); ASSERT(!mDirtyBitsGuard.valid() || mDirtyBitsGuard.value().test(index));
mDirtyBits.set(index); mDirtyBits.set(index);
invalidateCompletenessCache(context); invalidateCompletenessCache();
FramebufferAttachment *attachment = getAttachmentFromSubjectIndex(index); FramebufferAttachment *attachment = getAttachmentFromSubjectIndex(index);
...@@ -2025,21 +2023,21 @@ void Framebuffer::setDefaultWidth(const Context *context, GLint defaultWidth) ...@@ -2025,21 +2023,21 @@ void Framebuffer::setDefaultWidth(const Context *context, GLint defaultWidth)
{ {
mState.mDefaultWidth = defaultWidth; mState.mDefaultWidth = defaultWidth;
mDirtyBits.set(DIRTY_BIT_DEFAULT_WIDTH); mDirtyBits.set(DIRTY_BIT_DEFAULT_WIDTH);
invalidateCompletenessCache(context); invalidateCompletenessCache();
} }
void Framebuffer::setDefaultHeight(const Context *context, GLint defaultHeight) void Framebuffer::setDefaultHeight(const Context *context, GLint defaultHeight)
{ {
mState.mDefaultHeight = defaultHeight; mState.mDefaultHeight = defaultHeight;
mDirtyBits.set(DIRTY_BIT_DEFAULT_HEIGHT); mDirtyBits.set(DIRTY_BIT_DEFAULT_HEIGHT);
invalidateCompletenessCache(context); invalidateCompletenessCache();
} }
void Framebuffer::setDefaultSamples(const Context *context, GLint defaultSamples) void Framebuffer::setDefaultSamples(const Context *context, GLint defaultSamples)
{ {
mState.mDefaultSamples = defaultSamples; mState.mDefaultSamples = defaultSamples;
mDirtyBits.set(DIRTY_BIT_DEFAULT_SAMPLES); mDirtyBits.set(DIRTY_BIT_DEFAULT_SAMPLES);
invalidateCompletenessCache(context); invalidateCompletenessCache();
} }
void Framebuffer::setDefaultFixedSampleLocations(const Context *context, void Framebuffer::setDefaultFixedSampleLocations(const Context *context,
...@@ -2047,7 +2045,7 @@ void Framebuffer::setDefaultFixedSampleLocations(const Context *context, ...@@ -2047,7 +2045,7 @@ void Framebuffer::setDefaultFixedSampleLocations(const Context *context,
{ {
mState.mDefaultFixedSampleLocations = defaultFixedSampleLocations; mState.mDefaultFixedSampleLocations = defaultFixedSampleLocations;
mDirtyBits.set(DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS); mDirtyBits.set(DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS);
invalidateCompletenessCache(context); invalidateCompletenessCache();
} }
void Framebuffer::setDefaultLayers(GLint defaultLayers) void Framebuffer::setDefaultLayers(GLint defaultLayers)
......
...@@ -238,7 +238,7 @@ class Framebuffer final : public angle::ObserverInterface, ...@@ -238,7 +238,7 @@ class Framebuffer final : public angle::ObserverInterface,
void setDefaultFixedSampleLocations(const Context *context, bool defaultFixedSampleLocations); void setDefaultFixedSampleLocations(const Context *context, bool defaultFixedSampleLocations);
void setDefaultLayers(GLint defaultLayers); void setDefaultLayers(GLint defaultLayers);
void invalidateCompletenessCache(const Context *context); void invalidateCompletenessCache();
ANGLE_INLINE GLenum checkStatus(const Context *context) ANGLE_INLINE GLenum checkStatus(const Context *context)
{ {
...@@ -343,9 +343,7 @@ class Framebuffer final : public angle::ObserverInterface, ...@@ -343,9 +343,7 @@ class Framebuffer final : public angle::ObserverInterface,
angle::Result syncState(const Context *context); angle::Result syncState(const Context *context);
// Observer implementation // Observer implementation
void onSubjectStateChange(const Context *context, void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
angle::SubjectIndex index,
angle::SubjectMessage message) override;
bool formsRenderingFeedbackLoopWith(const Context *context) const; bool formsRenderingFeedbackLoopWith(const Context *context) const;
bool formsCopyingFeedbackLoopWith(GLuint copyTextureID, bool formsCopyingFeedbackLoopWith(GLuint copyTextureID,
......
...@@ -37,14 +37,14 @@ bool Subject::hasObservers() const ...@@ -37,14 +37,14 @@ bool Subject::hasObservers() const
return !mObservers.empty(); return !mObservers.empty();
} }
void Subject::onStateChange(const gl::Context *context, SubjectMessage message) const void Subject::onStateChange(SubjectMessage message) const
{ {
if (mObservers.empty()) if (mObservers.empty())
return; return;
for (const ObserverBindingBase *binding : mObservers) for (const ObserverBindingBase *binding : mObservers)
{ {
binding->getObserver()->onSubjectStateChange(context, binding->getSubjectIndex(), message); binding->getObserver()->onSubjectStateChange(binding->getSubjectIndex(), message);
} }
} }
...@@ -89,9 +89,9 @@ void ObserverBinding::bind(Subject *subject) ...@@ -89,9 +89,9 @@ void ObserverBinding::bind(Subject *subject)
} }
} }
void ObserverBinding::onStateChange(const gl::Context *context, SubjectMessage message) const void ObserverBinding::onStateChange(SubjectMessage message) const
{ {
getObserver()->onSubjectStateChange(context, getSubjectIndex(), message); getObserver()->onSubjectStateChange(getSubjectIndex(), message);
} }
void ObserverBinding::onSubjectReset() void ObserverBinding::onSubjectReset()
......
...@@ -16,11 +16,6 @@ ...@@ -16,11 +16,6 @@
#include "common/FastVector.h" #include "common/FastVector.h"
#include "common/angleutils.h" #include "common/angleutils.h"
namespace gl
{
class Context;
} // namespace gl
namespace angle namespace angle
{ {
template <typename HaystackT, typename NeedleT> template <typename HaystackT, typename NeedleT>
...@@ -37,23 +32,23 @@ using SubjectIndex = size_t; ...@@ -37,23 +32,23 @@ using SubjectIndex = size_t;
// Observer and Subject and handle different types of events. // Observer and Subject and handle different types of events.
enum class SubjectMessage enum class SubjectMessage
{ {
// Used by the VertexArray class to notify a binding count change might need to update the // Used by gl::VertexArray to notify gl::Context of a gl::Buffer binding count change. Triggers
// validation cache. // a validation cache update.
BindingChanged, BindingChanged,
// Only the contents (pixels, bytes, etc) changed in this Subject. Rather than the storage for // Only the contents (pixels, bytes, etc) changed in this Subject. Distinct from the object
// the subject. // storage.
ContentsChanged, ContentsChanged,
// Used by Samplers, Textures and Framebuffers to indicate to the Observer (Context) that it // Sent by gl::Sampler, gl::Texture, gl::Framebuffer and others to notifiy gl::Context. This
// will need to call syncState. // flag indicates to call syncState before next use.
DirtyBitsFlagged, DirtyBitsFlagged,
// Generic state change message. Used in multiple places. // Generic state change message. Used in multiple places for different purposes.
SubjectChanged, SubjectChanged,
// Special events passed from Buffers, through VertexArrays into the Context to indicate a bound // Indicates a bound gl::Buffer is now mapped or unmapped. Passed from gl::Buffer, through
// Buffer is now mapped. // gl::VertexArray, into gl::Context. Used to track validation.
SubjectMapped, SubjectMapped,
SubjectUnmapped, SubjectUnmapped,
}; };
...@@ -63,9 +58,7 @@ class ObserverInterface ...@@ -63,9 +58,7 @@ class ObserverInterface
{ {
public: public:
virtual ~ObserverInterface(); virtual ~ObserverInterface();
virtual void onSubjectStateChange(const gl::Context *context, virtual void onSubjectStateChange(SubjectIndex index, SubjectMessage message) = 0;
SubjectIndex index,
SubjectMessage message) = 0;
}; };
class ObserverBindingBase class ObserverBindingBase
...@@ -93,7 +86,7 @@ class Subject : NonCopyable ...@@ -93,7 +86,7 @@ class Subject : NonCopyable
Subject(); Subject();
virtual ~Subject(); virtual ~Subject();
void onStateChange(const gl::Context *context, SubjectMessage message) const; void onStateChange(SubjectMessage message) const;
bool hasObservers() const; bool hasObservers() const;
void resetObservers(); void resetObservers();
...@@ -129,7 +122,7 @@ class ObserverBinding final : public ObserverBindingBase ...@@ -129,7 +122,7 @@ class ObserverBinding final : public ObserverBindingBase
ANGLE_INLINE void reset() { bind(nullptr); } ANGLE_INLINE void reset() { bind(nullptr); }
void onStateChange(const gl::Context *context, SubjectMessage message) const; void onStateChange(SubjectMessage message) const;
void onSubjectReset() override; void onSubjectReset() override;
ANGLE_INLINE const Subject *getSubject() const { return mSubject; } ANGLE_INLINE const Subject *getSubject() const { return mSubject; }
......
...@@ -18,9 +18,7 @@ namespace ...@@ -18,9 +18,7 @@ namespace
struct ObserverClass : public ObserverInterface struct ObserverClass : public ObserverInterface
{ {
void onSubjectStateChange(const gl::Context *context, void onSubjectStateChange(SubjectIndex index, SubjectMessage message) override
SubjectIndex index,
SubjectMessage message) override
{ {
wasNotified = true; wasNotified = true;
} }
...@@ -36,7 +34,7 @@ TEST(ObserverTest, BasicUsage) ...@@ -36,7 +34,7 @@ TEST(ObserverTest, BasicUsage)
binding.bind(&subject); binding.bind(&subject);
ASSERT_FALSE(observer.wasNotified); ASSERT_FALSE(observer.wasNotified);
subject.onStateChange(nullptr, SubjectMessage::SubjectChanged); subject.onStateChange(SubjectMessage::SubjectChanged);
ASSERT_TRUE(observer.wasNotified); ASSERT_TRUE(observer.wasNotified);
} }
......
...@@ -102,7 +102,7 @@ angle::Result Renderbuffer::setStorage(const Context *context, ...@@ -102,7 +102,7 @@ angle::Result Renderbuffer::setStorage(const Context *context,
mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat), mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat),
0, InitState::MayNeedInit); 0, InitState::MayNeedInit);
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -119,7 +119,7 @@ angle::Result Renderbuffer::setStorageMultisample(const Context *context, ...@@ -119,7 +119,7 @@ angle::Result Renderbuffer::setStorageMultisample(const Context *context,
mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat), mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat),
static_cast<GLsizei>(samples), InitState::MayNeedInit); static_cast<GLsizei>(samples), InitState::MayNeedInit);
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -133,7 +133,7 @@ angle::Result Renderbuffer::setStorageEGLImageTarget(const Context *context, egl ...@@ -133,7 +133,7 @@ angle::Result Renderbuffer::setStorageEGLImageTarget(const Context *context, egl
mState.update(static_cast<GLsizei>(image->getWidth()), static_cast<GLsizei>(image->getHeight()), mState.update(static_cast<GLsizei>(image->getWidth()), static_cast<GLsizei>(image->getHeight()),
Format(image->getFormat()), 0, image->sourceInitState()); Format(image->getFormat()), 0, image->sourceInitState());
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -237,7 +237,7 @@ GLuint TextureManager::createTexture() ...@@ -237,7 +237,7 @@ GLuint TextureManager::createTexture()
return AllocateEmptyObject(&mHandleAllocator, &mObjectMap); return AllocateEmptyObject(&mHandleAllocator, &mObjectMap);
} }
void TextureManager::signalAllTexturesDirty(const Context *context) const void TextureManager::signalAllTexturesDirty() const
{ {
for (const auto &texture : mObjectMap) for (const auto &texture : mObjectMap)
{ {
...@@ -245,7 +245,7 @@ void TextureManager::signalAllTexturesDirty(const Context *context) const ...@@ -245,7 +245,7 @@ void TextureManager::signalAllTexturesDirty(const Context *context) const
{ {
// We don't know if the Texture needs init, but that's ok, since it will only force // We don't know if the Texture needs init, but that's ok, since it will only force
// a re-check, and will not initialize the pixels if it's not needed. // a re-check, and will not initialize the pixels if it's not needed.
texture.second->signalDirtyStorage(context, InitState::MayNeedInit); texture.second->signalDirtyStorage(InitState::MayNeedInit);
} }
} }
} }
...@@ -440,13 +440,13 @@ void FramebufferManager::setDefaultFramebuffer(Framebuffer *framebuffer) ...@@ -440,13 +440,13 @@ void FramebufferManager::setDefaultFramebuffer(Framebuffer *framebuffer)
mObjectMap.assign(0, framebuffer); mObjectMap.assign(0, framebuffer);
} }
void FramebufferManager::invalidateFramebufferComplenessCache(const Context *context) const void FramebufferManager::invalidateFramebufferComplenessCache() const
{ {
for (const auto &framebuffer : mObjectMap) for (const auto &framebuffer : mObjectMap)
{ {
if (framebuffer.second) if (framebuffer.second)
{ {
framebuffer.second->invalidateCompletenessCache(context); framebuffer.second->invalidateCompletenessCache();
} }
} }
} }
...@@ -498,7 +498,7 @@ void MemoryObjectManager::reset(const Context *context) ...@@ -498,7 +498,7 @@ void MemoryObjectManager::reset(const Context *context)
GLuint MemoryObjectManager::createMemoryObject(rx::GLImplFactory *factory) GLuint MemoryObjectManager::createMemoryObject(rx::GLImplFactory *factory)
{ {
GLuint handle = mHandleAllocator.allocate(); GLuint handle = mHandleAllocator.allocate();
MemoryObject *memoryObject = new MemoryObject(factory, handle); MemoryObject *memoryObject = new MemoryObject(factory, handle);
memoryObject->addRef(); memoryObject->addRef();
mMemoryObjects.assign(handle, memoryObject); mMemoryObjects.assign(handle, memoryObject);
......
...@@ -175,7 +175,7 @@ class TextureManager : public TypedResourceManager<Texture, HandleAllocator, Tex ...@@ -175,7 +175,7 @@ class TextureManager : public TypedResourceManager<Texture, HandleAllocator, Tex
return mObjectMap.query(handle); return mObjectMap.query(handle);
} }
void signalAllTexturesDirty(const Context *context) const; void signalAllTexturesDirty() const;
ANGLE_INLINE Texture *checkTextureAllocation(rx::GLImplFactory *factory, ANGLE_INLINE Texture *checkTextureAllocation(rx::GLImplFactory *factory,
GLuint handle, GLuint handle,
...@@ -269,7 +269,7 @@ class FramebufferManager ...@@ -269,7 +269,7 @@ class FramebufferManager
Framebuffer *getFramebuffer(GLuint handle) const; Framebuffer *getFramebuffer(GLuint handle) const;
void setDefaultFramebuffer(Framebuffer *framebuffer); void setDefaultFramebuffer(Framebuffer *framebuffer);
void invalidateFramebufferComplenessCache(const Context *context) const; void invalidateFramebufferComplenessCache() const;
Framebuffer *checkFramebufferAllocation(rx::GLImplFactory *factory, Framebuffer *checkFramebufferAllocation(rx::GLImplFactory *factory,
const Caps &caps, const Caps &caps,
......
...@@ -39,7 +39,7 @@ const std::string &Sampler::getLabel() const ...@@ -39,7 +39,7 @@ const std::string &Sampler::getLabel() const
void Sampler::setMinFilter(const Context *context, GLenum minFilter) void Sampler::setMinFilter(const Context *context, GLenum minFilter)
{ {
mState.setMinFilter(minFilter); mState.setMinFilter(minFilter);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getMinFilter() const GLenum Sampler::getMinFilter() const
...@@ -50,7 +50,7 @@ GLenum Sampler::getMinFilter() const ...@@ -50,7 +50,7 @@ GLenum Sampler::getMinFilter() const
void Sampler::setMagFilter(const Context *context, GLenum magFilter) void Sampler::setMagFilter(const Context *context, GLenum magFilter)
{ {
mState.setMagFilter(magFilter); mState.setMagFilter(magFilter);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getMagFilter() const GLenum Sampler::getMagFilter() const
...@@ -61,7 +61,7 @@ GLenum Sampler::getMagFilter() const ...@@ -61,7 +61,7 @@ GLenum Sampler::getMagFilter() const
void Sampler::setWrapS(const Context *context, GLenum wrapS) void Sampler::setWrapS(const Context *context, GLenum wrapS)
{ {
mState.setWrapS(wrapS); mState.setWrapS(wrapS);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getWrapS() const GLenum Sampler::getWrapS() const
...@@ -72,7 +72,7 @@ GLenum Sampler::getWrapS() const ...@@ -72,7 +72,7 @@ GLenum Sampler::getWrapS() const
void Sampler::setWrapT(const Context *context, GLenum wrapT) void Sampler::setWrapT(const Context *context, GLenum wrapT)
{ {
mState.setWrapT(wrapT); mState.setWrapT(wrapT);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getWrapT() const GLenum Sampler::getWrapT() const
...@@ -83,7 +83,7 @@ GLenum Sampler::getWrapT() const ...@@ -83,7 +83,7 @@ GLenum Sampler::getWrapT() const
void Sampler::setWrapR(const Context *context, GLenum wrapR) void Sampler::setWrapR(const Context *context, GLenum wrapR)
{ {
mState.setWrapR(wrapR); mState.setWrapR(wrapR);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getWrapR() const GLenum Sampler::getWrapR() const
...@@ -94,7 +94,7 @@ GLenum Sampler::getWrapR() const ...@@ -94,7 +94,7 @@ GLenum Sampler::getWrapR() const
void Sampler::setMaxAnisotropy(const Context *context, float maxAnisotropy) void Sampler::setMaxAnisotropy(const Context *context, float maxAnisotropy)
{ {
mState.setMaxAnisotropy(maxAnisotropy); mState.setMaxAnisotropy(maxAnisotropy);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
float Sampler::getMaxAnisotropy() const float Sampler::getMaxAnisotropy() const
...@@ -105,7 +105,7 @@ float Sampler::getMaxAnisotropy() const ...@@ -105,7 +105,7 @@ float Sampler::getMaxAnisotropy() const
void Sampler::setMinLod(const Context *context, GLfloat minLod) void Sampler::setMinLod(const Context *context, GLfloat minLod)
{ {
mState.setMinLod(minLod); mState.setMinLod(minLod);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLfloat Sampler::getMinLod() const GLfloat Sampler::getMinLod() const
...@@ -116,7 +116,7 @@ GLfloat Sampler::getMinLod() const ...@@ -116,7 +116,7 @@ GLfloat Sampler::getMinLod() const
void Sampler::setMaxLod(const Context *context, GLfloat maxLod) void Sampler::setMaxLod(const Context *context, GLfloat maxLod)
{ {
mState.setMaxLod(maxLod); mState.setMaxLod(maxLod);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLfloat Sampler::getMaxLod() const GLfloat Sampler::getMaxLod() const
...@@ -127,7 +127,7 @@ GLfloat Sampler::getMaxLod() const ...@@ -127,7 +127,7 @@ GLfloat Sampler::getMaxLod() const
void Sampler::setCompareMode(const Context *context, GLenum compareMode) void Sampler::setCompareMode(const Context *context, GLenum compareMode)
{ {
mState.setCompareMode(compareMode); mState.setCompareMode(compareMode);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getCompareMode() const GLenum Sampler::getCompareMode() const
...@@ -138,7 +138,7 @@ GLenum Sampler::getCompareMode() const ...@@ -138,7 +138,7 @@ GLenum Sampler::getCompareMode() const
void Sampler::setCompareFunc(const Context *context, GLenum compareFunc) void Sampler::setCompareFunc(const Context *context, GLenum compareFunc)
{ {
mState.setCompareFunc(compareFunc); mState.setCompareFunc(compareFunc);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getCompareFunc() const GLenum Sampler::getCompareFunc() const
...@@ -149,7 +149,7 @@ GLenum Sampler::getCompareFunc() const ...@@ -149,7 +149,7 @@ GLenum Sampler::getCompareFunc() const
void Sampler::setSRGBDecode(const Context *context, GLenum sRGBDecode) void Sampler::setSRGBDecode(const Context *context, GLenum sRGBDecode)
{ {
mState.setSRGBDecode(sRGBDecode); mState.setSRGBDecode(sRGBDecode);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
GLenum Sampler::getSRGBDecode() const GLenum Sampler::getSRGBDecode() const
...@@ -160,7 +160,7 @@ GLenum Sampler::getSRGBDecode() const ...@@ -160,7 +160,7 @@ GLenum Sampler::getSRGBDecode() const
void Sampler::setBorderColor(const Context *context, const ColorGeneric &color) void Sampler::setBorderColor(const Context *context, const ColorGeneric &color)
{ {
mState.setBorderColor(color); mState.setBorderColor(color);
onStateChange(context, angle::SubjectMessage::DirtyBitsFlagged); onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
} }
const ColorGeneric &Sampler::getBorderColor() const const ColorGeneric &Sampler::getBorderColor() const
......
...@@ -131,12 +131,12 @@ Error Surface::destroyImpl(const Display *display) ...@@ -131,12 +131,12 @@ Error Surface::destroyImpl(const Display *display)
return NoError(); return NoError();
} }
void Surface::postSwap(const gl::Context *context) void Surface::postSwap()
{ {
if (mRobustResourceInitialization && mSwapBehavior != EGL_BUFFER_PRESERVED) if (mRobustResourceInitialization && mSwapBehavior != EGL_BUFFER_PRESERVED)
{ {
mInitState = gl::InitState::MayNeedInit; mInitState = gl::InitState::MayNeedInit;
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
} }
} }
...@@ -234,14 +234,14 @@ Error Surface::swap(const gl::Context *context) ...@@ -234,14 +234,14 @@ Error Surface::swap(const gl::Context *context)
TRACE_EVENT0("gpu.angle", "egl::Surface::swap"); TRACE_EVENT0("gpu.angle", "egl::Surface::swap");
ANGLE_TRY(mImplementation->swap(context)); ANGLE_TRY(mImplementation->swap(context));
postSwap(context); postSwap();
return NoError(); return NoError();
} }
Error Surface::swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects) Error Surface::swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects)
{ {
ANGLE_TRY(mImplementation->swapWithDamage(context, rects, n_rects)); ANGLE_TRY(mImplementation->swapWithDamage(context, rects, n_rects));
postSwap(context); postSwap();
return NoError(); return NoError();
} }
......
...@@ -227,7 +227,7 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject ...@@ -227,7 +227,7 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
private: private:
Error destroyImpl(const Display *display); Error destroyImpl(const Display *display);
void postSwap(const gl::Context *context); void postSwap();
Error releaseRef(const Display *display); Error releaseRef(const Display *display);
gl::InitState mInitState; gl::InitState mInitState;
......
...@@ -408,7 +408,7 @@ class Texture final : public RefCountObject, ...@@ -408,7 +408,7 @@ class Texture final : public RefCountObject,
GLint getMemorySize() const; GLint getMemorySize() const;
GLint getLevelMemorySize(TextureTarget target, GLint level) const; GLint getLevelMemorySize(TextureTarget target, GLint level) const;
void signalDirtyStorage(const Context *context, InitState initState); void signalDirtyStorage(InitState initState);
bool isSamplerComplete(const Context *context, const Sampler *optionalSampler); bool isSamplerComplete(const Context *context, const Sampler *optionalSampler);
...@@ -478,9 +478,7 @@ class Texture final : public RefCountObject, ...@@ -478,9 +478,7 @@ class Texture final : public RefCountObject,
bool hasAnyDirtyBit() const { return mDirtyBits.any(); } bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
// ObserverInterface implementation. // ObserverInterface implementation.
void onSubjectStateChange(const gl::Context *context, void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
angle::SubjectIndex index,
angle::SubjectMessage message) override;
private: private:
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override; rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override;
...@@ -508,7 +506,7 @@ class Texture final : public RefCountObject, ...@@ -508,7 +506,7 @@ class Texture final : public RefCountObject,
angle::Result handleMipmapGenerationHint(Context *context, int level); angle::Result handleMipmapGenerationHint(Context *context, int level);
void signalDirtyState(const Context *context, size_t dirtyBit); void signalDirtyState(size_t dirtyBit);
TextureState mState; TextureState mState;
DirtyBits mDirtyBits; DirtyBits mDirtyBits;
......
...@@ -199,7 +199,7 @@ void TransformFeedback::onVerticesDrawn(const Context *context, GLsizei count, G ...@@ -199,7 +199,7 @@ void TransformFeedback::onVerticesDrawn(const Context *context, GLsizei count, G
{ {
if (buffer.get() != nullptr) if (buffer.get() != nullptr)
{ {
buffer->onTransformFeedback(context); buffer->onTransformFeedback();
} }
} }
} }
......
...@@ -127,7 +127,8 @@ VertexArray::VertexArray(rx::GLImplFactory *factory, ...@@ -127,7 +127,8 @@ VertexArray::VertexArray(rx::GLImplFactory *factory,
size_t maxAttribBindings) size_t maxAttribBindings)
: mId(id), : mId(id),
mState(this, maxAttribs, maxAttribBindings), mState(this, maxAttribs, maxAttribBindings),
mVertexArray(factory->createVertexArray(mState)) mVertexArray(factory->createVertexArray(mState)),
mBufferAccessValidationEnabled(false)
{ {
for (size_t attribIndex = 0; attribIndex < maxAttribBindings; ++attribIndex) for (size_t attribIndex = 0; attribIndex < maxAttribBindings; ++attribIndex)
{ {
...@@ -248,10 +249,9 @@ ANGLE_INLINE void VertexArray::setDirtyBindingBit(size_t bindingIndex, ...@@ -248,10 +249,9 @@ ANGLE_INLINE void VertexArray::setDirtyBindingBit(size_t bindingIndex,
mDirtyBindingBits[bindingIndex].set(dirtyBindingBit); mDirtyBindingBits[bindingIndex].set(dirtyBindingBit);
} }
ANGLE_INLINE void VertexArray::updateCachedBufferBindingSize(const Context *context, ANGLE_INLINE void VertexArray::updateCachedBufferBindingSize(VertexBinding *binding)
VertexBinding *binding)
{ {
if (!context->isBufferAccessValidationEnabled()) if (!mBufferAccessValidationEnabled)
return; return;
for (size_t boundAttribute : binding->getBoundAttributesMask()) for (size_t boundAttribute : binding->getBoundAttributesMask())
...@@ -317,7 +317,7 @@ void VertexArray::bindVertexBufferImpl(const Context *context, ...@@ -317,7 +317,7 @@ void VertexArray::bindVertexBufferImpl(const Context *context,
binding->assignBuffer(boundBuffer); binding->assignBuffer(boundBuffer);
binding->setOffset(offset); binding->setOffset(offset);
binding->setStride(stride); binding->setStride(stride);
updateCachedBufferBindingSize(context, binding); updateCachedBufferBindingSize(binding);
// Update client memory attribute pointers. Affects all bound attributes. // Update client memory attribute pointers. Affects all bound attributes.
if (boundBuffer) if (boundBuffer)
...@@ -552,22 +552,20 @@ VertexArray::DirtyBitType VertexArray::getDirtyBitFromIndex(bool contentsChanged ...@@ -552,22 +552,20 @@ VertexArray::DirtyBitType VertexArray::getDirtyBitFromIndex(bool contentsChanged
} }
} }
void VertexArray::onSubjectStateChange(const gl::Context *context, void VertexArray::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message)
angle::SubjectIndex index,
angle::SubjectMessage message)
{ {
switch (message) switch (message)
{ {
case angle::SubjectMessage::ContentsChanged: case angle::SubjectMessage::ContentsChanged:
setDependentDirtyBit(context, true, index); setDependentDirtyBit(true, index);
break; break;
case angle::SubjectMessage::SubjectChanged: case angle::SubjectMessage::SubjectChanged:
if (!IsElementArrayBufferSubjectIndex(index)) if (!IsElementArrayBufferSubjectIndex(index))
{ {
updateCachedBufferBindingSize(context, &mState.mVertexBindings[index]); updateCachedBufferBindingSize(&mState.mVertexBindings[index]);
} }
setDependentDirtyBit(context, false, index); setDependentDirtyBit(false, index);
break; break;
case angle::SubjectMessage::BindingChanged: case angle::SubjectMessage::BindingChanged:
...@@ -583,17 +581,17 @@ void VertexArray::onSubjectStateChange(const gl::Context *context, ...@@ -583,17 +581,17 @@ void VertexArray::onSubjectStateChange(const gl::Context *context,
{ {
updateCachedMappedArrayBuffersBinding(mState.mVertexBindings[index]); updateCachedMappedArrayBuffersBinding(mState.mVertexBindings[index]);
} }
onStateChange(context, angle::SubjectMessage::SubjectMapped); onStateChange(angle::SubjectMessage::SubjectMapped);
break; break;
case angle::SubjectMessage::SubjectUnmapped: case angle::SubjectMessage::SubjectUnmapped:
setDependentDirtyBit(context, true, index); setDependentDirtyBit(true, index);
if (!IsElementArrayBufferSubjectIndex(index)) if (!IsElementArrayBufferSubjectIndex(index))
{ {
updateCachedMappedArrayBuffersBinding(mState.mVertexBindings[index]); updateCachedMappedArrayBuffersBinding(mState.mVertexBindings[index]);
} }
onStateChange(context, angle::SubjectMessage::SubjectUnmapped); onStateChange(angle::SubjectMessage::SubjectUnmapped);
break; break;
default: default:
...@@ -602,14 +600,12 @@ void VertexArray::onSubjectStateChange(const gl::Context *context, ...@@ -602,14 +600,12 @@ void VertexArray::onSubjectStateChange(const gl::Context *context,
} }
} }
void VertexArray::setDependentDirtyBit(const gl::Context *context, void VertexArray::setDependentDirtyBit(bool contentsChanged, angle::SubjectIndex index)
bool contentsChanged,
angle::SubjectIndex index)
{ {
DirtyBitType dirtyBit = getDirtyBitFromIndex(contentsChanged, index); DirtyBitType dirtyBit = getDirtyBitFromIndex(contentsChanged, index);
ASSERT(!mDirtyBitsGuard.valid() || mDirtyBitsGuard.value().test(dirtyBit)); ASSERT(!mDirtyBitsGuard.valid() || mDirtyBitsGuard.value().test(dirtyBit));
mDirtyBits.set(dirtyBit); mDirtyBits.set(dirtyBit);
onStateChange(context, angle::SubjectMessage::ContentsChanged); onStateChange(angle::SubjectMessage::ContentsChanged);
} }
bool VertexArray::hasTransformFeedbackBindingConflict(const gl::Context *context) const bool VertexArray::hasTransformFeedbackBindingConflict(const gl::Context *context) const
......
...@@ -196,9 +196,7 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -196,9 +196,7 @@ class VertexArray final : public angle::ObserverInterface,
} }
// Observer implementation // Observer implementation
void onSubjectStateChange(const gl::Context *context, void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
angle::SubjectIndex index,
angle::SubjectMessage message) override;
// Dirty bits for VertexArrays use a heirarchical design. At the top level, each attribute // Dirty bits for VertexArrays use a heirarchical design. At the top level, each attribute
// has a single dirty bit. Then an array of MAX_ATTRIBS dirty bits each has a dirty bit for // has a single dirty bit. Then an array of MAX_ATTRIBS dirty bits each has a dirty bit for
...@@ -280,6 +278,11 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -280,6 +278,11 @@ class VertexArray final : public angle::ObserverInterface,
return getIndexRangeImpl(context, type, indexCount, indices, indexRangeOut); return getIndexRangeImpl(context, type, indexCount, indices, indexRangeOut);
} }
void setBufferAccessValidationEnabled(bool enabled)
{
mBufferAccessValidationEnabled = enabled;
}
private: private:
~VertexArray() override; ~VertexArray() override;
...@@ -290,12 +293,10 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -290,12 +293,10 @@ class VertexArray final : public angle::ObserverInterface,
void setDirtyBindingBit(size_t bindingIndex, DirtyBindingBitType dirtyBindingBit); void setDirtyBindingBit(size_t bindingIndex, DirtyBindingBitType dirtyBindingBit);
DirtyBitType getDirtyBitFromIndex(bool contentsChanged, angle::SubjectIndex index) const; DirtyBitType getDirtyBitFromIndex(bool contentsChanged, angle::SubjectIndex index) const;
void setDependentDirtyBit(const gl::Context *context, void setDependentDirtyBit(bool contentsChanged, angle::SubjectIndex index);
bool contentsChanged,
angle::SubjectIndex index);
// These are used to optimize draw call validation. // These are used to optimize draw call validation.
void updateCachedBufferBindingSize(const Context *context, VertexBinding *binding); void updateCachedBufferBindingSize(VertexBinding *binding);
void updateCachedTransformFeedbackBindingValidation(size_t bindingIndex, const Buffer *buffer); void updateCachedTransformFeedbackBindingValidation(size_t bindingIndex, const Buffer *buffer);
void updateCachedMappedArrayBuffers(bool isMapped, const AttributesMask &boundAttributesMask); void updateCachedMappedArrayBuffers(bool isMapped, const AttributesMask &boundAttributesMask);
void updateCachedMappedArrayBuffersBinding(const VertexBinding &binding); void updateCachedMappedArrayBuffersBinding(const VertexBinding &binding);
...@@ -366,6 +367,7 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -366,6 +367,7 @@ class VertexArray final : public angle::ObserverInterface,
}; };
mutable IndexRangeCache mIndexRangeCache; mutable IndexRangeCache mIndexRangeCache;
bool mBufferAccessValidationEnabled;
}; };
} // namespace gl } // namespace gl
......
...@@ -494,7 +494,7 @@ void SetSamplerParameterBase(Context *context, ...@@ -494,7 +494,7 @@ void SetSamplerParameterBase(Context *context,
break; break;
} }
sampler->onStateChange(context, angle::SubjectMessage::ContentsChanged); sampler->onStateChange(angle::SubjectMessage::ContentsChanged);
} }
// Warning: you should ensure binding really matches attrib.bindingIndex before using this function. // Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
......
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
#include "libANGLE/ImageIndex.h" #include "libANGLE/ImageIndex.h"
#include "libANGLE/Observer.h" #include "libANGLE/Observer.h"
namespace gl
{
class Context;
} // namespace gl
namespace rx namespace rx
{ {
class FramebufferAttachmentRenderTarget; class FramebufferAttachmentRenderTarget;
......
...@@ -82,7 +82,7 @@ angle::Result EGLImageD3D::copyToLocalRendertarget(const gl::Context *context) ...@@ -82,7 +82,7 @@ angle::Result EGLImageD3D::copyToLocalRendertarget(const gl::Context *context)
// Invalidate FBOs with this Image attached. Only currently applies to D3D11. // Invalidate FBOs with this Image attached. Only currently applies to D3D11.
for (egl::ImageSibling *target : mState.targets) for (egl::ImageSibling *target : mState.targets)
{ {
target->onStateChange(context, angle::SubjectMessage::SubjectChanged); target->onStateChange(angle::SubjectMessage::SubjectChanged);
} }
return mRenderer->createRenderTargetCopy(context, curRenderTarget, &mRenderTarget); return mRenderer->createRenderTargetCopy(context, curRenderTarget, &mRenderTarget);
......
...@@ -952,13 +952,13 @@ bool Buffer11::supportsDirectBinding() const ...@@ -952,13 +952,13 @@ bool Buffer11::supportsDirectBinding() const
void Buffer11::initializeStaticData(const gl::Context *context) void Buffer11::initializeStaticData(const gl::Context *context)
{ {
BufferD3D::initializeStaticData(context); BufferD3D::initializeStaticData(context);
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
} }
void Buffer11::invalidateStaticData(const gl::Context *context) void Buffer11::invalidateStaticData(const gl::Context *context)
{ {
BufferD3D::invalidateStaticData(context); BufferD3D::invalidateStaticData(context);
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
} }
void Buffer11::onCopyStorage(BufferStorage *dest, BufferStorage *source) void Buffer11::onCopyStorage(BufferStorage *dest, BufferStorage *source)
...@@ -1151,7 +1151,7 @@ angle::Result Buffer11::NativeStorage::resize(const gl::Context *context, ...@@ -1151,7 +1151,7 @@ angle::Result Buffer11::NativeStorage::resize(const gl::Context *context,
// Notify that the storage has changed. // Notify that the storage has changed.
if (mOnStorageChanged) if (mOnStorageChanged)
{ {
mOnStorageChanged->onStateChange(context, angle::SubjectMessage::SubjectChanged); mOnStorageChanged->onStateChange(angle::SubjectMessage::SubjectChanged);
} }
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -1307,7 +1307,7 @@ angle::Result TextureGL::setBaseLevel(const gl::Context *context, GLuint baseLev ...@@ -1307,7 +1307,7 @@ angle::Result TextureGL::setBaseLevel(const gl::Context *context, GLuint baseLev
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_BASE_LEVEL); mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_BASE_LEVEL);
// Signal to the GL layer that the Impl has dirty bits. // Signal to the GL layer that the Impl has dirty bits.
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
stateManager->bindTexture(getType(), mTextureID); stateManager->bindTexture(getType(), mTextureID);
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_BASE_LEVEL, baseLevel); functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_BASE_LEVEL, baseLevel);
...@@ -1326,7 +1326,7 @@ void TextureGL::setMinFilter(const gl::Context *context, GLenum filter) ...@@ -1326,7 +1326,7 @@ void TextureGL::setMinFilter(const gl::Context *context, GLenum filter)
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MIN_FILTER); mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MIN_FILTER);
// Signal to the GL layer that the Impl has dirty bits. // Signal to the GL layer that the Impl has dirty bits.
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
stateManager->bindTexture(getType(), mTextureID); stateManager->bindTexture(getType(), mTextureID);
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_MIN_FILTER, filter); functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_MIN_FILTER, filter);
...@@ -1343,7 +1343,7 @@ void TextureGL::setMagFilter(const gl::Context *context, GLenum filter) ...@@ -1343,7 +1343,7 @@ void TextureGL::setMagFilter(const gl::Context *context, GLenum filter)
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MAG_FILTER); mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MAG_FILTER);
// Signal to the GL layer that the Impl has dirty bits. // Signal to the GL layer that the Impl has dirty bits.
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
stateManager->bindTexture(getType(), mTextureID); stateManager->bindTexture(getType(), mTextureID);
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_MAG_FILTER, filter); functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_MAG_FILTER, filter);
...@@ -1367,7 +1367,7 @@ void TextureGL::setSwizzle(const gl::Context *context, GLint swizzle[4]) ...@@ -1367,7 +1367,7 @@ void TextureGL::setSwizzle(const gl::Context *context, GLint swizzle[4])
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_SWIZZLE_ALPHA); mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_SWIZZLE_ALPHA);
// Signal to the GL layer that the Impl has dirty bits. // Signal to the GL layer that the Impl has dirty bits.
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
stateManager->bindTexture(getType(), mTextureID); stateManager->bindTexture(getType(), mTextureID);
functions->texParameteriv(ToGLenum(getType()), GL_TEXTURE_SWIZZLE_RGBA, swizzle); functions->texParameteriv(ToGLenum(getType()), GL_TEXTURE_SWIZZLE_RGBA, swizzle);
...@@ -1509,7 +1509,7 @@ void TextureGL::setLevelInfo(const gl::Context *context, ...@@ -1509,7 +1509,7 @@ void TextureGL::setLevelInfo(const gl::Context *context,
if (updateWorkarounds) if (updateWorkarounds)
{ {
mLocalDirtyBits |= GetLevelWorkaroundDirtyBits(); mLocalDirtyBits |= GetLevelWorkaroundDirtyBits();
onStateChange(context, angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
} }
} }
......
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