mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-07 06:09:57 +03:00
Defines the interface between the test suite (or an other TraceLibrary class user) and trace libraries. TraceFunctions defines entry points for calls suite->trace, such as SetupReplay() or SetBinaryDataDir(). TraceCallbacks defines entry points for calls trace->suite, for example for loading .angledata.gz files. These are set up via the exported SetupEntryPoints() call. Functions like SetupReplay etc no longer need to be exported from the trace library. TraceInfo (parsed representation of the trace json) is moved to trace_interface as is. This is convenient for further changes to the fixture that will allow to easily move some of the captured parameters to json. This also moves Decompress functionality (and memory ownership) to test suite entirely, which avoids Decompress/Delete callbacks - the trace just calls LoadBinaryData via TraceCallbacks and TraceLibrary releases the memory either on FinishReplay or in its destructor. This should also take care of the memory leak described in https://crrev.com/c/3858185 Bug: b/286072760 Change-Id: Ibc6f6f64156ad805b1917c8fc41a3b0d2c0d6375 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4594445 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
297 lines
10 KiB
C++
297 lines
10 KiB
C++
//
|
|
// Copyright 2022 The ANGLE Project Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
// trace_interpreter.h:
|
|
// Parser and interpreter for the C-based replays.
|
|
//
|
|
|
|
#ifndef ANGLE_TRACE_INTERPRETER_H_
|
|
#define ANGLE_TRACE_INTERPRETER_H_
|
|
|
|
#include "common/frame_capture_utils.h"
|
|
#include "frame_capture_test_utils.h"
|
|
#include "traces_export.h"
|
|
|
|
namespace angle
|
|
{
|
|
struct TraceString
|
|
{
|
|
std::vector<std::string> strings;
|
|
std::vector<const char *> pointers;
|
|
};
|
|
using TraceStringMap = std::map<std::string, TraceString>;
|
|
|
|
constexpr size_t kMaxTokenSize = 200;
|
|
constexpr size_t kMaxParameters = 32;
|
|
using Token = char[kMaxTokenSize];
|
|
|
|
CallCapture ParseCallCapture(const Token &nameToken,
|
|
size_t numParamTokens,
|
|
const Token *paramTokens,
|
|
const TraceStringMap &strings);
|
|
|
|
template <typename T>
|
|
void PackParameter(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<uint32_t>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<int32_t>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<void *>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const int32_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<void **>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<int32_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<uint64_t>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<int64_t>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const int64_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<int64_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<uint64_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const char *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const void *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<uint32_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const uint32_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<float>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<uint8_t>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<float *>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const float *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<GLsync>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const char *const *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const char **>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<GLDEBUGPROCKHR>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<EGLDEBUGPROCKHR>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const struct AHardwareBuffer *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<EGLSetBlobFuncANDROID>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<EGLGetBlobFuncANDROID>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<int16_t>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const int16_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<char *>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<unsigned char *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const void *const *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<const uint64_t *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
#if defined(ANGLE_PLATFORM_WINDOWS)
|
|
|
|
template <>
|
|
void PackParameter<EGLNativeDisplayType>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
#endif // defined(ANGLE_PLATFORM_WINDOWS)
|
|
|
|
#if defined(ANGLE_PLATFORM_WINDOWS) || defined(ANGLE_PLATFORM_ANDROID)
|
|
template <>
|
|
void PackParameter<EGLNativeWindowType>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<EGLNativePixmapType>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
#endif // defined(ANGLE_PLATFORM_WINDOWS) || defined(ANGLE_PLATFORM_ANDROID)
|
|
|
|
// On Apple platforms, std::is_same<uint64_t, long> is false despite being both 8 bits.
|
|
#if defined(ANGLE_PLATFORM_APPLE) || !defined(ANGLE_IS_64_BIT_CPU)
|
|
template <>
|
|
void PackParameter<const long *>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
template <>
|
|
void PackParameter<long *>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<long>(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings);
|
|
|
|
template <>
|
|
void PackParameter<unsigned long>(ParamBuffer ¶ms,
|
|
const Token &token,
|
|
const TraceStringMap &strings);
|
|
#endif // defined(ANGLE_PLATFORM_APPLE) || !defined(ANGLE_IS_64_BIT_CPU)
|
|
|
|
template <typename T>
|
|
void PackParameter(ParamBuffer ¶ms, const Token &token, const TraceStringMap &strings)
|
|
{
|
|
static_assert(AssertFalse<T>::value, "No specialization for type.");
|
|
}
|
|
|
|
template <typename T>
|
|
struct ParameterPacker;
|
|
|
|
template <typename Ret>
|
|
struct ParameterPacker<Ret()>
|
|
{
|
|
static void Pack(ParamBuffer ¶ms, const Token *tokens, const TraceStringMap &strings) {}
|
|
};
|
|
|
|
template <typename Ret, typename Arg>
|
|
struct ParameterPacker<Ret(Arg)>
|
|
{
|
|
static void Pack(ParamBuffer ¶ms, const Token *tokens, const TraceStringMap &strings)
|
|
{
|
|
PackParameter<Arg>(params, tokens[0], strings);
|
|
}
|
|
};
|
|
|
|
template <typename Ret, typename Arg, typename... Args>
|
|
struct ParameterPacker<Ret(Arg, Args...)>
|
|
{
|
|
static void Pack(ParamBuffer ¶ms, const Token *tokens, const TraceStringMap &strings)
|
|
{
|
|
PackParameter<Arg>(params, tokens[0], strings);
|
|
ParameterPacker<Ret(Args...)>::Pack(params, &tokens[1], strings);
|
|
}
|
|
};
|
|
|
|
template <typename Ret, typename Arg, typename... Args>
|
|
struct ParameterPacker<Ret (*)(Arg, Args...)>
|
|
{
|
|
static void Pack(ParamBuffer ¶ms, const Token *tokens, const TraceStringMap &strings)
|
|
{
|
|
PackParameter<Arg>(params, tokens[0], strings);
|
|
ParameterPacker<Ret(Args...)>::Pack(params, &tokens[1], strings);
|
|
}
|
|
};
|
|
|
|
template <typename Func>
|
|
struct RemoveStdCall;
|
|
|
|
template <typename Ret, typename... Args>
|
|
struct RemoveStdCall<Ret KHRONOS_APIENTRY(Args...)>
|
|
{
|
|
using Type = Ret(Args...);
|
|
};
|
|
|
|
template <typename Func>
|
|
struct RemoveStdCall
|
|
{
|
|
using Type = Func;
|
|
};
|
|
|
|
template <typename Func>
|
|
ParamBuffer ParseParameters(const Token *paramTokens, const TraceStringMap &strings)
|
|
{
|
|
ParamBuffer params;
|
|
ParameterPacker<typename RemoveStdCall<Func>::Type>::Pack(params, paramTokens, strings);
|
|
return params;
|
|
}
|
|
} // namespace angle
|
|
|
|
extern "C" {
|
|
void SetupReplay();
|
|
void ReplayFrame(uint32_t frameIndex);
|
|
void ResetReplay();
|
|
ANGLE_REPLAY_EXPORT const char *GetSerializedContextState(uint32_t frameIndex);
|
|
} // extern "C"
|
|
|
|
#endif // ANGLE_TRACE_INTERPRETER_H_
|