{"id":6358,"date":"2024-01-03T10:22:18","date_gmt":"2024-01-03T18:22:18","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/pix\/?p=6358"},"modified":"2024-02-27T17:32:33","modified_gmt":"2024-02-28T01:32:33","slug":"circular-timing-captures","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/pix\/circular-timing-captures\/","title":{"rendered":"Circular Timing Captures"},"content":{"rendered":"<p>Starting with the <a href=\"https:\/\/devblogs.microsoft.com\/pix\/pix-2402-07\/\">2402.07 version of PIX on Windows<\/a> and <a href=\"https:\/\/devblogs.microsoft.com\/pix\/winpixeventruntime\/\">version 1.0.231030001 of the WinPIXEventRuntime<\/a>, <span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\"><a href=\"https:\/\/devblogs.microsoft.com\/pix\/timing-captures-new\/\">Timing Captures<\/a> can now be run in a new &#8220;Circular&#8221;, or &#8220;ring-buffer&#8221; mode, in addition to the previously available &#8220;Sequential&#8221; mode.\u00a0 The new Circular mode is available both through the PIX UI and programmatically using the <a href=\"https:\/\/devblogs.microsoft.com\/pix\/programmatic-timing-captures-now-available\/\">PIXBeginCapture<\/a> API.\u00a0 <\/span><\/p>\n<p><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">When capturing in Circular mode, PIX stores the capture data in a fixed sized buffer on disk. When the buffer is full, the oldest capture data is aged out to make room for newer data. Because the amount of space needed to store capture data is fixed, Circular captures can be run continuously.\u00a0 The on-disk buffer is stored in the user&#8217;s %TEMP% directory and is deleted when the capturing process is complete.<\/span><\/p>\n<p>The new <strong>Capture Mode<\/strong> setting in the PIX UI is used to choose between <strong>Circular<\/strong> and <strong>Sequential<\/strong> mode.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_capture_mode_setting.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-6359\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_capture_mode_setting.png\" alt=\"Image circular captures capture mode setting\" width=\"649\" height=\"357\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_capture_mode_setting.png 649w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_capture_mode_setting-300x165.png 300w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/a><\/p>\n<p>When <strong>Capture Mode<\/strong> is set to <strong>Circular<\/strong>, use the edit field or the slider to specify the size of the on-disk buffer.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_buffer_size_setting.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-6360\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_buffer_size_setting.png\" alt=\"Image circular captures buffer size setting\" width=\"638\" height=\"428\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_buffer_size_setting.png 638w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2024\/01\/circular_captures_buffer_size_setting-300x201.png 300w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Note that capturing <strong>GPU timings<\/strong> and <strong>GPU resources<\/strong> are not currently supported in <strong>Circular<\/strong> mode.<\/p>\n<p>Both <strong>Circular<\/strong> and <strong>Sequential<\/strong> capture are stopped from the PIX UI using the <strong>Stop Timing Capture<\/strong> button.<\/p>\n<p>Circular Timing Captures are particularly useful when taken programmatically using <a href=\"https:\/\/devblogs.microsoft.com\/pix\/programmatic-timing-captures-now-available\/\">PIXBeginCapture<\/a>.\u00a0 In this scenario, a capture can be started and left running until a spike in frame time, or any other event that&#8217;s significant from a performance perspective, is detected.\u00a0 The capture can then be stopped using <a href=\"https:\/\/devblogs.microsoft.com\/pix\/programmatic-timing-captures-now-available\/\">PIXEndCapture<\/a>.\u00a0 The resulting capture will contain the last N seconds of data, depending on the size of the on-disk buffer and the amount of capture data generated.<\/p>\n<p>Two values must be set in the <em>PIXCaptureParameters<\/em> structure to enable <strong>Circular<\/strong> captures.\u00a0 First, specify the value <em>PIXCaptureParameters::FileCircular<\/em> for the <em>CaptureStorage<\/em> field. Next, set the <em>MaximumToolingMemorySizeMb<\/em> field to specify the size of the on-disk buffer.\u00a0 Remember that your game must be running with administrator permissions to take a capture Timing Capture programmatically.<\/p>\n<p><strong>Circular<\/strong> timing capture code sample:<\/p>\n<pre class=\"prettyprint language-cpp\"><code class=\"language-cpp\">        #include pix3.h        \r\n         \r\n        g_hTimingCapturer = PIXLoadLatestWinPixTimingCapturerLibrary();\r\n        if (g_hTimingCapturer == NULL)\r\n        {\r\n            \/\/ process error\r\n        }\r\n\r\n        PIXCaptureParameters captureParams = {};\r\n\r\n        captureParams.TimingCaptureParameters.FileName = L\"c:\\\\captures\\\\hitch_detected.wpix\";\r\n        captureParams.TimingCaptureParameters.CaptureCpuSamples = true;\r\n        captureParams.TimingCaptureParameters.CaptureCallstacks = true;\r\n        captureParams.TimingCaptureParameters.CpuSamplesPerSecond = 4000;\r\n<strong>        captureParams.TimingCaptureParameters.MaximumToolingMemorySizeMb = 256;<\/strong>\r\n<strong>        captureParams.TimingCaptureParameters.CaptureStorage = PIXCaptureParameters::FileCircular;<\/strong>\r\n\r\n        HRESULT hrProgCapture = PIXBeginCapture(PIX_CAPTURE_TIMING, &amp;captureParams);\r\n\r\n        if (!SUCCEEDED(hrProgCapture))\r\n        {\r\n            \/\/ process error\r\n        }\r\n        \r\n        \/\/ title code runs - stop the capture when an interesting performance event is detected\r\n        HRESULT hrEndCapture = PIXEndCapture(false);\r\n\r\n        if (!SUCCEEDED(hrEndCapture))\r\n        {\r\n            \/\/ process error\r\n        }<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>As always, keep sending us bug reports and feature requests using the PIX Feedback button in the upper right corner of the PIX UI.<\/p>\n<p>Steven.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Starting with the 2402.07 version of PIX on Windows and version 1.0.231030001 of the WinPIXEventRuntime, Timing Captures can now be run in a new &#8220;Circular&#8221;, or &#8220;ring-buffer&#8221; mode, in addition to the previously available &#8220;Sequential&#8221; mode.\u00a0 The new Circular mode is available both through the PIX UI and programmatically using the PIXBeginCapture API.\u00a0 When capturing [&hellip;]<\/p>\n","protected":false},"author":1915,"featured_media":6360,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6358","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pix"],"acf":[],"blog_post_summary":"<p>Starting with the 2402.07 version of PIX on Windows and version 1.0.231030001 of the WinPIXEventRuntime, Timing Captures can now be run in a new &#8220;Circular&#8221;, or &#8220;ring-buffer&#8221; mode, in addition to the previously available &#8220;Sequential&#8221; mode.\u00a0 The new Circular mode is available both through the PIX UI and programmatically using the PIXBeginCapture API.\u00a0 When capturing [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts\/6358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/users\/1915"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/comments?post=6358"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts\/6358\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media\/6360"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media?parent=6358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/categories?post=6358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/tags?post=6358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}