Best practice to get raw pointers (e.g. ID3D12Resource_unmanaged*) without AddRef/Release overhead in hot paths? #1606
Unanswered
littletoxic
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using CsWin32 with .NET 10 (
[GeneratedComInterface]) to learn DirectX 12.The Problem:
In the render loop, I often need to fill native structs like
D3D12_RESOURCE_BARRIER. This struct requires a raw pointer (ID3D12Resource_unmanaged* pResource).However, I only hold the managed interface
ID3D12Resource.To get the pointer, I currently have to use
ComInterfaceMarshaller:My Concern:
Doing
AddRefandReleaseevery single frame for every resource seems inefficient, especially since the managedID3D12Resourceobject already holds the pointer internally.My Current Workaround:
I wrote a helper struct
ComPtr<T>to cache the pointer or scope the lifetime:My Question:
ComInterfaceMarshaller) the intended best practice for this scenario?Beta Was this translation helpful? Give feedback.
All reactions