Split context state by locality of get/set effect

Some state are purely local to the context when get or set.  For
example, the state of depth test does not affect and is not affected by
any other state.

Some state on the other hand may affect other contexts.  In particular,
some objects are shared between contexts of a share group, and may
affect each other through the observer interface.

These sets of state are separated to create a clear boundary between
state that can and cannot be accessed without holding the share group
lock.  A follow up change removes locking from the entry points that
purely access the former set of states.

For the latter state, it is likely possible to access most if not all of
them without holding a lock, but careful inspection is required before
that can be considered.  In particular, most entry points that simply
bind an object are likely harmless if the ref counter is turned atomic.

Bug: angleproject:8224
Change-Id: I91c3fa9de870c13d48012a5e06c177dab4010907
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4651375
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Roman Lavrov <romanl@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi
2023-06-27 16:01:58 -04:00
committed by Angle LUCI CQ
parent 5f581f879c
commit ccf8530b4e
9 changed files with 2446 additions and 1923 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -92,7 +92,7 @@ GLES1State::GLES1State()
GLES1State::~GLES1State() = default;
// Taken from the GLES 1.x spec which specifies all initial state values.
void GLES1State::initialize(const Context *context, const State *state)
void GLES1State::initialize(const Context *context, const LocalState *state)
{
mGLState = state;

View File

@@ -162,7 +162,7 @@ struct ClipPlaneParameters
class Context;
class GLES1Renderer;
class State;
class LocalState;
class GLES1State final : angle::NonCopyable
{
@@ -170,7 +170,7 @@ class GLES1State final : angle::NonCopyable
GLES1State();
~GLES1State();
void initialize(const Context *context, const State *state);
void initialize(const Context *context, const LocalState *state);
void setAlphaTestParameters(AlphaTestFunc func, GLfloat ref);
const AlphaTestParameters &getAlphaTestParameters() const;
@@ -271,11 +271,11 @@ class GLES1State final : angle::NonCopyable
void setAllDirty() { mDirtyBits.set(); }
private:
friend class State;
friend class LocalState;
friend class GLES1Renderer;
// Back pointer for reading from State.
const State *mGLState;
const LocalState *mGLState;
using DirtyBits = angle::BitSet<DIRTY_GLES1_MAX>;
DirtyBits mDirtyBits;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -990,6 +990,8 @@ template <typename T>
using TransformFeedbackBuffersArray =
std::array<T, gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS>;
using ClipDistanceEnableBits = angle::BitSet32<IMPLEMENTATION_MAX_CLIP_DISTANCES>;
template <typename T>
using QueryTypeMap = angle::PackedEnumMap<QueryType, T>;

View File

@@ -87,7 +87,7 @@ class [[nodiscard]] ScopedGLState : angle::NonCopyable
stateManager->setDepthRange(0.0f, 1.0f);
stateManager->setClipControl(gl::ClipOrigin::LowerLeft,
gl::ClipDepthMode::NegativeOneToOne);
stateManager->setClipDistancesEnable(gl::State::ClipDistanceEnableBits());
stateManager->setClipDistancesEnable(gl::ClipDistanceEnableBits());
stateManager->setDepthClampEnabled(false);
stateManager->setBlendEnabled(false);
stateManager->setColorMask(true, true, true, true);

View File

@@ -2606,7 +2606,7 @@ void StateManagerGL::setProvokingVertex(GLenum mode)
}
}
void StateManagerGL::setClipDistancesEnable(const gl::State::ClipDistanceEnableBits &enables)
void StateManagerGL::setClipDistancesEnable(const gl::ClipDistanceEnableBits &enables)
{
if (enables == mEnabledClipDistances)
{
@@ -2614,7 +2614,7 @@ void StateManagerGL::setClipDistancesEnable(const gl::State::ClipDistanceEnableB
}
ASSERT(mMaxClipDistances <= gl::IMPLEMENTATION_MAX_CLIP_DISTANCES);
gl::State::ClipDistanceEnableBits diff = enables ^ mEnabledClipDistances;
gl::ClipDistanceEnableBits diff = enables ^ mEnabledClipDistances;
for (size_t i : diff)
{
if (enables.test(i))
@@ -2731,10 +2731,9 @@ void StateManagerGL::updateMultiviewBaseViewLayerIndexUniformImpl(
}
}
void StateManagerGL::updateEmulatedClipDistanceState(
const gl::ProgramExecutable *executable,
const gl::Program *program,
const gl::State::ClipDistanceEnableBits enables) const
void StateManagerGL::updateEmulatedClipDistanceState(const gl::ProgramExecutable *executable,
const gl::Program *program,
const gl::ClipDistanceEnableBits enables) const
{
ASSERT(mFeatures.emulateClipDistanceState.enabled);
if (executable && executable->hasClipDistance())

View File

@@ -271,7 +271,7 @@ class StateManagerGL final : angle::NonCopyable
void setProvokingVertex(GLenum mode);
void setClipDistancesEnable(const gl::State::ClipDistanceEnableBits &enables);
void setClipDistancesEnable(const gl::ClipDistanceEnableBits &enables);
void setLogicOpEnabled(bool enabled);
void setLogicOp(gl::LogicalOperation opcode);
@@ -345,7 +345,7 @@ class StateManagerGL final : angle::NonCopyable
void updateEmulatedClipDistanceState(const gl::ProgramExecutable *executable,
const gl::Program *program,
const gl::State::ClipDistanceEnableBits enables) const;
const gl::ClipDistanceEnableBits enables) const;
void updateMultiviewBaseViewLayerIndexUniformImpl(
const gl::Program *program,
@@ -542,7 +542,7 @@ class StateManagerGL final : angle::NonCopyable
GLenum mProvokingVertex;
gl::State::ClipDistanceEnableBits mEnabledClipDistances;
gl::ClipDistanceEnableBits mEnabledClipDistances;
const size_t mMaxClipDistances;
bool mLogicOpEnabled;