From 02706dfc5f0526f4f8ca337be16d7b00640ba168 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Wed, 26 Feb 2025 21:20:29 -0500 Subject: Fix precompiledTargetModule tests (#6455) * Fix precompiledTargetModule tests Add SPIRV-Tool linker support to gfx unit tests and use the linker in precompileModule tests that use precompiled modules to reconstitute SPIRV shaders that were modularly compiled. Fix a Slang reference count bug in the precompile service. * Use sm_6_6 New DXC requires higher version for linkability. * Rename helper function, pass by reference * Link through slang-glslang * Add missing files * Fix metal * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He --- tools/gfx/vulkan/glslang-module.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tools/gfx/vulkan/glslang-module.h (limited to 'tools/gfx/vulkan/glslang-module.h') diff --git a/tools/gfx/vulkan/glslang-module.h b/tools/gfx/vulkan/glslang-module.h new file mode 100644 index 000000000..cda903577 --- /dev/null +++ b/tools/gfx/vulkan/glslang-module.h @@ -0,0 +1,36 @@ +// glslang-module.h +#pragma once + +#include "core/slang-list.h" +#include "external/spirv-tools/include/spirv-tools/linker.hpp" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang-glslang/slang-glslang.h" +#include "slang.h" + +namespace gfx +{ + +struct GlslangModule +{ + /// true if has been initialized + SLANG_FORCE_INLINE bool isInitialized() const { return m_module != nullptr; } + + /// Initialize + Slang::Result init(); + + /// Destroy + void destroy(); + + /// Dtor + ~GlslangModule() { destroy(); } + + Slang::ComPtr linkSPIRV(Slang::List> spirvModules); + +protected: + void* m_module = nullptr; + + glslang_LinkSPIRVFunc m_linkSPIRVFunc = nullptr; +}; + +} // namespace gfx -- cgit v1.2.3