diff --git a/modules/shader_compiler/config/SLANG.cmake b/modules/shader_compiler/config/SLANG.cmake index b8afe8bc8bcd684bb5027e99143e5ea4076b9127..09460b23931752d1e7d306fb19e3c2de601ba80d 100644 --- a/modules/shader_compiler/config/SLANG.cmake +++ b/modules/shader_compiler/config/SLANG.cmake @@ -57,8 +57,6 @@ if (${slang_status}) set(SLANG_STDLIB_META_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${vkcv_shader_compiler_lib}/slang/source/slang/stdlib-meta) target_include_directories(slang BEFORE PUBLIC ${SLANG_STDLIB_META_OUTPUT_DIR}) - - message(WARNING ${SLANG_STDLIB_META_OUTPUT_DIR}) list(APPEND vkcv_shader_compiler_libraries slang lz4_static miniz unordered_dense::unordered_dense) list(APPEND vkcv_shader_compiler_includes ${vkcv_shader_compiler_lib}/slang/include ${slang_system_includes}) diff --git a/modules/shader_compiler/config/Shady.cmake b/modules/shader_compiler/config/Shady.cmake index 3156521dbc200ff202f48f3994caa783801f3af5..3fac573354c3d2cd92f768c6976226a2dab03230 100644 --- a/modules/shader_compiler/config/Shady.cmake +++ b/modules/shader_compiler/config/Shady.cmake @@ -4,12 +4,19 @@ use_git_submodule("${vkcv_shader_compiler_lib_path}/shady" shady_status) if (${shady_status}) set(EXTERNAL_JSON_C ON CACHE INTERNAL "") set(EXTERNAL_SPIRV_HEADERS ON CACHE INTERNAL "") - set(EXTERNAL_MURMUR3 ON CACHE INTERNAL "") set(EXTERNAL_JSON_C_INCLUDE ${JSON_C_INCLUDE_DIR} CACHE INTERNAL "") set(BUILD_RUNTIME OFF CACHE INTERNAL "") set(BUILD_SAMPLES OFF CACHE INTERNAL "") + + if (vkcv_build_attribute EQUAL "SHARED") + set(BUILD_SHARED_LIBS ON CACHE INTERNAL "") + else () + set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") + endif () + + set(SHADY_ENABLE_JAVA_BINDINGS OFF CACHE INTERNAL "") add_subdirectory(${vkcv_shader_compiler_lib}/shady) diff --git a/modules/shader_compiler/lib/shady b/modules/shader_compiler/lib/shady index 31e9f66867a4803bae0c3c6ca08adaf71bf4f818..bff2671298293f05e3f74c2add8de1c0a0279a14 160000 --- a/modules/shader_compiler/lib/shady +++ b/modules/shader_compiler/lib/shady @@ -1 +1 @@ -Subproject commit 31e9f66867a4803bae0c3c6ca08adaf71bf4f818 +Subproject commit bff2671298293f05e3f74c2add8de1c0a0279a14 diff --git a/modules/shader_compiler/src/vkcv/shader/LLVMCompiler.cpp b/modules/shader_compiler/src/vkcv/shader/LLVMCompiler.cpp index e415e19a70729e5288ce64f15a1e386cd7b963ca..4d537ce9dee44534ad6468c9e9a89f28d8ae051d 100644 --- a/modules/shader_compiler/src/vkcv/shader/LLVMCompiler.cpp +++ b/modules/shader_compiler/src/vkcv/shader/LLVMCompiler.cpp @@ -6,23 +6,27 @@ extern "C" { #include <shady/driver.h> + #include <shady/ir.h> } namespace vkcv::shader { - LLVMCompiler::LLVMCompiler(LLVMCompileTarget target) - : ShadyCompiler(), m_target(target) {} - - static bool shadyCompileModule(Module* module, - ShaderStage shaderStage, - const std::string& shaderSource, - const ShaderCompiledFunction &compiled, - const std::filesystem::path &includePath) { - ShadyErrorCodes codes = driver_load_source_file( - SrcLLVM, - shaderSource.length(), + LLVMCompiler::LLVMCompiler(LLVMCompileTarget target) + : ShadyCompiler(), m_target(target) {} + + static bool shadyCompileModule(Module* module, + ShaderStage shaderStage, + const std::string& shaderSource, + const ShaderCompiledFunction &compiled, + const std::filesystem::path &includePath) { + CompilerConfig compiler = shd_default_compiler_config(); + ShadyErrorCodes codes = shd_driver_load_source_file( + &compiler, + SrcLLVM, + shaderSource.length(), shaderSource.c_str(), - module + "main", + &module ); switch (codes) { @@ -44,13 +48,13 @@ namespace vkcv::shader { const std::filesystem::path tmp_path = generateTemporaryFilePath(); - DriverConfig config = default_driver_config(); + DriverConfig config = shd_default_driver_config(); - config.target = TgtSPV; + config.target = TgtSPV; config.output_filename = tmp_path.string().c_str(); - codes = driver_compile(&config, module); - destroy_driver_config(&config); + codes = shd_driver_compile(&config, module); + shd_destroy_driver_config(&config); switch (codes) { case NoError: @@ -77,12 +81,12 @@ namespace vkcv::shader { return true; } - static bool shadyCompileArena(IrArena* arena, - ShaderStage shaderStage, - const std::string& shaderSource, - const ShaderCompiledFunction &compiled, - const std::filesystem::path &includePath) { - Module* module = new_module(arena, "slim_module"); + static bool shadyCompileArena(IrArena* arena, + ShaderStage shaderStage, + const std::string& shaderSource, + const ShaderCompiledFunction &compiled, + const std::filesystem::path &includePath) { + Module* module = shd_new_module(arena, "slim_module"); if (nullptr == module) { vkcv_log(LogLevel::ERROR, "Module could not be created"); @@ -92,17 +96,18 @@ namespace vkcv::shader { return shadyCompileModule(module, shaderStage, shaderSource, compiled, includePath); } - bool LLVMCompiler::compileSource(ShaderStage shaderStage, - const std::string& shaderSource, - const ShaderCompiledFunction& compiled, - const std::filesystem::path& includePath) { - if (ShaderStage::COMPUTE != shaderStage) { + bool LLVMCompiler::compileSource(ShaderStage shaderStage, + const std::string& shaderSource, + const ShaderCompiledFunction& compiled, + const std::filesystem::path& includePath) { + if (ShaderStage::COMPUTE != shaderStage) { vkcv_log(LogLevel::ERROR, "Shader stage not supported"); return false; } - ArenaConfig config = default_arena_config(); - IrArena* arena = new_ir_arena(config); + TargetConfig target = shd_default_target_config(); + ArenaConfig config = shd_default_arena_config(&target); + IrArena* arena = shd_new_ir_arena(&config); if (nullptr == arena) { vkcv_log(LogLevel::ERROR, "IR Arena could not be created"); @@ -111,8 +116,8 @@ namespace vkcv::shader { bool result = shadyCompileArena(arena, shaderStage, shaderSource, compiled, includePath); - destroy_ir_arena(arena); - return result; - } + shd_destroy_ir_arena(arena); + return result; + } } diff --git a/modules/shader_compiler/src/vkcv/shader/SlimCompiler.cpp b/modules/shader_compiler/src/vkcv/shader/SlimCompiler.cpp index 6270bb8efa245617da4c7f8f5a7e8663ccd282d1..6560e0632541c7f381b38a7853f04bafa0f95e13 100644 --- a/modules/shader_compiler/src/vkcv/shader/SlimCompiler.cpp +++ b/modules/shader_compiler/src/vkcv/shader/SlimCompiler.cpp @@ -6,23 +6,27 @@ extern "C" { #include <shady/driver.h> + #include <shady/ir.h> } namespace vkcv::shader { - SlimCompiler::SlimCompiler(SlimCompileTarget target) - : ShadyCompiler(), m_target(target) {} - - static bool shadyCompileModule(Module* module, - ShaderStage shaderStage, - const std::string& shaderSource, - const ShaderCompiledFunction &compiled, - const std::filesystem::path &includePath) { - ShadyErrorCodes codes = driver_load_source_file( + SlimCompiler::SlimCompiler(SlimCompileTarget target) + : ShadyCompiler(), m_target(target) {} + + static bool shadyCompileModule(Module* module, + ShaderStage shaderStage, + const std::string& shaderSource, + const ShaderCompiledFunction &compiled, + const std::filesystem::path &includePath) { + CompilerConfig compiler = shd_default_compiler_config(); + ShadyErrorCodes codes = shd_driver_load_source_file( + &compiler, SrcSlim, shaderSource.length(), shaderSource.c_str(), - module + "main", + &module ); switch (codes) { @@ -44,13 +48,13 @@ namespace vkcv::shader { const std::filesystem::path tmp_path = generateTemporaryFilePath(); - DriverConfig config = default_driver_config(); + DriverConfig config = shd_default_driver_config(); config.target = TgtSPV; config.output_filename = tmp_path.string().c_str(); - codes = driver_compile(&config, module); - destroy_driver_config(&config); + codes = shd_driver_compile(&config, module); + shd_destroy_driver_config(&config); switch (codes) { case NoError: @@ -82,7 +86,7 @@ namespace vkcv::shader { const std::string& shaderSource, const ShaderCompiledFunction &compiled, const std::filesystem::path &includePath) { - Module* module = new_module(arena, "slim_module"); + Module* module = shd_new_module(arena, "slim_module"); if (nullptr == module) { vkcv_log(LogLevel::ERROR, "Module could not be created"); @@ -101,8 +105,9 @@ namespace vkcv::shader { return false; } - ArenaConfig config = default_arena_config(); - IrArena* arena = new_ir_arena(config); + TargetConfig target = shd_default_target_config(); + ArenaConfig config = shd_default_arena_config(&target); + IrArena* arena = shd_new_ir_arena(&config); if (nullptr == arena) { vkcv_log(LogLevel::ERROR, "IR Arena could not be created"); @@ -111,7 +116,7 @@ namespace vkcv::shader { bool result = shadyCompileArena(arena, shaderStage, shaderSource, compiled, includePath); - destroy_ir_arena(arena); + shd_destroy_ir_arena(arena); return result; }