From 0c4c63b4a575f45f5dcf03f26b78becd36b0efca Mon Sep 17 00:00:00 2001 From: Lujin Wang <143145775+lujinwangnv@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:55:11 -0700 Subject: Fix missing debug info for the included slang file (#7281) * Fix missing debug info in the included slang file Issue: https://github.com/shader-slang/slang/issues/7271 Debug info including DebugFunction, DebugLocation, and DebugValue are missing in IR for "#included" Slang shader file. The included shader file was not added to TranslationUnit's source file list, therefore mapSourceFileToDebugSourceInst.add() was not called for the source in generateIRForTranslationUnit(), and later mapSourceFileToDebugSourceInst.tryGetValue() could not get value for the source to add DebugLocationDecoration, which led to missing DebugFunction, DebugLocation and other debug info for the included file in IR. Adding the include file in TranslationUnit's source file list fixes the issue. * Add source file using PreprocessorHandler Call _addSourceFile from FrontEndPreprocessorHandler::handleFileDependency. * Just use FrontEndPreprocessorHandler * Make _addSourceFile public * format code * Distingush the included source file * Add m_includedFileSet to avoid adding dup file HashSet m_includedFileSet; --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-compiler.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/slang/slang-compiler.h') diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 8f7f7d49a..861719aac 100644 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1880,6 +1880,7 @@ public: { m_sourceArtifacts.clear(); m_sourceFiles.clear(); + m_includedFileSet.clear(); } /// Add a source artifact @@ -1888,6 +1889,8 @@ public: /// Add both the artifact and the sourceFile. void addSource(IArtifact* sourceArtifact, SourceFile* sourceFile); + void addIncludedSourceFileIfNotExist(SourceFile* sourceFile); + // The entry points associated with this translation unit List> const& getEntryPoints() { return module->getEntryPoints(); } @@ -1936,6 +1939,9 @@ protected: // NOTE! This member is generated lazily from m_sourceArtifacts // it is *necessary* to call requireSourceFiles to ensure it's in sync. List m_sourceFiles; + + // Track all the included source files added in m_sourceFiles + HashSet m_includedFileSet; }; enum class FloatingPointMode : SlangFloatingPointModeIntegral -- cgit v1.2.3