Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ Framework/Externals/slang/source/**/*.natvis
!Framework/Externals/slang/source/**/*.cpp
!Framework/Externals/slang/source/**/*.cpp
!Framework/Externals/slang/source/**/*.h

# Ignore intermediate files that Slang dumps when
# we ask it to preserve intermedites
slang-dump*
8 changes: 2 additions & 6 deletions Framework/Source/FalcorConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,5 @@

#define _ENABLE_NVAPI false // Controls NVIDIA specific DX extensions. If it is set to true, make sure you have the NVAPI package in your 'Externals' directory. View the readme for more information

#define FALCOR_BUILD_SPIRE 1 /* Set this to 1 to enable Slang compiler to be built into Falcor */
#define FALCOR_USE_SLANG_AS_PREPROCESSOR 0 /* Set this to 1 to use Slang as a source-to-source preprocessor */

#if (FALCOR_USE_SLANG_AS_PREPROCESSOR) && !FALCOR_BUILD_SPIRE
#error Trying to use Slang without building it
#endif
#define FALCOR_SLANG_DISABLE_LINE_DIRECTIVES 0 /* Set this to 1 to disable emission of `#line` directives in Slang-generated code */
#define FALCOR_SLANG_DUMP_COMPILER_INTERMEDIATES 0 /* Set this to 1 to enable dumping of intermediate code generated by Slang to disk */
23 changes: 23 additions & 0 deletions Framework/Source/Graphics/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,29 @@ namespace Falcor
slangFlags |= SLANG_COMPILE_FLAG_NO_CHECKING;
spSetCompileFlags(slangRequest, slangFlags);

// Enable this block to disable the emission of `#line` directives
// and hopefully make the HLSL/GLSL output by Slang a bit more
// readable.
//
// This is useful for diagnosing issues where Slang outputs bogus
// code and you need to isolate what Slang is doing wrong.
//
// This is way less useful if the user's code has a legitimate
// issue in it, because it will be reported at a location
// unrelated to the code they wrote. That is why it is off by default.
#if FALCOR_SLANG_DISABLE_LINE_DIRECTIVES
spSetLineDirectiveMode(slangRequest, SLANG_LINE_DIRECTIVE_MODE_NONE);
#endif

// Enable this block to make Slang dump intermediate HLSL/GLSL
// and DXBC/SPIR-V (both binary and assembly) for every shader
// it compiles. These will be dumped to the current working
// directory and named `slang-dump-*.{glsl,hlsl,spv,dxbc,spv.asm,dxbc.asm}
#if FALCOR_SLANG_DUMP_COMPILER_INTERMEDIATES
spSetDumpIntermediates(slangRequest, true);
#endif


// Now lets add all our input shader code, one-by-one
int translationUnitsAdded = 0;
for(auto source : mDesc.mSources)
Expand Down