Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1cc49bb

Browse files
null77Commit Bot
authored andcommitted
Squash State::mContext and State::mID.
These were both id values for the context. This CL consolidates to the monotonically increasing ID since it is both safer and easier to debug. Makes life easier when indexing feedback loops by context ID. Bug: angleproject:4517 Change-Id: I28b40fed4e6e68ea72742f7defde5f8638f4cd47 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2134408 Reviewed-by: Kenneth Russell <[email protected]> Reviewed-by: Courtney Goeltzenleuchter <[email protected]> Commit-Queue: Courtney Goeltzenleuchter <[email protected]>
1 parent dd29370 commit 1cc49bb

File tree

6 files changed

+31
-35
lines changed

6 files changed

+31
-35
lines changed

src/libANGLE/Context.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@ Context::Context(egl::Display *display,
255255
const egl::AttributeMap &attribs,
256256
const egl::DisplayExtensions &displayExtensions,
257257
const egl::ClientExtensions &clientExtensions)
258-
: mState(reinterpret_cast<ContextID>(this),
259-
shareContext ? &shareContext->mState : nullptr,
258+
: mState(shareContext ? &shareContext->mState : nullptr,
260259
shareTextures,
261260
&mOverlay,
262261
clientType,

src/libANGLE/Context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
344344
const egl::ClientExtensions &clientExtensions);
345345

346346
// Use for debugging.
347-
int id() const { return mState.mID; }
347+
ContextID id() const { return mState.getContextID(); }
348348

349349
egl::Error onDestroy(const egl::Display *display);
350350
~Context() override;

src/libANGLE/FrameCapture.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ std::string GetDefaultOutDirectory()
171171

172172
struct FmtCapturePrefix
173173
{
174-
FmtCapturePrefix(int contextIdIn, const std::string &captureLabelIn)
174+
FmtCapturePrefix(gl::ContextID contextIdIn, const std::string &captureLabelIn)
175175
: contextId(contextIdIn), captureLabel(captureLabelIn)
176176
{}
177-
int contextId;
177+
gl::ContextID contextId;
178178
const std::string &captureLabel;
179179
};
180180

@@ -188,26 +188,26 @@ std::ostream &operator<<(std::ostream &os, const FmtCapturePrefix &fmt)
188188
{
189189
os << fmt.captureLabel;
190190
}
191-
os << "_capture_context" << fmt.contextId;
191+
os << "_capture_context" << static_cast<int>(fmt.contextId);
192192
return os;
193193
}
194194

195195
struct FmtReplayFunction
196196
{
197-
FmtReplayFunction(int contextIdIn, uint32_t frameIndexIn)
197+
FmtReplayFunction(gl::ContextID contextIdIn, uint32_t frameIndexIn)
198198
: contextId(contextIdIn), frameIndex(frameIndexIn)
199199
{}
200-
int contextId;
200+
gl::ContextID contextId;
201201
uint32_t frameIndex;
202202
};
203203

204204
std::ostream &operator<<(std::ostream &os, const FmtReplayFunction &fmt)
205205
{
206-
os << "ReplayContext" << fmt.contextId << "Frame" << fmt.frameIndex << "()";
206+
os << "ReplayContext" << static_cast<int>(fmt.contextId) << "Frame" << fmt.frameIndex << "()";
207207
return os;
208208
}
209209

210-
std::string GetCaptureFileName(int contextId,
210+
std::string GetCaptureFileName(gl::ContextID contextId,
211211
const std::string &captureLabel,
212212
uint32_t frameIndex,
213213
const char *suffix)
@@ -219,7 +219,7 @@ std::string GetCaptureFileName(int contextId,
219219
}
220220

221221
std::string GetCaptureFilePath(const std::string &outDir,
222-
int contextId,
222+
gl::ContextID contextId,
223223
const std::string &captureLabel,
224224
uint32_t frameIndex,
225225
const char *suffix)
@@ -645,7 +645,9 @@ struct SaveFileHelper
645645
std::string filePath;
646646
};
647647

648-
std::string GetBinaryDataFilePath(bool compression, int contextId, const std::string &captureLabel)
648+
std::string GetBinaryDataFilePath(bool compression,
649+
gl::ContextID contextId,
650+
const std::string &captureLabel)
649651
{
650652
std::stringstream fnameStream;
651653
fnameStream << FmtCapturePrefix(contextId, captureLabel) << ".angledata";
@@ -658,7 +660,7 @@ std::string GetBinaryDataFilePath(bool compression, int contextId, const std::st
658660

659661
void SaveBinaryData(bool compression,
660662
const std::string &outDir,
661-
int contextId,
663+
gl::ContextID contextId,
662664
const std::string &captureLabel,
663665
const std::vector<uint8_t> &binaryData)
664666
{
@@ -695,7 +697,7 @@ void SaveBinaryData(bool compression,
695697

696698
void WriteLoadBinaryDataCall(bool compression,
697699
std::ostream &out,
698-
int contextId,
700+
gl::ContextID contextId,
699701
const std::string &captureLabel)
700702
{
701703
std::string binaryDataFileName = GetBinaryDataFilePath(compression, contextId, captureLabel);
@@ -704,7 +706,7 @@ void WriteLoadBinaryDataCall(bool compression,
704706

705707
void WriteCppReplay(bool compression,
706708
const std::string &outDir,
707-
int contextId,
709+
gl::ContextID contextId,
708710
const std::string &captureLabel,
709711
uint32_t frameIndex,
710712
const std::vector<CallCapture> &frameCalls,
@@ -730,7 +732,7 @@ void WriteCppReplay(bool compression,
730732

731733
if (frameIndex == 0 || !setupCalls.empty())
732734
{
733-
out << "void SetupContext" << Str(contextId) << "Replay()\n";
735+
out << "void SetupContext" << Str(static_cast<int>(contextId)) << "Replay()\n";
734736
out << "{\n";
735737

736738
std::stringstream setupCallStream;
@@ -786,7 +788,7 @@ void WriteCppReplay(bool compression,
786788

787789
void WriteCppReplayIndexFiles(bool compression,
788790
const std::string &outDir,
789-
int contextId,
791+
gl::ContextID contextId,
790792
const std::string &captureLabel,
791793
uint32_t frameStart,
792794
uint32_t frameEnd,
@@ -834,8 +836,9 @@ void WriteCppReplayIndexFiles(bool compression,
834836
header << "constexpr uint32_t kReplayFrameStart = " << frameStart << ";\n";
835837
header << "constexpr uint32_t kReplayFrameEnd = " << frameEnd << ";\n";
836838
header << "\n";
837-
header << "void SetupContext" << contextId << "Replay();\n";
838-
header << "void ReplayContext" << contextId << "Frame(uint32_t frameIndex);\n";
839+
header << "void SetupContext" << static_cast<int>(contextId) << "Replay();\n";
840+
header << "void ReplayContext" << static_cast<int>(contextId)
841+
<< "Frame(uint32_t frameIndex);\n";
839842
header << "\n";
840843
header << "using FramebufferChangeCallback = void(*)(void *userData, GLenum target, GLuint "
841844
"framebuffer);\n";
@@ -946,14 +949,15 @@ void WriteCppReplayIndexFiles(bool compression,
946949
source << "}\n";
947950

948951
source << "\n";
949-
source << "void ReplayContext" << contextId << "Frame(uint32_t frameIndex)\n";
952+
source << "void ReplayContext" << static_cast<int>(contextId) << "Frame(uint32_t frameIndex)\n";
950953
source << "{\n";
951954
source << " switch (frameIndex)\n";
952955
source << " {\n";
953956
for (uint32_t frameIndex = frameStart; frameIndex < frameEnd; ++frameIndex)
954957
{
955958
source << " case " << frameIndex << ":\n";
956-
source << " ReplayContext" << contextId << "Frame" << frameIndex << "();\n";
959+
source << " ReplayContext" << static_cast<int>(contextId) << "Frame"
960+
<< frameIndex << "();\n";
957961
source << " break;\n";
958962
}
959963
source << " default:\n";
@@ -1413,9 +1417,8 @@ void CaptureMidExecutionSetup(const gl::Context *context,
14131417
const TextureLevelDataMap &cachedTextureLevelData)
14141418
{
14151419
const gl::State &apiState = context->getState();
1416-
gl::State replayState(0, nullptr, nullptr, nullptr, EGL_OPENGL_ES_API,
1417-
apiState.getClientVersion(), false, true, true, true, false,
1418-
EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
1420+
gl::State replayState(nullptr, nullptr, nullptr, EGL_OPENGL_ES_API, apiState.getClientVersion(),
1421+
false, true, true, true, false, EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
14191422

14201423
// Small helper function to make the code more readable.
14211424
auto cap = [setupCalls](CallCapture &&call) { setupCalls->emplace_back(std::move(call)); };

src/libANGLE/State.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ ANGLE_INLINE void ActiveTexturesCache::set(size_t textureIndex, Texture *texture
303303
mTextures[textureIndex] = texture;
304304
}
305305

306-
State::State(ContextID contextIn,
307-
const State *shareContextState,
306+
State::State(const State *shareContextState,
308307
TextureManager *shareTextures,
309308
const OverlayType *overlay,
310309
const EGLenum clientType,
@@ -319,7 +318,6 @@ State::State(ContextID contextIn,
319318
mClientType(clientType),
320319
mContextPriority(contextPriority),
321320
mClientVersion(clientVersion),
322-
mContext(contextIn),
323321
mBufferManager(AllocateOrGetSharedResourceManager(shareContextState, &State::mBufferManager)),
324322
mShaderProgramManager(
325323
AllocateOrGetSharedResourceManager(shareContextState, &State::mShaderProgramManager)),

src/libANGLE/State.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class ActiveTexturesCache final : angle::NonCopyable
8484
class State : angle::NonCopyable
8585
{
8686
public:
87-
State(ContextID contextIn,
88-
const State *shareContextState,
87+
State(const State *shareContextState,
8988
TextureManager *shareTextures,
9089
const OverlayType *overlay,
9190
const EGLenum clientType,
@@ -98,13 +97,11 @@ class State : angle::NonCopyable
9897
EGLenum contextPriority);
9998
~State();
10099

101-
int id() const { return mID; }
102-
103100
void initialize(Context *context);
104101
void reset(const Context *context);
105102

106103
// Getters
107-
ContextID getContextID() const { return mContext; }
104+
ContextID getContextID() const { return mID; }
108105
EGLenum getClientType() const { return mClientType; }
109106
EGLenum getContextPriority() const { return mContextPriority; }
110107
GLint getClientMajorVersion() const { return mClientVersion.major; }
@@ -824,12 +821,11 @@ class State : angle::NonCopyable
824821
// Dispatch table for buffer update functions.
825822
static const angle::PackedEnumMap<BufferBinding, BufferBindingSetter> kBufferSetters;
826823

827-
int mID;
824+
ContextID mID;
828825

829826
EGLenum mClientType;
830827
EGLenum mContextPriority;
831828
Version mClientVersion;
832-
ContextID mContext;
833829

834830
// Caps to use for validation
835831
Caps mCaps;

src/libANGLE/entry_points_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
9999

100100
inline int CID(const Context *context)
101101
{
102-
return context != nullptr ? context->id() : 0;
102+
return context != nullptr ? static_cast<int>(context->id()) : 0;
103103
}
104104
} // namespace gl
105105

0 commit comments

Comments
 (0)