Commit 42c453fe by Jamie Madill Committed by Commit Bot

Move perf test common files to a source set.

Similarly to a prior patch this organizes the common perf test sources into a single target. This will allow us to more easily support setting compiler flags on particular perf test sources. This also fixes some build errors that popped up when new warnings were enabled. Bug: angleproject:3630 Change-Id: I866885199f93a5055e8d160e39f72d1f8209bc75 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2103086 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 5df2c9ea
...@@ -219,6 +219,38 @@ if (is_win || is_linux || is_mac || is_android) { ...@@ -219,6 +219,38 @@ if (is_win || is_linux || is_mac || is_android) {
} }
} }
template("angle_perftests_common") {
assert(defined(invoker.test_utils))
angle_source_set(target_name) {
testonly = true
sources = [
"../third_party/trace_event/trace_event.h",
"perf_tests/ANGLEPerfTest.cpp",
"perf_tests/ANGLEPerfTest.h",
"perf_tests/ANGLEPerfTestArgs.cpp",
"perf_tests/ANGLEPerfTestArgs.h",
"perf_tests/DrawCallPerfParams.cpp",
"perf_tests/DrawCallPerfParams.h",
"perf_tests/third_party/perf/perf_result_reporter.cc",
"perf_tests/third_party/perf/perf_result_reporter.h",
"perf_tests/third_party/perf/perf_test.cc",
"perf_tests/third_party/perf/perf_test.h",
]
deps = [ "$angle_jsoncpp_dir:jsoncpp" ]
public_deps = [ "${invoker.test_utils}" ]
public_configs += [ "${angle_root}:libANGLE_config" ]
}
}
angle_perftests_common("angle_perftests_shared") {
test_utils = ":angle_common_test_utils_shared"
}
angle_perftests_common("angle_perftests_static") {
test_utils = ":angle_common_test_utils_static"
}
if (is_win || is_linux || is_android || is_mac) { if (is_win || is_linux || is_android || is_mac) {
import("angle_perftests.gni") import("angle_perftests.gni")
...@@ -229,17 +261,12 @@ if (is_win || is_linux || is_android || is_mac) { ...@@ -229,17 +261,12 @@ if (is_win || is_linux || is_android || is_mac) {
main = "angle_perftests_main" main = "angle_perftests_main"
deps = [ deps = [
":angle_common_test_utils_static", ":angle_perftests_static",
"$angle_jsoncpp_dir:jsoncpp",
"$angle_root:libANGLE", "$angle_root:libANGLE",
"$angle_root:libEGL_static", "$angle_root:libEGL_static",
"$angle_root:libGLESv2_static", "$angle_root:libGLESv2_static",
] ]
if (is_win) {
sources += angle_white_box_perf_tests_win_sources
}
# These tests depend on vulkan_command_buffer_utils, which is # These tests depend on vulkan_command_buffer_utils, which is
# not yet compatible with mac # not yet compatible with mac
if (angle_enable_vulkan && !is_mac) { if (angle_enable_vulkan && !is_mac) {
...@@ -249,11 +276,6 @@ if (is_win || is_linux || is_android || is_mac) { ...@@ -249,11 +276,6 @@ if (is_win || is_linux || is_android || is_mac) {
"$angle_root/src/libANGLE/renderer/vulkan:angle_vulkan_entry_points", "$angle_root/src/libANGLE/renderer/vulkan:angle_vulkan_entry_points",
] ]
} }
configs += [
"${angle_jsoncpp_dir}:jsoncpp_config",
"${angle_root}:libANGLE_config",
]
} }
} }
...@@ -267,10 +289,7 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) { ...@@ -267,10 +289,7 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) {
main = "angle_perftests_main" main = "angle_perftests_main"
deps = [ deps = [
":angle_common_test_utils_shared", ":angle_perftests_shared",
"$angle_jsoncpp_dir:jsoncpp",
"$angle_root:angle_common",
"$angle_root:angle_system_utils",
"$angle_spirv_tools_dir:spvtools_val", "$angle_spirv_tools_dir:spvtools_val",
] ]
...@@ -279,11 +298,6 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) { ...@@ -279,11 +298,6 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) {
"${angle_root}:libGLESv2", "${angle_root}:libGLESv2",
] ]
configs += [
"${angle_jsoncpp_dir}:jsoncpp_config",
"${angle_root}:libANGLE_config",
]
if (is_win || is_linux) { if (is_win || is_linux) {
data_deps += [ "${angle_root}/third_party/glmark2:glmark2_angle" ] data_deps += [ "${angle_root}/third_party/glmark2:glmark2_angle" ]
} }
......
...@@ -2,62 +2,49 @@ ...@@ -2,62 +2,49 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
_angle_perf_test_common_sources = [ angle_perf_tests_sources = [
"../third_party/trace_event/trace_event.h", "perf_tests/BindingPerf.cpp",
"perf_tests/ANGLEPerfTest.cpp", "perf_tests/BlitFramebufferPerf.cpp",
"perf_tests/ANGLEPerfTest.h", "perf_tests/BufferSubData.cpp",
"perf_tests/ANGLEPerfTestArgs.cpp", "perf_tests/ClearPerf.cpp",
"perf_tests/ANGLEPerfTestArgs.h", "perf_tests/DispatchComputePerf.cpp",
"perf_tests/third_party/perf/perf_result_reporter.cc", "perf_tests/DrawCallPerf.cpp",
"perf_tests/third_party/perf/perf_result_reporter.h", "perf_tests/DrawElementsPerf.cpp",
"perf_tests/third_party/perf/perf_test.cc", "perf_tests/DynamicPromotionPerfTest.cpp",
"perf_tests/third_party/perf/perf_test.h", "perf_tests/EGLMakeCurrentPerf.cpp",
"perf_tests/IndexConversionPerf.cpp",
"perf_tests/InstancingPerf.cpp",
"perf_tests/InterleavedAttributeData.cpp",
"perf_tests/LinkProgramPerfTest.cpp",
"perf_tests/MultiviewPerf.cpp",
"perf_tests/PointSprites.cpp",
"perf_tests/TextureSampling.cpp",
"perf_tests/TextureUploadPerf.cpp",
"perf_tests/TexturesPerf.cpp",
"perf_tests/UniformsPerf.cpp",
"perf_tests/VulkanBarriersPerf.cpp",
"perf_tests/glmark2Benchmark.cpp",
"test_utils/ANGLETest.cpp",
"test_utils/ANGLETest.h",
"test_utils/MultiviewTest.cpp",
"test_utils/MultiviewTest.h",
"test_utils/draw_call_perf_utils.cpp",
"test_utils/draw_call_perf_utils.h",
] ]
angle_perf_tests_sources = _angle_perf_test_common_sources + [ angle_white_box_perf_tests_sources = [
"perf_tests/BlitFramebufferPerf.cpp", "angle_unittests_utils.h",
"perf_tests/BindingPerf.cpp", "perf_tests/BitSetIteratorPerf.cpp",
"perf_tests/BufferSubData.cpp", "perf_tests/CompilerPerf.cpp",
"perf_tests/ClearPerf.cpp", "perf_tests/EGLInitializePerf.cpp", # Uses ANGLEGetDisplayPlatform, a
"perf_tests/DispatchComputePerf.cpp", # non-standard EP.
"perf_tests/DrawCallPerf.cpp", "perf_tests/ResultPerf.cpp",
"perf_tests/DrawCallPerfParams.cpp", ]
"perf_tests/DrawCallPerfParams.h",
"perf_tests/DrawElementsPerf.cpp",
"perf_tests/DynamicPromotionPerfTest.cpp",
"perf_tests/EGLMakeCurrentPerf.cpp",
"perf_tests/IndexConversionPerf.cpp",
"perf_tests/InstancingPerf.cpp",
"perf_tests/InterleavedAttributeData.cpp",
"perf_tests/LinkProgramPerfTest.cpp",
"perf_tests/MultiviewPerf.cpp",
"perf_tests/PointSprites.cpp",
"perf_tests/TextureSampling.cpp",
"perf_tests/TextureUploadPerf.cpp",
"perf_tests/TexturesPerf.cpp",
"perf_tests/UniformsPerf.cpp",
"perf_tests/VulkanBarriersPerf.cpp",
"perf_tests/glmark2Benchmark.cpp",
"test_utils/ANGLETest.cpp",
"test_utils/ANGLETest.h",
"test_utils/MultiviewTest.cpp",
"test_utils/MultiviewTest.h",
"test_utils/draw_call_perf_utils.cpp",
"test_utils/draw_call_perf_utils.h",
]
angle_white_box_perf_tests_sources =
_angle_perf_test_common_sources + [
"angle_unittests_utils.h",
"perf_tests/BitSetIteratorPerf.cpp",
"perf_tests/CompilerPerf.cpp",
"perf_tests/EGLInitializePerf.cpp", # Uses ANGLEGetDisplayPlatform, a
# non-standard EP.
"perf_tests/ResultPerf.cpp",
]
angle_white_box_perf_tests_win_sources = if (is_win) {
[ "perf_tests/IndexDataManagerTest.cpp" ] angle_white_box_perf_tests_sources +=
[ "perf_tests/IndexDataManagerTest.cpp" ]
}
angle_white_box_perf_tests_vulkan_sources = [ angle_white_box_perf_tests_vulkan_sources = [
"perf_tests/VulkanCommandBufferPerf.cpp", "perf_tests/VulkanCommandBufferPerf.cpp",
......
...@@ -220,13 +220,13 @@ void ANGLEPerfTest::run() ...@@ -220,13 +220,13 @@ void ANGLEPerfTest::run()
} }
// Calibrate to a fixed number of steps during an initial set time. // Calibrate to a fixed number of steps during an initial set time.
if (!gStepsToRunOverride.valid()) if (gStepsToRunOverride <= 0)
{ {
doRunLoop(kCalibrationRunTimeSeconds); doRunLoop(kCalibrationRunTimeSeconds);
// Scale steps down according to the time that exeeded one second. // Scale steps down according to the time that exeeded one second.
double scale = kCalibrationRunTimeSeconds / mTimer.getElapsedTime(); double scale = kCalibrationRunTimeSeconds / mTimer.getElapsedTime();
mStepsToRun = static_cast<size_t>(static_cast<double>(mNumStepsPerformed) * scale); mStepsToRun = static_cast<unsigned int>(static_cast<double>(mNumStepsPerformed) * scale);
// Calibration allows the perf test runner script to save some time. // Calibration allows the perf test runner script to save some time.
if (gCalibration) if (gCalibration)
...@@ -237,7 +237,7 @@ void ANGLEPerfTest::run() ...@@ -237,7 +237,7 @@ void ANGLEPerfTest::run()
} }
else else
{ {
mStepsToRun = gStepsToRunOverride.value(); mStepsToRun = gStepsToRunOverride;
} }
// Do another warmup run. Seems to consistently improve results. // Do another warmup run. Seems to consistently improve results.
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
namespace angle namespace angle
{ {
bool gCalibration = false; bool gCalibration = false;
Optional<unsigned int> gStepsToRunOverride; int gStepsToRunOverride = -1;
bool gEnableTrace = false; bool gEnableTrace = false;
const char *gTraceFile = "ANGLETrace.json"; const char *gTraceFile = "ANGLETrace.json";
} // namespace angle } // namespace angle
using namespace angle; using namespace angle;
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
namespace angle namespace angle
{ {
extern bool gCalibration; extern bool gCalibration;
extern Optional<unsigned int> gStepsToRunOverride; extern int gStepsToRunOverride;
extern bool gEnableTrace; extern bool gEnableTrace;
extern const char *gTraceFile; extern const char *gTraceFile;
inline bool OneFrame() inline bool OneFrame()
{ {
return gStepsToRunOverride.valid() && gStepsToRunOverride.value() == 1; return gStepsToRunOverride == 1;
} }
} // namespace angle } // namespace angle
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "perf_test.h" #include "perf_test.h"
#include "common/third_party/base/anglebase/no_destructor.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <vector> #include <vector>
...@@ -13,21 +15,21 @@ namespace ...@@ -13,21 +15,21 @@ namespace
std::string FormatString(const char *fmt, va_list vararg) std::string FormatString(const char *fmt, va_list vararg)
{ {
static std::vector<char> buffer(512); static angle::base::NoDestructor<std::vector<char>> buffer(512);
// Attempt to just print to the current buffer // Attempt to just print to the current buffer
int len = vsnprintf(&buffer[0], buffer.size(), fmt, vararg); int len = vsnprintf(buffer->data(), buffer->size(), fmt, vararg);
if (len < 0 || static_cast<size_t>(len) >= buffer.size()) if (len < 0 || static_cast<size_t>(len) >= buffer->size())
{ {
// Buffer was not large enough, calculate the required size and resize the buffer // Buffer was not large enough, calculate the required size and resize the buffer
len = vsnprintf(NULL, 0, fmt, vararg); len = vsnprintf(NULL, 0, fmt, vararg);
buffer.resize(len + 1); buffer->resize(len + 1);
// Print again // Print again
vsnprintf(&buffer[0], buffer.size(), fmt, vararg); vsnprintf(buffer->data(), buffer->size(), fmt, vararg);
} }
return std::string(buffer.data(), len); return std::string(buffer->data(), len);
} }
std::string StringPrintf(const char *fmt, ...) std::string StringPrintf(const char *fmt, ...)
......
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