SlangSession

Inherits: RefCounted

A session provides a scope for code that is loaded.

Description

A session provides a scope for code that is loaded.

A session can be used to load modules of Slang source code, and to request target-specific compiled binaries and layout information.

See the Slang documentation for more information.

Properties

ShaderTypeLayoutShape.MatrixLayout

default_matrix_layout

1

bool

enable_glsl

false

SlangCompileTarget

format

6

Dictionary

preprocessor_macros

{}

String

profile

"spirv_1_5"

PackedStringArray

search_paths

PackedStringArray()

Methods

SlangComponentType

create_composite_component_type(component_types: Array[SlangComponentType])

SlangSession

create_default_session() static

Dictionary

get_builtin_macros() static

String

get_builtin_modules_path() static

SlangModule

load_module_from_source_file(module_name: String, path: String)

SlangModule

load_module_from_source_string(module_name: String, path: String, source_text: String)


Enumerations

enum SlangCompileTarget: 🔗

SlangCompileTarget SLANG_TARGET_UNKNOWN = 0

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_TARGET_NONE = 1

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_GLSL = 2

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_GLSL_VULKAN_DEPRECATED = 3

Deprecated: deprecated and removed: just use SLANG_GLSL.

SlangCompileTarget SLANG_GLSL_VULKAN_ONE_DESC_DEPRECATED = 4

Deprecated: deprecated and removed

SlangCompileTarget SLANG_HLSL = 5

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_SPIRV = 6

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_SPIRV_ASM = 7

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_DXBC = 8

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_DXBC_ASM = 9

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_DXIL = 10

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_DXIL_ASM = 11

There is currently no description for this enum. Please help us by contributing one!

SlangCompileTarget SLANG_C_SOURCE = 12

The C language

SlangCompileTarget SLANG_CPP_SOURCE = 13

C++ code for shader kernels.

SlangCompileTarget SLANG_HOST_EXECUTABLE = 14

Standalone binary executable (for hosting CPU/OS)

SlangCompileTarget SLANG_SHADER_SHARED_LIBRARY = 15

A shared library/Dll for shader kernels (for hosting CPU/OS)

SlangCompileTarget SLANG_SHADER_HOST_CALLABLE = 16

A CPU target that makes the compiled shader code available to be run immediately

SlangCompileTarget SLANG_CUDA_SOURCE = 17

Cuda source

SlangCompileTarget SLANG_PTX = 18

PTX

SlangCompileTarget SLANG_CUDA_OBJECT_CODE = 19

Object code that contains CUDA functions.

SlangCompileTarget SLANG_OBJECT_CODE = 20

Object code that can be used for later linking (kernel/shader)

SlangCompileTarget SLANG_HOST_CPP_SOURCE = 21

C++ code for host library or executable.

SlangCompileTarget SLANG_HOST_HOST_CALLABLE = 22

Host callable host code (ie non kernel/shader)

SlangCompileTarget SLANG_CPP_PYTORCH_BINDING = 23

C++ PyTorch binding code.

SlangCompileTarget SLANG_METAL = 24

Metal shading language

SlangCompileTarget SLANG_METAL_LIB = 25

Metal library

SlangCompileTarget SLANG_METAL_LIB_ASM = 26

Metal library assembly

SlangCompileTarget SLANG_HOST_SHARED_LIBRARY = 27

A shared library/Dll for host code (for hosting CPU/OS)

SlangCompileTarget SLANG_WGSL = 28

WebGPU shading language

SlangCompileTarget SLANG_WGSL_SPIRV_ASM = 29

SPIR-V assembly via WebGPU shading language

SlangCompileTarget SLANG_WGSL_SPIRV = 30

SPIR-V via WebGPU shading language

SlangCompileTarget SLANG_HOST_VM = 31

Bytecode that can be interpreted by the Slang VM

SlangCompileTarget SLANG_CPP_HEADER = 32

C++ header for shader kernels.

SlangCompileTarget SLANG_CUDA_HEADER = 33

Cuda header

SlangCompileTarget SLANG_HOST_OBJECT_CODE = 34

Host object code

SlangCompileTarget SLANG_HOST_LLVM_IR = 35

Host LLVM IR assembly

SlangCompileTarget SLANG_SHADER_LLVM_IR = 36

Host LLVM IR assembly (kernel/shader)

SlangCompileTarget SLANG_TARGET_MAX = 37

There is currently no description for this enum. Please help us by contributing one!


Property Descriptions

ShaderTypeLayoutShape.MatrixLayout default_matrix_layout = 1 🔗

  • void set_default_matrix_layout(value: ShaderTypeLayoutShape.MatrixLayout)

  • ShaderTypeLayoutShape.MatrixLayout get_default_matrix_layout()

The default matrix layout for this compilation session.

This should never be changed after loading any modules with this session, create a new session instead.


bool enable_glsl = false 🔗

  • void set_enable_glsl(value: bool)

  • bool get_enable_glsl()

True if GLSL is enabled for this session.

This should never be changed after loading any modules with this session, create a new session instead.


SlangCompileTarget format = 6 🔗

The target format to generate code for (e.g., SPIR-V, DXIL, etc.).

This should never be changed after loading any modules with this session, create a new session instead.


Dictionary preprocessor_macros = {} 🔗

  • void set_preprocessor_macros(value: Dictionary)

  • Dictionary get_preprocessor_macros()

The preprocessor macros to define for compilation.

This should never be changed after loading any modules with this session, create a new session instead.


String profile = "spirv_1_5" 🔗

  • void set_profile(value: String)

  • String get_profile()

The profile to use for compilation. Consult Slang documentation for the list of valid profiles.

This should never be changed after loading any modules with this session, create a new session instead.


PackedStringArray search_paths = PackedStringArray() 🔗

  • void set_search_paths(value: PackedStringArray)

  • PackedStringArray get_search_paths()

The search paths to use during compilation when searching for included or imported files.

This should never be changed after loading any modules with this session, create a new session instead.

Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.


Method Descriptions

SlangComponentType create_composite_component_type(component_types: Array[SlangComponentType]) 🔗

Combine multiple component types to create a composite component type.


SlangSession create_default_session() static 🔗

Create a session configured to use the default / built-in modules and preprocess macros.


Dictionary get_builtin_macros() static 🔗

Gets the preprocessor macros declared for built-in modules included with the Godot Slang plugin.

For example, this includes the GODOT_MAJOR_VERSION and GODOT_MINOR_VERSION macros.


String get_builtin_modules_path() static 🔗

Gets the (globalized) path containing the Slang modules included with this plugin.


SlangModule load_module_from_source_file(module_name: String, path: String) 🔗

Loads a module into this session from a file path.


SlangModule load_module_from_source_string(module_name: String, path: String, source_text: String) 🔗

Loads a module into this session from a String containing the source code.