@@ -824,6 +824,155 @@ extern "C"
824
824
SLANG_OPTIMIZATION_LEVEL_MAXIMAL, /* *< Include optimizations that may take a very long time, or may involve severe space-vs-speed tradeoffs */
825
825
};
826
826
827
+ // All compiler option names supported by Slang.
828
+ namespace slang
829
+ {
830
+ enum class CompilerOptionName
831
+ {
832
+ MacroDefine, // stringValue0: macro name; stringValue1: macro value
833
+ DepFile,
834
+ EntryPointName,
835
+ Specialize,
836
+ Help,
837
+ HelpStyle,
838
+ Include, // stringValue: additional include path.
839
+ Language,
840
+ MatrixLayoutColumn, // bool
841
+ MatrixLayoutRow, // bool
842
+ ModuleName, // stringValue0: module name.
843
+ Output,
844
+ Profile, // intValue0: profile
845
+ Stage, // intValue0: stage
846
+ Target, // intValue0: CodeGenTarget
847
+ Version,
848
+ WarningsAsErrors, // stringValue0: "all" or comma separated list of warning codes or names.
849
+ DisableWarnings, // stringValue0: comma separated list of warning codes or names.
850
+ EnableWarning, // stringValue0: warning code or name.
851
+ DisableWarning, // stringValue0: warning code or name.
852
+ DumpWarningDiagnostics,
853
+ InputFilesRemain,
854
+ EmitIr, // bool
855
+ ReportDownstreamTime, // bool
856
+ ReportPerfBenchmark, // bool
857
+ SkipSPIRVValidation, // bool
858
+
859
+ SourceEmbedStyle,
860
+ SourceEmbedName,
861
+ SourceEmbedLanguage,
862
+
863
+ // Target
864
+
865
+ Capability, // intValue0: CapabilityName
866
+ DefaultImageFormatUnknown, // bool
867
+ DisableDynamicDispatch, // bool
868
+ DisableSpecialization, // bool
869
+ FloatingPointMode, // intValue0: FloatingPointMode
870
+ DebugInformation, // intValue0: DebugInfoLevel
871
+ LineDirectiveMode,
872
+ Optimization, // intValue0: OptimizationLevel
873
+ Obfuscate, // bool
874
+
875
+ VulkanBindShift, // intValue0 (lower 8 bits): kind; intValue0(higher bits): set; intValue1: shift
876
+ VulkanBindGlobals, // intValue0: index; intValue1: set
877
+ VulkanInvertY, // bool
878
+ VulkanUseEntryPointName, // bool
879
+ VulkanUseGLLayout, // bool
880
+ VulkanEmitReflection, // bool
881
+
882
+ GLSLForceScalarLayout, // bool
883
+ EnableEffectAnnotations, // bool
884
+
885
+ EmitSpirvViaGLSL, // bool
886
+ EmitSpirvDirectly, // bool
887
+ SPIRVCoreGrammarJSON, // stringValue0: json path
888
+
889
+ // Downstream
890
+
891
+ CompilerPath,
892
+ DefaultDownstreamCompiler,
893
+ DownstreamArgs, // stringValue0: downstream compiler name. stringValue1: argument list, one per line.
894
+ PassThrough,
895
+
896
+ // Repro
897
+
898
+ DumpRepro,
899
+ DumpReproOnError,
900
+ ExtractRepro,
901
+ LoadRepro,
902
+ LoadReproDirectory,
903
+ ReproFallbackDirectory,
904
+
905
+ // Debugging
906
+
907
+ DumpAst,
908
+ DumpIntermediatePrefix,
909
+ DumpIntermediates, // bool
910
+ DumpIr, // bool
911
+ DumpIrIds,
912
+ PreprocessorOutput,
913
+ OutputIncludes,
914
+ ReproFileSystem,
915
+ SerialIr, // bool
916
+ SkipCodeGen, // bool
917
+ ValidateIr, // bool
918
+ VerbosePaths,
919
+ VerifyDebugSerialIr,
920
+ NoCodeGen, // Not used.
921
+
922
+ // Experimental
923
+
924
+ FileSystem,
925
+ Heterogeneous,
926
+ NoMangle,
927
+ AllowGLSL,
928
+
929
+ // Internal
930
+
931
+ ArchiveType,
932
+ CompileStdLib,
933
+ Doc,
934
+ IrCompression,
935
+ LoadStdLib,
936
+ ReferenceModule,
937
+ SaveStdLib,
938
+ SaveStdLibBinSource,
939
+ TrackLiveness,
940
+
941
+ // Deprecated
942
+ ParameterBlocksUseRegisterSpaces,
943
+
944
+ CountOfParsableOptions,
945
+
946
+ // Used in parsed options only.
947
+ DebugInformationFormat, // intValue0: DebugInfoFormat
948
+ VulkanBindShiftAll, // intValue0: kind; intValue1: shift
949
+ GenerateWholeProgram, // bool
950
+
951
+ CountOf,
952
+ };
953
+
954
+ enum class CompilerOptionValueKind
955
+ {
956
+ Int,
957
+ String
958
+ };
959
+
960
+ struct CompilerOptionValue
961
+ {
962
+ CompilerOptionValueKind kind = CompilerOptionValueKind::Int;
963
+ int32_t intValue0 = 0 ;
964
+ int32_t intValue1 = 0 ;
965
+ const char * stringValue0 = nullptr ;
966
+ const char * stringValue1 = nullptr ;
967
+ };
968
+
969
+ struct CompilerOptionEntry
970
+ {
971
+ CompilerOptionName name;
972
+ CompilerOptionValue value;
973
+ };
974
+ }
975
+
827
976
/* * A result code for a Slang API operation.
828
977
829
978
This type is generally compatible with the Windows API `HRESULT` type. In particular, negative values indicate
@@ -2433,9 +2582,16 @@ extern "C"
2433
2582
SLANG_API SlangReflectionVariableLayout* spReflection_getGlobalParamsVarLayout (
2434
2583
SlangReflection* reflection);
2435
2584
2585
+ }
2436
2586
#ifdef __cplusplus
2587
+
2588
+ namespace slang
2589
+ {
2590
+ struct ISession ;
2437
2591
}
2438
2592
2593
+ SLANG_API slang::ISession* spReflection_GetSession (SlangReflection* reflection);
2594
+
2439
2595
/* Helper interfaces for C++ users */
2440
2596
namespace slang
2441
2597
{
@@ -3239,6 +3395,11 @@ namespace slang
3239
3395
return spReflection_GetTypeParameterCount ((SlangReflection*) this );
3240
3396
}
3241
3397
3398
+ slang::ISession* getSession ()
3399
+ {
3400
+ return spReflection_GetSession ((SlangReflection*)this );
3401
+ }
3402
+
3242
3403
TypeParameterReflection* getTypeParameterByIndex (unsigned index)
3243
3404
{
3244
3405
return (TypeParameterReflection*)spReflection_GetTypeParameterByIndex ((SlangReflection*) this , index );
@@ -3350,7 +3511,6 @@ namespace slang
3350
3511
struct ITypeConformance ;
3351
3512
struct IGlobalSession ;
3352
3513
struct IModule ;
3353
- struct ISession ;
3354
3514
3355
3515
struct SessionDesc ;
3356
3516
struct SpecializationArg ;
@@ -3564,6 +3724,16 @@ namespace slang
3564
3724
*/
3565
3725
virtual SLANG_NO_THROW SlangResult SLANG_MCALL setSPIRVCoreGrammar (
3566
3726
char const * jsonPath) = 0;
3727
+
3728
+ /* * Parse slangc command line options into a SessionDesc that can be used to create a session
3729
+ * with all the compiler options specified in the command line.
3730
+ * @param argc The number of command line arguments.
3731
+ * @param argv An input array of command line arguments to parse.
3732
+ * @param outSessionDesc A pointer to a SessionDesc struct to receive parsed session desc.
3733
+ * @param outAuxAllocation Auxillary memory allocated to hold data used in the sesion desc.
3734
+ */
3735
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL parseCommandLineArguments (
3736
+ int argc, const char * const * argv, SessionDesc* outSessionDesc, ISlangUnknown** outAuxAllocation) = 0;
3567
3737
};
3568
3738
3569
3739
#define SLANG_UUID_IGlobalSession IGlobalSession::getTypeGuid ()
@@ -4215,22 +4385,21 @@ namespace slang
4215
4385
/* * Whether to force `scalar` layout for glsl shader storage buffers.
4216
4386
*/
4217
4387
bool forceGLSLScalarBufferLayout = false ;
4388
+
4389
+ /* * Pointer to an array of compiler option entries, whose size is compilerOptionEntryCount.
4390
+ */
4391
+ CompilerOptionEntry* compilerOptionEntries = nullptr ;
4392
+
4393
+ /* * Number of additional compiler option entries.
4394
+ */
4395
+ uint32_t compilerOptionEntryCount = 0 ;
4396
+
4218
4397
};
4219
4398
4220
4399
typedef uint32_t SessionFlags;
4221
4400
enum
4222
4401
{
4223
- kSessionFlags_None = 0 ,
4224
-
4225
- /* * Use application-specific policy for semantics of the `shared` keyword.
4226
-
4227
- This is a legacy/compatibility flag to help an existing Slang client
4228
- migrate to new language features, and should *not* be used by other
4229
- clients. This feature may be removed in a future release without a
4230
- deprecation warning, and this bit may be re-used for another feature.
4231
- You have been warned.
4232
- */
4233
- kSessionFlag_FalcorCustomSharedKeywordSemantics = 1 << 0 ,
4402
+ kSessionFlags_None = 0
4234
4403
};
4235
4404
4236
4405
struct PreprocessorMacroDesc
@@ -4270,6 +4439,15 @@ namespace slang
4270
4439
4271
4440
bool enableEffectAnnotations = false ;
4272
4441
bool allowGLSLSyntax = false ;
4442
+
4443
+ /* * Pointer to an array of compiler option entries, whose size is compilerOptionEntryCount.
4444
+ */
4445
+ CompilerOptionEntry* compilerOptionEntries = nullptr ;
4446
+
4447
+ /* * Number of additional compiler option entries.
4448
+ */
4449
+ uint32_t compilerOptionEntryCount = 0 ;
4450
+
4273
4451
};
4274
4452
4275
4453
enum class ContainerType
@@ -4657,6 +4835,15 @@ namespace slang
4657
4835
*/
4658
4836
virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint (
4659
4837
const char * newName, IComponentType** outEntryPoint) = 0 ;
4838
+
4839
+ /* * Link and specify additional compiler options when generating code
4840
+ * from the linked program.
4841
+ */
4842
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions (
4843
+ IComponentType** outLinkedComponentType,
4844
+ uint32_t compilerOptionEntryCount,
4845
+ CompilerOptionEntry* compilerOptionEntries,
4846
+ ISlangBlob** outDiagnostics = nullptr ) = 0 ;
4660
4847
};
4661
4848
#define SLANG_UUID_IComponentType IComponentType::getTypeGuid ()
4662
4849
0 commit comments