Add [SuppressGCTransition] to D3D12 command recording methods
john-h-k opened this issue · comments
Description (optional)
Introduce [SuppressGCTransition]
to calls that record commands on a command list. This does not include Close/Reset commands, nor any commands from parent types (e.g Get/SetPrivateData
.
Rationale
These are some of the hottest methods in the API (this is why they don't return error codes etc). Constant GC transitions while calling them are liable to have a non-negligible impact on performance.
Drawbacks
Naturally, SuppressGCTransition
has risks. In my experience, all the methods on these list have trivial execution times (sub 1-us), and they are explicitly single threaded, so they should not be taking any syncprims.
Other thoughts
An interesting alternative is some sort of method to "batch" the transitions via an API. E.g instead of what is implicitly
EnterPreemptive();
list->IASetVertexBuffers(...);
ExitPreemptive();
EnterPreemptive();
list->OMSetDepthBounds(...);
ExitPreemptive();
EnterPreemptive();
list->Draw(...);
ExitPreemptive();
being able to explicitly do
EnterPreemptive();
list->IASetVertexBuffers(...);
list->OMSetDepthBounds(...);
list->Draw(...);
ExitPreemptive();
This will only be possible for DirectX in .NET 6+ as that is when CallConvSuppressGCTransition
will be available.
I'm generally fine with doing this for Vulkan, but it would be good to understand what differences in behavior may exist for various debug layers or other features that can be enabled.
This isn't feasible to do due to the debug and other layers. It will cause deadlocks and other problematic behavior.