DirectX-Headers icon indicating copy to clipboard operation
DirectX-Headers copied to clipboard

The willing api for fixing aggregate returns

Open lygstate opened this issue 2 years ago • 1 comments

lygstate avatar Jul 29 '22 19:07 lygstate

Using an inline function for C is slightly different compared to the macros. Specifically, this is valid with a macro but not with an inline:

ID3D12Resource1 *res;
D3D12_RESOURCE_DESC desc;
ID3D12Resource_GetDesc(res, &desc);

With the macro, that calls into ID3D12Resource1Vtbl::GetDesc, which takes an ID3D12Resource1 * as the This pointer, even though the macro name is ID3D12Resource_GetDesc. With the inline function, the type of the This pointer has to match the name of the function being called. It's minor, but it means that upgrading a C codebase from (e.g.) ID3D12Device to ID3D12Device1 or any of the other 10+ variations on the device interface need to find/replace the macros.

This is on my to-do list, to see what can be done in MIDL vs what can be done manually via helper headers externally to MIDL. Note that I'm treating this as low priority though - the important thing is that the D3D12 APIs can be invoked by the various compilers for the various platforms across C and C++ and actually work correctly, even if it requires some #ifdef soup in the calling code. At this juncture, the only real cross-platform and cross-compiler codebase is Mesa, and I expect the total number of callers who care about this to be in the single digits for the foreseeable future.

jenatali avatar Aug 04 '22 18:08 jenatali