Search Issue Tracker

Won't Fix

Votes

1

Found in

2022.3.5f1

Issue ID

UUM-42954

Regression

No

[SRP Core] Enabling Motion Vector Per Object Data on a ScriptableRenderContext.DrawRenderers breaks static batching

-

Steps to reproduce:
1. Open the user's attached project "MotionVectorsBug.zip"
2. Open "Scene/ShaderCalibration.unity"
3. Right-click on the game view tab and attach renderdoc
4. Enter play mode and observe the batch count in the statistics overlay. There should be ~70 batches with ~1850 saved by batching.
5. Take a renderdoc capture
6. Open the capture, and in the Event Browser find UIR.DrawChain->UniversalRenderPipeline.RenderSingleCameraInternal: Main Camera->ScriptableRenderer.Execute->DrawOpaqueObjects. Each call in the list after the first should be a simple DrawInstancedIndexed call that does not bind any new data.
7. Click the "Toggle Motion Vectors" button in the bottom left of the game view
8. The batch count should now be ~9000 with ~9000 saved by batching, and the frame times should increase by a few milliseconds
9. Take another renderdoc capture
10. Open the capture and find DrawOpaqueObjects in the event list again. Every call in the list should now needlessly rebind the exact same constant buffer to the vertex and pixel stages

Expected results: Enabling Motion Vector Per Object Data on a ScriptableRenderContext.DrawRenderers does not break static batching
Actual Results: Enabling Motion Vector Per Object Data on a ScriptableRenderContext.DrawRenderers breaks static batching

Reproducible in: URP 14.0.8 (2022.3.5f1)
Could not test on 2021.3.28f1, 2023.1.5f1, 2023.2.0b1 and 2023.3.0a1 due to the project using a modified version of URP package

Environment tested on: Windows 10

Notes:
-The example project includes a scene with several thousand static batched cubes, a slightly modified URP that adds the ability to toggle requiring PerObjectData.MotionVectors on the DrawObjectsPass class, and a simple shader that uses the unity_MatrixPreviousM and unity_MatrixPreviousMI matrices
-Adding MotionVectors to the DrawingSettings.perObjectData flags used by ScriptableRenderContext.DrawRenderers breaks static batching for objects whose shaders utilize the unity_MatrixPreviousM or unity_MatrixPreviousMI matrices. Enabling this flag causes each draw call for static batched objects to rebind the same UnityPerDraw constant buffer over and over. For static-batched objects, the previous frame matrices should not change and should be treated the same way as the current frame's object-to-world and world-to-object matrices which do not require rebinding the UnityPerDraw constant buffer.

  1. Resolution Note:

    Thank you for reporting a bug to Unity.

    We have reviewed the issue carefully, and in this case, the team is unable to prioritize fixing this bug. There are a number of reasons we make this decision, including the impact and severity of the issue across our user and customer base, and the possibility that future plans may solve the problem in a different way.

    Today we will be closing this case. Thank you again for taking the time to report this issue, and please let us know if there is anything else that changes the impact or severity of this issue.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.