// SPDX-License-Identifier: LGPL-3.0-only // SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts® export module Crafter.Build:Shader; import std; namespace fs = std::filesystem; namespace Crafter { export enum class ShaderType { Vertex, TessControl, TessEvaluation, Geometry, Fragment, Compute, RayGen, Intersect, AnyHit, ClosestHit, Miss, Callable, Task, Mesh, }; export class Shader { public: fs::path path; std::string entrypoint; ShaderType type; // Preprocessor macros for this compile, spelled like the compiler's -D: // "NAME" (defined to 1) or "NAME=VALUE". They are placed ahead of the // source, so one file can be registered more than once and take a // different #ifdef branch each time. Note the spelling differs from // Configuration::defines, which is a list of {name, value} pairs. std::vector defines; // Names the output when one source is compiled more than once: empty // gives ".spv", "sets" gives ".sets.spv". One file-name // component: no path separators. Every entry of a configuration must // end up with its own OutputName(); Build() fails if two collide, so // each extra compile of a source needs its own variant. Check() // compares only the source's mtime: changing defines without touching // the source leaves the old output in place. std::string variant; Shader(fs::path&& path, std::string&& entrypoint, ShaderType type); // File name of the compiled SPIR-V, relative to the output directory. // The single source of truth for it: Check, Compile and the artifact // forwarding in Build() all go through here. fs::path OutputName() const; bool Check(const fs::path& outputDir) const; std::string Compile(const fs::path& outputDir, std::span includeDirs) const; }; }