March 20th, 2023

Programmatic Timing Captures now available

Steven Pratschner
Program Manager

As described in Programmatic Captures, the PIXBeginCapture and PIXEndCapture can now be used to start and stop Timing Captures from code running in your title.  Programmatic Timing Captures are available starting with the 2303.02 release of PIX on Windows and version 1.0.230302001 of the WinPIXEventRuntime.

Timing captures use several ETW providers.  This dependency requires your title to be running with administrator privileges to be able to take programmatic captures.  Also note that a helper dll, WinPixTimingCapturer.dll, must be loaded before calling PIXBeginCapture.  The easiest way to load this dll is by calling the PIXLoadLatestWinPixTimingCapturerLibrary helper function.

The following code sample loads the helper dll, calls PIXBeginCapture to start the capture, then calls PIXEndCapture to end the capture.  At this time, the discard parameter to PIXEndCapture is ignored.

        #include pix3.h        
         
        g_hTimingCapturer = PIXLoadLatestWinPixTimingCapturerLibrary();
        if (g_hTimingCapturer == NULL)
        {
            // process error
        }

        PIXCaptureParameters captureParams = {};

        captureParams.TimingCaptureParameters.FileName = L"c:\\captures\\hitch_detected.wpix";
        captureParams.TimingCaptureParameters.CaptureCpuSamples = true;
        captureParams.TimingCaptureParameters.CaptureCallstacks = true;
        captureParams.TimingCaptureParameters.CpuSamplesPerSecond = 4000;

        HRESULT hrProgCapture = PIXBeginCapture(PIX_CAPTURE_TIMING, &captureParams);

        if (!SUCCEEDED(hrProgCapture))
        {
            // process error
        }
        
        // title code runs
        HRESULT hrEndCapture = PIXEndCapture(false);

        if (!SUCCEEDED(hrEndCapture))
        {
            // process error
        }

 

See Programmatic Captures for more information on the programmatic capture APIs and the PIXCaptureParameters structure.

Steven.

Category
PIX

Author

Steven Pratschner
Program Manager

I'm the Program Manager for the PIX CPU tools in the Gaming Division at Microsoft. PIX helps you identify the performance issues that may be affecting the frame rate of your DX12 AAA title on Windows and on Xbox.

0 comments

Discussion are closed.