Performance of shader compilation at launch time


For the last few years, I've been working on the HLSL compiler. Now that Windows 10 is out the door, I finally have the opportunity to come back to blogging for a while, and hopefully help other developers build successful apps and games.

My first topic is a simple reminder that when your app is launched, you have a limited time to set things up for display. There is a timeout imposed to ensure that the user isn't left looking at the splash screen for an app that is hung. You need to be thoughtful about what work you're going to do at this point - first impressions matter!

An important point for games that is sometimes overlooked is that it's generally a bad idea to compile all your shaders during the limited window of time you have on startup. This type of work is best avoided altogether, or at least done in the background.

You'll be using CPU to compile and/or create shaders, and possible doing I/O to get the bytecode, and it's a much better strategy to simply do this work as a background or deferred bit of work.

Remember: just because it's fast on your computer doesn't mean it will be fast everywhere. CPU, I/O and even the work the graphics driver will do when creating a shader can vary quite a bit depending on what hardware the user has and what the rest of the system is doing at the time. Play it safe!

Some references you'll want to be familiar with include these.

Enjoy!

Comments (0)

Skip to main content