mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 17:35:30 +00:00
Add Log.h to replace all uses of iostream
On Android iostream doesn't appear in logcat, the system log that's often used for printf debugging. Introduce Chromium/ANGLE like logging that looks like the following: InfoLog() << stuff << stuff; This makes sure the message is put in logcat on Android and removes static initializers from <iostream> BUG=dawn:286 Change-Id: Ie0d018f49bcac1a7b740739a6e59d45ae6728638 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14102 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: David Turner <digit@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
1d6250d016
commit
95586ff184
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
#include "common/Log.h"
|
||||
#include "common/Math.h"
|
||||
#include "common/Platform.h"
|
||||
#include "dawn/dawn_proc.h"
|
||||
@@ -28,7 +29,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -159,7 +159,7 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
||||
std::cout << "\n\nUsage: " << argv[0]
|
||||
InfoLog() << "\n\nUsage: " << argv[0]
|
||||
<< " [GTEST_FLAGS...] [-w] [-d] [-c] [--adapter-vendor-id=x]\n"
|
||||
" -w, --use-wire: Run the tests through the wire (defaults to no wire)\n"
|
||||
" -d, --enable-backend-validation: Enable backend validation (defaults"
|
||||
@@ -168,8 +168,7 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) {
|
||||
"(defaults to no capture)\n"
|
||||
" --skip-validation: Skip Dawn validation\n"
|
||||
" --adapter-vendor-id: Select adapter by vendor id to run end2end tests"
|
||||
"on multi-GPU systems \n"
|
||||
<< std::endl;
|
||||
"on multi-GPU systems \n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +187,7 @@ void DawnTestEnvironment::SetUp() {
|
||||
mInstance.get()->DiscoverDefaultAdapters();
|
||||
DiscoverOpenGLAdapter();
|
||||
|
||||
std::cout << "Testing configuration\n"
|
||||
InfoLog() << "Testing configuration\n"
|
||||
"---------------------\n"
|
||||
"UseWire: "
|
||||
<< (mUseWire ? "true" : "false")
|
||||
@@ -205,12 +204,8 @@ void DawnTestEnvironment::SetUp() {
|
||||
"BeginCaptureOnStartup: "
|
||||
<< (mBeginCaptureOnStartup ? "true" : "false")
|
||||
<< "\n"
|
||||
"\n";
|
||||
|
||||
// Preparing for outputting hex numbers
|
||||
std::cout << std::showbase << std::hex << std::setfill('0') << std::setw(4);
|
||||
|
||||
std::cout << "System adapters: \n";
|
||||
"\n"
|
||||
<< "System adapters: \n";
|
||||
for (const dawn_native::Adapter& adapter : mInstance->GetAdapters()) {
|
||||
const dawn_native::PCIInfo& pci = adapter.GetPCIInfo();
|
||||
|
||||
@@ -221,14 +216,16 @@ void DawnTestEnvironment::SetUp() {
|
||||
deviceId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
||||
<< pci.deviceId;
|
||||
|
||||
std::cout << " - \"" << pci.name << "\"\n";
|
||||
std::cout << " type: " << DeviceTypeName(adapter.GetDeviceType())
|
||||
<< ", backend: " << ParamName(adapter.GetBackendType()) << "\n";
|
||||
std::cout << " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
||||
// Preparing for outputting hex numbers
|
||||
InfoLog() << std::showbase << std::hex << std::setfill('0') << std::setw(4)
|
||||
|
||||
<< " - \"" << pci.name << "\"\n"
|
||||
<< " type: " << DeviceTypeName(adapter.GetDeviceType())
|
||||
<< ", backend: " << ParamName(adapter.GetBackendType()) << "\n"
|
||||
<< " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
||||
<< (mHasVendorIdFilter && mVendorIdFilter == pci.vendorId ? " [Selected]" : "")
|
||||
<< "\n";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void DawnTestEnvironment::TearDown() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#ifndef TESTS_DAWNTEST_H_
|
||||
#define TESTS_DAWNTEST_H_
|
||||
|
||||
#include "common/Log.h"
|
||||
#include "dawn/dawn_proc_table.h"
|
||||
#include "dawn/webgpu_cpp.h"
|
||||
#include "dawn_native/DawnNative.h"
|
||||
@@ -294,11 +295,11 @@ class DawnTestBase {
|
||||
};
|
||||
|
||||
// Skip a test when the given condition is satisfied.
|
||||
#define DAWN_SKIP_TEST_IF(condition) \
|
||||
if (condition) { \
|
||||
std::cout << "Test skipped: " #condition "." << std::endl; \
|
||||
GTEST_SKIP(); \
|
||||
return; \
|
||||
#define DAWN_SKIP_TEST_IF(condition) \
|
||||
if (condition) { \
|
||||
InfoLog() << "Test skipped: " #condition "."; \
|
||||
GTEST_SKIP(); \
|
||||
return; \
|
||||
}
|
||||
|
||||
template <typename Params = DawnTestParam>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "tests/perf_tests/DawnPerfTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Log.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
||||
#include "utils/Timer.h"
|
||||
@@ -112,14 +113,13 @@ DawnPerfTestEnvironment::DawnPerfTestEnvironment(int argc, char** argv)
|
||||
}
|
||||
|
||||
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
||||
std::cout
|
||||
InfoLog()
|
||||
<< "Additional flags:"
|
||||
<< " [--calibration] [--override-steps=x] [--enable-tracing] [--trace-file=file]\n"
|
||||
<< " --calibration: Only run calibration. Calibration allows the perf test"
|
||||
" runner script to save some time.\n"
|
||||
<< " --override-steps: Set a fixed number of steps to run for each test\n"
|
||||
<< " --trace-file: The file to dump trace results.\n"
|
||||
<< std::endl;
|
||||
<< " --trace-file: The file to dump trace results.\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user