Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';在DirectX12下不能全屏显示_C++_Directx 12_Dxgi - Fatal编程技术网

C++ Can';在DirectX12下不能全屏显示

C++ Can';在DirectX12下不能全屏显示,c++,directx-12,dxgi,C++,Directx 12,Dxgi,我有一个使用DirectX12的应用程序。我想在我的应用程序中支持全屏模式。 但是,每次调用IDXGISwapChain::SetFullscreenState()时,我都会遇到以下错误: DXGI错误:IDXGISwapChain::GetContainingOutput:交换链的适配器 不控制swapchain窗口所在的输出 IDXGISwapChain::SetFullscreenState()返回的错误代码为 0x887a0004 我的电脑有两个GPU: 英特尔(R)高清图形630和 N

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

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

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

0x887a0004

我的电脑有两个GPU:

英特尔(R)高清图形630和

NVIDIA GeForce GTX 1060

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

用于创建IDXGISwapChain3的代码流为

//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()应该成功,但失败了。

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

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

此处的最佳选项是仅抑制错误:

#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
#如果已定义(_调试)
//启用调试层(需要图形工具“可选功能”)。
//
//注意:在设备创建后启用调试层将使活动设备无效。
{
ComPtr调试控制器;
if(成功(D3D12GetDebugInterface(IID_PPV_参数(debugController.GetAddressOf())))
{
调试控制器->启用调试层();
}
其他的
{
OutputDebugStringA(“警告:Direct3D调试设备不可用\n”);
}
ComPtr-dxgiInfoQueue;
if(成功(DXGIGetDebugInterface1(0,IID_PPV_参数(dxgiInfoQueue.GetAddressOf())))
{
dxgiInfoQueue->SetBreakOnSeverity(DXGI\u DEBUG\u ALL,DXGI\u INFO\u QUEUE\u MESSAGE\u SEVERITY\u ERROR,true);
dxgiInfoQueue->SetBreakOnSeverity(DXGI\u DEBUG\u ALL,DXGI\u INFO\u QUEUE\u MESSAGE\u SEVERITY\u corrupt,true);
DXGI\u信息\u队列\u消息\u ID隐藏[]=
{
80/*IDXGISwapChain::GetContainingOutput:交换链的适配器不控制交换链窗口所在的输出。*/,
};
DXGI_INFO_QUEUE_FILTER={};
filter.DenyList.NumIDs=\u countof(隐藏);
filter.DenyList.pIDList=hide;
dxgiInfoQueue->AddStorageFilterEntries(DXGI\u DEBUG\u DXGI,&filter);
}
}
#恩迪夫
我在上的所有模板中都使用此选项

此页面可能有助于: