Compare commits

..

2 Commits

Author SHA1 Message Date
df0da96c38 Add compute shader support 2026-03-16 12:58:09 +01:00
3a7b137165 Add debug compiler 2026-01-22 02:04:26 +01:00
3 changed files with 6 additions and 8 deletions

View File

@@ -51,3 +51,4 @@ if (MSVC)
else() else()
target_compile_options(TheChef PRIVATE -Wall -Wextra -Wpedantic) target_compile_options(TheChef PRIVATE -Wall -Wextra -Wpedantic)
endif() endif()

View File

@@ -58,7 +58,7 @@ public:
static bool IsEntryShader(const fs::path& p) static bool IsEntryShader(const fs::path& p)
{ {
const auto ext = ToLower(p.extension().string()); const auto ext = ToLower(p.extension().string());
return ext == ".vert" || ext == ".frag"; return ext == ".vert" || ext == ".frag" || ext == ".comp";
} }
static bool IsIncludeOnlyShader(const fs::path& p) static bool IsIncludeOnlyShader(const fs::path& p)
@@ -114,6 +114,7 @@ private:
const auto ext = ToLower(p.extension().string()); const auto ext = ToLower(p.extension().string());
if (ext == ".vert") return EShLangVertex; if (ext == ".vert") return EShLangVertex;
if (ext == ".frag") return EShLangFragment; if (ext == ".frag") return EShLangFragment;
if (ext == ".comp") return EShLangCompute;
throw std::runtime_error("Unknown entry shader stage extension: " + p.string()); throw std::runtime_error("Unknown entry shader stage extension: " + p.string());
} }

View File

@@ -1,6 +1,3 @@
// main.cpp (updated)
// Standard
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <string> #include <string>
@@ -8,16 +5,12 @@
#include <cctype> #include <cctype>
#include <chrono> #include <chrono>
#include <stdexcept> #include <stdexcept>
#include <cstdlib>
// Manifest
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
// Logging
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h> #include <spdlog/sinks/stdout_color_sinks.h>
// Your shader compiler header
#include "ShaderCompiler.h" #include "ShaderCompiler.h"
namespace fs = std::filesystem; namespace fs = std::filesystem;
@@ -122,6 +115,7 @@ int main(int argc, char** argv) {
if (args.clean && fs::exists(args.output)) { if (args.clean && fs::exists(args.output)) {
spdlog::info("Cleaning output dir: {}", args.output.string()); spdlog::info("Cleaning output dir: {}", args.output.string());
fs::remove_all(args.output); fs::remove_all(args.output);
return 0;
} }
fs::create_directories(args.output); fs::create_directories(args.output);
@@ -130,6 +124,8 @@ int main(int argc, char** argv) {
// ---------------------------- // ----------------------------
SpirvShaderCompiler::Options scOpt; SpirvShaderCompiler::Options scOpt;
scOpt.debugInfo = false; // set true if you want debug info in SPIR-V scOpt.debugInfo = false; // set true if you want debug info in SPIR-V
scOpt.defines = { "DEBUG=1" };
// Common conventions (adjust to your folder layout): // Common conventions (adjust to your folder layout):
// - shaders live under <input>/shaders // - shaders live under <input>/shaders