Ives TI
Ives TI

Reputation: 147

How to compile HLSL shaders with Vulkan?

I'm current learning Vulkan API, it's time to create pipeline, I chose HLSL because in the future I want to reuse shaders in DirectX and when I get an RTX GPU I intend to bring ray tracing, I'm new in HLSL, I wrote a simple vertex shader:

float4 main(float2 pos : POSITIONT) : SV_POSITION
{
    return float4(pos, 0, 1);
}

Following this tutorial i try to compile: glslc.exe VertexShader.hlsl -o vertex.spv

And i get this error: glslc: error: 'VertexShader.hlsl': .hlsl file encountered but no -fshader-stage specified ahead

So, how to compile HLSL in Vulkan?

Upvotes: 3

Views: 4461

Answers (2)

dj2
dj2

Reputation: 9620

The other option is to use the DXC compiler (https://github.com/Microsoft/DirectXShaderCompiler) which has a SPIR-V backend available. This would be the same compiler you end up using with DirectX as well.

Upvotes: 3

Ives TI
Ives TI

Reputation: 147

Solveld adding -fshader-stage=vertex

Upvotes: 2

Related Questions