0

I am attempting to create a device and swapchain from a IDXGIAdapter. All my code succeeds untill a call to CreateSwapChain which returns DXGI_ERROR_INVALID_CALL.

MSDN says a return of DXGI_ERROR_INVALID_CALL can happen when DXGI_SWAP_CHAIN_DESC is null or the IDXGISwapChain** is null.

Im not really sure what it means by "IDXGISwapChain** is null" seeing as it is the output (im guessing it is when you actually type NULL.

my swapchain is defined as...

IDXGISwapChain* m_pSwapChain;

and my other code is...

IDXGIAdapter * pPrimaryAdapter = m_vAdapters.at(0); 

HRESULT hr = D3D10CreateDevice(pPrimaryAdapter,
                                D3D10_DRIVER_TYPE_HARDWARE,
                                NULL,
                                NULL,//D3D10_CREATE_DEVICE_SINGLETHREADED
                                D3D10_SDK_VERSION,
                                &m_pD3DDevice);


if(hr != S_OK)
{
    MessageBox(NULL, L"Error ###: Creation of Direct3D10 Device Failed", 0, 0);
    return false;
}

//m_pDXGIFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER ); 
if(FAILED(m_pDXGIFactory->MakeWindowAssociation(hWnd, 0 )))
{
    MessageBox(0, L"Error ###: MakeWindowAssociation Failed", 0,0);
    return false;
}

IDXGIDevice * pDXGIDevice;
if(FAILED(m_pD3DDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&pDXGIDevice)))
{
    MessageBox(0, L"QueryInterface pDXGIDevice Failed", 0,0);
    return false;
}




DXGI_SWAP_CHAIN_DESC SwapChainDesc;

    SwapChainDesc.BufferCount = 1;
    SwapChainDesc.BufferDesc.Width = 800;
    SwapChainDesc.BufferDesc.Height = 600;
    SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
    SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
    SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    SwapChainDesc.OutputWindow = hWnd;
    SwapChainDesc.SampleDesc.Count = 1;
    SwapChainDesc.SampleDesc.Quality = 0;
    SwapChainDesc.Windowed = TRUE;



hr = m_pDXGIFactory->CreateSwapChain(pDXGIDevice, &SwapChainDesc, &m_pSwapChain);

switch(hr)
{
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
    {
        MessageBox(NULL, L"CreateSwapChainFailure: DXGI_ERROR_NOT_CURRENTLY_AVAILABLE", 0,0);
        return false;
    }break;
case DXGI_ERROR_INVALID_CALL:
    {
        MessageBox(NULL, L"CreateSwapChainFailure: DXGI_ERROR_INVALID_CALL", 0, 0);
        return false;
    }break;

};

1 Answers1

1

have you tried zeroing the memory of SwapChainDesc before assigning values? You didn't specify all the values of the structure, so unless it's zeroed some of the parameters might be invalid.

Try:

DXGI_SWAP_CHAIN_DESC SwapChainDesc;
ZeroMemory(&SwapChainDesc, sizeof(SwapChainDesc));

SwapChainDesc.BufferCount = 1;
....
yiding
  • 3,482
  • 18
  • 17