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 args) { std::vector 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 ifaces = {}; std::array 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{}(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; }