Skip to content

Commit 13bc017

Browse files
committed
Refine Slang documentation: improve wording, add Discord link, and include GLSL compatibility example.
1 parent ad089d1 commit 13bc017

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

chapters/high_level_shader_language_comparison.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ interface IVertexShader
269269
// Input structure with semantics
270270
struct Input
271271
{
272-
float3 position : POSITION;
273-
float3 normal : NORMAL;
274-
float2 texCoord : TEXCOORD0;
272+
float3 position;
273+
float3 normal;
274+
float2 texCoord;
275275
};
276276
277277
// Output structure with semantics
@@ -471,7 +471,6 @@ struct MaterialResources
471471
};
472472
473473
// Declare a parameter block with explicit binding
474-
[[vk::binding(0, 0)]]
475474
ParameterBlock<MaterialResources> material;
476475
477476
// Usage in shader code

chapters/hlsl.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ifndef::images[:images: images/]
77

88
[[hlsl-in-vulkan]]
99
= HLSL in Vulkan
10-
:toc:
1110

1211
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.
1312

@@ -68,7 +67,7 @@ struct SceneUBO {
6867
float4x4 projection;
6968
};
7069
[[vk::binding(0, 0)]]
71-
ConstantBuffer<SceneUBO> ubo;
70+
ConstantBuffer<SceneUBO> ubo : register(0, 0);
7271
// Vertex shader main function
7372
VSOutput main(VSInput input) {
7473
VSOutput output = (VSOutput)0;

chapters/slang.adoc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ ifndef::images[:images: images/]
77

88
[[slang-in-vulkan]]
99
= Slang in Vulkan
10-
:toc:
10+
1111

1212
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.
1313

1414
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.
1515

1616
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.
1717

18-
image::{images}what_is_spirv_dxc.png[what_is_spriv_dxc.png]
1918

2019
[[educational-resources]]
2120
== Educational resources
2221

23-
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].
2423

2524
== Why Use Slang for Vulkan?
2625

@@ -34,7 +33,7 @@ There are several advantages to using Slang for Vulkan development:
3433

3534
== Differences Between HLSL and Slang
3635

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.
3837

3938
=== Generics and Templates
4039

@@ -148,7 +147,7 @@ While Slang maintains HLSL syntax compatibility, it introduces some new syntax e
148147

149148
=== Compilation Differences
150149

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:
152151

153152
* *Multi-target compilation*: Compile the same shader for multiple graphics APIs
154153
* *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
179178

180179
== Migration Guide: from HLSL to Slang
181180

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.
183182

184183
[TIP]
185184
====
@@ -461,6 +460,13 @@ For HLSL compatibility mode:
461460
slangc -profile glsl_spirv -entry main -o output.spv -language hlsl input.hlsl
462461
----
463462

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+
464470
Key command-line options include:
465471

466472
* `-profile`: Specifies the target profile (use `glsl_spirv` for Vulkan)

0 commit comments

Comments
 (0)