yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
4d20fd329
master
1public namespace slang 2{ 3 4public typedef int32_t Result; 5public typedef uint64_t Size; 6public typedef int64_t Int; 7public typedef uint64_t UInt; 8 9/*! 10@brief Severity of a diagnostic generated by the compiler. 11Values come from the enum below, with higher values representing more severe 12conditions, and all values >= SLANG_SEVERITY_ERROR indicating compilation 13failure. 14*/ 15public enum SlangSeverity 16{ 17 SLANG_SEVERITY_DISABLED = 0, /**< A message that is disabled, filtered out. */ 18 SLANG_SEVERITY_NOTE, /**< An informative message. */ 19 SLANG_SEVERITY_WARNING, /**< A warning, which indicates a possible proble. */ 20 SLANG_SEVERITY_ERROR, /**< An error, indicating that compilation failed. */ 21 SLANG_SEVERITY_FATAL, /**< An unrecoverable error, which forced compilation to abort. */ 22 SLANG_SEVERITY_INTERNAL, /**< An internal error, indicating a logic error in the compiler. */ 23}; 24 25public enum SlangDiagnosticFlags 26{ 27 SLANG_DIAGNOSTIC_FLAG_VERBOSE_PATHS = 0x01, 28 SLANG_DIAGNOSTIC_FLAG_TREAT_WARNINGS_AS_ERRORS = 0x02 29}; 30 31public enum SlangBindableResourceType 32{ 33 SLANG_NON_BINDABLE = 0, 34 SLANG_TEXTURE, 35 SLANG_SAMPLER, 36 SLANG_UNIFORM_BUFFER, 37 SLANG_STORAGE_BUFFER, 38}; 39 40public enum SlangCompileTarget 41{ 42 SLANG_TARGET_UNKNOWN, 43 SLANG_TARGET_NONE, 44 SLANG_GLSL, 45 SLANG_GLSL_VULKAN, //< deprecated: just use `SLANG_GLSL` 46 SLANG_GLSL_VULKAN_ONE_DESC, //< deprecated 47 SLANG_HLSL, 48 SLANG_SPIRV, 49 SLANG_SPIRV_ASM, 50 SLANG_DXBC, 51 SLANG_DXBC_ASM, 52 SLANG_DXIL, 53 SLANG_DXIL_ASM, 54 SLANG_C_SOURCE, ///< The C language 55 SLANG_CPP_SOURCE, ///< C++ code for shader kernels. 56 SLANG_CPP_PYTORCH_BINDING, 57 SLANG_HOST_EXECUTABLE, ///< Standalone binary executable (for hosting CPU/OS) 58 SLANG_SHADER_SHARED_LIBRARY, ///< A shared library/Dll for shader kernels (for hosting CPU/OS) 59 SLANG_SHADER_HOST_CALLABLE, ///< A CPU target that makes the compiled shader code available to be run immediately 60 SLANG_CUDA_SOURCE, ///< Cuda source 61 SLANG_PTX, ///< PTX 62 SLANG_OBJECT_CODE, ///< Object code that can be used for later linking 63 SLANG_HOST_CPP_SOURCE, ///< C++ code for host library or executable. 64 SLANG_HOST_HOST_CALLABLE, ///< 65 SLANG_TARGET_COUNT_OF, 66}; 67 68/* A "container format" describes the way that the outputs 69for multiple files, entry points, targets, etc. should be 70combined into a single artifact for output. */ 71public enum SlangContainerFormat 72{ 73 /* Don't generate a container. */ 74 SLANG_CONTAINER_FORMAT_NONE, 75 76 /* Generate a container in the `.slang-module` format, 77 which includes reflection information, compiled kernels, etc. */ 78 SLANG_CONTAINER_FORMAT_SLANG_MODULE, 79}; 80 81public enum SlangPassThrough : int 82{ 83 SLANG_PASS_THROUGH_NONE, 84 SLANG_PASS_THROUGH_FXC, 85 SLANG_PASS_THROUGH_DXC, 86 SLANG_PASS_THROUGH_GLSLANG, 87 SLANG_PASS_THROUGH_SPIRV_DIS, 88 SLANG_PASS_THROUGH_CLANG, ///< Clang C/C++ compiler 89 SLANG_PASS_THROUGH_VISUAL_STUDIO, ///< Visual studio C/C++ compiler 90 SLANG_PASS_THROUGH_GCC, ///< GCC C/C++ compiler 91 SLANG_PASS_THROUGH_GENERIC_C_CPP, ///< Generic C or C++ compiler, which is decided by the source type 92 SLANG_PASS_THROUGH_NVRTC, ///< NVRTC Cuda compiler 93 SLANG_PASS_THROUGH_LLVM, ///< LLVM 'compiler' - includes LLVM and Clang 94 SLANG_PASS_THROUGH_SPIRV_OPT, 95 SLANG_PASS_THROUGH_COUNT_OF, 96}; 97 98/* Defines an archive type used to holds a 'file system' type structure. */ 99public enum SlangArchiveType : int 100{ 101 SLANG_ARCHIVE_TYPE_UNDEFINED, 102 SLANG_ARCHIVE_TYPE_ZIP, 103 SLANG_ARCHIVE_TYPE_RIFF, ///< Riff container with no compression 104 SLANG_ARCHIVE_TYPE_RIFF_DEFLATE, 105 SLANG_ARCHIVE_TYPE_RIFF_LZ4, 106 SLANG_ARCHIVE_TYPE_COUNT_OF, 107}; 108 109/*! 110Flags to control compilation behavior. 111*/ 112public enum SlangCompileFlags 113{ 114 /* Do as little mangling of names as possible, to try to preserve original names */ 115 SLANG_COMPILE_FLAG_NO_MANGLING = 1 << 3, 116 117 /* Skip code generation step, just check the code and generate layout */ 118 SLANG_COMPILE_FLAG_NO_CODEGEN = 1 << 4, 119 120 /* Obfuscate shader names on release products */ 121 SLANG_COMPILE_FLAG_OBFUSCATE = 1 << 5, 122 123 /* Deprecated flags: kept around to allow existing applications to 124 compile. Note that the relevant features will still be left in 125 their default state. */ 126 SLANG_COMPILE_FLAG_NO_CHECKING = 0, 127 SLANG_COMPILE_FLAG_SPLIT_MIXED_TYPES = 0, 128}; 129 130/*! 131@brief Flags to control code generation behavior of a compilation target */ 132public enum SlangTargetFlags 133{ 134 None = 0, 135 136 /* When compiling for a D3D Shader Model 5.1 or higher target, allocate 137 distinct register spaces for parameter blocks. 138 139 @deprecated This behavior is now enabled unconditionally. 140 */ 141 SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES = 1 << 4, 142 143 /* When set, will generate target code that contains all entrypoints defined 144 in the input source or specified via the `spAddEntryPoint` function in a 145 single output module (library/source file). 146 */ 147 SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM = 1 << 8, 148 149 /* When set, will dump out the IR between intermediate compilation steps.*/ 150 SLANG_TARGET_FLAG_DUMP_IR = 1 << 9, 151 152 /* When set, will generate SPIRV directly instead of going through glslang. */ 153 SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY = 1 << 10, 154}; 155 156/*! 157@brief Options to control floating-point precision guarantees for a target. 158*/ 159public enum SlangFloatingPointMode 160{ 161 SLANG_FLOATING_POINT_MODE_DEFAULT = 0, 162 SLANG_FLOATING_POINT_MODE_FAST, 163 SLANG_FLOATING_POINT_MODE_PRECISE, 164}; 165 166/*! 167@brief Options to control emission of `#line` directives 168*/ 169public enum SlangLineDirectiveMode 170{ 171 SLANG_LINE_DIRECTIVE_MODE_DEFAULT = 0, /**< Default behavior: pick behavior base on target. */ 172 SLANG_LINE_DIRECTIVE_MODE_NONE, /**< Don't emit line directives at all. */ 173 SLANG_LINE_DIRECTIVE_MODE_STANDARD, /**< Emit standard C-style `#line` directives. */ 174 SLANG_LINE_DIRECTIVE_MODE_GLSL, /**< Emit GLSL-style directives with file *number* instead of name */ 175}; 176 177public enum SlangSourceLanguage : int 178{ 179 SLANG_SOURCE_LANGUAGE_UNKNOWN, 180 SLANG_SOURCE_LANGUAGE_SLANG, 181 SLANG_SOURCE_LANGUAGE_HLSL, 182 SLANG_SOURCE_LANGUAGE_GLSL, 183 SLANG_SOURCE_LANGUAGE_C, 184 SLANG_SOURCE_LANGUAGE_CPP, 185 SLANG_SOURCE_LANGUAGE_CUDA, 186 SLANG_SOURCE_LANGUAGE_COUNT_OF, 187}; 188 189public enum SlangProfileID 190{ 191 SLANG_PROFILE_UNKNOWN, 192}; 193 194public enum SlangCapabilityID 195{ 196 SLANG_CAPABILITY_UNKNOWN = 0, 197}; 198 199public enum SlangMatrixLayoutMode 200{ 201 SLANG_MATRIX_LAYOUT_MODE_UNKNOWN = 0, 202 SLANG_MATRIX_LAYOUT_ROW_MAJOR, 203 SLANG_MATRIX_LAYOUT_COLUMN_MAJOR, 204}; 205 206public enum SlangStage 207{ 208 SLANG_STAGE_NONE, 209 SLANG_STAGE_VERTEX, 210 SLANG_STAGE_HULL, 211 SLANG_STAGE_DOMAIN, 212 SLANG_STAGE_GEOMETRY, 213 SLANG_STAGE_FRAGMENT, 214 SLANG_STAGE_COMPUTE, 215 SLANG_STAGE_RAY_GENERATION, 216 SLANG_STAGE_INTERSECTION, 217 SLANG_STAGE_ANY_HIT, 218 SLANG_STAGE_CLOSEST_HIT, 219 SLANG_STAGE_MISS, 220 SLANG_STAGE_CALLABLE, 221 SLANG_STAGE_MESH, 222 SLANG_STAGE_AMPLIFICATION, 223}; 224 225public enum SlangDebugInfoLevel 226{ 227 SLANG_DEBUG_INFO_LEVEL_NONE = 0, /**< Don't emit debug information at all. */ 228 SLANG_DEBUG_INFO_LEVEL_MINIMAL, /**< Emit as little debug information as possible, while still supporting stack trackes. */ 229 SLANG_DEBUG_INFO_LEVEL_STANDARD, /**< Emit whatever is the standard level of debug information for each target. */ 230 SLANG_DEBUG_INFO_LEVEL_MAXIMAL, /**< Emit as much debug infromation as possible for each target. */ 231}; 232 233public enum SlangOptimizationLevel 234{ 235 SLANG_OPTIMIZATION_LEVEL_NONE = 0, /**< Don't optimize at all. */ 236 SLANG_OPTIMIZATION_LEVEL_DEFAULT, /**< Default optimization level: balance code quality and compilation time. */ 237 SLANG_OPTIMIZATION_LEVEL_HIGH, /**< Optimize aggressively. */ 238 SLANG_OPTIMIZATION_LEVEL_MAXIMAL, /**< Include optimizations that may take a very long time, or may involve severe space-vs-speed tradeoffs */ 239}; 240public enum SlangTypeKind 241{ 242 NONE, 243 STRUCT, 244 ARRAY, 245 MATRIX, 246 VECTOR, 247 SCALAR, 248 CONSTANT_BUFFER, 249 RESOURCE, 250 SAMPLER_STATE, 251 TEXTURE_BUFFER, 252 SHADER_STORAGE_BUFFER, 253 PARAMETER_BLOCK, 254 GENERIC_TYPE_PARAMETER, 255 INTERFACE, 256 OUTPUT_STREAM, 257 SPECIALIZED, 258 FEEDBACK, 259 COUNT, 260}; 261 262public enum SlangScalarType 263{ 264 NONE, 265 VOID, 266 BOOL, 267 INT32, 268 UINT32, 269 INT64, 270 UINT64, 271 FLOAT16, 272 FLOAT32, 273 FLOAT64, 274 INT8, 275 UINT8, 276 INT16, 277 UINT16, 278}; 279 280public struct TypeReflection 281{ 282}; 283 284public enum CompileStdLibFlags 285{ 286 WriteDocumentation = 0x1, 287}; 288 289[COM("8BA5FB08-5195-40e2-AC58-0D-98-9C-3A-01-02")] 290public interface ISlangBlob 291{ 292 public void *getBufferPointer(); 293 public Size getBufferSize(); 294}; 295 296/** Description of a code generation target. 297 */ 298public struct TargetDesc 299{ 300 /** The size of this structure, in bytes. 301 */ 302 public Size structureSize = 40; 303 304 /** The target format to generate code for (e.g., SPIR-V, DXIL, etc.) 305 */ 306 public SlangCompileTarget format = SlangCompileTarget.SLANG_TARGET_UNKNOWN; 307 308 /** The compilation profile supported by the target (e.g., "Shader Model 5.1") 309 */ 310 public SlangProfileID profile = SlangProfileID.SLANG_PROFILE_UNKNOWN; 311 312 /** Flags for the code generation target. Currently unused. */ 313 public SlangTargetFlags flags = SlangTargetFlags.None; 314 315 /** Default mode to use for floating-point operations on the target. 316 */ 317 public SlangFloatingPointMode floatingPointMode = SlangFloatingPointMode.SLANG_FLOATING_POINT_MODE_DEFAULT; 318 319 /** Optimization level to use for the target. 320 */ 321 public SlangOptimizationLevel optimizationLevel = SlangOptimizationLevel.SLANG_OPTIMIZATION_LEVEL_DEFAULT; 322 323 /** The line directive mode for output source code. 324 */ 325 public SlangLineDirectiveMode lineDirectiveMode = SlangLineDirectiveMode.SLANG_LINE_DIRECTIVE_MODE_DEFAULT; 326 327 /** Whether to force `scalar` layout for glsl shader storage buffers. 328 */ 329 public bool forceGLSLScalarBufferLayout = false; 330}; 331 332public enum SessionFlags 333{ 334 kSessionFlags_None = 0 335}; 336 337public struct PreprocessorMacroDesc 338{ 339 public NativeString name; 340 public NativeString value; 341}; 342 343public struct SessionDesc 344{ 345 /** The size of this structure, in bytes. 346 */ 347 public Size structureSize = 72; 348 349 /** Code generation targets to include in the session. 350 */ 351 public TargetDesc *targets = nullptr; 352 public Int targetCount = 0; 353 354 /** Flags to configure the session. 355 */ 356 public SessionFlags flags = SessionFlags.kSessionFlags_None; 357 358 /** Default layout to assume for variables with matrix types. 359 */ 360 public SlangMatrixLayoutMode defaultMatrixLayoutMode = SlangMatrixLayoutMode.SLANG_MATRIX_LAYOUT_ROW_MAJOR; 361 362 /** Paths to use when searching for `#include`d or `import`ed files. 363 */ 364 public NativeString *searchPaths = nullptr; 365 public Int searchPathCount = 0; 366 367 public PreprocessorMacroDesc *preprocessorMacros = nullptr; 368 public Int preprocessorMacroCount = 0; 369 370 public void *fileSystem = nullptr; 371}; 372 373/** A global session for interaction with the Slang library. 374 375An application may create and re-use a single global session across 376multiple sessions, in order to amortize startups costs (in current 377Slang this is mostly the cost of loading the Slang standard library). 378 379The global session is currently *not* thread-safe and objects created from 380a single global session should only be used from a single thread at 381a time. 382*/ 383[COM("c140b5fd-0c78-452e-ba7c-1a-1e-70-c7-f7-1c")] 384public interface IGlobalSession 385{ 386}; 387 388public enum class ContainerType 389{ 390 None, UnsizedArray, StructuredBuffer, ConstantBuffer, ParameterBlock 391}; 392 393/** A session provides a scope for code that is loaded. 394 395A session can be used to load modules of Slang source code, 396and to request target-specific compiled binaries and layout 397information. 398 399In order to be able to load code, the session owns a set 400of active "search paths" for resolving `#include` directives 401and `import` declrations, as well as a set of global 402preprocessor definitions that will be used for all code 403that gets `import`ed in the session. 404 405If multiple user shaders are loaded in the same session, 406and import the same module (e.g., two source files do `import X`) 407then there will only be one copy of `X` loaded within the session. 408 409In order to be able to generate target code, the session 410owns a list of available compilation targets, which specify 411code generation options. 412 413Code loaded and compiled within a session is owned by the session 414and will remain resident in memory until the session is released. 415Applications wishing to control the memory usage for compiled 416and loaded code should use multiple sessions. 417*/ 418[COM("67618701-d116-468f-ab3b-47-4b-ed-ce-0e-3d")] 419public interface ISession 420{ 421}; 422 423[COM("5bc42be8-5c50-4929-9e5e-d15e7c24015f")] 424public interface IComponentType 425{ 426} 427 428public struct TypeLayoutReflection { } 429 430/** The kind of specialization argument. */ 431public enum class SpecializationArgKind : int32_t 432{ 433 Unknown, /**< An invalid specialization argument. */ 434 Type, /**< Specialize to a type. */ 435}; 436 437public struct SpecializationArg 438{ 439 public SpecializationArgKind kind; 440 /** A type specialization argument, used for `Kind::Type`. */ 441 public TypeReflection *type; 442} 443 444}