• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
gfxCahd

ResizeBuffers Bug

7 posts in this topic

calling swapChain.ResizeBuffers doesn't have any effect on the refresh rate. I go through the trouble of getting a modeDescription that the monitor supports (GetClosestMachingMode) and yet the swapChain remains stuck at 60fps, and I get the warning

 

DXGI Warning: IDXGISwapChain::Present: Fullscreen presentation inefficiencies incurred due to application not using IDXGISwapChain::ResizeBuffers appropriately, specifying a DXGI_MODE_DESC not available in IDXGIOutput::GetDisplayModeList, or not using DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH. DXGI_SWAP_CHAIN_DESC::BufferDesc = { 800, 600, { 60, 1 }, R8G8B8A8_UNORM, 0, 0 }; DXGI_SWAP_CHAIN_DESC::SampleDesc = { 1, 0 }; DXGI_SWAP_CHAIN_DESC::Flags = 0x2;

 

So, is this a confirmed bug?

0

Share this post


Link to post
Share on other sites
Yep I remember this bug when I was playing wityh my DX engine. If I remember correctly, I ended up queiring new back buffer out of swap chain.
1

Share this post


Link to post
Share on other sites

So, whenever I want to transition to fullscreen from windowed, or change fullscreen resolution I need to recreate the swapChain?

 

p.s. I thought DXGI was created to make window handling easier. This is turning out to be worse than the d3d9 way of doing things...

0

Share this post


Link to post
Share on other sites

ResizeBuffers works but your general observation is correct: DXGI is simpler if you're using it at the most basic level (starting up in a single mode and never switching from that mode aside from using Alt-Enter to toggle fullscreen/windowed, letting DXGI handle the toggle) but as soon as you try to implement your own mode switching, with support for different resolutions, refresh rates and windowed versus fullscreen, it becomes significantly more complex than the old way.

 

As a general rule, the sequence that works looks like this:

 

If going from fullscreen to windowed, call SetFullscreenState (FALSE, NULL), then call ResizeTarget.

If going from windowed to fullscreen, call ResizeTarget, then call SetFullscreenState (TRUE, NULL).

Otherwise just call ResizeTarget.

 

Wait for a WM_SIZE message to come in (the OS will generate this automatically in response to the ResizeTarget call).

Call ClearState, OMSetRenderTargets (NULL), and release your current RenderTargets to ensure you've cleared any outstanding references on your buffers.

Call ResizeBuffers.

Recreate anything that needs to be recreated (typically your backbuffer's RTV, your depth/stencil texture and it's DSV, and any other render targets you're using)

 

Generally I don't respond immedately to events as they happen when doing this; I've found that doing so is almost 100% guaranteed to get things happening in the wrong sequence and mess up badly.  Problems I've observed include back buffers not being sized correctly for the window, the taskbar size interfering with fullscreen modes, etc.  Instead I just set a flag on my video state, and at the start of the next frame I check for this flag and respond to it there.  If the response requires any kind of follow-up, I set another flag and defer again to the following frame.  If all flags are clear, I draw the frame, otherwise I skip drawing it.

 

It's also important to use MakeWindowAssociation with DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER, using a DXGI Factory obtained via SwapChain->GetParent, otherwise DXGI may kick in and decide to do it's own thing (instead of what you want it to do) at any point during this process.

1

Share this post


Link to post
Share on other sites

Have you gone through all of the details here to make sure you are following the requested process when jumping from windowed to fullscreen or vice versa?  I just tried doing this with one of my samples, and I get the same behavior when Alt+Enter swapping between fullscreen and windowed, and it appears others have had similar issues (here too).

 

I would be curious to hear if anyone is able to do the mode switching without this performance warning...

0

Share this post


Link to post
Share on other sites

Ok, it's been a while, but thank you all for the replies.

 

A quick update:

 

I tried recreating the swapChain on resizing to fullscreen. This does result in the swapChain getting a new (and accurate) refresh rate. But the DXGI warnings persist.

 

DXGI Warning: IDXGISwapChain::Present: Fullscreen presentation inefficiencies incurred due to application not using IDXGISwapChain::ResizeBuffers appropriately, specifying a DXGI_MODE_DESC not available in IDXGIOutput::GetDisplayModeList, or not using DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH. DXGI_SWAP_CHAIN_DESC::BufferDesc = { 720, 576, { 60317, 1000 }, R8G8B8A8_UNORM, 1, 2 }; DXGI_SWAP_CHAIN_DESC::SampleDesc = { 1, 0 }; DXGI_SWAP_CHAIN_DESC::Flags = 0x2;

 

Unless anyone has any ideas, I'm gonna concede defeat and just ignore this warning.

 

0

Share this post


Link to post
Share on other sites

I would be curious to hear if anyone is able to do the mode switching without this performance warning...

 

This works for me:

 

- create swapchain with DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH

- call MakeWindowAssociation with DXGI_MWA_NO_WINDOW_CHANGES and DXGI_MWA_NO_ALT_ENTER (this means you have to handle window messages and styles explicitely)

 

... then when switching from windowed to fullscreen:

 

- call ResizeTarget with the fullscreen parameters

- call SetFullscreenState(TRUE, NULL)

- call ResizeTarget with the same parameters as before except a zeroed refresh rate (why? I have no idea, it's what MSDN tells me to do)

- call ResizeBuffers

 

... although to be fair I don't remember if it was one of the above steps that made the warning go away or if it was a result of fiddling with window message handling.

0

Share this post


Link to post
Share on other sites

^Thanks. I found something else that works

 

Calling resizeBuffers TWICE (once right before setting the swapchain to fullscreen, and once right after) removes the error for me.

I guess the confusion is caused by the fact that some people have resizeBuffers called when they get a WM_SIZE windows message, so they only call resizeBuffers once in their main function.

 

Also, create your swapChain with a refreshRate of Zero!

 

Btw, is there a way to test whether my game is flipping or blipping? I don't trust the D3D debug messages. The swapChain's refreshrate NEVER CHANGES after creation, and though a refresh rate of zero should in theory result in DXGI picking the appropriate refresh rate itself the second time you call resizeBuffers, I'd like to be able to verify this. 

Edited by gfxCahd
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0