microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.45k stars 369 forks source link

Xbox One "Line drawing and anti aliasing" Tutorial Requires IID_GRAPHICS_PPV_ARGS #137

Closed kromenak closed 1 year ago

kromenak commented 1 year ago

Hello, I was going through the various DXTK12 tutorials on an Xbox One, and I ran into some trouble during the "Line drawing and anti aliasing" tutorial.

When implementing MSAA, the instructions specify using IID_PPV_ARGS for the various DX12 calls. However, this code failed to compile for Xbox One. After a bit of digging, I discovered that it did work if I used IID_GRAPHICS_PPV_ARGS instead.

I don't fully understand the need for IID_GRAPHICS_PPV_ARGS, and it isn't very well documented anywhere that I can find. I do see that DXTK12 uses this macro a lot internally, and DXTK12 also defines this macro if it is not defined.

When I run DX12 code on my desktop, I can use IID_PPV_ARGS just fine, so it seems like the need for IID_GRAPHICS_PPV_ARGS is maybe a console-only thing.

Anyway, it might be helpful to update the tutorial to use IID_GRAPHICS_PPV_ARGS, or maybe even add a technical note to the tutorial explaining the distinction.

walbourn commented 1 year ago

Thanks for the feedback. I'll review my use of IID_PPV_ARGS in the tutorials/docs.

For Xbox, the Direct3D APIs are NOT "COM" based and have been changed significantly for performance on the fixed hardware of the console. As such, this breaks the standard IID_PPV_ARGS macro. The IID_GRAPHICS_PPV_ARGS macro was created for the console version, and you still use IID_PPV_ARGS for WIC and other COM APIs even on console.

To make it easier to write portable code, I have this in DirectXHelpers.h:

#ifndef IID_GRAPHICS_PPV_ARGS
#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x)
#endif

I'll run through and add a technical note for this issue.

walbourn commented 1 year ago

https://github.com/microsoft/DirectXTK12/wiki/DirectXHelpers#xbox-specific