summaryrefslogtreecommitdiffstats
path: root/slang.h
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2019-03-12 12:24:03 -0700
committerGitHub <noreply@github.com>2019-03-12 12:24:03 -0700
commit3cfccfd4991df01deaf132f11b4eaa6848a32c4e (patch)
treef94567d7e6f7601c67b7c201add21fc644ba18fd /slang.h
parent9722990745f4e91ab1bf9fb682c72e173cd123b4 (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 'slang.h')
-rw-r--r--slang.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/slang.h b/slang.h
index 55185e110..226bd86fd 100644
--- a/slang.h
+++ b/slang.h
@@ -535,7 +535,25 @@ extern "C"
SLANG_STAGE_PIXEL = SLANG_STAGE_FRAGMENT,
};
-
+ typedef SlangUInt32 SlangDebugInfoLevel;
+ enum
+ {
+ SLANG_DEBUG_INFO_LEVEL_NONE = 0, /**< Don't emit debug information at all. */
+ SLANG_DEBUG_INFO_LEVEL_MINIMAL, /**< Emit as little debug information as possible, while still supporting stack trackes. */
+ SLANG_DEBUG_INFO_LEVEL_STANDARD, /**< Emit whatever is the standard level of debug information for each target. */
+ SLANG_DEBUG_INFO_LEVEL_MAXIMAL, /**< Emit as much debug infromation as possible for each target. */
+
+ };
+
+ typedef SlangUInt32 SlangOptimizationLevel;
+ enum
+ {
+ SLANG_OPTIMIZATION_LEVEL_NONE = 0, /**< Don't optimize at all. */
+ SLANG_OPTIMIZATION_LEVEL_DEFAULT, /**< Default optimization level: balance code quality and compilation time. */
+ SLANG_OPTIMIZATION_LEVEL_HIGH, /**< Optimize aggressively. */
+ SLANG_OPTIMIZATION_LEVEL_MAXIMAL, /**< Include optimizations that may take a very long time, or may involve severe space-vs-speed tradeoffs */
+ };
+
/** A result code for a Slang API operation.
This type is generally compatible with the Windows API `HRESULT` type. In particular, negative values indicate
@@ -1103,6 +1121,20 @@ extern "C"
SlangMatrixLayoutMode mode);
/*!
+ @brief Set the level of debug information to produce.
+ */
+ SLANG_API void spSetDebugInfoLevel(
+ SlangCompileRequest* request,
+ SlangDebugInfoLevel level);
+
+ /*!
+ @brief Set the level of optimization to perform.
+ */
+ SLANG_API void spSetOptimizationLevel(
+ SlangCompileRequest* request,
+ SlangOptimizationLevel level);
+
+ /*!
@brief Set the container format to be used for binary output.
*/
SLANG_API void spSetOutputContainerFormat(