Reincarnation of the PIX Graphical Debugger for DirectX 12

    I love graphical debuggers. I love ordinary ones too, but graphic ones are more. They give a feeling akin to peering behind the curtains of a theater during a performance: "Yeah, this decoration is mounted like this, and this ray of light falls from here, and this cabinet does not have a back wall ...". The graphical debugger draws a bridge of understanding between the text code of the application and the resulting beautiful picture.

    But the industry does not pamper us with an abundance of such tools. There are graphical debuggers from Intel, NVidia and AMD, but they do not work on competitors' chips and are intended not so much for development / debugging as for benchmarks and showing off their video cards. They tell well WHAT and WHEN happened, but poorly explain WHY and HOW TO CORRECT.

    In another camp is my favorite RenderDoc, which I already wrote about. A great utility written by the guys from Crytek for themselves and people. Open source, support for all vendors, DirectX11 (with plans for Vulcan and DirectX12), a bunch of small useful little things.

    The second representative was once PIX, a DirectX9 performance analysis utility. It was conceived as a development tool for XBox (the name itself is an abbreviation for Performance Investigation for XBox), but it worked well for desktop applications. Until that moment, until she died (with the release of DirectX 10/11 and new versions of Windows). Microsoft, whose marketers defeated engineers once again, declared Visual Studio the only tool for graphical debugging, in which for these purposes there was a lot of superfluous, much was missing, and something was completely impossible. Studio is a great tool for programming, but it is far from being a good thing for studying, profiling and debugging graphic code (especially foreign code).

    All this despondency lasted several years until Microsoft engineers won a temporary victory and in January 2017 Microsoft announced the launch of a beta of a completely updated version of PIX for DirectX 12!

    Let's see what we got.

    Environment setting


    You will need Windows 10 (to use DirectX 12). PIX itself can be downloaded from here . Well, you also need an application that draws something using DirectX 12. For starters, you can take, for example, official examples from Microsoft, here they are on GitHub . To build them, you will need Visual Studio (2015 or later, a free Community is fine) and a Windows 10 SDK .

    Download and install all of the above, collect examples, run PIX.

    Beginning of work




    The PIX startup window looks good. There is something from the latest versions of Office, something from Visual Studio and very little from the style of UWP applications that is now fashionable in Microsoft today. We are immediately invited to do one of six actions to choose from: GPU Capture and Timing Capture relate to the graphics adapter, the rest of the items relate to ordinary profiling, which is of little interest to us in the context of this article.

    The need for two GPU Capture and Timing Capture points, as one of the PIX developers explained in the presentation, is dictated by the fact that there is no way at the same time to find out the detailed state of the graphic pipeline and keep the timings unchanged, since access to one of them changes the second (in this Heisenberg equation was given as an illustration in the place :)). Therefore, in each case, you have to choose whether we want to debug performance or rendering accuracy now.

    For performance measurements, we have vendor utilities, so let's focus on GPU Capture. We are offered to either run one of the UWP applications installed on this computer, or indicate the path to the usual binary. There is also an Attach tab, but it is not to our liking - it works only for ordinary profiling, but it is graphical debugging that will be enabled only for an application launched from under PIX. This, by the way, creates a problem with launchers (which in Renderdoc, for example, is solved). Well, maybe someday they will fix it here.



    For experiments, I took this example - it is simple as a door, and at the same time it allows you to demonstrate everything you need, because it makes a lot of draw calls.



    You can judge that PIX has been successfully implemented in the application by the caption at the top of the frame. Now you need to take a “snapshot” of rendering a single frame - using PrintScreen in a running application or using a button with a camera from PIX. The captured image looks like this:



    Open the image. We see the order of frame rendering operations:



    At the bottom there is a timeline, but there is nothing on it. This is not a bug, but a feature. In order for something to appear there, you need to start the "playback" of the picture (the "Start" button in the upper right). Then PIX will restore in memory all the resources needed for rendering and call all methods (in the same order, with the same parameters). And here is our timeline.



    Here you can evaluate the performance, parallelism and the overall big picture. After choosing a specific draw call, you can go to the neighboring Pipeline tab and see what was drawn there.



    We can view the state of the input buffers, the attached textures and shaders, the result of rendering after making this call:



    By right-clicking somewhere in the picture we can see the history of rendering of this pixel:





    We see that this particular pixel was affected twice during rendering of the current frame - when cleaning the canvas and when drawing the texture of the "checkers" later.

    From the context menu of any step in the rendering history, you can start debugging the shader that drew this pixel:



    image

    The debugger is good - you can go in steps, use breakpoints, go back, in the Autos window you can see all the necessary values. There is even an Edit & Continue for the shader code.

    In general, I liked the new PIX. There are minor roughnesses (lack of support for launchers, work with only one GPU), but this is all fixable. Of the global flaws, I would only note the lack of support for DirectX 11 - this is still a very common standard and the lack of support for it in both the old and new versions of PIX is very frustrating.

    New PIX Resources for Further Study



    Also popular now: