Commit 49010904 by Jamie Madill Committed by Commit Bot

Refactor test parameters to TracePerfTest.

Reduces much of the code duplication by adding some new helper methods. The helpers allow combining test parameters similarly to how the GoogleTest Combine() and Values() generators work. They are more general and work by returning collections of test parameters instead of combining generator functions. Also updates the GLMark2 benchmark runner to use the new methods. Bug: angleproject:3630 Change-Id: Ibc10f9afb401e119d67a7119974a1a8d9b5abb60 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057353 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 25097b6c
...@@ -195,5 +195,4 @@ ParamsT NullDevice(const ParamsT &input) ...@@ -195,5 +195,4 @@ ParamsT NullDevice(const ParamsT &input)
return output; return output;
} }
} // namespace params } // namespace params
#endif // PERF_TESTS_ANGLE_PERF_TEST_H_ #endif // PERF_TESTS_ANGLE_PERF_TEST_H_
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
// //
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "common/PackedEnums.h"
#include "common/system_utils.h" #include "common/system_utils.h"
#include "tests/perf_tests/ANGLEPerfTest.h" #include "tests/perf_tests/ANGLEPerfTest.h"
#include "util/egl_loader_autogen.h" #include "util/egl_loader_autogen.h"
...@@ -33,6 +34,7 @@ enum class TracePerfTestID ...@@ -33,6 +34,7 @@ enum class TracePerfTestID
TRex800, TRex800,
TRex900, TRex900,
TRex1300, TRex1300,
InvalidEnum,
}; };
struct TracePerfParams final : public RenderTestParams struct TracePerfParams final : public RenderTestParams
...@@ -167,83 +169,43 @@ void TracePerfTest::drawBenchmark() ...@@ -167,83 +169,43 @@ void TracePerfTest::drawBenchmark()
stopGpuTimer(); stopGpuTimer();
} }
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_200_210() TEST_P(TracePerfTest, Run)
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex200;
return params;
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_800_810()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex800;
return params;
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_900_910()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex900;
return params;
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_1300_1310()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex1300;
return params;
}
TracePerfParams TRexReplayPerfVulkanParams_200_210()
{ {
TracePerfParams params; run();
params.eglParameters = VULKAN();
params.testID = TracePerfTestID::TRex200;
return params;
} }
TracePerfParams TRexReplayPerfVulkanParams_800_810() TracePerfParams GL(const TracePerfParams &in)
{ {
TracePerfParams params; TracePerfParams out = in;
params.eglParameters = VULKAN(); out.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex800; return out;
return params;
} }
TracePerfParams TRexReplayPerfVulkanParams_900_910() TracePerfParams Vulkan(const TracePerfParams &in)
{ {
TracePerfParams params; TracePerfParams out = in;
params.eglParameters = VULKAN(); out.eglParameters = VULKAN();
params.testID = TracePerfTestID::TRex900; return out;
return params;
} }
TracePerfParams TRexReplayPerfVulkanParams_1300_1310() // Note: WGL replay currently broken because interface locations are not remapped.
ANGLE_MAYBE_UNUSED TracePerfParams WGL(const TracePerfParams &in)
{ {
TracePerfParams params; TracePerfParams out = in;
params.eglParameters = VULKAN(); out.driver = angle::GLESDriverType::SystemWGL;
params.testID = TracePerfTestID::TRex1300; return out;
return params;
} }
TEST_P(TracePerfTest, Run) TracePerfParams CombineTestID(const TracePerfParams &in, TracePerfTestID id)
{ {
run(); TracePerfParams out = in;
out.testID = id;
return out;
} }
ANGLE_INSTANTIATE_TEST(TracePerfTest, std::vector<TracePerfParams> gTestsWithID =
TRexReplayPerfOpenGLOrGLESParams_200_210(), CombineWithValues({TracePerfParams()}, AllEnums<TracePerfTestID>(), CombineTestID);
TRexReplayPerfOpenGLOrGLESParams_800_810(), std::vector<TracePerfParams> gTestsWithRenderer = CombineWithFuncs(gTestsWithID, {GL, Vulkan});
TRexReplayPerfOpenGLOrGLESParams_900_910(), ANGLE_INSTANTIATE_TEST_ARRAY(TracePerfTest, gTestsWithRenderer);
TRexReplayPerfOpenGLOrGLESParams_1300_1310(),
TRexReplayPerfVulkanParams_200_210(),
TRexReplayPerfVulkanParams_800_810(),
TRexReplayPerfVulkanParams_900_910(),
TRexReplayPerfVulkanParams_1300_1310());
} // anonymous namespace } // anonymous namespace
...@@ -77,25 +77,23 @@ constexpr BenchmarkInfo kBenchmarks[] = { ...@@ -77,25 +77,23 @@ constexpr BenchmarkInfo kBenchmarks[] = {
{"loop:fragment-steps=5:fragment-uniform=true:vertex-steps=5", "loop"}, {"loop:fragment-steps=5:fragment-uniform=true:vertex-steps=5", "loop"},
}; };
using GLMark2BenchmarkTestParams = std::tuple<PlatformParameters, size_t>; struct GLMark2TestParams : public PlatformParameters
std::string GLMark2BenchmarkPrint(
const ::testing::TestParamInfo<GLMark2BenchmarkTestParams> &paramsInfo)
{ {
const GLMark2BenchmarkTestParams &params = paramsInfo.param; BenchmarkInfo info;
std::ostringstream out; };
out << std::get<0>(params) << '_';
out << kBenchmarks[std::get<1>(params)].name;
return out.str(); std::ostream &operator<<(std::ostream &os, const GLMark2TestParams &params)
{
os << static_cast<const PlatformParameters &>(params) << "_" << params.info.name;
return os;
} }
class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParams> class GLMark2Benchmark : public testing::TestWithParam<GLMark2TestParams>
{ {
public: public:
GLMark2Benchmark() GLMark2Benchmark()
{ {
switch (std::get<0>(GetParam()).getRenderer()) switch (GetParam().getRenderer())
{ {
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
mBackend = "d3d11"; mBackend = "d3d11";
...@@ -109,7 +107,7 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam ...@@ -109,7 +107,7 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam
default: default:
break; break;
} }
std::string story = kBenchmarks[std::get<1>(GetParam())].name; std::string story = GetParam().info.name;
mReporter = std::make_unique<perf_test::PerfResultReporter>("glmark2_" + mBackend, story); mReporter = std::make_unique<perf_test::PerfResultReporter>("glmark2_" + mBackend, story);
mReporter->RegisterImportantMetric(".fps", "fps"); mReporter->RegisterImportantMetric(".fps", "fps");
mReporter->RegisterImportantMetric(".score", "score"); mReporter->RegisterImportantMetric(".score", "score");
...@@ -123,7 +121,7 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam ...@@ -123,7 +121,7 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam
return; return;
} }
const BenchmarkInfo benchmarkInfo = kBenchmarks[std::get<1>(GetParam())]; const BenchmarkInfo benchmarkInfo = GetParam().info;
const char *benchmark = benchmarkInfo.glmark2Config; const char *benchmark = benchmarkInfo.glmark2Config;
const char *benchmarkName = benchmarkInfo.name; const char *benchmarkName = benchmarkInfo.name;
bool completeRun = benchmark == nullptr || benchmark[0] == '\0'; bool completeRun = benchmark == nullptr || benchmark[0] == '\0';
...@@ -275,11 +273,28 @@ TEST_P(GLMark2Benchmark, Run) ...@@ -275,11 +273,28 @@ TEST_P(GLMark2Benchmark, Run)
run(); run();
} }
ANGLE_INSTANTIATE_TEST_COMBINE_1(GLMark2Benchmark, GLMark2TestParams CombineEGLPlatform(const GLMark2TestParams &in, EGLPlatformParameters eglParams)
GLMark2BenchmarkPrint, {
testing::Range(static_cast<size_t>(0), ArraySize(kBenchmarks)), GLMark2TestParams out = in;
ES2_D3D11(), out.eglParameters = eglParams;
ES2_OPENGLES(), return out;
ES2_VULKAN()); }
GLMark2TestParams CombineInfo(const GLMark2TestParams &in, BenchmarkInfo info)
{
GLMark2TestParams out = in;
out.info = info;
return out;
}
using namespace egl_platform;
std::vector<GLMark2TestParams> gTestsWithInfo =
CombineWithValues({GLMark2TestParams()}, kBenchmarks, CombineInfo);
std::vector<EGLPlatformParameters> gEGLPlatforms = {D3D11(), OPENGLES(), VULKAN()};
std::vector<GLMark2TestParams> gTestsWithPlatform =
CombineWithValues(gTestsWithInfo, gEGLPlatforms, CombineEGLPlatform);
ANGLE_INSTANTIATE_TEST_ARRAY(GLMark2Benchmark, gTestsWithPlatform);
} // namespace } // namespace
...@@ -113,6 +113,10 @@ struct CombinedPrintToStringParamName ...@@ -113,6 +113,10 @@ struct CombinedPrintToStringParamName
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
#define ANGLE_INSTANTIATE_TEST_ARRAY(testName, valuesin) \
INSTANTIATE_TEST_SUITE_P(, testName, testing::ValuesIn(::angle::FilterTestParams(valuesin)), \
testing::PrintToStringParamName())
#define ANGLE_ALL_TEST_PLATFORMS_ES1 \ #define ANGLE_ALL_TEST_PLATFORMS_ES1 \
ES1_D3D11(), ES1_OPENGL(), ES1_OPENGLES(), ES1_VULKAN(), ES1_VULKAN_SWIFTSHADER() ES1_D3D11(), ES1_OPENGL(), ES1_OPENGLES(), ES1_VULKAN(), ES1_VULKAN_SWIFTSHADER()
...@@ -185,13 +189,10 @@ struct CombinedPrintToStringParamName ...@@ -185,13 +189,10 @@ struct CombinedPrintToStringParamName
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
// Instantiate the test for a combination of N parameters and the enumeration of platforms in the // Instantiate the test for a combination of N parameters and the
// extra args, similar to ANGLE_INSTANTIATE_TEST. The macros are defined only for the Ns currently // enumeration of platforms in the extra args, similar to
// in use, and can be expanded as necessary. // ANGLE_INSTANTIATE_TEST. The macros are defined only for the Ns
#define ANGLE_INSTANTIATE_TEST_COMBINE_1(testName, print, combine1, first, ...) \ // currently in use, and can be expanded as necessary.
const decltype(first) testName##params[] = {first, ##__VA_ARGS__}; \
INSTANTIATE_TEST_SUITE_P( \
, testName, testing::Combine(ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), combine1), print)
#define ANGLE_INSTANTIATE_TEST_COMBINE_4(testName, print, combine1, combine2, combine3, combine4, \ #define ANGLE_INSTANTIATE_TEST_COMBINE_4(testName, print, combine1, combine2, combine3, combine4, \
first, ...) \ first, ...) \
const decltype(first) testName##params[] = {first, ##__VA_ARGS__}; \ const decltype(first) testName##params[] = {first, ##__VA_ARGS__}; \
...@@ -210,21 +211,60 @@ struct CombinedPrintToStringParamName ...@@ -210,21 +211,60 @@ struct CombinedPrintToStringParamName
// Checks if a config is expected to be supported by checking a system-based white list. // Checks if a config is expected to be supported by checking a system-based white list.
bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters &param); bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters &param);
// Determines if a config is supported by trying to initialize it. Does not require SystemInfo. // Determines if a config is supported by trying to initialize it. Does
// not require SystemInfo.
bool IsConfigSupported(const PlatformParameters &param); bool IsConfigSupported(const PlatformParameters &param);
// Returns shared test system information. Can be used globally in the tests. // Returns shared test system information. Can be used globally in the
// tests.
SystemInfo *GetTestSystemInfo(); SystemInfo *GetTestSystemInfo();
// Returns a list of all enabled test platform names. For use in configuration enumeration. // Returns a list of all enabled test platform names. For use in
// configuration enumeration.
std::vector<std::string> GetAvailableTestPlatformNames(); std::vector<std::string> GetAvailableTestPlatformNames();
// Active config (e.g. ES2_Vulkan). // Active config (e.g. ES2_Vulkan).
extern std::string gSelectedConfig; extern std::string gSelectedConfig;
// Use a separate isolated process per test config. This works around driver flakiness when using // Use a separate isolated process per test config. This works around
// multiple APIs/windows/etc in the same process. // driver flakiness when using multiple APIs/windows/etc in the same
// process.
extern bool gSeparateProcessPerConfig; extern bool gSeparateProcessPerConfig;
// For use with ANGLE_INSTANTIATE_TEST_ARRAY
template <typename ParamsT>
using ModifierFunc = std::function<ParamsT(const ParamsT &)>;
template <typename ParamsT>
std::vector<ParamsT> CombineWithFuncs(const std::vector<ParamsT> &in,
const std::vector<ModifierFunc<ParamsT>> &modifiers)
{
std::vector<ParamsT> out;
for (const ParamsT &paramsIn : in)
{
for (ModifierFunc<ParamsT> modifier : modifiers)
{
out.push_back(modifier(paramsIn));
}
}
return out;
}
template <typename ParamT, typename ModifiersT, typename ModifierT>
std::vector<ParamT> CombineWithValues(const std::vector<ParamT> &in,
const ModifiersT &modifiers,
ParamT combine(const ParamT &, ModifierT))
{
std::vector<ParamT> out;
for (const ParamT &paramsIn : in)
{
for (ModifierT modifier : modifiers)
{
out.push_back(combine(paramsIn, modifier));
}
}
return out;
}
} // namespace angle } // namespace angle
#define ANGLE_SKIP_TEST_IF(COND) \ #define ANGLE_SKIP_TEST_IF(COND) \
......
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