Search Issue Tracker
Won't Fix
Votes
0
Found in
2023.2.0a16
2023.3.0a3
Issue ID
UUM-35652
Regression
No
Cannot bind same structured buffer to 2 fragment shaders in Windows Editor
h2. Reproduction Steps
- Open repro-project [https://github.com/Wilfrid-Unity/test-unity-structuredbuffers-in-fragmentshaders] in Unity Windows Editor
- Open SampleScene
- Rename mentions of "UNITY_EDITOR" in the 2 scripts, to something like "UNITY_EDITOR_DISABLED_CODE"
- Press "Play"
h2. Expected Outcome
In Windows Editor, the same GraphicsBuffer can be bound to two different shader fragment (one "write" pass, one "read" pass).
As a result, the quad on the right can use data from the structured buffer written during rendering of the quad on the left:
!image-2023-05-15-16-21-27-377.png!
h2.
h2. Actual Outcome
In Windows Editor, the same GraphicsBuffer cannot be bound to two different shader fragments, when the quad on the right tries to read from the StructuredBuffer, it only gets (0,0,0) values (or debug colors in DX12 Editor):
!image-2023-05-15-16-24-41-541.png!
h2.
h2. Additional Information
h3. Specs
GraphicsFence manual page says:
You don't need to use a graphics fence to synchronise a GPU task writing to a resource and another GPU task reading the resource.
Unity handles these resource dependencies automatically.
So this case should work, according to our documentation.
h3. Results on Other platforms
This case works on other platform that I tested (Nitendo Switch), using only a single buffer and no GPU copy (I verified in graphics debugger that the correct GPU barriers were inserted between the "write" and "read" draws):
!image-2023-05-15-16-28-33-761.png!
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
Resolution Note:
The issue is due to incorrect usage of the Unity C# API. The primary way to bind and unbind UAVs is via Graphics.SetRandomWriteTarget() and Graphics.ClearRandomWriteTargets() but for some reason on Switch the UAVs can also be set implicitly by calling Material.SetBuffer(). Relying on the implicit binding of UAVs is not in accordance with Unity C# API design.