Vulkan renderer backend (#2564)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
Adrian Cojocaru
2024-08-01 22:49:49 +03:00
committed by GitHub
parent 88993b9420
commit 072aa32e8b
103 changed files with 11459 additions and 135 deletions

View File

@@ -1,9 +1,9 @@
#pragma once
#include <ghc/filesystem.hpp>
#include <filesystem>
namespace mbgl {
namespace filesystem = ghc::filesystem;
namespace filesystem = std::filesystem;
} // namespace mbgl

View File

@@ -51,7 +51,7 @@ objc_library(
ios_unit_test(
name = "RenderTest",
minimum_os_version = "12.0",
minimum_os_version = "13.0",
provisioning_profile = "//platform/ios:xcode_profile",
runner = "@build_bazel_rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
test_host = "//platform/ios/test/common:RenderTestApp",

View File

@@ -103,12 +103,12 @@ mbgl::filesystem::path getValidPath(const std::string& manifestPath, const std::
std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifestPath, std::string testFilter) {
Manifest manifest;
const auto filePath = mbgl::filesystem::path(manifestPath);
manifest.manifestPath = manifestPath.substr(0, manifestPath.find(filePath.filename()));
manifest.manifestPath = manifestPath.substr(0, manifestPath.find(filePath.filename().generic_string()));
auto contents = readJson(filePath);
if (!contents.is<mbgl::JSDocument>()) {
mbgl::Log::Error(mbgl::Event::General,
"Provided manifest file: " + std::string(filePath) + " is not a valid json");
"Provided manifest file: " + filePath.generic_string() + " is not a valid json");
return std::nullopt;
}
@@ -116,11 +116,12 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
if (document.HasMember("result_path")) {
const auto& resultPathValue = document["result_path"];
if (!resultPathValue.IsString()) {
mbgl::Log::Warning(mbgl::Event::General,
"Invalid result_path is provided inside the manifest file: " + std::string(filePath));
mbgl::Log::Warning(
mbgl::Event::General,
"Invalid result_path is provided inside the manifest file: " + filePath.generic_string());
return std::nullopt;
}
manifest.resultPath = (getValidPath(manifest.manifestPath, resultPathValue.GetString()) / "").string();
manifest.resultPath = (getValidPath(manifest.manifestPath, resultPathValue.GetString()) / "").generic_string();
if (manifest.resultPath.empty()) {
return std::nullopt;
}
@@ -129,10 +130,10 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
const auto& cachePathValue = document["cache_path"];
if (!cachePathValue.IsString()) {
mbgl::Log::Warning(mbgl::Event::General,
"Invalid cache_path is provided inside the manifest file: " + std::string(filePath));
"Invalid cache_path is provided inside the manifest file: " + filePath.generic_string());
return std::nullopt;
}
manifest.cachePath = (getValidPath(manifest.manifestPath, ".") / cachePathValue.GetString()).string();
manifest.cachePath = (getValidPath(manifest.manifestPath, ".") / cachePathValue.GetString()).generic_string();
if (manifest.cachePath.empty()) {
return std::nullopt;
}
@@ -141,8 +142,9 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
if (document.HasMember("access_token")) {
const auto& apiKeyValue = document["access_token"];
if (!apiKeyValue.IsString()) {
mbgl::Log::Warning(mbgl::Event::General,
"Invalid access_token is provided inside the manifest file: " + std::string(filePath));
mbgl::Log::Warning(
mbgl::Event::General,
"Invalid access_token is provided inside the manifest file: " + filePath.generic_string());
return std::nullopt;
}
manifest.apiKey = apiKeyValue.GetString();
@@ -157,7 +159,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
mbgl::Log::Warning(mbgl::Event::General,
"Invalid base_test_path is provided inside the manifest "
"file: " +
std::string(filePath));
filePath.generic_string());
return std::nullopt;
}
baseTestPath = getValidPath(manifest.manifestPath, testPathValue.GetString());
@@ -169,8 +171,9 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
if (document.HasMember("metric_path")) {
const auto& metricPathValue = document["metric_path"];
if (!metricPathValue.IsString()) {
mbgl::Log::Warning(mbgl::Event::General,
"Invalid metric_path is provided inside the manifest file: " + std::string(filePath));
mbgl::Log::Warning(
mbgl::Event::General,
"Invalid metric_path is provided inside the manifest file: " + filePath.generic_string());
return std::nullopt;
}
expectedMetricPath = getValidPath(manifest.manifestPath, metricPathValue.GetString());
@@ -185,7 +188,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
mbgl::Log::Warning(mbgl::Event::General,
"Provided expectation_paths inside the manifest file: %s is "
"not a valid array" +
std::string(filePath));
filePath.generic_string());
return std::nullopt;
}
for (const auto& value : expectationPathValue.GetArray()) {
@@ -193,7 +196,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
mbgl::Log::Warning(mbgl::Event::General,
"Invalid expectation path item is provided inside the "
"manifest file: " +
std::string(filePath));
filePath.generic_string());
return std::nullopt;
}
expectationPaths.emplace_back(getValidPath(manifest.manifestPath, value.GetString()));
@@ -206,9 +209,9 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
if (document.HasMember("ignore_paths")) {
const auto& ignorePathValue = document["ignore_paths"];
if (!ignorePathValue.IsArray()) {
mbgl::Log::Warning(
mbgl::Event::General,
"Provided ignore_paths inside the manifest file: " + std::string(filePath) + " is not a valid array");
mbgl::Log::Warning(mbgl::Event::General,
"Provided ignore_paths inside the manifest file: " + filePath.generic_string() +
" is not a valid array");
return std::nullopt;
}
for (const auto& value : ignorePathValue.GetArray()) {
@@ -216,7 +219,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
mbgl::Log::Warning(mbgl::Event::General,
"Invalid ignore path item is provided inside the manifest "
"file: " +
std::string(filePath));
filePath.generic_string());
return std::nullopt;
}
ignorePaths.emplace_back(getValidPath(manifest.manifestPath, value.GetString()));
@@ -232,7 +235,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
if (!probesValue.IsArray()) {
mbgl::Log::Warning(
mbgl::Event::General,
"Provided probes inside the manifest file: " + std::string(filePath) + "is not a valid array");
"Provided probes inside the manifest file: " + filePath.generic_string() + "is not a valid array");
return std::nullopt;
}
for (const auto& value : probesValue.GetArray()) {
@@ -240,7 +243,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
mbgl::Log::Warning(mbgl::Event::General,
"Invalid probe type is provided inside the manifest "
"file: " +
std::string(filePath));
filePath.generic_string());
return std::nullopt;
}
manifest.probes.emplace(value.GetString());
@@ -251,7 +254,7 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
const auto& filterValue = document["filter"];
if (!filterValue.IsString()) {
mbgl::Log::Warning(mbgl::Event::General,
"Invalid filter is provided inside the manifest file: " + std::string(filePath));
"Invalid filter is provided inside the manifest file: " + filePath.generic_string());
return std::nullopt;
}
@@ -276,14 +279,14 @@ std::optional<Manifest> ManifestParser::parseManifest(const std::string& manifes
for (auto& testPath : mbgl::filesystem::recursive_directory_iterator(path)) {
// Skip paths that fail regexp search.
if (!testFilter.empty() && !std::regex_search(testPath.path().string(), std::regex(testFilter))) {
if (!testFilter.empty() && !std::regex_search(testPath.path().generic_string(), std::regex(testFilter))) {
continue;
}
if (testPath.path().filename() == "style.json") {
const auto defaultExpectationPath{std::move(mbgl::filesystem::path(testPath).remove_filename())};
const auto rootLength = manifest.testRootPath.length();
auto testId = defaultExpectationPath.string();
auto testId = defaultExpectationPath.generic_string();
testId = testId.substr(rootLength + 1, testId.length() - rootLength - 1);
std::vector<mbgl::filesystem::path> expectedMetricPaths{expectedMetricPath};

View File

@@ -171,7 +171,7 @@ std::string toJSON(const std::vector<mbgl::Feature>& features, unsigned indent,
}
JSONReply readJson(const mbgl::filesystem::path& jsonPath) {
auto maybeJSON = mbgl::util::readFile(jsonPath);
auto maybeJSON = mbgl::util::readFile(jsonPath.generic_string());
if (!maybeJSON) {
return {std::string("Unable to open file ") + jsonPath.string()};
}
@@ -311,17 +311,17 @@ std::vector<std::string> readExpectedEntries(const std::regex& regex, const mbgl
} // namespace
std::vector<std::string> readExpectedImageEntries(const mbgl::filesystem::path& base) {
static const std::regex regex(".*/expected.*.png");
static const std::regex regex(".*[/\\\\]expected.*.png");
return readExpectedEntries(regex, base);
}
std::vector<std::string> readExpectedMetricEntries(const mbgl::filesystem::path& base) {
static const std::regex regex(".*/metrics.json");
static const std::regex regex(".*[/\\\\]metrics.json");
return readExpectedEntries(regex, base);
}
std::vector<std::string> readExpectedJSONEntries(const mbgl::filesystem::path& base) {
static const std::regex regex(".*/expected.*.json");
static const std::regex regex(".*[/\\\\]expected.*.json");
return readExpectedEntries(regex, base);
}
@@ -960,7 +960,7 @@ TestOperations parseTestOperations(TestMetadata& metadata) {
}
size_t size = 0;
if (compressed) {
size = mbgl::util::compress(*mbgl::util::readFile(filePath)).size();
size = mbgl::util::compress(*mbgl::util::readFile(filePath.generic_string())).size();
} else {
size = mbgl::filesystem::file_size(filePath);
}

View File

@@ -127,7 +127,7 @@ ArgumentsTuple parseArguments(int argc, char** argv) {
shuffle,
online,
seed,
manifestPath.string(),
manifestPath.generic_string(),
updateResults,
std::move(testFilter)};
}
@@ -194,7 +194,7 @@ int runRenderTests(int argc, char** argv, std::function<void()> testStatus) {
bool shouldIgnore = false;
std::string ignoreReason;
const std::string ignoreName = id;
const mbgl::filesystem::path ignoreName(id);
const auto it = std::find_if(
ignores.cbegin(), ignores.cend(), [&ignoreName](auto pair) { return pair.first == ignoreName; });
if (it != ignores.end()) {
@@ -266,7 +266,7 @@ int runRenderTests(int argc, char** argv, std::function<void()> testStatus) {
}
}
const std::string manifestName = mbgl::filesystem::path(manifestPath).stem();
const std::string manifestName = mbgl::filesystem::path(manifestPath).stem().generic_string();
const std::string resultPath = manifest.getResultPath() + "/" + manifestName + ".html";
std::string resultsHTML = createResultPage(stats, metadatas, shuffle, seed);
mbgl::util::write_file(resultPath, resultsHTML);
@@ -300,7 +300,7 @@ int runRenderTests(int argc, char** argv, std::function<void()> testStatus) {
100.0 * stats.erroredTests / count);
}
printf("Results at: %s\n", mbgl::filesystem::canonical(resultPath).c_str());
printf("Results at: %s\n", mbgl::filesystem::canonical(resultPath).generic_string().c_str());
return returnCode;
}

View File

@@ -290,7 +290,7 @@ void TestRunner::checkProbingResults(TestMetadata& resultMetadata) {
const std::string& message = std::string()) {
try {
mbgl::filesystem::create_directories(path);
mbgl::util::write_file(path / "metrics.json", serializeMetrics(resultMetadata.metrics));
mbgl::util::write_file((path / "metrics.json").generic_string(), serializeMetrics(resultMetadata.metrics));
resultMetadata.errorMessage += message;
} catch (mbgl::filesystem::filesystem_error& ex) {
const auto msg = "Failed to write metrics. path='" + path.string() + "' err='" + ex.what() +