You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapters/hlsl.adoc
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,6 @@ ifndef::images[:images: images/]
7
7
8
8
[[hlsl-in-vulkan]]
9
9
= HLSL in Vulkan
10
-
:toc:
11
10
12
11
Vulkan does not directly consume shaders in a human-readable text format, but instead uses xref:{chapters}what_is_spirv.adoc[SPIR-V] as an intermediate representation. This opens the option to use shader languages other than e.g. GLSL, as long as they can target the Vulkan SPIR-V environment.
Vulkan does not directly consume shaders in a human-readable text format, but instead uses xref:{chapters}what_is_spirv.adoc[SPIR-V] as an intermediate representation. This opens the option to use shader languages other than e.g. GLSL, as long as they can target the Vulkan SPIR-V environment.
13
13
14
14
link:https://github.com/shader-slang/slang[Slang] is a modern shading language and compiler designed to extend xref:{chapters}hlsl.adoc[HLSL] with advanced features. It's largely backward-compatible with HLSL 2018 but adds features like generics, interfaces, and reflection capabilities. Slang can target multiple backends, including SPIR-V for Vulkan.
15
15
16
16
With link:https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#unsupported-hlsl-features[a few exceptions], all Vulkan features and shader stages available with GLSL can be used with Slang too, including recent Vulkan additions like hardware accelerated ray tracing. On the other hand, Slang to SPIR-V supports Vulkan exclusive features that are not (yet) available in DirectX.
For Slang, the official link:https://github.com/shader-slang/slang[GitHub repository] and link:https://docs.shader-slang.org/en/latest/[documentation] are the best resources to get started.
22
+
For Slang, the official link:https://github.com/shader-slang/slang[GitHub repository] and link:https://docs.shader-slang.org/en/latest/[documentation] are the best resources to get started. Additionally, the best place to get help is the link:https://khr.io/slangdiscord[slang discord server].
24
23
25
24
== Why Use Slang for Vulkan?
26
25
@@ -34,7 +33,7 @@ There are several advantages to using Slang for Vulkan development:
34
33
35
34
== Differences Between HLSL and Slang
36
35
37
-
While Slang is built on HLSL and maintains backward compatibility, it adds several powerful features that make shader development more efficient, maintainable, and flexible.
36
+
While Slang is built on HLSL, it adds several powerful features that make shader development more efficient, maintainable, and flexible.
38
37
39
38
=== Generics and Templates
40
39
@@ -148,7 +147,7 @@ While Slang maintains HLSL syntax compatibility, it introduces some new syntax e
148
147
149
148
=== Compilation Differences
150
149
151
-
Slang provides its own compiler (`slangc`) with different capabilities than the HLSL compiler:
150
+
Slang provides its own compiler (`slangc`) and runtime compilation API with different capabilities than the HLSL compiler:
152
151
153
152
* *Multi-target compilation*: Compile the same shader for multiple graphics APIs
154
153
* *Cross-compilation*: Generate code for different shader stages from a single source
@@ -179,7 +178,7 @@ From the application's point-of-view, using Slang is exactly the same as using G
179
178
180
179
== Migration Guide: from HLSL to Slang
181
180
182
-
Migrating from HLSL to Slang can be done incrementally, as Slang maintains backward compatibility with HLSL. This guide provides a step-by-step approach to migrating your shaders.
181
+
Migrating from HLSL to Slang can be done incrementally, as Slang is similar enough to HLSL that it mostly supports HLSL. This guide provides a step-by-step approach to migrating your shaders.
183
182
184
183
[TIP]
185
184
====
@@ -461,6 +460,13 @@ For HLSL compatibility mode:
461
460
slangc -profile glsl_spirv -entry main -o output.spv -language hlsl input.hlsl
462
461
----
463
462
463
+
For GLSL compatibility mode:
464
+
465
+
[source]
466
+
----
467
+
slangc -profile glsl_spirv -entry main -o output.spv -language glsl input.glsl
468
+
----
469
+
464
470
Key command-line options include:
465
471
466
472
* `-profile`: Specifies the target profile (use `glsl_spirv` for Vulkan)
0 commit comments