Skip to content

Conversation

@gpx1000
Copy link
Contributor

@gpx1000 gpx1000 commented Jul 21, 2025

No description provided.

@spencer-lunarg
Copy link
Contributor

I know @SaschaWillems already wrote a whole chapter around this "area" so want him approval

Also @swoods-nv would also be great to review

Copy link

@swoods-nv swoods-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main overarching comment is that I'd recommend caution when phrasing migration from HLSL->Slang as "upgrading" or similar. Vulkan consciously chooses not to have an official shading language, and both Slang and HLSL continue to evolve and gain new features.

@SaschaWillems
Copy link
Collaborator

There is def. some duplication here. The chapters I did are:

The latter was written with additional shading languages in mind.

So maybe it's better to

  • To a general slang chapter like the one I did for HLSL (first link)
  • And add slang to the already available high level shader language comparison (second link)

A separate chapter that kinda combines what we have + slang might be confusing.

@gpx1000
Copy link
Contributor Author

gpx1000 commented Jul 22, 2025

Okay, sounds good, I'll try to move things around.

@SaschaWillems
Copy link
Collaborator

Btw. the official slang docs do have migration guides, so maybe something we could link to:

@gpx1000
Copy link
Contributor Author

gpx1000 commented Jul 22, 2025

Good call on using those links, I'll add it in. The next version will have a lot of copy pasting to place the details in the right place. Should have a new version once I finish reviewing all changes.

@gpx1000
Copy link
Contributor Author

gpx1000 commented Jul 22, 2025

Alright, significant copy/pasting and reorganizing into the existing structure. I don't think I lost any of the details I wrote in the original version. However, hopefully that's closer to where things should go.


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.

image::{images}what_is_spirv_dxc.png[what_is_spriv_dxc.png]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is here, feels unrelated to Slang

Copy link
Contributor

@spencer-lunarg spencer-lunarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Adding Slang to the high_level_shader_language_comparison.adoc page is great (I often know a term in in GLSL and need to look up the Slang equivalent)
  • Will wait for @SaschaWillems approval on the HLSL additions added
  • Will wait for @swoods-nv for a re-read and approval on the new Slang chapter

* Be mindful of matrix layout differences
* Consider using a shader generation system

=== Performance Optimization
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything after (and including) this chapter (up to the conclusion) isn't specific to HLSL. Might be better to move this to a separate chapter.

* *Consider push constants*: Use push constants for frequently changing small data
* *Be mindful of SPIR-V limitations*: Some HLSL features may not translate directly to SPIR-V

== Migration from GLSL to HLSL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lof ot content in this chapter is a duplication of what's already present in the high level shading language chapter. Might be better to just link to that instead.


[[hlsl-in-vulkan]]
= HLSL in Vulkan
:toc:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this was explicitly added? Antora already takes care o the toc, this might lead to a duplicated toc in the docs site build.

float4x4 projection;
};
[[vk::binding(0, 0)]]
ConstantBuffer<SceneUBO> ubo;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is meant to show a portable shader, register notation should be added.

struct Input
{
float3 position : POSITION;
float3 normal : NORMAL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik you can skip pretty much all of those semantics all along in Slang. I don't use stuff like NORMAL, TEXCOORDn, etc. in my samples with Slang.

};
// Declare a parameter block with explicit binding
[[vk::binding(0, 0)]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik the whole idea behind parameter blocks is that you DON'T need to specify explicit bindings anymore.

@SaschaWillems
Copy link
Collaborator

That's a lot of text to review ^^

Added a few comments. One of the things that IMO needs more attention is Skang's ability to automatically generate binding slots. For me, that was one of the best things about Slang, and while you can somehow find that information in this PR I'd like to see that more explicitly stated.

[[educational-resources]]
== Educational resources

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's worth mentioning here, but the Slang Discord is an additional resource; this can be especially helpful if you are troubleshooting.


== Differences Between HLSL and Slang

While Slang is built on HLSL and maintains backward compatibility, it adds several powerful features that make shader development more efficient, maintainable, and flexible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more "backward compatibility" here that should get softened.


=== Compilation Differences

Slang provides its own compiler (`slangc`) with different capabilities than the HLSL compiler:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth mentioning the runtime compilation API here as well


== Migration Guide: from HLSL to Slang

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"backward compatibility" again

slangc -profile glsl_spirv -entry main -o output.spv input.slang
----

For HLSL compatibility mode:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there's also a GLSL full-compatibility flag (but can't remember the specific cases that it's required for -- in general, Slang can handle most GLSL without the flag. The migration Slang doc page might have more info.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants