When I call the IDXGISwapChain::SetFullscreenState method, it does not return. The window goes fullscreen, but accepts no further input. A println!() put right after never fires. I am assuming there is some sort of deadlock happening behind the scenes, but the docs don't go into what all it locks.

  • Does SetFullscreenState perform any locking?

  • If so, what does it lock?

  • What other issues could cause SetFullscreenState to never return?

I am using Rust 1.44.1 with winapi 0.3.9. I am passing minwindef::TRUE and a null pointer as arguments (passing minwindef::FALSE returns, but does the opposite of what I want). I am using the following options in the swapchain desc:

desc.BufferCount = 1;
desc.BufferDesc.Width = width;
desc.BufferDesc.Height = height;
desc.BufferDesc.Format = dxgiformat::DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferUsage = dxgitype::DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.OutputWindow = *hwnd.inner();
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Windowed = minwindef::TRUE;
  • \$\begingroup\$ Where did you get the refresh rate numbers from? Did you enumerate them via DXGI or did you just hard-code for 60? There are some additional constraints around DXGI and you really should be using properly enumerated refresh rates if you're not already doing so - otherwise you may be masking other problems. \$\endgroup\$ Jul 10 '20 at 14:27
  • \$\begingroup\$ The numbers came from the tutorial I was following. They are hard-coded. I'll look into fixing those. \$\endgroup\$
    – cwhakes
    Jul 10 '20 at 18:33

I figured out the issue.

Before returning, SetFullscreenState sends a WM_MOVE then a WM_SIZE to the event loop. I was only paying attention to the WM_SIZE, which never got called because my version of WM_MOVE blocked.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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