diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-28 22:57:07 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-28 22:57:07 -0800 |
| commit | 73a61edda8893901acad05bb4e7d3110db5041a8 (patch) | |
| tree | bb6331b28715a4e95fcd7724ad338149ce56e562 /tools | |
| parent | d2644e2f8f0abb73bbd6afd70816f6bf245340da (diff) | |
[SPIRV] Add NonSemanticDebugInfo for step-through debugging. (#3644)
* [SPIRV] Add NonSemanticDebugInfo for step-through debugging.
* Fix.
* Fix.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx-unit-test/gfx-test-util.cpp | 23 | ||||
| -rw-r--r-- | tools/gfx/cpu/cpu-device.cpp | 2 | ||||
| -rw-r--r-- | tools/gfx/cuda/cuda-device.cpp | 2 | ||||
| -rw-r--r-- | tools/gfx/d3d11/d3d11-device.cpp | 2 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-device.cpp | 2 | ||||
| -rw-r--r-- | tools/gfx/open-gl/render-gl.cpp | 2 | ||||
| -rw-r--r-- | tools/gfx/slang-context.h | 17 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-device.cpp | 2 |
8 files changed, 47 insertions, 5 deletions
diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp index 748ced5eb..fe06a1745 100644 --- a/tools/gfx-unit-test/gfx-test-util.cpp +++ b/tools/gfx-unit-test/gfx-test-util.cpp @@ -4,7 +4,7 @@ #include <slang-com-ptr.h> #define GFX_ENABLE_RENDERDOC_INTEGRATION 0 - +#define GFX_ENABLE_SPIRV_DEBUG 0 #if GFX_ENABLE_RENDERDOC_INTEGRATION # include "external/renderdoc_app.h" # include <windows.h> @@ -278,10 +278,25 @@ namespace gfx_test gfx::D3D12DeviceExtendedDesc extDesc = {}; extDesc.rootParameterShaderAttributeName = "root"; + + gfx::SlangSessionExtendedDesc slangExtDesc = {}; + Slang::List<slang::CompilerOptionEntry> entries; + slang::CompilerOptionEntry emitSpirvDirectlyEntry; + emitSpirvDirectlyEntry.name = slang::CompilerOptionName::EmitSpirvDirectly; + emitSpirvDirectlyEntry.value.intValue0 = 1; + entries.add(emitSpirvDirectlyEntry); +#if GFX_ENABLE_SPIRV_DEBUG + slang::CompilerOptionEntry debugLevelCompilerOptionEntry; + debugLevelCompilerOptionEntry.name = slang::CompilerOptionName::DebugInformation; + debugLevelCompilerOptionEntry.value.intValue0 = SLANG_DEBUG_INFO_LEVEL_STANDARD; + entries.add(debugLevelCompilerOptionEntry); +#endif + slangExtDesc.compilerOptionEntries = entries.getBuffer(); + slangExtDesc.compilerOptionEntryCount = (uint32_t)entries.getCount(); - deviceDesc.extendedDescCount = 1; - void* extDescPtr = &extDesc; - deviceDesc.extendedDescs = &extDescPtr; + deviceDesc.extendedDescCount = 2; + void* extDescPtrs[2] = { &extDesc, &slangExtDesc }; + deviceDesc.extendedDescs = extDescPtrs; // TODO: We should also set the debug callback // (And in general reduce the differences (and duplication) between diff --git a/tools/gfx/cpu/cpu-device.cpp b/tools/gfx/cpu/cpu-device.cpp index f248cf52a..bd747d998 100644 --- a/tools/gfx/cpu/cpu-device.cpp +++ b/tools/gfx/cpu/cpu-device.cpp @@ -27,6 +27,8 @@ namespace cpu { SLANG_RETURN_ON_FAIL(slangContext.initialize( desc.slang, + desc.extendedDescCount, + desc.extendedDescs, SLANG_SHADER_HOST_CALLABLE, "sm_5_1", makeArray(slang::PreprocessorMacroDesc{ "__CPU__", "1" }).getView())); diff --git a/tools/gfx/cuda/cuda-device.cpp b/tools/gfx/cuda/cuda-device.cpp index 377a5aba2..0fcf9319e 100644 --- a/tools/gfx/cuda/cuda-device.cpp +++ b/tools/gfx/cuda/cuda-device.cpp @@ -142,6 +142,8 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) { SLANG_RETURN_ON_FAIL(slangContext.initialize( desc.slang, + desc.extendedDescCount, + desc.extendedDescs, SLANG_PTX, "sm_5_1", makeArray(slang::PreprocessorMacroDesc{ "__CUDA_COMPUTE__", "1" }).getView())); diff --git a/tools/gfx/d3d11/d3d11-device.cpp b/tools/gfx/d3d11/d3d11-device.cpp index 20e17b082..148590831 100644 --- a/tools/gfx/d3d11/d3d11-device.cpp +++ b/tools/gfx/d3d11/d3d11-device.cpp @@ -34,6 +34,8 @@ SlangResult DeviceImpl::initialize(const Desc& desc) { SLANG_RETURN_ON_FAIL(slangContext.initialize( desc.slang, + desc.extendedDescCount, + desc.extendedDescs, SLANG_DXBC, "sm_5_0", makeArray(slang::PreprocessorMacroDesc{ "__D3D11__", "1" }).getView())); diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp index bbf27b4f7..58b13fe41 100644 --- a/tools/gfx/d3d12/d3d12-device.cpp +++ b/tools/gfx/d3d12/d3d12-device.cpp @@ -910,6 +910,8 @@ Result DeviceImpl::initialize(const Desc& desc) } SLANG_RETURN_ON_FAIL(slangContext.initialize( desc.slang, + desc.extendedDescCount, + desc.extendedDescs, compileTarget, profileName, makeArray(slang::PreprocessorMacroDesc{ "__D3D12__", "1" }).getView())); diff --git a/tools/gfx/open-gl/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp index b5ab14fe8..abb178375 100644 --- a/tools/gfx/open-gl/render-gl.cpp +++ b/tools/gfx/open-gl/render-gl.cpp @@ -2007,6 +2007,8 @@ SLANG_NO_THROW Result SLANG_MCALL GLDevice::initialize(const Desc& desc) { SLANG_RETURN_ON_FAIL(slangContext.initialize( desc.slang, + desc.extendedDescCount, + desc.extendedDescs, SLANG_GLSL, "glsl_440", makeArray( diff --git a/tools/gfx/slang-context.h b/tools/gfx/slang-context.h index 8ae14d4aa..79f39c3e6 100644 --- a/tools/gfx/slang-context.h +++ b/tools/gfx/slang-context.h @@ -10,7 +10,11 @@ namespace gfx public: Slang::ComPtr<slang::IGlobalSession> globalSession; Slang::ComPtr<slang::ISession> session; - Result initialize(const gfx::IDevice::SlangDesc& desc, SlangCompileTarget compileTarget, const char* defaultProfileName, + Result initialize(const gfx::IDevice::SlangDesc& desc, + uint32_t extendedDescCount, + void** extendedDescs, + SlangCompileTarget compileTarget, + const char* defaultProfileName, Slang::ConstArrayView<slang::PreprocessorMacroDesc> additionalMacros) { if (desc.slangGlobalSession) @@ -45,6 +49,17 @@ namespace gfx slangSessionDesc.targets = &targetDesc; slangSessionDesc.targetCount = 1; + for (uint32_t i = 0; i < extendedDescCount; i++) + { + if ((*(StructType*)extendedDescs[i]) == StructType::SlangSessionExtendedDesc) + { + auto extDesc = (SlangSessionExtendedDesc*)extendedDescs[i]; + slangSessionDesc.compilerOptionEntryCount = extDesc->compilerOptionEntryCount; + slangSessionDesc.compilerOptionEntries = extDesc->compilerOptionEntries; + break; + } + } + SLANG_RETURN_ON_FAIL(globalSession->createSession(slangSessionDesc, session.writeRef())); return SLANG_OK; } diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp index 641b50bf6..1b79887ca 100644 --- a/tools/gfx/vulkan/vk-device.cpp +++ b/tools/gfx/vulkan/vk-device.cpp @@ -933,6 +933,8 @@ SlangResult DeviceImpl::initialize(const Desc& desc) SLANG_RETURN_ON_FAIL(slangContext.initialize( desc.slang, + desc.extendedDescCount, + desc.extendedDescs, SLANG_SPIRV, "sm_5_1", makeArray(slang::PreprocessorMacroDesc{ "__VK__", "1" }).getView())); |
