2026-07-22 18:09:06 +02:00
|
|
|
//SPDX-License-Identifier: MIT
|
|
|
|
|
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
|
|
2026-06-02 22:09:30 +00:00
|
|
|
import std;
|
|
|
|
|
import Crafter.Build;
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
|
using namespace Crafter;
|
|
|
|
|
|
|
|
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
|
|
|
bool isWasm = false;
|
|
|
|
|
for (std::string_view a : args) {
|
|
|
|
|
if (a.starts_with("--target=") && a.find("wasm") != std::string_view::npos) {
|
|
|
|
|
isWasm = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> graphicsArgs(args.begin(), args.end());
|
|
|
|
|
Configuration* graphics = LocalProject({
|
|
|
|
|
.projectFile = "../../project.cpp",
|
|
|
|
|
.args = graphicsArgs,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Configuration cfg;
|
|
|
|
|
cfg.path = "./";
|
|
|
|
|
cfg.name = "RTVolume";
|
|
|
|
|
cfg.outputName = "RTVolume";
|
|
|
|
|
cfg.type = ConfigurationType::Executable;
|
|
|
|
|
if (isWasm) {
|
|
|
|
|
cfg.target = "wasm32-wasip1";
|
|
|
|
|
cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_DOM", ""});
|
|
|
|
|
cfg.compileFlags.push_back("-msimd128");
|
|
|
|
|
}
|
|
|
|
|
ApplyStandardArgs(cfg, args);
|
|
|
|
|
cfg.dependencies = { graphics };
|
|
|
|
|
|
|
|
|
|
std::array<fs::path, 0> ifaces = {};
|
|
|
|
|
std::array<fs::path, 1> impls = { "main" };
|
|
|
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
|
|
|
|
|
|
|
|
|
if (isWasm) {
|
|
|
|
|
cfg.files.emplace_back(fs::path("raygen.wgsl"));
|
|
|
|
|
cfg.files.emplace_back(fs::path("intersection.wgsl"));
|
|
|
|
|
cfg.files.emplace_back(fs::path("anyhit.wgsl"));
|
|
|
|
|
cfg.files.emplace_back(fs::path("closesthit.wgsl"));
|
|
|
|
|
cfg.files.emplace_back(fs::path("miss.wgsl"));
|
|
|
|
|
cfg.files.emplace_back(fs::path("resolve.wgsl"));
|
2026-06-16 14:12:12 +00:00
|
|
|
// GPU producer for the AABB build input (issue #37): writes the
|
|
|
|
|
// procedural boxes into a device buffer fed straight to BuildProcedural.
|
|
|
|
|
cfg.files.emplace_back(fs::path("aabbs.comp.wgsl"));
|
2026-06-02 22:09:30 +00:00
|
|
|
EnableWasiBrowserRuntime(cfg);
|
2026-06-13 00:17:37 +00:00
|
|
|
} else {
|
|
|
|
|
cfg.shaders.emplace_back(fs::path("raygen.glsl"), std::string("main"), ShaderType::RayGen);
|
|
|
|
|
cfg.shaders.emplace_back(fs::path("miss.glsl"), std::string("main"), ShaderType::Miss);
|
|
|
|
|
cfg.shaders.emplace_back(fs::path("closesthit.glsl"), std::string("main"), ShaderType::ClosestHit);
|
|
|
|
|
cfg.shaders.emplace_back(fs::path("anyhit.glsl"), std::string("main"), ShaderType::AnyHit);
|
|
|
|
|
cfg.shaders.emplace_back(fs::path("intersection.glsl"), std::string("main"), ShaderType::Intersect);
|
2026-06-16 14:12:12 +00:00
|
|
|
// GPU producer for the AABB build input (issue #37): writes the
|
|
|
|
|
// procedural boxes into a device buffer fed straight to BuildProcedural.
|
|
|
|
|
cfg.shaders.emplace_back(fs::path("aabbs.comp.glsl"), std::string("main"), ShaderType::Compute);
|
2026-06-02 22:09:30 +00:00
|
|
|
}
|
|
|
|
|
return cfg;
|
|
|
|
|
}
|