首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能在DirectX12下全屏运行

不能在DirectX12下全屏运行
EN

Stack Overflow用户
提问于 2019-07-08 09:34:44
回答 2查看 1.2K关注 0票数 1

我有一个使用DirectX12的应用程序。我想在我的应用程序中支持全屏模式。但是,每次调用IDXGISwapChain::SetFullscreenState()时,都会得到以下错误:

DXGI错误: IDXGISwapChain::GetContainingOutput: swapchain的适配器不控制swapchain窗口所在的输出。

IDXGISwapChain::SetFullscreenState()返回的错误代码是

0x887a0004

我的电脑有两个GPU:

Intel(R) HD Graphics 630和

NVIDIA GeForce GTX 1060

后者是错误发生时用来创建d3d12设备的适配器。如果适配器是前者,则不会出现错误。

用于创建IDXGISwapChain3的代码流是

代码语言:javascript
复制
//variables used in the code example
ID3D12Device *pDevice;
IDXGIFactory4 *pDXGIFactory;
IDXGIAdapter *pAdapter;
ID3D12CommandQueue *pCommandQueue;
IDXGISwapChain1 *pTempSwapchain;
IDXGISwapChain3 *pSwapchain;

//the code flow
CreateDXGIFactory2();
pDXGIFactory->EnumAdapter();
D3D12CreateDevice(pAdapter, ...);
pD3DDevice->CreateCommandQueue();
pDXGIFactory->CreateSwapChainForHwnd(pCommandQueue, ..., &pTempSwapchain);
pTempSwapchain->QueryInterface(IID_PPV_ARGS(&pSwapChain));

IDXGISwapChain::SetFullscreenState()应该成功,但失败了。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-07-22 20:48:47

请注意,问题是DXGI调试层的怪癖和“混合图形”解决方案的实现方式(取决于当时使用的设备)的具体组合。

这里最好的选择就是抑制错误:

代码语言:javascript
复制
#if defined(_DEBUG)
    // Enable the debug layer (requires the Graphics Tools "optional feature").
    //
    // NOTE: Enabling the debug layer after device creation will invalidate the active device.
    {
        ComPtr<ID3D12Debug> debugController;
        if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(debugController.GetAddressOf()))))
        {
            debugController->EnableDebugLayer();
        }
        else
        {
            OutputDebugStringA("WARNING: Direct3D Debug Device is not available\n");
        }

        ComPtr<IDXGIInfoQueue> dxgiInfoQueue;
        if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(dxgiInfoQueue.GetAddressOf()))))
        {
            dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, true);
            dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, true);

            DXGI_INFO_QUEUE_MESSAGE_ID hide[] =
            {
                80 /* IDXGISwapChain::GetContainingOutput: The swapchain's adapter does not control the output on which the swapchain's window resides. */,
            };
            DXGI_INFO_QUEUE_FILTER filter = {};
            filter.DenyList.NumIDs = _countof(hide);
            filter.DenyList.pIDList = hide;
            dxgiInfoQueue->AddStorageFilterEntries(DXGI_DEBUG_DXGI, &filter);
        }
    }
#endif

我在GitHub上的所有模板中都使用了这一点。

票数 2
EN

Stack Overflow用户

发布于 2019-07-11 00:03:11

我找到了解决办法。使用IDXGIFactory 6::EnumAdapterByGpuPreference()方法,而不是IDXGIFactory::EnumAdapter()方法,则错误将消失。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56932066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档