• 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.
  • entries
  • comments
  • views

Resizing D3D11 Windows

Sign in to follow this  
Followers 0
Jason Z


I've spent the better part of the last week or so working on getting the Hieroglyph 3 code base set up to respond to window sizing events. It is substantially easier to resize a window (in the rendering world this is equivalent to resizing a swap chain) in D3D11 than it used to be in D3D9, but there is still some gotchas involved in the process. Due to the amount of time involved in the change, I thought I would share my experiences here to hopefully help others going through the same process.

[subheading]Resizing Windows (Swap Chains) in D3D11[/subheading]

Most rendering frameworks (at least in my experience) start out with statically defined window sizes. Nearly all sample applications are defined to utilize a static window size, and the corresponding resources that go along with it are also statically sized. This includes the swap chain for rendering into the window, as well as any other resources that a particular rendering setup may use (such as the GBuffer size in a deferred renderer). This is fine for samples, since they aren't intended to manage resizable windows. However, if you decide to take your sample engine to the next step, it becomes necessary to support a user resizing their window...

There is some fairly clear guidance about how to resize a swap chain in D3D11 provided by Microsoft, which you can find here. Since D3D10, the low level windows surface API is DXGI - this is different than it was for D3D9, which came around before DXGI existed. In any case, the general advice is that a D3D11 application should resize a window's swap chain any time it receives a WM_SIZE message, and it should use the IDXGISwapChain::ResizeBuffers(...) method. This is a fairly simple operation, and as long as you build some infrastructure into your application for handling windows messages, then you should be in pretty good shape.

[subheading]Some Small Complications[/subheading]
Of course, things are never as simple as advertised. As mentioned in the preceding link, an application has to release all references to the texture resource supplied by a swap chain before it can be resized. This includes all direct Texture2D references, any resource views to that texture resource, AND any pipeline bindings that have used the texture resource. That is all perfectly clear, but if you have implemented multithreaded rendering, then that further complicates things by requiring all deferred contexts, immediate contexts, and command lists that have used the swap chain's texture resource to release them (via a clear state call). And of course, you have to take care of resizing the depth stencil resources, viewports, and so on as well...

This is where it can be a bit tricky to implement the resizing function. If you haven't implemented your renderer to centralize your references to their corresponding API objects, it can get pretty ugly pretty quickly. Fortunately in HG3 I have used a proxy class to represent my resources within the engine, which only uses indices to reference resources. The actual resource pointers are all housed within my renderer class, which compartmentalizes any actions that need to capture all references to a resource (which in this case is a resize operation). It may cost a tiny bit in performance to use a proxy class, but in the end, unless you are writing a renderer for Battlefield 3 (or some other AAA game) then this tiny amount of performance cost is not likely to be noticed...

Anyways, I now have resizing up and functional within the engine. It works on the WaterSimulationI sample, but I am incorporating the changes to the remainder of the sample applications before I push the changes to the Hieroglyph repository. Here are a couple of screen shots before and after a resize event, demonstrating the usage of the resized swap chains:


There are still a few robustness improvements that I am working out as well, but as soon as I finish them up the results will be a fully updated set of samples that will correctly update as a user changes the window size. As a nice bonus, this also includes when a user switches to full screen - it simply acts like another resize event, regardless of if the window change is to fullscreen or just a window size change.

Sign in to follow this  
Followers 0


There are no comments to display.

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