1
\$\begingroup\$

I'm implementing the ability to tweak graphics settings in my application at runtime (resolution, refresh rate, v-sync, multisampling).
It is possible to update the resolution, format and refresh rate using IDXGISwapChain::ResizeTarget and IDXGISwapChain::ResizeBuffers. However, I cannot find any way to update the swapchain's sampling(count and quality) in the same way. The only option I have is to go to windowed mode using IDXGISwapChain::SetFullscreenState, then release the swapchain, recreate the swapchain with a new DXGI_SWAP_CHAIN_DESC, and then go back to fullscreen again. (Didn't mention releasing and recreating back buffer and depth stencil since it is a must do).
I am willing to stay at full-screen mode before and after the settings are applied.

\$\endgroup\$
2
\$\begingroup\$

I had a look through my own code to look into answering this question. And someone more qualified may have a more accurate answer. To answer your question about sample and quality, unfortunately no, you cant and also tearing down the associated z buffer etc as well. You are correct in releasing swapchain and creating. BUT, there is an alternative.

What you are asking about, count and quality I will assume is about the MsAA you would like to run with. From my experience, and I was in the same position you are in, doing this to the SWAPCHAIN Buffer wasn't the way to go. I instead use the swapchain buffer only to present the final rendered frame and control refreshrate, format and resolution of actual visual frame on the monitor. That means, that I have a separate class that manages the actual render target where all my drawing is done and use ResolveSubResource to take my MsAA buffer to a single sample result (which is what your swap buffer will be). That allows for decoupling of the management of the underlying sample count from the refreshrate etc, those attributes that inherently dont change the structure of your swapchain buffer from those that do.

You still will need to dispose your backbuffer and the z buffer, plus any other structures that are associated to your render target, but you can now change your AA sampling almost instantaneously. What this also means is, that you segregate your games internal resolution away from the resolution of the monitor. This is also handy if you want to say lower the internal resolution of your game while still displaying at the native res of the monitor for example.

Hope this helps.

For completeness, I've added my game and resolution management into it. If it fires up (hope it does), go to settings->graphic Settings and you can see what options I have employed through the suggestions above.

insanesoftware.com.au/Strafe_Latest_Build.rar

\$\endgroup\$
  • 1
    \$\begingroup\$ Thanks, making use of ID3D11DeviceContext::ResolveSubresource was in my alternatives list and your answer solidified my decision. \$\endgroup\$ – Abrar Borno Sep 6 '19 at 9:13

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.