summaryrefslogtreecommitdiff
path: root/render-test/metadata.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'render-test/metadata.hpp')
-rw-r--r--render-test/metadata.hpp89
1 files changed, 85 insertions, 4 deletions
diff --git a/render-test/metadata.hpp b/render-test/metadata.hpp
index d23a0fb296..567c89e3fc 100644
--- a/render-test/metadata.hpp
+++ b/render-test/metadata.hpp
@@ -1,14 +1,22 @@
#pragma once
+#include <mbgl/util/geo.hpp>
#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/size.hpp>
#include <mbgl/map/mode.hpp>
+#include <mbgl/renderer/query.hpp>
#include "filesystem.hpp"
#include <map>
+namespace mbgl {
+namespace gfx {
+struct RenderingStats;
+}
+} // namespace mbgl
+
struct TestStatistics {
TestStatistics() = default;
@@ -20,6 +28,10 @@ struct TestStatistics {
};
struct TestPaths {
+ TestPaths() = default;
+ TestPaths(mbgl::filesystem::path stylePath_, std::vector<mbgl::filesystem::path> expectations_)
+ : stylePath(std::move(stylePath_)), expectations(std::move(expectations_)) {}
+
mbgl::filesystem::path stylePath;
std::vector<mbgl::filesystem::path> expectations;
@@ -29,20 +41,83 @@ struct TestPaths {
}
};
+inline std::tuple<bool, float> checkValue(float expected, float actual, float tolerance) {
+ float delta = expected * tolerance;
+ assert(delta >= 0.0f);
+ return std::make_tuple(std::abs(expected - actual) <= delta, delta);
+}
+
+struct FileSizeProbe {
+ FileSizeProbe() = default;
+ FileSizeProbe(std::string path_, uintmax_t size_, float tolerance_)
+ : path(std::move(path_)), size(size_), tolerance(tolerance_) {}
+
+ std::string path;
+ uintmax_t size;
+ float tolerance;
+};
+
struct MemoryProbe {
MemoryProbe() = default;
- MemoryProbe(size_t peak_, size_t allocations_)
- : peak(peak_)
- , allocations(allocations_) {}
+ MemoryProbe(size_t peak_, size_t allocations_) : peak(peak_), allocations(allocations_), tolerance(0.0f) {}
size_t peak;
size_t allocations;
+ float tolerance;
+
+ static std::tuple<bool, float> checkPeak(const MemoryProbe& expected, const MemoryProbe& actual) {
+ return checkValue(expected.peak, actual.peak, actual.tolerance);
+ }
+
+ static std::tuple<bool, float> checkAllocations(const MemoryProbe& expected, const MemoryProbe& actual) {
+ return checkValue(expected.allocations, actual.allocations, actual.tolerance);
+ }
+};
+
+struct FpsProbe {
+ float average = 0.0;
+ float minOnePc = 0.0;
+ float tolerance = 0.0f;
+};
+
+struct NetworkProbe {
+ NetworkProbe() = default;
+ NetworkProbe(size_t requests_, size_t transferred_) : requests(requests_), transferred(transferred_) {}
+
+ size_t requests;
+ size_t transferred;
+};
+
+struct GfxProbe {
+ struct Memory {
+ Memory() = default;
+ Memory(int allocated_, int peak_) : allocated(allocated_), peak(peak_) {}
+
+ int allocated;
+ int peak;
+ };
+
+ GfxProbe() = default;
+ GfxProbe(const mbgl::gfx::RenderingStats&, const GfxProbe&);
+
+ int numDrawCalls;
+ int numTextures;
+ int numBuffers;
+ int numFrameBuffers;
+
+ Memory memTextures;
+ Memory memIndexBuffers;
+ Memory memVertexBuffers;
};
class TestMetrics {
public:
- bool isEmpty() const { return memory.empty(); }
+ bool isEmpty() const { return fileSize.empty() && memory.empty() && network.empty() && fps.empty() && gfx.empty(); }
+ std::map<std::string, FileSizeProbe> fileSize;
std::map<std::string, MemoryProbe> memory;
+ std::map<std::string, NetworkProbe> network;
+ std::map<std::string, FpsProbe> fps;
+ std::map<std::string, GfxProbe> gfx;
};
struct TestMetadata {
@@ -50,6 +125,8 @@ struct TestMetadata {
TestPaths paths;
mbgl::JSDocument document;
+ bool renderTest = true;
+ bool outputsImage = true;
mbgl::Size size{ 512u, 512u };
float pixelRatio = 1.0f;
@@ -61,6 +138,9 @@ struct TestMetadata {
bool axonometric = false;
double xSkew = 0.0;
double ySkew = 1.0;
+ mbgl::ScreenCoordinate queryGeometry{0u, 0u};
+ mbgl::ScreenBox queryGeometryBox{{0u, 0u}, {0u, 0u}};
+ mbgl::RenderedQueryOptions queryOptions;
// TODO
uint32_t fadeDuration = 0;
@@ -72,6 +152,7 @@ struct TestMetadata {
std::string color;
std::string actual;
+ std::string actualJson;
std::string expected;
std::string diff;