Hello, I am a bit new to DX12 and I'm trying to implement dynamic resources in my engine. Currently, I have 2-4 of each object that manages per-frame resources, so that's 2-4 fences (ID3D12Fence, value and event), ConstantBufferRing, DescriptorRing... etc. So basically each object has its own timeline, in my SwapBuffers function, I simply present, wait for the next frame and reset all its allocations. Is this wrong/inefficient ? I have seen many posts that recommend managing these resources with a single fence, but I can't see how to sync with the GPU otherwise.
Fencing per-frame resources
Fences are very heavyweight in D3D12: you'll want to minimize their usage. The simplest way to manage this is to have once fence that you signal after each frame is submitted to the GPU, so that you can know that the entire frame's worth of work has completed. Then you simply advance all of your per-frame resources to the next buffer after waiting for a previous frame to finish by waiting on the fence.
You can see an example from my code here: notice how I submit command buffers, signal the fence wait for an earlier frame to finish, and then swap command buffers (I also update per-frame temp buffers and descriptor heaps in EndFrame_Helpers()).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement