Skip to content

Commit 2359921

Browse files
authored
Merge pull request shader-slang#1383 from csyonghe/dyndispatch
Add compiler flag to disable specialization pass.
2 parents 1c77c44 + 8452129 commit 2359921

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ tests/**/*.cpp
3131
# Files generated by other shader compilers
3232

3333
*.spv
34+
35+
# Intermediate source files generated during build process
36+
/source/slang/slang-ast-generated.h
37+
/source/slang/slang-ast-generated-macro.h
38+
/source/slang/hlsl.meta.slang.h
39+
/source/slang/core.meta.slang.h

source/slang/slang-compiler.h

+4
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,10 @@ namespace Slang
17591759
/// Should SPIR-V be generated directly from Slang IR rather than via translation to GLSL?
17601760
bool shouldEmitSPIRVDirectly = false;
17611761

1762+
1763+
// If true will allow generating dynamic dispatch code for generics.
1764+
bool allowDynamicCode = false;
1765+
17621766
String m_dumpIntermediatePrefix;
17631767

17641768
private:

source/slang/slang-emit.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ Result linkAndOptimizeIR(
270270
// perform specialization of functions based on parameter
271271
// values that need to be compile-time constants.
272272
//
273-
specializeModule(irModule);
273+
if (!compileRequest->allowDynamicCode)
274+
specializeModule(irModule);
274275

275276
// Debugging code for IR transformations...
276277
#if 0

source/slang/slang-options.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ struct OptionsParser
557557
{
558558
requestImpl->getFrontEndReq()->useSerialIRBottleneck = true;
559559
}
560+
else if (argStr == "-allow-dynamic-code")
561+
{
562+
requestImpl->getBackEndReq()->allowDynamicCode = true;
563+
}
560564
else if (argStr == "-verbose-paths")
561565
{
562566
requestImpl->getSink()->setFlag(DiagnosticSink::Flag::VerbosePath);

0 commit comments

Comments
 (0)