d3d12: Add {set,get}_user_data() methods to command allocator

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5877>
This commit is contained in:
Seungha Yang 2024-01-03 01:15:27 +09:00
parent 9d5277e70e
commit d3b3a1c00a
2 changed files with 35 additions and 0 deletions

View file

@ -34,9 +34,17 @@ using namespace Microsoft::WRL;
struct _GstD3D12CommandAllocator : public GstMiniObject struct _GstD3D12CommandAllocator : public GstMiniObject
{ {
~_GstD3D12CommandAllocator ()
{
if (notify)
notify (user_data);
}
GstD3D12CommandAllocatorPool *pool = nullptr; GstD3D12CommandAllocatorPool *pool = nullptr;
D3D12_COMMAND_LIST_TYPE type; D3D12_COMMAND_LIST_TYPE type;
ComPtr < ID3D12CommandAllocator > ca; ComPtr < ID3D12CommandAllocator > ca;
gpointer user_data = nullptr;
GDestroyNotify notify = nullptr;
}; };
struct GstD3D12CommandAllocatorPoolPrivate struct GstD3D12CommandAllocatorPoolPrivate
@ -248,3 +256,24 @@ gst_d3d12_command_allocator_get_handle (GstD3D12CommandAllocator * cmd,
return TRUE; return TRUE;
} }
void
gst_d3d12_command_allocator_set_user_data (GstD3D12CommandAllocator * cmd,
gpointer user_data, GDestroyNotify notify)
{
g_return_if_fail (cmd);
if (cmd->notify)
cmd->notify (cmd->user_data);
cmd->user_data = user_data;
cmd->notify = notify;
}
gpointer
gst_d3d12_command_allocator_get_user_data (GstD3D12CommandAllocator * cmd)
{
g_return_val_if_fail (cmd, nullptr);
return cmd->user_data;
}

View file

@ -48,5 +48,11 @@ D3D12_COMMAND_LIST_TYPE gst_d3d12_command_allocator_get_command_type (Gst
gboolean gst_d3d12_command_allocator_get_handle (GstD3D12CommandAllocator * cmd, gboolean gst_d3d12_command_allocator_get_handle (GstD3D12CommandAllocator * cmd,
ID3D12CommandAllocator ** ca); ID3D12CommandAllocator ** ca);
void gst_d3d12_command_allocator_set_user_data (GstD3D12CommandAllocator * cmd,
gpointer user_data,
GDestroyNotify notify);
gpointer gst_d3d12_command_allocator_get_user_data (GstD3D12CommandAllocator * cmd);
G_END_DECLS G_END_DECLS