Search Issue Tracker
Won't Fix
Won't Fix in 2023.3.X
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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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.
Resolution Note (2023.3.X):
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.