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 ...@@ -298,9 +298,11 @@ static_assert(static_cast<gl::PrimitiveMode>(10) == gl::PrimitiveMode::TriangleS
static_assert(static_cast<gl::PrimitiveMode>(11) == gl::PrimitiveMode::EnumCount, static_assert(static_cast<gl::PrimitiveMode>(11) == gl::PrimitiveMode::EnumCount,
"gl::PrimitiveMode enum values have changed, update kMinimumPrimitiveCounts."); "gl::PrimitiveMode enum values have changed, update kMinimumPrimitiveCounts.");
constexpr angle::SubjectIndex kVertexArraySubjectIndex = 0; constexpr angle::SubjectIndex kVertexArraySubjectIndex = gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES + 0;
constexpr angle::SubjectIndex kReadFramebufferSubjectIndex = 1; constexpr angle::SubjectIndex kReadFramebufferSubjectIndex =
constexpr angle::SubjectIndex kDrawFramebufferSubjectIndex = 2; gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES + 1;
constexpr angle::SubjectIndex kDrawFramebufferSubjectIndex =
gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES + 2;
} // anonymous namespace } // anonymous namespace
namespace gl namespace gl
...@@ -7561,7 +7563,6 @@ void Context::onSubjectStateChange(const Context *context, ...@@ -7561,7 +7563,6 @@ void Context::onSubjectStateChange(const Context *context,
angle::SubjectIndex index, angle::SubjectIndex index,
angle::SubjectMessage message) angle::SubjectMessage message)
{ {
ASSERT(message == angle::SubjectMessage::CONTENTS_CHANGED);
switch (index) switch (index)
{ {
case kVertexArraySubjectIndex: case kVertexArraySubjectIndex:
...@@ -7578,7 +7579,8 @@ void Context::onSubjectStateChange(const Context *context, ...@@ -7578,7 +7579,8 @@ void Context::onSubjectStateChange(const Context *context,
break; break;
default: default:
UNREACHABLE(); ASSERT(index < mGLState.getActiveTexturesCache().size());
mGLState.onActiveTextureStateChange(index);
break; break;
} }
} }
......
...@@ -123,7 +123,7 @@ State::~State() ...@@ -123,7 +123,7 @@ State::~State()
{ {
} }
void State::initialize(const Context *context) void State::initialize(Context *context)
{ {
const Caps &caps = context->getCaps(); const Caps &caps = context->getCaps();
const Extensions &extensions = context->getExtensions(); const Extensions &extensions = context->getExtensions();
...@@ -218,7 +218,7 @@ void State::initialize(const Context *context) ...@@ -218,7 +218,7 @@ void State::initialize(const Context *context)
for (uint32_t textureIndex = 0; textureIndex < caps.maxCombinedTextureImageUnits; for (uint32_t textureIndex = 0; textureIndex < caps.maxCombinedTextureImageUnits;
++textureIndex) ++textureIndex)
{ {
mCompleteTextureBindings.emplace_back(this, textureIndex); mCompleteTextureBindings.emplace_back(context, textureIndex);
} }
mSamplers.resize(caps.maxCombinedTextureImageUnits); mSamplers.resize(caps.maxCombinedTextureImageUnits);
...@@ -2796,16 +2796,14 @@ const ImageUnit &State::getImageUnit(GLuint unit) const ...@@ -2796,16 +2796,14 @@ const ImageUnit &State::getImageUnit(GLuint unit) const
} }
// Handle a dirty texture event. // Handle a dirty texture event.
void State::onSubjectStateChange(const Context *context, void State::onActiveTextureStateChange(size_t textureIndex)
angle::SubjectIndex index,
angle::SubjectMessage message)
{ {
// Conservatively assume all textures are dirty. // Conservatively assume all textures are dirty.
// TODO(jmadill): More fine-grained update. // TODO(jmadill): More fine-grained update.
mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES);
if (!mActiveTexturesCache[index] || if (!mActiveTexturesCache[textureIndex] ||
mActiveTexturesCache[index]->initState() == InitState::MayNeedInit) mActiveTexturesCache[textureIndex]->initState() == InitState::MayNeedInit)
{ {
mCachedTexturesInitState = InitState::MayNeedInit; mCachedTexturesInitState = InitState::MayNeedInit;
} }
......
...@@ -35,7 +35,7 @@ class VertexArray; ...@@ -35,7 +35,7 @@ class VertexArray;
class Context; class Context;
struct Caps; struct Caps;
class State : public angle::ObserverInterface, angle::NonCopyable class State : angle::NonCopyable
{ {
public: public:
State(bool debug, State(bool debug,
...@@ -43,9 +43,9 @@ class State : public angle::ObserverInterface, angle::NonCopyable ...@@ -43,9 +43,9 @@ class State : public angle::ObserverInterface, angle::NonCopyable
bool clientArraysEnabled, bool clientArraysEnabled,
bool robustResourceInit, bool robustResourceInit,
bool programBinaryCacheEnabled); bool programBinaryCacheEnabled);
~State() override; ~State();
void initialize(const Context *context); void initialize(Context *context);
void reset(const Context *context); void reset(const Context *context);
// State chunk getters // State chunk getters
...@@ -472,10 +472,7 @@ class State : public angle::ObserverInterface, angle::NonCopyable ...@@ -472,10 +472,7 @@ class State : public angle::ObserverInterface, angle::NonCopyable
const ActiveTexturePointerArray &getActiveTexturesCache() const { return mActiveTexturesCache; } const ActiveTexturePointerArray &getActiveTexturesCache() const { return mActiveTexturesCache; }
ComponentTypeMask getCurrentValuesTypeMask() const { return mCurrentValuesTypeMask; } ComponentTypeMask getCurrentValuesTypeMask() const { return mCurrentValuesTypeMask; }
// Observer implementation. void onActiveTextureStateChange(size_t textureIndex);
void onSubjectStateChange(const Context *context,
angle::SubjectIndex index,
angle::SubjectMessage message) override;
Error clearUnclearedActiveTextures(const Context *context); 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