Hello,
We have a Low-level native plug-in in D3D12 that is adding commands to the active command buffer (getting it from IUnityGraphicsD3D12v7::CommandRecordingState()).
Even though we set the flag kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState for our event, if we modify the descriptor heaps (ID3D12GraphicsCommandList::SetDescriptorHeaps), they are not properly restored by Unity when it continues adding commands to the same command buffer after us.
I have verified this with RenderDoc. The workaround is requesting a new command buffer each time we are invoked (using kUnityD3D12EventConfigFlag_FlushCommandBuffers), but this is a bit more expensive that continuing writing to the active command buffer.
Any hints on this?
Thank you!
@tvirolai Please, let us know if you can help with this. Thanks!
Hi,
Changing the descriptor heap is a very expensive operation on some HW. So while requesting a new commandbuffer might be bit more expensive on the CPU side it’s nowhere near as heavy as the descriptor heap on the GPU side. If we’d restore the desc heaps we’d need to do it in every occasion just in case causing a massive performance penalty (It’s essentially a full GPU idle wait). You will still get the full GPU wait idle on the new commandlist but it won’t force that waitidle on every single plugin user.
The kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState is more for things like draw state (what PSO is bound etc etc), not heavy operations like this.
Yes, changing the descriptor heap is expensive and I was going to propose an improvement for this after understanding if this was a bug or not.
For NVN you expose callbacks for registering Textures and Samplers. Shouldn’t you do the same for D3D12 and that way we can use the same heap as Unity?
Thank you!
The available way currently is Unity - Scripting API: Texture2D.CreateExternalTexture but this doesn’t really help much if you’re doing drawcalls yourself.
Yes, exactly, we would need access to the heaps used by Unity and callbacks to allocate textures and samplers from them. Something very similar to what you already have in the NVN renderer.
What would be the best way to request support for this?
Thank you!
Any news on this @tvirolai ? Thanks
It’s in the backlog. Unfortunately I can’t say anything about when we’ll get to it just yet.
Hello. I also want to know the solution. When I invoke SetDescriptorHeaps() function, unity cannot draw correctly.Is there any progress now?
1 Like
Any news on this? @tvirolai
1 Like