Commit 1cc49bb2 by Jamie Madill Committed by Commit Bot

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/+/2134408Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
parent dd29370c
......@@ -255,8 +255,7 @@ Context::Context(egl::Display *display,
const egl::AttributeMap &attribs,
const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions)
: mState(reinterpret_cast<ContextID>(this),
shareContext ? &shareContext->mState : nullptr,
: mState(shareContext ? &shareContext->mState : nullptr,
shareTextures,
&mOverlay,
clientType,
......
......@@ -344,7 +344,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
const egl::ClientExtensions &clientExtensions);
// Use for debugging.
int id() const { return mState.mID; }
ContextID id() const { return mState.getContextID(); }
egl::Error onDestroy(const egl::Display *display);
~Context() override;
......
......@@ -171,10 +171,10 @@ std::string GetDefaultOutDirectory()
struct FmtCapturePrefix
{
FmtCapturePrefix(int contextIdIn, const std::string &captureLabelIn)
FmtCapturePrefix(gl::ContextID contextIdIn, const std::string &captureLabelIn)
: contextId(contextIdIn), captureLabel(captureLabelIn)
{}
int contextId;
gl::ContextID contextId;
const std::string &captureLabel;
};
......@@ -188,26 +188,26 @@ std::ostream &operator<<(std::ostream &os, const FmtCapturePrefix &fmt)
{
os << fmt.captureLabel;
}
os << "_capture_context" << fmt.contextId;
os << "_capture_context" << static_cast<int>(fmt.contextId);
return os;
}
struct FmtReplayFunction
{
FmtReplayFunction(int contextIdIn, uint32_t frameIndexIn)
FmtReplayFunction(gl::ContextID contextIdIn, uint32_t frameIndexIn)
: contextId(contextIdIn), frameIndex(frameIndexIn)
{}
int contextId;
gl::ContextID contextId;
uint32_t frameIndex;
};
std::ostream &operator<<(std::ostream &os, const FmtReplayFunction &fmt)
{
os << "ReplayContext" << fmt.contextId << "Frame" << fmt.frameIndex << "()";
os << "ReplayContext" << static_cast<int>(fmt.contextId) << "Frame" << fmt.frameIndex << "()";
return os;
}
std::string GetCaptureFileName(int contextId,
std::string GetCaptureFileName(gl::ContextID contextId,
const std::string &captureLabel,
uint32_t frameIndex,
const char *suffix)
......@@ -219,7 +219,7 @@ std::string GetCaptureFileName(int contextId,
}
std::string GetCaptureFilePath(const std::string &outDir,
int contextId,
gl::ContextID contextId,
const std::string &captureLabel,
uint32_t frameIndex,
const char *suffix)
......@@ -645,7 +645,9 @@ struct SaveFileHelper
std::string filePath;
};
std::string GetBinaryDataFilePath(bool compression, int contextId, const std::string &captureLabel)
std::string GetBinaryDataFilePath(bool compression,
gl::ContextID contextId,
const std::string &captureLabel)
{
std::stringstream fnameStream;
fnameStream << FmtCapturePrefix(contextId, captureLabel) << ".angledata";
......@@ -658,7 +660,7 @@ std::string GetBinaryDataFilePath(bool compression, int contextId, const std::st
void SaveBinaryData(bool compression,
const std::string &outDir,
int contextId,
gl::ContextID contextId,
const std::string &captureLabel,
const std::vector<uint8_t> &binaryData)
{
......@@ -695,7 +697,7 @@ void SaveBinaryData(bool compression,
void WriteLoadBinaryDataCall(bool compression,
std::ostream &out,
int contextId,
gl::ContextID contextId,
const std::string &captureLabel)
{
std::string binaryDataFileName = GetBinaryDataFilePath(compression, contextId, captureLabel);
......@@ -704,7 +706,7 @@ void WriteLoadBinaryDataCall(bool compression,
void WriteCppReplay(bool compression,
const std::string &outDir,
int contextId,
gl::ContextID contextId,
const std::string &captureLabel,
uint32_t frameIndex,
const std::vector<CallCapture> &frameCalls,
......@@ -730,7 +732,7 @@ void WriteCppReplay(bool compression,
if (frameIndex == 0 || !setupCalls.empty())
{
out << "void SetupContext" << Str(contextId) << "Replay()\n";
out << "void SetupContext" << Str(static_cast<int>(contextId)) << "Replay()\n";
out << "{\n";
std::stringstream setupCallStream;
......@@ -786,7 +788,7 @@ void WriteCppReplay(bool compression,
void WriteCppReplayIndexFiles(bool compression,
const std::string &outDir,
int contextId,
gl::ContextID contextId,
const std::string &captureLabel,
uint32_t frameStart,
uint32_t frameEnd,
......@@ -834,8 +836,9 @@ void WriteCppReplayIndexFiles(bool compression,
header << "constexpr uint32_t kReplayFrameStart = " << frameStart << ";\n";
header << "constexpr uint32_t kReplayFrameEnd = " << frameEnd << ";\n";
header << "\n";
header << "void SetupContext" << contextId << "Replay();\n";
header << "void ReplayContext" << contextId << "Frame(uint32_t frameIndex);\n";
header << "void SetupContext" << static_cast<int>(contextId) << "Replay();\n";
header << "void ReplayContext" << static_cast<int>(contextId)
<< "Frame(uint32_t frameIndex);\n";
header << "\n";
header << "using FramebufferChangeCallback = void(*)(void *userData, GLenum target, GLuint "
"framebuffer);\n";
......@@ -946,14 +949,15 @@ void WriteCppReplayIndexFiles(bool compression,
source << "}\n";
source << "\n";
source << "void ReplayContext" << contextId << "Frame(uint32_t frameIndex)\n";
source << "void ReplayContext" << static_cast<int>(contextId) << "Frame(uint32_t frameIndex)\n";
source << "{\n";
source << " switch (frameIndex)\n";
source << " {\n";
for (uint32_t frameIndex = frameStart; frameIndex < frameEnd; ++frameIndex)
{
source << " case " << frameIndex << ":\n";
source << " ReplayContext" << contextId << "Frame" << frameIndex << "();\n";
source << " ReplayContext" << static_cast<int>(contextId) << "Frame"
<< frameIndex << "();\n";
source << " break;\n";
}
source << " default:\n";
......@@ -1413,9 +1417,8 @@ void CaptureMidExecutionSetup(const gl::Context *context,
const TextureLevelDataMap &cachedTextureLevelData)
{
const gl::State &apiState = context->getState();
gl::State replayState(0, nullptr, nullptr, nullptr, EGL_OPENGL_ES_API,
apiState.getClientVersion(), false, true, true, true, false,
EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
gl::State replayState(nullptr, nullptr, nullptr, EGL_OPENGL_ES_API, apiState.getClientVersion(),
false, true, true, true, false, EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
// Small helper function to make the code more readable.
auto cap = [setupCalls](CallCapture &&call) { setupCalls->emplace_back(std::move(call)); };
......
......@@ -303,8 +303,7 @@ ANGLE_INLINE void ActiveTexturesCache::set(size_t textureIndex, Texture *texture
mTextures[textureIndex] = texture;
}
State::State(ContextID contextIn,
const State *shareContextState,
State::State(const State *shareContextState,
TextureManager *shareTextures,
const OverlayType *overlay,
const EGLenum clientType,
......@@ -319,7 +318,6 @@ State::State(ContextID contextIn,
mClientType(clientType),
mContextPriority(contextPriority),
mClientVersion(clientVersion),
mContext(contextIn),
mBufferManager(AllocateOrGetSharedResourceManager(shareContextState, &State::mBufferManager)),
mShaderProgramManager(
AllocateOrGetSharedResourceManager(shareContextState, &State::mShaderProgramManager)),
......
......@@ -84,8 +84,7 @@ class ActiveTexturesCache final : angle::NonCopyable
class State : angle::NonCopyable
{
public:
State(ContextID contextIn,
const State *shareContextState,
State(const State *shareContextState,
TextureManager *shareTextures,
const OverlayType *overlay,
const EGLenum clientType,
......@@ -98,13 +97,11 @@ class State : angle::NonCopyable
EGLenum contextPriority);
~State();
int id() const { return mID; }
void initialize(Context *context);
void reset(const Context *context);
// Getters
ContextID getContextID() const { return mContext; }
ContextID getContextID() const { return mID; }
EGLenum getClientType() const { return mClientType; }
EGLenum getContextPriority() const { return mContextPriority; }
GLint getClientMajorVersion() const { return mClientVersion.major; }
......@@ -824,12 +821,11 @@ class State : angle::NonCopyable
// Dispatch table for buffer update functions.
static const angle::PackedEnumMap<BufferBinding, BufferBindingSetter> kBufferSetters;
int mID;
ContextID mID;
EGLenum mClientType;
EGLenum mContextPriority;
Version mClientVersion;
ContextID mContext;
// Caps to use for validation
Caps mCaps;
......
......@@ -99,7 +99,7 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
inline int CID(const Context *context)
{
return context != nullptr ? context->id() : 0;
return context != nullptr ? static_cast<int>(context->id()) : 0;
}
} // namespace gl
......
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