question

DeadStack avatar image
0 Votes"
DeadStack asked ·

Can't enable debug layer

I'm using TerraFX DirectX wrapper in a Desktop.WinUI project / .Net 5.

I've enabled the debug layer with the following code.

cs
            ID3D11Device* CreateD3DDevice(out ID3D11DeviceContext* pImmediateContext)
            {
                ID3D11Device* d3dDevice;
                ID3D11DeviceContext* immediateContext;

                D3D11_CREATE_DEVICE_FLAG flags = 0;
                // direct2d compat
                flags |= D3D11_CREATE_DEVICE_FLAG.D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if (DEBUG)
                // debug layer
                flags |= D3D11_CREATE_DEVICE_FLAG.D3D11_CREATE_DEVICE_DEBUG;
#endif

                var featureLevel = D3D_FEATURE_LEVEL_11_1;
                ThrowIfFailed(nameof(D3D11CreateDevice), D3D11CreateDevice(
                    (IDXGIAdapter*)DxgiAdapter, 
                    D3D_DRIVER_TYPE_HARDWARE, 
                    Software: IntPtr.Zero, 
                    Flags: (uint)flags, 
                    &featureLevel, 
                    FeatureLevels: 1, 
                    D3D11_SDK_VERSION, 
                    &d3dDevice, 
                    pFeatureLevel: null, 
                    &immediateContext));

                pImmediateContext = immediateContext;
                return d3dDevice;
            }


This works for one project - samples that are available for TerraFX, but it doesn't work in my own project built from the Desktop.WinUI project template in VS.

PS. No DirectX Tags available for these forums? You need to look through your tags, they need some work.

dotnet-csharpwindows-uwpwindows-uwp-xamlwindows-uwp-runtime
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DeadStack avatar image
0 Votes"
DeadStack answered ·

I needed to also set

cs
uint dxgiFactoryFlags = (uint)DXGI_CREATE_FACTORY_DEBUG;
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.