【问题标题】:DirectX D3D11CreateDeviceAndSwapChain returning E_INVALIDARGDirectX D3D11CreateDeviceAndSwapChain 返回 E_INVALIDARG
【发布时间】:2013-10-13 18:36:48
【问题描述】:

我有以下调用,无论我尝试什么,hresult 始终是 E_INVALIDARG:

LogMessage(L"Creating swap chain. Emulation: " + std::to_wstring(useSoftwareEmulation) + L", Debugging: " + std::to_wstring(enableRenderDebugging));
HRESULT hresult = D3D11CreateDeviceAndSwapChain(
    (useSoftwareEmulation ? NULL : currentAdapter), 
    (useSoftwareEmulation ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_UNKNOWN), 
    NULL, 
    (enableRenderDebugging ? D3D11_CREATE_DEVICE_DEBUG | D3D11_CREATE_DEVICE_DEBUGGABLE : 0),
    NULL,
    0,
    D3D11_SDK_VERSION,
    &swapChainDescriptor, 
    &swapChain,
    &graphicsCardInterface, 
    &runningFeatureLevel, 
    &graphicsCardContext
    );

根据上面的日志行,useSoftwareEmulationenableRenderDebugging 都是 false

所有其他变量的类型如下:

currentAdapterIDXGIAdapter*

swapChainDescriptorDXGI_SWAP_CHAIN_DESC

swapChainIDXGISwapChain*

graphicsCardInterfaceID3D11Device*

runningFeatureLevelD3D_FEATURE_LEVEL

graphicsCardContextID3D11DeviceContext*

【问题讨论】:

    标签: c++ directx directx-11


    【解决方案1】:

    误报:我的 swapChainDescriptor 有错误(即我的 MSAA 计数和质量值被交换)。

    希望这对将来的其他人有所帮助。

    【讨论】:

    • 将 D3D11_CREATE_DEVICE_DEBUG 传递给 D3D11CreateDevice 标志以捕获此类错误。
    • @MooseBoys 我在输出窗口上什么也看不到,即使我传递了这些参数。奇怪的。设置设备 + 交换链后,它们可能只显示实际图形调用的信息?
    • 是的,这是有道理的,因为您正在使用 CreateDeviceAndSwapChain 调用并且调用失败。我认为如果你使用 D3D11CreateDevice 后跟 IDXGIFactory::CreateSwapChain,你应该会看到调试信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-15
    • 2023-03-13
    相关资源
    最近更新 更多