Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My ID3D10Device creation works fine in debug mode but I throws an error in release mode:

DXGI_SWAP_CHAIN_DESC scDesc = {0};
    scDesc.BufferDesc.Width = desc.width;
    scDesc.BufferDesc.Height = desc.height;
    /*scDesc.BufferDesc.RefreshRate.Numerator = 60;
    scDesc.BufferDesc.RefreshRate.Denominator = 1;*/
    scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    scDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
    scDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

    scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    scDesc.BufferCount = 1;
    scDesc.OutputWindow = desc.hWnd;
    scDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
    scDesc.Flags = 0;

    scDesc.Windowed = true;
    scDesc.SampleDesc.Count = desc.sampleCount;
    scDesc.SampleDesc.Quality = desc.sampleQuality;

    // Create the device.
    UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)
    createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif

    HRESULT hr;
    hr = D3D10CreateDeviceAndSwapChain(
        nullptr,
        D3D10_DRIVER_TYPE_HARDWARE,
        NULL,
        createDeviceFlags,
        D3D10_SDK_VERSION,
        &scDesc,
        &g_Renderer.m_DxCore.pSwapChain,
        &g_Renderer.m_DxCore.pDevice);

    std::tcout<<hr;


//////RUNTIME ERROR HANDLING
    if(FAILED(hr)) {
        throw std::runtime_error("ERROR: Failed to create ID3D10Device and IDXGISwapChain");
    }

I've already checked each of these options, but none of it triggers. http://msdn.microsoft.com/en-us/library/windows/desktop/bb205278(v=vs.85).aspx

The value of the hr seems to be -2005270527, after checking it with std::cout<<hr My debugger also can't show the value of hr when hovering over it, for some reason. :(

What could the problem possibly be?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

The error code translates into DXGI_ERROR_INVALID_CALL. A likely reason for that error is an invalid (or zero) window handle being passed in the OutputWindow parameter. Could you check that it is properly set in your release mode run?

share|improve this answer
    
It is not properly set. If I set a breakpoint at scDesc.BufferDesc.Height = desc.height; it will stop there, but when I tell my debugger to go to the next statement (step over or F10 in Visual studio), the code seems to jump straight to D3D10CreateDeviceAndSwapChain(), and if I check for the values of the description it didn't adjust the values I told it to either. How is that even possible? –  xcrypt May 6 '12 at 11:19
    
@xcrypt: Not running the latest build by accident? I've done that a few times. –  DeadMG May 6 '12 at 15:58
    
I finally found my error! The reason was I did ASSERT(RegisterClass(myWndClass)); Ofcourse that's going to fail in release mode... stupid me! –  xcrypt May 10 '12 at 13:09
    
That's classic! Good job figuring it out! –  Paul-Jan May 10 '12 at 18:14

You're not supposed to specify a refresh rate when the device is windowed.

share|improve this answer
    
That shouldn't cause failure (they get ignored) –  bobobobo May 6 '12 at 3:34
    
I tried this, still have the error –  xcrypt May 6 '12 at 10:18

Release mode runtime won't zero out allocations if I recall correctly, perhaps some of the parameters in scDesc are junk values that now need initializing.

share|improve this answer
    
This is probably it. In your declaration you should always use something like DXGI_SWAP_CHAIN_DESC scDesc = { 0 } ; so that the structure begins 0'd out. –  bobobobo May 6 '12 at 3:35
    
I tried this, still have the error –  xcrypt May 6 '12 at 10:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.