webgpu triangle
This commit is contained in:
parent
64116cd980
commit
5553ded476
22 changed files with 2107 additions and 42 deletions
|
|
@ -4,6 +4,14 @@ 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",
|
||||
|
|
@ -14,6 +22,12 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
|
|||
cfg.path = "./";
|
||||
cfg.name = "VulkanTriangle";
|
||||
cfg.outputName = "VulkanTriangle";
|
||||
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 };
|
||||
|
||||
|
|
@ -21,8 +35,15 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
|
|||
std::array<fs::path, 1> impls = { "main" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
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);
|
||||
if (isWasm) {
|
||||
cfg.files.emplace_back(fs::path("raygen.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("closesthit.wgsl"));
|
||||
cfg.files.emplace_back(fs::path("miss.wgsl"));
|
||||
EnableWasiBrowserRuntime(cfg);
|
||||
} else {
|
||||
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