test(bench): SponzaBench harness + #40→HEAD perf measurement (#155)
Headless benchmark around the native Sponza RT scene: times setup and a measured Render() loop over the full multi-mesh atrium, prints BENCH metrics, and exits. Includes run-bench.sh and a README documenting the methodology and the measured net gain from #40 to current master. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3e116e6e43
commit
619e39369d
7 changed files with 616 additions and 0 deletions
60
examples/SponzaBench/project.cpp
Normal file
60
examples/SponzaBench/project.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import std;
|
||||
import Crafter.Build;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
// SponzaBench — a headless benchmark harness around the native Sponza
|
||||
// ray-tracing scene. Same asset bundle and shaders as examples/Sponza,
|
||||
// but main.cpp times setup + a fixed measured frame loop instead of
|
||||
// opening an interactive window. Native (Vulkan) only — the point is to
|
||||
// measure the native renderer's per-frame and setup cost across library
|
||||
// revisions (issue #155: net perf gain from #40 to now).
|
||||
constexpr std::string_view kSponzaGitUrl = "https://github.com/jimmiebergmann/Sponza.git";
|
||||
constexpr std::string_view kSponzaCommitSHA = "222338979d32f4f4818466291bdbc29f192b86ba";
|
||||
constexpr std::uint16_t kAlbedoSize = 1024u;
|
||||
|
||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||
std::vector<std::string> graphicsArgs(args.begin(), args.end());
|
||||
Configuration* graphics = LocalProject({
|
||||
.projectFile = "../../project.cpp",
|
||||
.args = graphicsArgs,
|
||||
});
|
||||
|
||||
Configuration cfg;
|
||||
cfg.path = "./";
|
||||
cfg.name = "SponzaBench";
|
||||
cfg.outputName = "SponzaBench";
|
||||
cfg.type = ConfigurationType::Executable;
|
||||
ApplyStandardArgs(cfg, args);
|
||||
cfg.dependencies = { graphics };
|
||||
|
||||
std::array<fs::path, 0> ifaces = {};
|
||||
std::array<fs::path, 1> impls = { "main" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
fs::path sponzaRoot = GitFetch({
|
||||
.url = std::string(kSponzaGitUrl),
|
||||
.commit = std::string(kSponzaCommitSHA),
|
||||
});
|
||||
std::string bundleKey = std::format("{}|{}", kSponzaCommitSHA, kAlbedoSize);
|
||||
auto bundleHash = std::hash<std::string>{}(bundleKey);
|
||||
fs::path bundleDir = fs::path("build") / std::format("sponza-bundle-{:016x}", bundleHash);
|
||||
|
||||
if (auto err = BuildOBJBundle(
|
||||
sponzaRoot / "sponza.obj",
|
||||
sponzaRoot / "sponza.mtl",
|
||||
bundleDir,
|
||||
kAlbedoSize); !err.empty()) {
|
||||
std::println(std::cerr, "Sponza bundle error: {}", err);
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
for (const auto& entry : fs::directory_iterator(bundleDir)) {
|
||||
if (entry.is_regular_file()) cfg.files.push_back(entry.path());
|
||||
}
|
||||
|
||||
cfg.shaders.emplace_back(fs::path("raygen.glsl"), std::string("main"), ShaderType::RayGen);
|
||||
cfg.shaders.emplace_back(fs::path("closesthit.glsl"), std::string("main"), ShaderType::ClosestHit);
|
||||
cfg.shaders.emplace_back(fs::path("miss.glsl"), std::string("main"), ShaderType::Miss);
|
||||
return cfg;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue