glslang use with HLSL

Hi,

Sorry, it’s probably a newbie question, but, I’m trying to use glslang library to convert some HLSL shader into SPIR-V.

after a call to ShCompile(), ShGetInfoLog() returns the following string

ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan.

So the HLSL is correctly detected but it seems the compiler doesn’t know it has to produce a Vulkan shader.
How can I do this ?
Am I missing something ?

Thanks.

Defeault is OpenGL environment target. Vulkan target has to be enabled in options.
Use EShMsgVulkanRules.

Thanks.

I was using EShMsgReadHlsl| EShMsgSpvRules but also adding EShMsgVulkanRules seems to be a ‘little’ better.

The next issue is '#include’ : Could not process include directive for header name: (…)

uh ? :doh:
Should I preprocess the file by myself ?

ShCompile() probably has no way to know what paths to search for #include.
Probably full path has to be provided, or maybe there are some additional settings?

I finally switched to the C++ API which takes an include handler object as input while there is no such functionality with the C API for some reason…

Now, I’m trying to use reflection data. I’ve managed to retrieve constant buffers & resource binding info, but it seems that info about a shader stage input / output other than vertex attributes are missing (I’m looking for something similar to what’s called ‘signature’ in d3d shaders, describing not only vertex attributes but also in/out interpolators, etc…).
If someone knows how to retrieve this from TShader, TProgram or spv binary, I’m interested in.

I use SPIRV-Cross for my reflection needs: GitHub - KhronosGroup/SPIRV-Cross: SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.

Not 100% sure if it exposes all the resources you’re interested in, but it’s worth investigating at least.