microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.88k stars 2k forks source link

There is no need to call UnbindAllValid(); function in dynamicdescriptorheap.cpp #851

Open OneSilverBullet opened 6 months ago

OneSilverBullet commented 6 months ago

In the DynamicDescriptorHeap.cpp file, the function CopyAndBindStagedTables is used for committing the descriptors table. However, the mini-engine calls the unbindAllValid function before committing the descriptors table, which is meaningless.

The UnbindAllValid function is used to update the m_StaleRootParamsBitMap according to the assignment of the descriptor tables. You don't need to call this function in the statement of committing the descriptors table. When I delete the code about the UnbindAllValid, the engine is still running well.

For better readability, I think we should delete the code about the UnbindAllValid.

stanard commented 3 months ago

I wrote this code a hundred years ago, so I've been trying to understand if what you're saying is right. My theory is that deleting the function call works for you because you aren't running out of descriptor space and needing to migrate descriptors to a new heap. The UnbindAllValid() call is conditionally invoked when there isn't the necessary space for the staged descriptors. It unbinds the already-committed descriptors to mark them as "stale". And when the new heap is allocated, all of the stale descriptors will be committed to it instead.