InstanceDataBuffers containing PerInstanceCustomData and PayloadExtensionData have broken offsets for reading the PerInstanceCustomData

When calculating offsets in SceneData.ush, the offset for custom data is calculated like so:

if (bHasPayloadExtension)
{
	Offsets.PayloadExtension = CurOffset;
	CurOffset += PrimitiveData.InstancePayloadExtensionSize;
}

if (bHasCustomData)
{
	Offsets.CustomData = CurOffset;
}

However PrimitiveData.InstancePayloadExtensionSize is always 0 since it never gets set anywhere so it will try and read the custom data at the start of the payload extension instead.

Managed to fix this by calculating InstancePayloadExtensionSize for the buffer and feeding it through to the shader.

Steps to Reproduce

  1. Create a custom primitive with an instance buffer utilising both PayloadExtensionData and PerInstanceCustomData.
  2. Try to read from the PerInstanceCustomData in a material.
  3. It will read the wrong data.

Hi Liam, thanks for bringing this issue to our attention. I managed to verify that the PrimitiveCustomData and PayloadExtensionData offsets are currently not properly working. I filed a ticket with the dev team, and they should handle this case from here. If you already have a fix on hand, you could also consider filing a pull request and linking it here to help speed up the process a bit. Let me know what you think.

A pull request on the Unreal GitHub repo? Or can I just upload a diff file here?

GitHub would be preferred, since integrating and testing the change will be much easier. Let me know if that’s possible

I have created a pull request here: https://github.com/EpicGames/UnrealEngine/pull/15168

Thanks for the quick turnaround. I have looped in the dev team about the change, and they should review it as soon as possible. If you haven’t heard back from anyone on the PR by the end of next week, please ping this ticket, and I’ll follow up with the team to get some movement. Let me know if that works for you.

Sounds good

Ok, great. I will put the case in pending status, which will auto-close in two weeks. That should give us enough time to come back to any feedback, if needed.