3

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?

Jeff Linahan
  • 3,775
  • 5
  • 37
  • 56
Ives TI
  • 137
  • 2
  • 9

2 Answers2

3

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.

dj2
  • 9,534
  • 4
  • 29
  • 52
2

Solveld adding -fshader-stage=vertex

Ives TI
  • 137
  • 2
  • 9