Commit 4bba74f0 by Luc Ferron Committed by Commit Bot

Refactor Texture::syncState to pass down the Context

Also returning a gl::Error everywhere. Bug: angleproject:2478 Change-Id: Ic8cae0ee7aee318bb95b3588044c34c62707b578 Reviewed-on: https://chromium-review.googlesource.com/1020083Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Luc Ferron <lucferron@chromium.org>
parent 3ec304db
......@@ -2563,7 +2563,7 @@ Error State::syncDirtyObjects(const Context *context, const DirtyObjects &bitset
ANGLE_TRY(mVertexArray->syncState(context));
break;
case DIRTY_OBJECT_PROGRAM_TEXTURES:
syncProgramTextures(context);
ANGLE_TRY(syncProgramTextures(context));
break;
default:
......@@ -2576,12 +2576,12 @@ Error State::syncDirtyObjects(const Context *context, const DirtyObjects &bitset
return NoError();
}
void State::syncProgramTextures(const Context *context)
Error State::syncProgramTextures(const Context *context)
{
// TODO(jmadill): Fine-grained updates.
if (!mProgram)
{
return;
return NoError();
}
ASSERT(mDirtyObjects[DIRTY_OBJECT_PROGRAM_TEXTURES]);
......@@ -2613,7 +2613,7 @@ void State::syncProgramTextures(const Context *context)
if (texture->isSamplerComplete(context, sampler) &&
!mDrawFramebuffer->hasTextureAttachment(texture))
{
texture->syncState();
ANGLE_TRY(texture->syncState(context));
mCompleteTextureCache[textureUnitIndex] = texture;
}
else
......@@ -2649,6 +2649,8 @@ void State::syncProgramTextures(const Context *context)
mActiveTexturesMask.reset(textureIndex);
}
}
return NoError();
}
Error State::syncDirtyObject(const Context *context, GLenum target)
......
......@@ -479,7 +479,7 @@ class State : public angle::ObserverInterface, angle::NonCopyable
const GLES1State &gles1() const { return mGLES1State; }
private:
void syncProgramTextures(const Context *context);
Error syncProgramTextures(const Context *context);
// Cached values from Context's caps
GLuint mMaxDrawBuffers;
......
......@@ -1236,7 +1236,7 @@ Error Texture::generateMipmap(const Context *context)
{
return NoError();
}
syncState();
ANGLE_TRY(syncState(context));
// Clear the base image(s) immediately if needed
if (context->isRobustResourceInitEnabled())
......@@ -1435,10 +1435,11 @@ GLuint Texture::getId() const
return id();
}
void Texture::syncState()
Error Texture::syncState(const Context *context)
{
mTexture->syncState(mDirtyBits);
ANGLE_TRY(mTexture->syncState(context, mDirtyBits));
mDirtyBits.reset();
return NoError();
}
rx::FramebufferAttachmentObjectImpl *Texture::getAttachmentImpl() const
......
......@@ -426,7 +426,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject
};
using DirtyBits = angle::BitSet<DIRTY_BIT_COUNT>;
void syncState();
Error syncState(const Context *context);
bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
private:
......
......@@ -140,7 +140,8 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
virtual gl::Error bindTexImage(const gl::Context *context, egl::Surface *surface) = 0;
virtual gl::Error releaseTexImage(const gl::Context *context) = 0;
virtual void syncState(const gl::Texture::DirtyBits &dirtyBits) = 0;
virtual gl::Error syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits) = 0;
protected:
const gl::TextureState &mState;
......
......@@ -112,7 +112,7 @@ class MockTextureImpl : public TextureImpl
MOCK_METHOD2(setBaseLevel, gl::Error(const gl::Context *, GLuint));
MOCK_METHOD1(syncState, void(const gl::Texture::DirtyBits &));
MOCK_METHOD2(syncState, gl::Error(const gl::Context *, const gl::Texture::DirtyBits &));
MOCK_METHOD0(destructor, void());
......
......@@ -637,9 +637,10 @@ gl::Error TextureD3D::setBaseLevel(const gl::Context *context, GLuint baseLevel)
return gl::NoError();
}
void TextureD3D::syncState(const gl::Texture::DirtyBits &dirtyBits)
gl::Error TextureD3D::syncState(const gl::Context *context, const gl::Texture::DirtyBits &dirtyBits)
{
// TODO(geofflang): Use dirty bits
return gl::NoError();
}
gl::Error TextureD3D::releaseTexStorage(const gl::Context *context)
......
......@@ -98,7 +98,8 @@ class TextureD3D : public TextureImpl
gl::Error setBaseLevel(const gl::Context *context, GLuint baseLevel) override;
void syncState(const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override;
......
......@@ -1062,11 +1062,11 @@ gl::Error TextureGL::setEGLImageTarget(const gl::Context *context,
return gl::InternalError();
}
void TextureGL::syncState(const gl::Texture::DirtyBits &dirtyBits)
gl::Error TextureGL::syncState(const gl::Context *context, const gl::Texture::DirtyBits &dirtyBits)
{
if (dirtyBits.none() && mLocalDirtyBits.none())
{
return;
return gl::NoError();
}
mStateManager->bindTexture(getType(), mTextureID);
......@@ -1187,6 +1187,7 @@ void TextureGL::syncState(const gl::Texture::DirtyBits &dirtyBits)
}
mLocalDirtyBits.reset();
return gl::NoError();
}
bool TextureGL::hasAnyDirtyBit() const
......
......@@ -166,7 +166,8 @@ class TextureGL : public TextureImpl
GLuint getTextureID() const;
gl::TextureType getType() const;
void syncState(const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits) override;
bool hasAnyDirtyBit() const;
gl::Error setBaseLevel(const gl::Context *context, GLuint baseLevel) override;
......
......@@ -131,8 +131,10 @@ gl::Error TextureNULL::releaseTexImage(const gl::Context *context)
return gl::NoError();
}
void TextureNULL::syncState(const gl::Texture::DirtyBits &dirtyBits)
gl::Error TextureNULL::syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits)
{
return gl::NoError();
}
gl::Error TextureNULL::setStorageMultisample(const gl::Context *context,
......
......@@ -85,7 +85,8 @@ class TextureNULL : public TextureImpl
gl::Error bindTexImage(const gl::Context *context, egl::Surface *surface) override;
gl::Error releaseTexImage(const gl::Context *context) override;
void syncState(const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error setStorageMultisample(const gl::Context *context,
gl::TextureType type,
......
......@@ -539,7 +539,7 @@ gl::Error IncompleteTextureSet::getIncompleteTexture(
area, GL_RGBA, GL_UNSIGNED_BYTE, color));
}
t->syncState();
ANGLE_TRY(t->syncState(context));
mIncompleteTextures[type].set(context, t.release());
*textureOut = mIncompleteTextures[type].get();
......
......@@ -468,9 +468,10 @@ vk::Error TextureVk::ensureImageInitialized(RendererVk *renderer)
return vk::NoError();
}
void TextureVk::syncState(const gl::Texture::DirtyBits &dirtyBits)
gl::Error TextureVk::syncState(const gl::Context *context, const gl::Texture::DirtyBits &dirtyBits)
{
// TODO(jmadill): Texture sync state.
return gl::NoError();
}
gl::Error TextureVk::setStorageMultisample(const gl::Context *context,
......
......@@ -129,7 +129,8 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const gl::ImageIndex &imageIndex,
FramebufferAttachmentRenderTarget **rtOut) override;
void syncState(const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits) override;
gl::Error setStorageMultisample(const gl::Context *context,
gl::TextureType type,
......
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