Adding benchmark

This commit is contained in:
Dynamitos
2024-07-05 12:02:46 +02:00
parent 8418cdbd11
commit fd8dc5ed0f
47 changed files with 1071 additions and 1010 deletions
+5
View File
@@ -0,0 +1,5 @@
target_sources(Benchmark
PUBLIC
main.cpp
PlayView.h
PlayView.cpp)
+63
View File
@@ -0,0 +1,63 @@
#include "PlayView.h"
#include "Window/Window.h"
#include <fstream>
#include <fmt/format.h>
using namespace Seele;
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath, bool useMeshCulling)
: GameView(graphics, window, createInfo, dllPath) {
getGlobals().useDepthCulling = useMeshCulling;
queryThread = std::thread([&]() {
PRenderGraphResources res = renderGraph.getResources();
Gfx::PPipelineStatisticsQuery cachedQuery = res->requestQuery("CACHED_QUERY");
Gfx::PPipelineStatisticsQuery depthQuery = res->requestQuery("DEPTH_QUERY");
Gfx::PPipelineStatisticsQuery baseQuery = res->requestQuery("BASEPASS_QUERY");
Gfx::PPipelineStatisticsQuery lightCullQuery = res->requestQuery("LIGHTCULL_QUERY");
Gfx::PPipelineStatisticsQuery visibilityQuery = res->requestQuery("VISIBILITY_QUERY");
Gfx::PTimestampQuery timeQuery = res->requestTimestampQuery("TIMESTAMP");
std::ofstream stats(fmt::format("stats{}.csv", useMeshCulling ? "" : "NOCULL"));
stats << std::fixed << std::setprecision(0);
stats << "RelTime,"
<< "CachedIAV,CachedIAP,CachedVS,CachedClipInv,CachedClipPrim,CachedFS,CachedCS,CachedTS,CachedMS,"
<< "DepthIAV,DepthIAP,DepthVS,DepthClipInv,DepthClipPrim,DepthFS,DepthCS,DepthTS,DepthMS,"
<< "BaseIAV,BaseIAP,BaseVS,BaseClipInv,BaseClipPrim,BaseFS,BaseCS,BaseTS,BaseMS,"
<< "LightCullIAV,LightCullIAP,LightCullVS,LightCullClipInv,LightCullClipPrim,LightCullFS,LightCullCS,LightCullTS,LightCullMS,"
<< "VisibilityIAV,VisibilityIAP,VisibilityVS,VisibilityClipInv,VisibilityClipPrim,VisibilityFS,VisibilityCS,VisibilityTS,"
"VisibilityMS,"
<< "CACHED,MIPGEN,DEPTHCULL,VISIBILITY,LIGHTCULL,BASE,FrameTime" << std::endl;
float start = 0;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
while (getGlobals().running) {
auto timestamps = timeQuery->getResults();
auto cachedResults = cachedQuery->getResults();
auto depthResults = depthQuery->getResults();
auto baseResults = baseQuery->getResults();
auto lightCullResults = lightCullQuery->getResults();
auto visiblityResults = visibilityQuery->getResults();
if (start == 0) {
start = timestamps[0].time;
}
stats << timestamps[0].time - start << "," << cachedResults << depthResults << baseResults << lightCullResults
<< visiblityResults << timestamps[1].time - timestamps[0].time << "," << timestamps[2].time - timestamps[1].time << ","
<< timestamps[3].time - timestamps[2].time << "," << timestamps[4].time - timestamps[3].time << ","
<< timestamps[5].time - timestamps[4].time << "," << timestamps[6].time - timestamps[5].time << ","
<< timestamps[6].time - timestamps[0].time << std::endl;
stats.flush();
}
});
}
PlayView::~PlayView() {}
void PlayView::beginUpdate() { GameView::beginUpdate(); }
void PlayView::update() { GameView::update(); }
void PlayView::commitUpdate() { GameView::commitUpdate(); }
void PlayView::prepareRender() { GameView::prepareRender(); }
void PlayView::render() { GameView::render(); }
void PlayView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier) { GameView::keyCallback(code, action, modifier); }
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include "Window/GameView.h"
namespace Seele {
class PlayView : public GameView {
public:
PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath, bool useMeshCulling);
virtual ~PlayView();
virtual void beginUpdate() override;
virtual void update() override;
virtual void commitUpdate() override;
virtual void prepareRender() override;
virtual void render() override;
virtual void keyCallback(Seele::KeyCode code, Seele::InputAction action, Seele::KeyModifier modifier) override;
private:
std::thread queryThread;
};
DECLARE_REF(PlayView)
} // namespace Seele
+60
View File
@@ -0,0 +1,60 @@
#include "Asset/AssetRegistry.h"
#include "Graphics/Initializer.h"
#include "Graphics/StaticMeshVertexData.h"
#include "Graphics/Vulkan/Graphics.h"
#include "PlayView.h"
#include "Window/WindowManager.h"
#include <fmt/core.h>
#include <random>
using namespace Seele;
// make it global so it gets deleted last and automatically
static Gfx::OGraphics graphics;
int main(int argc, char** argv) {
if (argc > 2)
{
return -1;
}
bool useDepthCulling = true;
if (argc == 2 && strcmp(argv[1], "NOCULL") == 0)
{
useDepthCulling = false;
}
std::filesystem::path binaryPath = "MeshShadingDemo.dll";
graphics = new Vulkan::Graphics();
GraphicsInitializer initializer;
graphics->init(initializer);
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
vd->init(graphics);
OWindowManager windowManager = new WindowManager();
AssetRegistry::init("Assets", graphics);
vd->commitMeshes();
WindowCreateInfo mainWindowInfo = {
.width = 1920,
.height = 1080,
.title = "Benchmark",
.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB,
};
auto window = windowManager->addWindow(graphics, mainWindowInfo);
ViewportCreateInfo sceneViewInfo = {
.dimensions =
{
.size = {1920, 1080},
.offset = {0, 0},
},
.numSamples = Gfx::SE_SAMPLE_COUNT_4_BIT,
};
OGameView sceneView = new PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string(), useDepthCulling);
sceneView->setFocused();
while (windowManager->isActive()) {
windowManager->render();
}
vd->destroy();
return 0;
}