Commit 6c43a01a by Jamie Madill Committed by Commit Bot

Make Context handle dirty texture events.

Moving from State to Context allows the Context to update the State Cache class directly. It also calls through to the State class to update the Texture cache. This consolidates notification events into the Context class. This is also in line with how we handle state event updates in other gl classes. Bug: angleproject:2747 Bug: angleproject:2763 Change-Id: Iff7dc7e46ee8768819235ebd151707cd2a03dfc9 Reviewed-on: https://chromium-review.googlesource.com/1166143 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent f2c6faf5
......@@ -298,9 +298,11 @@ static_assert(static_cast<gl::PrimitiveMode>(10) == gl::PrimitiveMode::TriangleS
static_assert(static_cast<gl::PrimitiveMode>(11) == gl::PrimitiveMode::EnumCount,
"gl::PrimitiveMode enum values have changed, update kMinimumPrimitiveCounts.");
constexpr angle::SubjectIndex kVertexArraySubjectIndex = 0;
constexpr angle::SubjectIndex kReadFramebufferSubjectIndex = 1;
constexpr angle::SubjectIndex kDrawFramebufferSubjectIndex = 2;
constexpr angle::SubjectIndex kVertexArraySubjectIndex = gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES + 0;
constexpr angle::SubjectIndex kReadFramebufferSubjectIndex =
gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES + 1;
constexpr angle::SubjectIndex kDrawFramebufferSubjectIndex =
gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES + 2;
} // anonymous namespace
namespace gl
......@@ -7561,7 +7563,6 @@ void Context::onSubjectStateChange(const Context *context,
angle::SubjectIndex index,
angle::SubjectMessage message)
{
ASSERT(message == angle::SubjectMessage::CONTENTS_CHANGED);
switch (index)
{
case kVertexArraySubjectIndex:
......@@ -7578,7 +7579,8 @@ void Context::onSubjectStateChange(const Context *context,
break;
default:
UNREACHABLE();
ASSERT(index < mGLState.getActiveTexturesCache().size());
mGLState.onActiveTextureStateChange(index);
break;
}
}
......
......@@ -123,7 +123,7 @@ State::~State()
{
}
void State::initialize(const Context *context)
void State::initialize(Context *context)
{
const Caps &caps = context->getCaps();
const Extensions &extensions = context->getExtensions();
......@@ -218,7 +218,7 @@ void State::initialize(const Context *context)
for (uint32_t textureIndex = 0; textureIndex < caps.maxCombinedTextureImageUnits;
++textureIndex)
{
mCompleteTextureBindings.emplace_back(this, textureIndex);
mCompleteTextureBindings.emplace_back(context, textureIndex);
}
mSamplers.resize(caps.maxCombinedTextureImageUnits);
......@@ -2796,16 +2796,14 @@ const ImageUnit &State::getImageUnit(GLuint unit) const
}
// Handle a dirty texture event.
void State::onSubjectStateChange(const Context *context,
angle::SubjectIndex index,
angle::SubjectMessage message)
void State::onActiveTextureStateChange(size_t textureIndex)
{
// Conservatively assume all textures are dirty.
// TODO(jmadill): More fine-grained update.
mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES);
if (!mActiveTexturesCache[index] ||
mActiveTexturesCache[index]->initState() == InitState::MayNeedInit)
if (!mActiveTexturesCache[textureIndex] ||
mActiveTexturesCache[textureIndex]->initState() == InitState::MayNeedInit)
{
mCachedTexturesInitState = InitState::MayNeedInit;
}
......
......@@ -35,7 +35,7 @@ class VertexArray;
class Context;
struct Caps;
class State : public angle::ObserverInterface, angle::NonCopyable
class State : angle::NonCopyable
{
public:
State(bool debug,
......@@ -43,9 +43,9 @@ class State : public angle::ObserverInterface, angle::NonCopyable
bool clientArraysEnabled,
bool robustResourceInit,
bool programBinaryCacheEnabled);
~State() override;
~State();
void initialize(const Context *context);
void initialize(Context *context);
void reset(const Context *context);
// State chunk getters
......@@ -472,10 +472,7 @@ class State : public angle::ObserverInterface, angle::NonCopyable
const ActiveTexturePointerArray &getActiveTexturesCache() const { return mActiveTexturesCache; }
ComponentTypeMask getCurrentValuesTypeMask() const { return mCurrentValuesTypeMask; }
// Observer implementation.
void onSubjectStateChange(const Context *context,
angle::SubjectIndex index,
angle::SubjectMessage message) override;
void onActiveTextureStateChange(size_t textureIndex);
Error clearUnclearedActiveTextures(const Context *context);
......
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