Commit b45a80db by Corentin Wallez

Make perftests use ANGLE_INSTANTIATE_TEST

This also moves ANGLE_INSTANTIATE_TEST to its own header and makes it generic over the type of test parameter. BUG=angleproject:892 Change-Id: Id4e3929d7ad06964b3259015915be84a8ee414f9 Reviewed-on: https://chromium-review.googlesource.com/272553Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent e3b10e8d
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
'<(angle_path)/src/tests/test_utils/ANGLETest.cpp', '<(angle_path)/src/tests/test_utils/ANGLETest.cpp',
'<(angle_path)/src/tests/test_utils/ANGLETest.h', '<(angle_path)/src/tests/test_utils/ANGLETest.h',
'<(angle_path)/src/tests/test_utils/angle_test_configs.h', '<(angle_path)/src/tests/test_utils/angle_test_configs.h',
'<(angle_path)/src/tests/test_utils/angle_test_instantiate.h',
], ],
'angle_end2end_tests_win_sources': 'angle_end2end_tests_win_sources':
[ [
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
'perf_tests/TexSubImage.cpp', 'perf_tests/TexSubImage.cpp',
'perf_tests/third_party/perf/perf_test.cc', 'perf_tests/third_party/perf/perf_test.cc',
'perf_tests/third_party/perf/perf_test.h', 'perf_tests/third_party/perf/perf_test.h',
'test_utils/angle_test_instantiate.h',
], ],
'angle_perf_tests_win_sources': 'angle_perf_tests_win_sources':
[ [
...@@ -47,6 +48,10 @@ ...@@ -47,6 +48,10 @@
[ [
'<@(angle_perf_tests_sources)', '<@(angle_perf_tests_sources)',
], ],
'include_dirs':
[
'<(angle_path)/src/tests'
],
'conditions': 'conditions':
[ [
['OS=="win"', ['OS=="win"',
......
...@@ -74,10 +74,18 @@ std::string RenderTestParams::suffix() const ...@@ -74,10 +74,18 @@ std::string RenderTestParams::suffix() const
{ {
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE: return "_d3d11"; case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE: return "_d3d11";
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE: return "_d3d9"; case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE: return "_d3d9";
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE: return "_gl";
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: return "_gles";
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE: return "_default";
default: assert(0); return "_unk"; default: assert(0); return "_unk";
} }
} }
EGLint RenderTestParams::getRenderer() const
{
return requestedRenderer;
}
ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams) ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name, testParams.suffix()), : ANGLEPerfTest(name, testParams.suffix()),
mTestParams(testParams), mTestParams(testParams),
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "OSWindow.h" #include "OSWindow.h"
#include "Timer.h" #include "Timer.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/debug.h"
#include "test_utils/angle_test_instantiate.h"
class Event; class Event;
...@@ -54,6 +56,8 @@ struct RenderTestParams ...@@ -54,6 +56,8 @@ struct RenderTestParams
{ {
virtual std::string suffix() const; virtual std::string suffix() const;
EGLint getRenderer() const;
EGLint requestedRenderer; EGLint requestedRenderer;
EGLint deviceType; EGLint deviceType;
EGLint glesMajorVersion; EGLint glesMajorVersion;
......
...@@ -356,8 +356,7 @@ TEST_P(BufferSubDataBenchmark, Run) ...@@ -356,8 +356,7 @@ TEST_P(BufferSubDataBenchmark, Run)
run(); run();
} }
INSTANTIATE_TEST_CASE_P(BufferUpdates, ANGLE_INSTANTIATE_TEST(BufferSubDataBenchmark,
BufferSubDataBenchmark, BufferUpdateD3D11Params(), BufferUpdateD3D9Params());
::testing::Values(BufferUpdateD3D11Params(), BufferUpdateD3D9Params()));
} // namespace } // namespace
...@@ -206,10 +206,7 @@ TEST_P(DrawCallPerfBenchmark, Run) ...@@ -206,10 +206,7 @@ TEST_P(DrawCallPerfBenchmark, Run)
run(); run();
} }
INSTANTIATE_TEST_CASE_P(DrawCallPerf, ANGLE_INSTANTIATE_TEST(DrawCallPerfBenchmark,
DrawCallPerfBenchmark, DrawCallPerfD3D11Params(), DrawCallPerfD3D9Params(), DrawCallPerfValidationOnly());
::testing::Values(DrawCallPerfD3D11Params(),
DrawCallPerfD3D9Params(),
DrawCallPerfValidationOnly()));
} // namespace } // namespace
...@@ -195,8 +195,7 @@ TEST_P(IndexConversionPerfTest, Run) ...@@ -195,8 +195,7 @@ TEST_P(IndexConversionPerfTest, Run)
run(); run();
} }
INSTANTIATE_TEST_CASE_P(IndexConversionPerf, ANGLE_INSTANTIATE_TEST(IndexConversionPerfTest,
IndexConversionPerfTest, IndexConversionPerfD3D11Params());
::testing::Values(IndexConversionPerfD3D11Params()));
} // namespace } // namespace
...@@ -224,6 +224,5 @@ TEST_P(PointSpritesBenchmark, Run) ...@@ -224,6 +224,5 @@ TEST_P(PointSpritesBenchmark, Run)
run(); run();
} }
INSTANTIATE_TEST_CASE_P(Render, ANGLE_INSTANTIATE_TEST(PointSpritesBenchmark,
PointSpritesBenchmark, D3D11Params(), D3D9Params());
::testing::Values(D3D11Params(), D3D9Params()));
...@@ -293,6 +293,5 @@ TEST_P(TexSubImageBenchmark, Run) ...@@ -293,6 +293,5 @@ TEST_P(TexSubImageBenchmark, Run)
run(); run();
} }
INSTANTIATE_TEST_CASE_P(TextureUpdates, ANGLE_INSTANTIATE_TEST(TexSubImageBenchmark,
TexSubImageBenchmark, D3D11Params(), D3D9Params());
::testing::Values(D3D11Params(), D3D9Params()));
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include "common/debug.h" #include "angle_test_instantiate.h"
#include "EGLWindow.h" #include "EGLWindow.h"
namespace angle namespace angle
...@@ -25,6 +25,8 @@ struct PlatformParameters ...@@ -25,6 +25,8 @@ struct PlatformParameters
{ {
} }
EGLint getRenderer() const { return mEGLPlatformParameters.renderer; }
EGLint mClientVersion; EGLint mClientVersion;
EGLPlatformParameters mEGLPlatformParameters; EGLPlatformParameters mEGLPlatformParameters;
...@@ -87,42 +89,6 @@ inline std::ostream &operator<<(std::ostream& stream, ...@@ -87,42 +89,6 @@ inline std::ostream &operator<<(std::ostream& stream,
return stream; return stream;
} }
inline std::vector<PlatformParameters> FilterPlatforms(const PlatformParameters *platforms, size_t numPlatforms)
{
std::vector<PlatformParameters> filtered;
for (size_t i = 0; i < numPlatforms; i++)
{
switch (platforms[i].mEGLPlatformParameters.renderer)
{
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
#if defined(ANGLE_ENABLE_D3D9)
filtered.push_back(platforms[i]);
#endif
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
#if defined(ANGLE_ENABLE_D3D11)
filtered.push_back(platforms[i]);
#endif
break;
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#if defined(ANGLE_ENABLE_OPENGL)
filtered.push_back(platforms[i]);
#endif
break;
default:
UNREACHABLE();
break;
}
}
return filtered;
}
inline PlatformParameters ES2_D3D9() inline PlatformParameters ES2_D3D9()
{ {
EGLPlatformParameters eglParams( EGLPlatformParameters eglParams(
...@@ -435,10 +401,6 @@ inline PlatformParameters ES3_OPENGLES() ...@@ -435,10 +401,6 @@ inline PlatformParameters ES3_OPENGLES()
return PlatformParameters(3, eglParams); return PlatformParameters(3, eglParams);
} }
#define ANGLE_INSTANTIATE_TEST(testName, ...) \
const PlatformParameters testName##params[] = {__VA_ARGS__}; \
INSTANTIATE_TEST_CASE_P(, testName, testing::ValuesIn(FilterPlatforms(testName##params, ArraySize(testName##params))));
} // namespace angle } // namespace angle
#endif // ANGLE_TEST_CONFIGS_H_ #endif // ANGLE_TEST_CONFIGS_H_
//
// Copyright (c) 2014 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.
//
// angle_test_instantiate.h: Adds support for filtering parameterized
// tests by platform, so we skip unsupported configs.
#ifndef ANGLE_TEST_INSTANTIATE_H_
#define ANGLE_TEST_INSTANTIATE_H_
#include "common/debug.h"
namespace angle
{
// This functions is used to filter which tests should be registered,
// internally it T::getRenderer() const that should be implemented for test
// parameter types.
template <typename T>
inline std::vector<T> FilterTestParams(const T *params, size_t numParams)
{
std::vector<T> filtered;
for (size_t i = 0; i < numParams; i++)
{
switch (params[i].getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
filtered.push_back(params[i]);
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
#if defined(ANGLE_ENABLE_D3D9)
filtered.push_back(params[i]);
#endif
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
#if defined(ANGLE_ENABLE_D3D11)
filtered.push_back(params[i]);
#endif
break;
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#if defined(ANGLE_ENABLE_OPENGL)
filtered.push_back(params[i]);
#endif
break;
default:
UNREACHABLE();
break;
}
}
return filtered;
}
namespace detail {
// Used with decltype to get the type of the first argument.
template <typename T, typename ... Args>
T ReturnFirst(T first, Args...)
{
return first;
}
} // namespace detail
// Instantiate the test once for each extra argument. The types of all the
// arguments must match, and getRenderer must be implemented for that type.
#define ANGLE_INSTANTIATE_TEST(testName, ...) \
const decltype(::angle::detail::ReturnFirst(__VA_ARGS__)) testName##params[] = {__VA_ARGS__}; \
INSTANTIATE_TEST_CASE_P(, testName, testing::ValuesIn(::angle::FilterTestParams(testName##params, ArraySize(testName##params))));
} // namespace angle
#endif // ANGLE_TEST_INSTANTIATE_H_
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