summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/core/slang-render-api-util.cpp8
-rw-r--r--source/core/slang-render-api-util.h2
-rw-r--r--source/slang/slang-compiler.cpp38
3 files changed, 47 insertions, 1 deletions
diff --git a/source/core/slang-render-api-util.cpp b/source/core/slang-render-api-util.cpp
index d8bcaf396..a9339c14e 100644
--- a/source/core/slang-render-api-util.cpp
+++ b/source/core/slang-render-api-util.cpp
@@ -17,6 +17,7 @@ namespace Slang {
{ RenderApiType::Vulkan, "vk,vulkan", ""},
{ RenderApiType::D3D12, "dx12,d3d12", ""},
{ RenderApiType::D3D11, "dx11,d3d11", "hlsl,hlsl-rewrite,slang"},
+ { RenderApiType::CPU, "cpu", ""},
};
static int _calcAvailableApis()
@@ -265,7 +266,8 @@ static bool _canLoadSharedLibrary(const char* libName)
case RenderApiType::OpenGl: return _canLoadSharedLibrary("opengl32");
case RenderApiType::Vulkan: return _canLoadSharedLibrary("vulkan-1");
case RenderApiType::D3D11: return _canLoadSharedLibrary("d3d11");
- case RenderApiType::D3D12: return _canLoadSharedLibrary("d3d12");
+ case RenderApiType::D3D12: return _canLoadSharedLibrary("d3d12");
+ case RenderApiType::CPU: return true;
default: break;
}
#elif SLANG_UNIX_FAMILY
@@ -277,6 +279,10 @@ static bool _canLoadSharedLibrary(const char* libName)
{
return true;
}
+ case RenderApiType::CPU:
+ {
+ return true;
+ }
default: break;
}
#endif
diff --git a/source/core/slang-render-api-util.h b/source/core/slang-render-api-util.h
index fbdd3930c..48b599653 100644
--- a/source/core/slang-render-api-util.h
+++ b/source/core/slang-render-api-util.h
@@ -15,6 +15,7 @@ enum class RenderApiType
Vulkan,
D3D12,
D3D11,
+ CPU,
CountOf,
};
@@ -27,6 +28,7 @@ struct RenderApiFlag
Vulkan = 1 << int(RenderApiType::Vulkan),
D3D12 = 1 << int(RenderApiType::D3D12),
D3D11 = 1 << int(RenderApiType::D3D11),
+ CPU = 1 << int(RenderApiType::CPU),
AllOf = (1 << int(RenderApiType::CountOf)) - 1 ///< All bits set
};
};
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index a88881b9d..75cd61bf9 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -561,6 +561,21 @@ namespace Slang
return translationUnit;
}
+ static TranslationUnitRequest* _getTranslationUnit(
+ EndToEndCompileRequest* endToEndReq,
+ Int entryPointIndex)
+ {
+ // If there isn't an end-to-end compile going on,
+ // there can be no pass-through.
+ //
+ if (!endToEndReq) return nullptr;
+
+ auto frontEndReq = endToEndReq->getFrontEndReq();
+ auto entryPointReq = frontEndReq->getEntryPointReq(entryPointIndex);
+ auto translationUnit = entryPointReq->getTranslationUnit();
+ return translationUnit;
+ }
+
static void _appendEscapedPath(const UnownedStringSlice& path, StringBuilder& outBuilder)
{
for (auto c : path)
@@ -1301,6 +1316,28 @@ SlangResult dissassembleDXILUsingDXC(
}
else
{
+ // TODO(JS): This is a hack for two reasons
+ // * That we just inject the source path for C/C++ include paths if we find the file
+ // * We should access the files through the ISlangFileSystem
+
+ translationUnit = _getTranslationUnit(endToEndReq, entryPointIndex);
+
+ const auto& sourceFiles = translationUnit->getSourceFiles();
+ if (sourceFiles.getCount() == 1)
+ {
+ const SourceFile* sourceFile = sourceFiles[0];
+ const PathInfo& pathInfo = sourceFile->getPathInfo();
+ if (pathInfo.type == PathInfo::Type::FoundPath || pathInfo.type == PathInfo::Type::Normal || pathInfo.type == PathInfo::Type::FromString)
+ {
+ String canonicalPath;
+ if (File::exists(pathInfo.foundPath) && SLANG_SUCCEEDED(Path::getCanonical(pathInfo.foundPath, canonicalPath)))
+ {
+ String sourceDir = Path::getParentDirectory(canonicalPath);
+ includePaths.add(sourceDir);
+ }
+ }
+ }
+
rawSource = emitCPPForEntryPoint(
slangRequest,
entryPoint,
@@ -1547,6 +1584,7 @@ SlangResult dissassembleDXILUsingDXC(
sharedLib->m_temporaryFileSet = productFileSet;
productFileSet.clear();
+ // Output the shared library
outSharedLib = sharedLib;
}
else