-
Notifications
You must be signed in to change notification settings - Fork 246
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
slang-RHI/WebGPU: Binding missing from bind group layout #5222
Comments
Category 1 details Output from slang-test, for
Generated WGSL for
|
Category 2 details Output from slang-test, for
WGSL for
|
I noticed that an assert is triggering in Slang-RHI (for |
@skallweitNV Is this something you cant take a look at? You can just run e.g.
To run slang-test:
|
@aleino-nv can you help to triage? Possible for you to fix? |
I suspect the issue is in RHI, but I can take a look and just ask @skallweitNV questions since he's in a similar timezone. |
I checked in with @skallweitNV and he said it seems as though Slang is giving reflection information that doesn't match the WGSL, and so this leads RHI to provide layout information that doesn't match what's in the shader, leading to the errors. If so then the issue should be investigated from the Slang side, instead. |
@skallweitNV |
Taking a step back, after debugging some more I'm now confused about the error message (
I'm confused because, while it's true that the group layout is missing one of the bindings, |
Actually, google has one hit that answers this, and the answer is yes! So next step is to check the attributes of this binding. |
The binding in question should be
The I'll pop this WGSL code into my native sample app to see if I can reproduce this error there, and then experiment on how to fix it. |
(Back to working on this now, after a detour.) I can reproduce a somewhat similar error message with the following code
If I enable the second block, then I can create the pipeline.
(This could be due to different versions of Dawn being used by slang-test and my test app setup.) |
(This is still for In renderer_test::AssignValsFromLayoutContext::assignAggregate I see two 'fields' corresponding to the two bindings in group 0. For some reason the first field (for binding 0) is a shader object and ends up adding a bind group layout element as follows:
The second field (for binding 1) is a buffer object and doesn't hit any code paths that create WGPUBindGroupLayoutEntry structs at all:
I don't currently see how these objects could possibly end up in the same bind group (as the generated WGSL code requires) if one is a buffer and the other is a shader object. |
Shader object and bind group are two orthogonal concepts. A new shader object does not need to be in its own binding group. For example, if the global scope defines: Texture2D t0; Then t1 is a sub object because it is referenced through ConstantBuffer, but that doesn't mean t1 gets its own binding group. To introduce a new binding group for the elements, users need to use the ParametetBlock |
Let me clarify: I don't see how with the current render test framework/RHI implementation, a shader object and a buffer could end up in the same bind group, as would be required by the WGSL shader, as it is currently generated. |
Unless I'm mistaken, the buffer is not accounted for at all in the pipeline layout. It's not even in its own bind group, so something is pretty wrong. I will do some debugging and compare with what happens on VK, when I get time to work on this. |
NOTE: This is just a test. The WGPU fixes are not yet included at this point. This helps to address issue shader-slang#5222.
(Context: debugging I found that WebGPU follows the same buffer structure as Vulkan:
The issue again is that you can't really bind staging buffers (implying map-writeable) as uniform buffers in WebGPU, while you can do that in Vulkan. |
This helps to address issue shader-slang#5222. Also disable Slang-RHI from fetching DXC and Agility SDK, since that seems to break our tests. (See issue shader-slang#5474.)
This helps to address shader-slang/slang#5222.
A change like shader-slang/slang-rhi#92 avoids the issue, at least for |
Confirmed: with this change, only the following errors are left for
|
With shader-slang/slang-rhi#91 as well, all errors go away. |
This fixes a teardown crash, and a buffer usage mismatch issue during bind group creation. This helps to address issue shader-slang#5222.
Crash issue is now also fixed in RHI. If I roll RHI in Slang with #5475 then the only issue left for column-major is that the buffer contents is not as expected. The first thing I notice there is that the matrixBuffer seems to be all zeros, so I'm investigating that now. |
Turns out recent RHI change didn't pass in init data when creating the buffer. I have a change that fixes that, and with this change I can finally get column-major to pass! |
This helps to address shader-slang/slang#5222
This helps to address shader-slang/slang#5222
This helps to address shader-slang/slang#5222
* Ensure that SimpleShaderObjectData returns nullptr for empty buffer This is a C++ technicality, and is not known to have caused any issue. https://en.cppreference.com/w/cpp/container/vector/data says: "If size() is 0, data() may or may not return a null pointer." Thus, we check if the underlying std::vector is empty and then explicitly return nullptr in this case. * WGPU: Supply initial data when creating buffers This helps to address shader-slang/slang#5222
This fixes a teardown crash, and a buffer usage mismatch issue during bind group creation. This helps to address issue shader-slang#5222.
This fixes a teardown crash, and a buffer usage mismatch issue during bind group creation. These Slang-RHI fixes allow several WGPU tests to be enabled: - tests/compute/column-major.slang - tests/compute/constant-buffer-memory-packing.slang - tests/compute/matrix-layout.hlsl - tests/compute/non-square-column-major.slang - tests/compute/row-major.slang - tests/hlsl/packoffset.slang This helps to address issue shader-slang#5222.
Managed to enable a whole bunch of tests when taking the above mentioned Slang-RHI update into use in Slang: #5475 Still there are some layout mismatch failures for other tests, so leaving this bug open and looking at those next. |
This fixes a teardown crash, and a buffer usage mismatch issue during bind group creation. These Slang-RHI fixes allow several WGPU tests to be enabled: - tests/compute/column-major.slang - tests/compute/constant-buffer-memory-packing.slang - tests/compute/matrix-layout.hlsl - tests/compute/non-square-column-major.slang - tests/compute/row-major.slang - tests/hlsl/packoffset.slang This helps to address issue shader-slang#5222.
This fixes a teardown crash, and a buffer usage mismatch issue during bind group creation. These Slang-RHI fixes allow several WGPU tests to be enabled: - tests/compute/column-major.slang - tests/compute/constant-buffer-memory-packing.slang - tests/compute/matrix-layout.hlsl - tests/compute/non-square-column-major.slang - tests/compute/row-major.slang - tests/hlsl/packoffset.slang This helps to address issue #5222.
...for example |
Here is the parameter-block.slang shader:
It currently compiles to this WGSL:
Then Slang-RHI creates a bind group layout with just a single binding, and so pipeline creation fails with:
|
(Continuing to debug parameter-block.slang)
I'm currently thinking that the WGSL emitter is not emitting the binding attributes correctly, and comparing with how the SPIR-V emitter does it. |
There may be missing logic in the parameter block layout rule for wgsl. Worth checking for any discrepancies between spirv and wgsl in slang-type-layout.h/cpp and slang-parameter-binding.h/cpp. |
This issue was split from #5172.
Affected tests under
tests/compute
(currently disabled):Binding doesn't exist in...
Number of entries X did not match the expected number of entries Y...
Tasks:
The text was updated successfully, but these errors were encountered: