创建 IDXGIFactory7 的正确方法 [英] Proper way to create a IDXGIFactory7
问题描述
我正在开发 DirectX 11 应用程序,但在创建 IDXGIFactory7 实例时遇到困难.我找不到 CreateDXGIFactory7() 函数,所以我使用 CreateDXGIFactory2() 像这样:
I am working on a DirectX 11 app and I am having difficulties creating an instance of IDXGIFactory7. I could not find a CreateDXGIFactory7() function so I am using CreateDXGIFactory2() like this:
IDXGIFactory7* factory;
HRESULT hr = ::CreateDXGIFactory2(DXGI_CREATE_FACTORY_DEBUG, __uuidof(IDXGIFactory7), (void**)&factory);
我遇到的困难是,当尝试在 Visual Studio 2019 中使用图形调试器时,此调用会引发异常.我还尝试了 IDXGIFactory6,它也会引发异常.如果我将其更改为 IDXGIFactory2,它就可以工作并且我可以使用图形调试器.
The difficulty I am having is that this call throws an exception when attempting to use the graphics debugger in Visual Studio 2019. I also tried IDXGIFactory6 which also throws an exception. If I change it to IDXGIFactory2 it works and I can use the graphics debugger.
此代码使用常规调试器可以正常运行和调试,但不能使用图形调试器.我收到以下异常:
This code does run and debug fine using the regular debugger, but not the graphics debugger. I get the following exception:
Exception thrown at 0x00007FFAE1513B29 in DirectXTemplated.exe: Microsoft C++ exception: GRFXTool::ToolException at memory location 0x0000004D28BFE010.
我从 https://www.3dgep.com/introduction 下载了示例-to-directx-11/ 并将其修改为在 QueryRefreshRate() 函数中使用 IDXGIFactory7 和 CreateDXGIFactory2() 而不是 IDXGIFactory.您需要在 main.cpp 的顶部设置 g_EnableVSync = TRUE 以创建工厂.这在尝试使用图形调试器时会产生异常.
I downloaded the sample from https://www.3dgep.com/introduction-to-directx-11/ and modified it to use IDXGIFactory7 and CreateDXGIFactory2() instead of IDXGIFactory in the QueryRefreshRate() function. You will need to set g_EnableVSync = TRUE at the top of main.cpp for it to create the factory. This does generate the exception when attempting to use the graphics debugger.
这是带有 Visual Studio v16.7.6 的 Windows 10 Pro x64 安装.
This is a Windows 10 Pro x64 installation with Visual Studio v16.7.6.
推荐答案
我出现这个错误的原因是因为 不再支持 DirectX12,所以这是它不起作用的一种情况
The Reason I had this error is because DirectX12 is no longer Supported according to Microsoft Team, so This is one case where It won't work
这篇关于创建 IDXGIFactory7 的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!