Fix HDRP build issues with DOTS_INSTANCING_ON shader variant #6490
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
Fix shader compilation errors with
DOTS_INSTANCING_ON
variants. This issue has been introduced a few weeks ago with #5842. However, no one noticed it because of a C++ side bug causing some shader errors not to be logged anywhere. A trunk PR fixing this recently landed and caused these shader compilation errors to become visible (case 1367936). Also, the pathological shader variants were in fact not used at all, which is why we didn't notice any rendering or picking issue :DNow regarding the problem itself:
The UnityPerDraw cbuffer doesn't exist with the
DOTS_INSTANCING_ON
shader variants, which means thatunity_ObjectToWorld
and friends don't exist as shader constants either. That kind of per-entity data needs to be loaded from the GPU bufferunity_DOTSInstanceData
. This is done with a few helper functions that are called when using theUNITY_MATRIX_M
macro.unity_ObjectToWorld
should never be used directly as a shader constant withDOTS_INSTANCING_ON
variants.The macros used to fetch per-entity data like
UNITY_MATRIX_M
don't need, and should not be re-defined by the picking header when using theDOTS_INSTANCING_ON
shader variants. It needs to be like this to match the way BatchRendererGroup objects picking is handled on the C++ side.Testing status
Manual testing: Building/Running BatchRendererGroup_HDRP + Run BRGGameObjects in Editor
Yamato PR HDRP on trunk green except for the following:
HDRP on Win_DX11_playmode_mono_Linear on version trunk
HDRP on Win_Vulkan_playmode_mono_Linear on version trunk
HDRP on OSX_Metal_playmode_mono_Linear on version trunk
HDRP on Linux_Vulkan_playmode_mono_Linear on version trunk
Find missing docs - hdrp
HDRP_DXR on Win_DX12_playmode_mono_Linear on version trunk
Yamato BatchRendererGroup on trunk green