Yes, its actually an "or . " I will explain. I develop helper classes for myself, for example DirectXToolKit. To control COM, I use Microsoft :: WRL :: ComPtr <T> (wrl.h).
struct Renderer { ComPtr<ID3D11Device> m_Device; ComPtr<ID3D11DeviceContext> m_ImmContext; }
When all resources are destroyed, an instance of the above structure must also be destroyed, but after calling dtor, I run an error in Microsoft :: WRL :: ComPtr <T> when it tries to free the device or context.
I have implemented dtor, where I manually release m_Device and m_ImmContext, but unfortunately the last element I am trying to release always encounters a problem in the function
unsigned long InternalRelease() throw() { unsigned long ref = 0; T* temp = ptr_; if (temp != nullptr) { ptr_ = nullptr; ref = temp->Release(); } return ref; }
here
ref = temp->Release();
When I manage to release the device first, the context causes an error, and vice versa (yes, when one of them was successfully released, the failure of the second participant failed). There was already a question like mine ( destroy directx device and swap chain ), but the window and swapchain were already destroyed, like other dx resources. I donβt know why this is happening. Any ideas?
Sorry for my imperfect English: 3
source share