gpt4 book ai didi

c++ - DirectX 11 E_INVALIDARG 在设备创建期间

转载 作者:行者123 更新时间:2023-11-30 05:40:52 24 4
gpt4 key购买 nike

创建 d3d11 设备和交换链的代码无法在某些计算机上运行并返回 E_INVALIDARG 错误。对于具有相同版本 DirectX 的计算机,这也有所不同。我似乎找不到不同行为的原因。

DXGI_MODE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(DXGI_MODE_DESC));
bufferDesc.Width = width;
bufferDesc.Height = height;
bufferDesc.RefreshRate.Numerator = 60;
bufferDesc.RefreshRate.Denominator = 1;
bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));
swapChainDesc.BufferDesc = bufferDesc;
swapChainDesc.SampleDesc.Count = aaCount;
swapChainDesc.SampleDesc.Quality = aaQuality;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 1;
swapChainDesc.OutputWindow = *hwnd;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

//results in E_INVALIDARG in some cases
hr = D3D11CreateDeviceAndSwapChain(
nullptr,
D3D_DRIVER_TYPE_HARDWARE,
nullptr,
NULL,
nullptr,
NULL,
D3D11_SDK_VERSION,
&swapChainDesc,
&SwapChain,
&d3d11Device,
nullptr,
&d3d11DevCon);

ID3D11Texture2D* BackBuffer;
hr = SwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (void**)(&BackBuffer) );

hr = d3d11Device->CreateRenderTargetView( BackBuffer, nullptr, &renderTargetView );

最佳答案

用 D3D11_CREATE_DEVICE_DEBUG 替换“Flags”参数(当前为 NULL),您将在输出中收到一条人类可读的错误消息,告诉您哪里出了问题。

关于c++ - DirectX 11 E_INVALIDARG 在设备创建期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31374780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com