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: Unable to read structs from ByteAddressBuffer #1254

Closed
zoddicus opened this issue Jan 7, 2020 · 1 comment · Fixed by #1255
Closed

HLSL: Unable to read structs from ByteAddressBuffer #1254

zoddicus opened this issue Jan 7, 2020 · 1 comment · Fixed by #1255
Labels
enhancement New feature to SPIRV-Cross is desired. in progress Issue is being actively worked on

Comments

@zoddicus
Copy link
Contributor

zoddicus commented Jan 7, 2020

As part of implementing WebGPU support in Chromium via the Dawn project, we have been using SPIRV-Cross to convert to platform specific shaders.

An external developer working with WebGPU enabled has reported a Windows specific issue with their shaders, https://bugs.chromium.org/p/chromium/issues/detail?id=1037829.

What they are experiencing is that code like this works correctly on Windows and Mac:

struct PointLight {
  vec4 color;
};

layout(set = 0, binding = 1) buffer LightBuffer {
  PointLight b_lights[];
};

fragColor = vec4(b_lights[0].color.rgb, 1.0);

but like the following fails on Windows:

struct PointLight {
  vec4 color;
};

layout(set = 0, binding = 1) buffer LightBuffer {
  PointLight b_lights[];
};

PointLight light = b_lights[0];
fragColor = vec4(light.color.rgb, 1.0);

It it believed that this due to an issue in SPIRV-Cross, from this comment on the issue:

The root cause of the crash is currently in SPIRV-Cross SSBOs are translated into RWByteAddressBuffers on D3D12, but reading structs from ByteAddressBuffer has not yet been supported in SPIRV-Cross, so SPIRV-Cross cannot correctly translate "PointLight light = b_lights[0];" into proper HLSL expressions.

@HansKristian-Work HansKristian-Work added the enhancement New feature to SPIRV-Cross is desired. label Jan 7, 2020
@HansKristian-Work
Copy link
Contributor

Yup, this is known (same with loading and storing arrays), but now that there is a use-case for it, I can implement it. It's mostly just tedious unrolling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature to SPIRV-Cross is desired. in progress Issue is being actively worked on
Projects
None yet
2 participants