shaderc icon indicating copy to clipboard operation
shaderc copied to clipboard

HLSL descriptor mapping doc ?

Open vlj opened this issue 7 years ago • 5 comments

glslc is able to build hlsl shader but it's not obvious how to describe descriptor layout. I'm not sure if it's possible to embed a root signature and how it maps to vulkan layouts.

vlj avatar Nov 28 '16 19:11 vlj

glslc's HLSL support is not yet complete.

glslc inherits the behaviours of Glslang. Glslang's dialect of HLSL allows layout(set= , binding=) and layout(push_constant), similar to how Vulkan bindings are supported for GLSL. For the Vulkan GLSL rules see https://www.khronos.org/registry/vulkan/specs/misc/GL_KHR_vulkan_glsl.txt

For Glslang's test case see https://github.com/KhronosGroup/glslang/blob/master/Test/hlsl.layout.frag and corresponding AST intermediate and SPIR-V assembly: https://github.com/KhronosGroup/glslang/blob/master/Test/baseResults/hlsl.layout.frag.out

Note that glslangValidator supports several options to automatically map bindings, and to "shift" binding numbers for UBOs, images, textures, and samplers. I plan to add those options to glslc as well.

dneto0 avatar Nov 28 '16 21:11 dneto0

@dneto0 Are there any plans to add support of RootSignature in GLSLC for converting bindings. In HLSL bindings are taken from the RootSignature. Can we add this option in GLSLC to support it.

ajaybedi avatar Jul 21 '17 15:07 ajaybedi

We rely on Glslang for HLSL compilation. So if Glslang exposes RootSignature support then Shaderc would get it. However, I don't think anybody else has asked for that.

dneto0 avatar Aug 02 '17 20:08 dneto0

@dneto0 Ok .thanks for the info. For now, I have added my own preprocessing step, where I read the rootSignature myself and parse the bindings and then change the register numbers before getting it converted to SPIRV through GLSLC.

I am seeing another issue though if you can comment on that: I had a simple HLSL shader having separate texture2d and sampler ... I converter this to SPIRV through glslc. It works fine on Windows but Android fails to createpipeline for this... (strange that its same code on windows)... Can this be due to driver issue ? Any clues ?

ajaybedi avatar Aug 02 '17 20:08 ajaybedi

I'm no expert in the API. Could it just be driver differences? For example, make sure that the selected image format is supported on both.

dneto0 avatar Aug 18 '17 22:08 dneto0