In DX12 API, we have this definition:
typedef struct D3D12_CPU_DESCRIPTOR_HANDLE
{
SIZE_T ptr;
} D3D12_CPU_DESCRIPTOR_HANDLE;
As the title says, what is the reason for it to be a struct? Is there any reason apart from being type safe? In my engine, I store size_t handles for my graphics types instead of this, because I am not including dx12 headers in the rest of the code base. I go out of my way to convert my size_t handles to D3D12_CPU_DESCRIPTOR_HANDLE like this:
typedef size_t wiCPUHandle; // My own handle type
inline D3D12_CPU_DESCRIPTOR_HANDLE ToNativeHandle(wiCPUHandle handle)
{
D3D12_CPU_DESCRIPTOR_HANDLE native;
native.ptr = handle;
return native;
}
And this function gets copied before every native API call to retrieve the native handle from my handle type. Doesn't seem like a very nice solution, maybe I am not realizing something obvious? In Vulkan, they simply typedef the handles to pointer type or uint64.