Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLSL shader seems to compile do combined image sampler but spirv cross does not detect it. #2119

Open
Makogan opened this issue Mar 8, 2023 · 2 comments
Labels
question Further progress depends on answer from issue creator.

Comments

@Makogan
Copy link

Makogan commented Mar 8, 2023

I am not sure if the issue is with spirv cross or shaderc but I am leaning towards spirv-cross.

I have this HLSL shader:

[[vk::combinedImageSampler]][[vk::binding(1)]]
Texture2D<float4> textures[3];
[[vk::combinedImageSampler]][[vk::binding(1)]]
SamplerState samp;

float4 main(
    [[vk::location(0)]] float3 normal : NORMAL0,
    [[vk::location(1)]] float3 uv : UV0
) : SV_TARGET
{
  return textures[int(uv.z)].Sample(samp, uv.xy);
}

Which shader C compiles. Note the directive [[vk::combinedImageSampler]]. In my current code base I am getting this validation error:

"Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-layout-00756 ] Object 0: handle = 0x55fe20a67de0, name = Logical device from NVIDIA GeForce GTX 1070, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x45717876 | Shader uses descriptor slot 0.1 (expected `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE`) but not declared in pipeline layout The Vulkan spec states: layout must be consistent with all shaders specified in pStages (https://vulkan.lunarg.com/doc/view/1.3.211.0/linux/1.3-extensions/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-layout-00756)"', crates/vulkan_bindings/src/hardware_interface.rs:914:5

After some debugging I realised that spirv-cross considers there are only separate shaders and samplers in the spirv code I am feeding it, i.e. sampeld_images is empty but separate_images has one entry.

So either shaderc has a bug and it is not recognising the directive (which is valid as per the microsoft documentation) or spirv-cross is making a mistake when parsing.

It seems the compiled shader does expect a combined image sampler, that makes me think it might be a mistake on spirv-cross's end. WHen I remove the directive I get a different error so it very much seems shaderc is correctly using the directive when making the shader?

@HansKristian-Work
Copy link
Contributor

Do you have the SPIR-V? DXC (which I think shaderc has to build on?) complains with

/tmp/test.hlsl:1:3: error: 'combinedImageSampler' attribute only applies to Textures (e.g., Texture2D) and SamplerState
[[vk::combinedImageSampler]][[vk::binding(1)]]
  ^

@HansKristian-Work HansKristian-Work added the question Further progress depends on answer from issue creator. label Mar 21, 2023
@HansKristian-Work
Copy link
Contributor

Ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further progress depends on answer from issue creator.
Projects
None yet
Development

No branches or pull requests

2 participants