Reputation: 103
I was wondering if its considered an "okay" practice to create a shader resource view for a ID3D12Resource
just before passing it into a ID3D12GraphicsCommandList
and destroying it afterward when the frame completes?
Do note that I create the descriptor view for the said resource only once.
Upvotes: 1
Views: 1238
Reputation: 8824
This is a quote from a Microsoft engineer about why CreateShaderResourceView return void and not an error code.
We intentionally don't have return codes on high frequency APIs since it would be a waste of CPU time to be checking for errors every call, which could be happening on the fly many thousands of times a frame.
They assume by design that it is an api that can be called many times a frame, the answer to your question is, yes, you can do it, it is not a problem.
You just have to be careful to protect the view lifetime in the descriptor heap for as long as the gpu may need it before overwriting it.
Upvotes: 1