diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-03-12 12:24:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-12 12:24:03 -0700 |
| commit | 3cfccfd4991df01deaf132f11b4eaa6848a32c4e (patch) | |
| tree | f94567d7e6f7601c67b7c201add21fc644ba18fd /source/slang/slang.cpp | |
| parent | 9722990745f4e91ab1bf9fb682c72e173cd123b4 (diff) | |
Add options to control optimization and debug information (#897)
The short version for command-line users is:
* Use `-g` to get debug info in the output, where supported
* Use `-O0` to disable optimizations, in case that improves debugability
* Use `-O2` for optimized/release builds where you can spend the extra compile time
The command-line options are matched with new API functions `spSetDebugInfoLevel()` and `spSetOptimizationLevel()` that set the equivalent information.
Right now these settings only affect how we invoke fxc and dxc. In the longer run I expect we will want to use them to control other things:
* Once we are emitting our own SPIR-V, the `-g` option should control what source-level name information we include in it.
* Whether or not `-g` is used could be used to decide whether we preserve the "name hints" in the IR, which in turn decide whether we output GLSL/HLSL source that uses names based on the original program.
* We will eventually need/want to include some amount of optimization passes on the Slang IR, and the `-O` options should control which of those passes are enabled on a particular invocation.
In this change I decided to expose the options at the level of the entire compile request for API users, and to store the actual information on the Linkage. We might want to revisit this decision and instead allow for the level of optimization to be chosen per-target as part of back-end state. Similarly, we might want to have more fine-grained control over the level of debug output per-target (although we'd still need a front-end setting to determine what debug info is generated into the Slang IR).
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index e97f5bb1b..affce384b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1831,6 +1831,30 @@ SLANG_API void spSetTargetMatrixLayoutMode( spSetMatrixLayoutMode(request, mode); } +/*! +@brief Set the level of debug information to produce. +*/ +SLANG_API void spSetDebugInfoLevel( + SlangCompileRequest* request, + SlangDebugInfoLevel level) +{ + auto req = convert(request); + auto linkage = req->getLinkage(); + linkage->debugInfoLevel = Slang::DebugInfoLevel(level); +} + +/*! +@brief Set the level of optimization to perform. +*/ +SLANG_API void spSetOptimizationLevel( + SlangCompileRequest* request, + SlangOptimizationLevel level) +{ + auto req = convert(request); + auto linkage = req->getLinkage(); + linkage->optimizationLevel = Slang::OptimizationLevel(level); +} + SLANG_API void spSetOutputContainerFormat( SlangCompileRequest* request, |
