Direct3D9/11/12 Swapchain rebuild

Started by
4 comments, last by cozzie 1 year, 3 months ago

Hi,

For some reason I am trying to configure some SwapChain settings during the app is running. I am going to configure those things:

  • SWAP_EFFECT
  • FULLSCREEN MODE
  • BUFFER COUNT

I know it is weird to do so, since most games mainly change fullscreen/resolution on the run, which can be done by IDXGISwapChain functions. There is no function to change swap effect or buffer count (at least I haven't find them), so I'm trying to rebuild the swapchain. Is there any method to achieve this?

Thanks,

CopZ_33

Advertisement

As far as i‘m aware, you might have to fully rebuild your swapchain for this to work. This essentially means releasing the old swapchaun, then recreating it+device and all related resources. This is similar to what you‘d have to do to gracefully handle the „device removed“ type of errors. So you could really try to kill two flys with one swat by implementing that handling and using it for your purpose.

main difficulties in such a scenario is that you have to recreate all resources. Things like state-descriptors are easy, you can call GetDesc on the old object (yes even if device was removed/reset). But everything else, youd have to eigther keep cpu copies or invoke creation again manually, like textures, buffers …

You can check out the msdn-sample, and there is even a microsoft -sample repo somewhere (dont have the link with me at that time). Maybe there is still a way to do it easier, but handling both scenarios this way could make sense.

@Juliean Thanks for your sharing. I'm writing a BenchMark test to measure FPS under various swapchain settings, so I need to change the swapchain feature ON THE RUN. Otherwise I could just stop the app, and relaunch it with different swapchain settings.

BTW, I need to do same thing for OpenGL and Vulkan, also in different platforms (Windows + Linux). Anyway, thanks for your help.

why can you not recreate the entite swapchain on the run? Just do it at the end or start of frame. Are you worried about frame-spikes? In my tests, overhead/delay was neglible, with about 400MB of GPU-assets having to be recreated, took probably less than a single frame until everything was running.

When it comes to switching fullscreen/windowd, changing buffercount/ backbuffer format and changing dimensions, you can get away with a swapchain→ResizeBuffers call.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement