Has anyone tried to use a IDXGISwapChain1 to do buffer swaps instead of SwapBuffers()? I’m not sure if it’s possible but since there is a new [b]IDXGIFactory2::CreateSwapChainForHwnd[/b], it seems possible in theory. Also since the swap chain can work on GDI windows (and since SwapBuffers() is also a GDI function), it also seems possible. Yet another reason I think it may be possible is that SwapBuffers() seems to work fine if called from a thread that doesn’t even have an OpenGL context, so the swapping may be disconnected from GL enough for this to be functional.
When I tried I was able to create the swap chain successfully but the Present1() call just clears the window to black and never showed my content.
The reason I’m interested in doing this is to have access to the better documented sync interval behavior outlined for Present1(). wglSwapInterval() has some bugs I’m running into on Nvidia drivers (submitted to Nvidia) that I’d like to work around if I could.
Also perhaps this could fix the tearing/corruption issue that happens on Windows 7/8 depending on Aero/Window state.
The code I’m using current is this:
auto dev = getDXDevice(); IDXGIDevice2 * pDXGIDevice; HRESULT hr = dev->QueryInterface(__uuidof(IDXGIDevice2), (void **)&pDXGIDevice); IDXGIAdapter * pDXGIAdapter; hr = pDXGIDevice->GetParent(__uuidof(IDXGIAdapter), (void **)&pDXGIAdapter); IDXGIFactory2 *fact; pDXGIAdapter->GetParent(__uuidof(IDXGIFactory2), (void **)&fact); DXGI_SWAP_CHAIN_DESC1 desc; memset(&desc, 0, sizeof(desc)); desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER; desc.BufferCount = 2; desc.Scaling = DXGI_SCALING_STRETCH; desc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; desc.Flags = DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE; hr = fact->CreateSwapChainForHwnd(dev, hwnd, &desc, nullptr, // fullscreen nullptr, // output restriction &theSwapChain);
and then the buffer swap is gone with glFinish() called by a call to theSwapChian->Present1().
Maybe this isn’t possible, just thought I’d raise the idea.