This commit is contained in:
2026-05-03 10:51:32 +10:00
parent be16b03024
commit f6db9ee3e6
6 changed files with 774 additions and 554 deletions

View File

@@ -0,0 +1,34 @@
#pragma once
#include "ShaderTypes.h"
#include <filesystem>
#include <string>
class ShaderCompiler
{
public:
ShaderCompiler(
const std::filesystem::path& repoRoot,
const std::filesystem::path& wrapperPath,
const std::filesystem::path& generatedGlslPath,
const std::filesystem::path& patchedGlslPath,
unsigned maxTemporalHistoryFrames);
bool BuildLayerFragmentShaderSource(const ShaderPackage& shaderPackage, std::string& fragmentShaderSource, std::string& error) const;
private:
std::string BuildWrapperSlangSource(const ShaderPackage& shaderPackage) const;
bool FindSlangCompiler(std::filesystem::path& compilerPath, std::string& error) const;
bool RunSlangCompiler(const std::filesystem::path& wrapperPath, const std::filesystem::path& outputPath, std::string& error) const;
bool PatchGeneratedGlsl(std::string& shaderText, std::string& error) const;
std::string ReadTextFile(const std::filesystem::path& path, std::string& error) const;
bool WriteTextFile(const std::filesystem::path& path, const std::string& contents, std::string& error) const;
private:
std::filesystem::path mRepoRoot;
std::filesystem::path mWrapperPath;
std::filesystem::path mGeneratedGlslPath;
std::filesystem::path mPatchedGlslPath;
unsigned mMaxTemporalHistoryFrames;
};