Commit 8693bdb8 by Jamie Madill Committed by Commit Bot

Add a few missing dirty bit cases.

Discovered some of these while investigating Texture dirty bits. BUG=angleproject:1387 Change-Id: I8b170462bfd283e4b0f9d47b7f7ddbaa7957914d Reviewed-on: https://chromium-review.googlesource.com/648051Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 7d738e26
...@@ -861,6 +861,10 @@ void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const ...@@ -861,6 +861,10 @@ void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const
std::string labelName = GetObjectLabelFromPointer(length, label); std::string labelName = GetObjectLabelFromPointer(length, label);
object->setLabel(labelName); object->setLabel(labelName);
// TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the
// specified object is active until we do this.
mGLState.setObjectDirty(identifier);
} }
void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label)
......
...@@ -597,22 +597,27 @@ const std::string &Framebuffer::getLabel() const ...@@ -597,22 +597,27 @@ const std::string &Framebuffer::getLabel() const
return mState.mLabel; return mState.mLabel;
} }
void Framebuffer::detachTexture(const Context *context, GLuint textureId) bool Framebuffer::detachTexture(const Context *context, GLuint textureId)
{ {
detachResourceById(context, GL_TEXTURE, textureId); return detachResourceById(context, GL_TEXTURE, textureId);
} }
void Framebuffer::detachRenderbuffer(const Context *context, GLuint renderbufferId) bool Framebuffer::detachRenderbuffer(const Context *context, GLuint renderbufferId)
{ {
detachResourceById(context, GL_RENDERBUFFER, renderbufferId); return detachResourceById(context, GL_RENDERBUFFER, renderbufferId);
} }
void Framebuffer::detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId) bool Framebuffer::detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId)
{ {
bool found = false;
for (size_t colorIndex = 0; colorIndex < mState.mColorAttachments.size(); ++colorIndex) for (size_t colorIndex = 0; colorIndex < mState.mColorAttachments.size(); ++colorIndex)
{ {
detachMatchingAttachment(context, &mState.mColorAttachments[colorIndex], resourceType, if (detachMatchingAttachment(context, &mState.mColorAttachments[colorIndex], resourceType,
resourceId, DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex); resourceId, DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex))
{
found = true;
}
} }
if (context->isWebGL1()) if (context->isWebGL1())
...@@ -626,19 +631,28 @@ void Framebuffer::detachResourceById(const Context *context, GLenum resourceType ...@@ -626,19 +631,28 @@ void Framebuffer::detachResourceById(const Context *context, GLenum resourceType
attachment->id() == resourceId) attachment->id() == resourceId)
{ {
resetAttachment(context, attachment->getBinding()); resetAttachment(context, attachment->getBinding());
found = true;
} }
} }
} }
else else
{ {
detachMatchingAttachment(context, &mState.mDepthAttachment, resourceType, resourceId, if (detachMatchingAttachment(context, &mState.mDepthAttachment, resourceType, resourceId,
DIRTY_BIT_DEPTH_ATTACHMENT); DIRTY_BIT_DEPTH_ATTACHMENT))
detachMatchingAttachment(context, &mState.mStencilAttachment, resourceType, resourceId, {
DIRTY_BIT_STENCIL_ATTACHMENT); found = true;
}
if (detachMatchingAttachment(context, &mState.mStencilAttachment, resourceType, resourceId,
DIRTY_BIT_STENCIL_ATTACHMENT))
{
found = true;
}
} }
return found;
} }
void Framebuffer::detachMatchingAttachment(const Context *context, bool Framebuffer::detachMatchingAttachment(const Context *context,
FramebufferAttachment *attachment, FramebufferAttachment *attachment,
GLenum matchType, GLenum matchType,
GLuint matchId, GLuint matchId,
...@@ -648,7 +662,10 @@ void Framebuffer::detachMatchingAttachment(const Context *context, ...@@ -648,7 +662,10 @@ void Framebuffer::detachMatchingAttachment(const Context *context,
{ {
attachment->detach(context); attachment->detach(context);
mDirtyBits.set(dirtyBit); mDirtyBits.set(dirtyBit);
return true;
} }
return false;
} }
const FramebufferAttachment *Framebuffer::getColorbuffer(size_t colorAttachment) const const FramebufferAttachment *Framebuffer::getColorbuffer(size_t colorAttachment) const
......
...@@ -169,8 +169,8 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver ...@@ -169,8 +169,8 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
const GLint *viewportOffsets); const GLint *viewportOffsets);
void resetAttachment(const Context *context, GLenum binding); void resetAttachment(const Context *context, GLenum binding);
void detachTexture(const Context *context, GLuint texture); bool detachTexture(const Context *context, GLuint texture);
void detachRenderbuffer(const Context *context, GLuint renderbuffer); bool detachRenderbuffer(const Context *context, GLuint renderbuffer);
const FramebufferAttachment *getColorbuffer(size_t colorAttachment) const; const FramebufferAttachment *getColorbuffer(size_t colorAttachment) const;
const FramebufferAttachment *getDepthbuffer() const; const FramebufferAttachment *getDepthbuffer() const;
...@@ -308,8 +308,8 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver ...@@ -308,8 +308,8 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLint copyTextureLayer) const; GLint copyTextureLayer) const;
private: private:
void detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId); bool detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId);
void detachMatchingAttachment(const Context *context, bool detachMatchingAttachment(const Context *context,
FramebufferAttachment *attachment, FramebufferAttachment *attachment,
GLenum matchType, GLenum matchType,
GLuint matchId, GLuint matchId,
......
...@@ -79,6 +79,6 @@ class Sampler final : public RefCountObject, public LabeledObject ...@@ -79,6 +79,6 @@ class Sampler final : public RefCountObject, public LabeledObject
SamplerState mSamplerState; SamplerState mSamplerState;
}; };
} } // namespace gl
#endif // LIBANGLE_SAMPLER_H_ #endif // LIBANGLE_SAMPLER_H_
...@@ -197,9 +197,9 @@ void State::initialize(const Context *context, ...@@ -197,9 +197,9 @@ void State::initialize(const Context *context,
void State::reset(const Context *context) void State::reset(const Context *context)
{ {
for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++) for (auto &bindingVec : mSamplerTextures)
{ {
TextureBindingVector &textureVector = bindingVec->second; TextureBindingVector &textureVector = bindingVec.second;
for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++) for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{ {
textureVector[textureIdx].set(context, nullptr); textureVector[textureIdx].set(context, nullptr);
...@@ -834,14 +834,14 @@ void State::detachTexture(const Context *context, const TextureMap &zeroTextures ...@@ -834,14 +834,14 @@ void State::detachTexture(const Context *context, const TextureMap &zeroTextures
// as if Texture2DAttachment had been called, with a texture of 0, for each attachment point to which this // as if Texture2DAttachment had been called, with a texture of 0, for each attachment point to which this
// image was attached in the currently bound framebuffer. // image was attached in the currently bound framebuffer.
if (mReadFramebuffer) if (mReadFramebuffer && mReadFramebuffer->detachTexture(context, texture))
{ {
mReadFramebuffer->detachTexture(context, texture); mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER);
} }
if (mDrawFramebuffer) if (mDrawFramebuffer && mDrawFramebuffer->detachTexture(context, texture))
{ {
mDrawFramebuffer->detachTexture(context, texture); mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER);
} }
} }
...@@ -893,6 +893,7 @@ void State::detachSampler(const Context *context, GLuint sampler) ...@@ -893,6 +893,7 @@ void State::detachSampler(const Context *context, GLuint sampler)
void State::setRenderbufferBinding(const Context *context, Renderbuffer *renderbuffer) void State::setRenderbufferBinding(const Context *context, Renderbuffer *renderbuffer)
{ {
mRenderbuffer.set(context, renderbuffer); mRenderbuffer.set(context, renderbuffer);
mDirtyBits.set(DIRTY_BIT_RENDERBUFFER_BINDING);
} }
GLuint State::getRenderbufferId() const GLuint State::getRenderbufferId() const
...@@ -913,7 +914,7 @@ void State::detachRenderbuffer(const Context *context, GLuint renderbuffer) ...@@ -913,7 +914,7 @@ void State::detachRenderbuffer(const Context *context, GLuint renderbuffer)
if (mRenderbuffer.id() == renderbuffer) if (mRenderbuffer.id() == renderbuffer)
{ {
mRenderbuffer.set(context, nullptr); setRenderbufferBinding(context, nullptr);
} }
// [OpenGL ES 2.0.24] section 4.4 page 111: // [OpenGL ES 2.0.24] section 4.4 page 111:
...@@ -924,14 +925,17 @@ void State::detachRenderbuffer(const Context *context, GLuint renderbuffer) ...@@ -924,14 +925,17 @@ void State::detachRenderbuffer(const Context *context, GLuint renderbuffer)
Framebuffer *readFramebuffer = mReadFramebuffer; Framebuffer *readFramebuffer = mReadFramebuffer;
Framebuffer *drawFramebuffer = mDrawFramebuffer; Framebuffer *drawFramebuffer = mDrawFramebuffer;
if (readFramebuffer) if (readFramebuffer && readFramebuffer->detachRenderbuffer(context, renderbuffer))
{ {
readFramebuffer->detachRenderbuffer(context, renderbuffer); mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER);
} }
if (drawFramebuffer && drawFramebuffer != readFramebuffer) if (drawFramebuffer && drawFramebuffer != readFramebuffer)
{ {
drawFramebuffer->detachRenderbuffer(context, renderbuffer); if (drawFramebuffer->detachRenderbuffer(context, renderbuffer))
{
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER);
}
} }
} }
......
...@@ -445,6 +445,6 @@ inline bool operator!=(const TextureState &a, const TextureState &b) ...@@ -445,6 +445,6 @@ inline bool operator!=(const TextureState &a, const TextureState &b)
{ {
return !(a == b); return !(a == b);
} }
} } // namespace gl
#endif // LIBANGLE_TEXTURE_H_ #endif // LIBANGLE_TEXTURE_H_
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