1
我在調用CreateSwapChain時收到DXGI_ERROR_INVALID_CALL。 這裏是我的代碼來創建命令隊列。無法修復DXGI_ERROR_INVALID_CALL - DX12
D3D12_COMMAND_QUEUE_DESC cqDesc = {};
cqDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
cqDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
hr = g_pDevice->CreateCommandQueue(&cqDesc, IID_PPV_ARGS(&g_pCommandQueue));
if (FAILED(hr)) {
return false;
}
這裏是我打電話給CreateSwapChain的地方。
DXGI_MODE_DESC bBuffDesc = {}; //To describe the display model.
SecureZeroMemory(&bBuffDesc, sizeof(bBuffDesc));
bBuffDesc.Height = Height; // ** Might have to give condition for windowed mode
bBuffDesc.Width = Width;
bBuffDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
bBuffDesc.RefreshRate.Denominator = Denominator;
bBuffDesc.RefreshRate.Numerator = Numerator;
bBuffDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
bBuffDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
DXGI_SAMPLE_DESC sampleDesc; //To describe multi-sampling preference.
sampleDesc.Count = 1; //We are not using multi-sampling. We take 1 sample per pixel.
sampleDesc.Quality = 0; // no antialiasing
DXGI_SWAP_CHAIN_DESC swapChainDesc = {}; //To describe the swap chain.
swapChainDesc.BufferCount = g_cnFrameBufferCount;
swapChainDesc.BufferDesc = bBuffDesc;
swapChainDesc.SampleDesc = sampleDesc;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; //Tells the pipeline that this is a remder target and not a shader input.
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; //Discard the buffer after calling present.
swapChainDesc.OutputWindow = hwnd;
//swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY;
//swapChainDesc.Windowed = false;
if (g_bWindowed) { // Windowed mode
swapChainDesc.Windowed = true;
}
else { //Full-Screen mode
swapChainDesc.Windowed = false;
}
IDXGISwapChain * tempSwapChain = nullptr;
hr = dxgiFactory->CreateSwapChain(g_pCommandQueue, &swapChainDesc, &tempSwapChain);
我小時返回上述錯誤。任何幫助,將不勝感激。
更新(問題仍然存在)
- 移除作爲在註釋
- 指出的亞當研究發現,小時返回S_OK窗口模式不必要地使用SecureZeroMemory的。好像這個問題已經做全屏模式
爲什麼在您調用CreateSwapChain之前SecureZeroMemory正在處理您的swapChainDesc? –
感謝您指出Adam Miles。我只是發現這是完全沒有必要的。反正這個問題不是因爲那個。 – ngub05