{"id":2420,"date":"2019-09-11T11:20:29","date_gmt":"2019-09-11T18:20:29","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/directx\/?p=2420"},"modified":"2019-09-11T11:20:29","modified_gmt":"2019-09-11T18:20:29","slug":"dred-v1-2-supports-pix-marker-and-event-strings-in-auto-breadcrumbs","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/directx\/dred-v1-2-supports-pix-marker-and-event-strings-in-auto-breadcrumbs\/","title":{"rendered":"DRED v1.2 supports PIX marker and event strings in Auto-Breadcrumbs"},"content":{"rendered":"<p>In Windows 10 1903, DRED 1.1 provided D3D12 developers with the ability to diagnose device removed events using GPU page fault data and automatic breadcrumbs. As a result, TDR debugging pain has been greatly reduced.\u00a0 Hooray!\u00a0 Unfortunately, developers still struggle to pinpoint which specific GPU workloads triggered the error.\u00a0 So, we&#8217;ve made a few tweaks in DRED in the Windows 10 20H1 Release Preview.\u00a0 Specifically, DRED 1.2 adds &#8216;Context Data&#8217; to auto-breadcrumbs by integrating PIX marker and event strings into the auto-breadcrumb data.\u00a0 With context data, developers can more precisely determine where a GPU fault occurred.\u00a0 For example, instead of observing that a TDR occurs after the 71&#8217;st DrawInstanced call, the data can now indicate the fault occurred after the second DrawInstanced following the &#8220;BeginFoliage&#8221; PIX begin-event.<\/p>\n<h4>DRED 1.2 API&#8217;s<\/h4>\n<p>New D3D12 interfaces and data structures have been added to D3D12 to support DRED 1.2.<\/p>\n<h5>ID3D12DeviceRemovedExtendedDataSettings1<\/h5>\n<p>ID3D12DeviceRemovedExtendedDataSettings1 inherits from <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12\/nn-d3d12-id3d12deviceremovedextendeddatasettings\">ID3D12DeviceRemovedExtendedDataSettings<\/a>, adding a method for controlling DRED 1.2 breadcrumb context data.<\/p>\n<pre class=\"lang:default decode:true\">void ID3D12DeviceRemovedExtendedDataSettings::SetBreadcrumbContextEnablement(D3D12_DRED_ENABLEMENT Enablement);<\/pre>\n<div>\n<h5>ID3D12DeviceRemovedExtendedData1<\/h5>\n<div>ID3D12DeviceRemovedExtendedData1 inherits from <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12\/nn-d3d12-id3d12deviceremovedextendeddata\">ID3D12DeviceRemovedExtendedData<\/a>, providing access to DRED 1.2 breadcrumb context data.<\/div>\n<div><\/div>\n<div>\n<pre class=\"lang:default decode:true \">HRESULT ID3D12DeviceRemovedExtendedData1::GetAutoBreadcrumbsOutput1(D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 *pOutput);<\/pre>\n<div>\n<h5>D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1<\/h5>\n<div>\n<pre class=\"lang:default decode:true \">typedef struct D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1\r\n{\r\n    const D3D12_AUTO_BREADCRUMB_NODE1 *pHeadAutoBreadcrumbNode;\r\n} D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1;<\/pre>\n<p>pHeadAutoBreadcrumbsNode<\/p>\n<p style=\"padding-left: 40px;\">Points to the head of a linked list of D3D12_AUTO_BREADCRUMB_NODE1 structures.<\/p>\n<h5>D3D12_AUTO_BREADCRUMB_NODE1<\/h5>\n<p>Almost identical to <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12\/ns-d3d12-d3d12_auto_breadcrumb_node\">D3D12_AUTO_BREADCRUMB_NODE<\/a> with additional members describing DRED 1.2 breadcrumb context data.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div>\n<pre class=\"lang:default decode:true \">typedef struct D3D12_AUTO_BREADCRUMB_NODE1\r\n{\r\n    const char *pCommandListDebugNameA;\r\n    const wchar_t *pCommandListDebugNameW;\r\n    const char *pCommandQueueDebugNameA;\r\n    const wchar_t *pCommandQueueDebugNameW;\r\n    ID3D12GraphicsCommandList *pCommandList;\r\n    ID3D12CommandQueue *pCommandQueue;\r\n    UINT BreadcrumbCount;\r\n    const UINT *pLastBreadcrumbValue;\r\n    const D3D12_AUTO_BREADCRUMB_OP *pCommandHistory;\r\n    const struct D3D12_AUTO_BREADCRUMB_NODE1 *pNext;\r\n<span style=\"color: #ff0000;\">    UINT BreadcrumbContextsCount;\r\n    D3D12_DRED_BREADCRUMB_CONTEXT *pBreadcrumbContexts;<\/span>\r\n} D3D12_AUTO_BREADCRUMB_NODE1;<\/pre>\n<p>BreadcrumbContextsCount<\/p>\n<p style=\"padding-left: 40px;\">Number of D3D12_DRED_BREADCRUMB_CONTEXT elements in the array pointed to by pBreadcrumbContexts.<\/p>\n<p>pBreadcrumbContexts<\/p>\n<p style=\"padding-left: 40px;\">Pointer to an array of D3D12_DRED_BREADCRUMB_CONTEXT\u00a0 structures.<\/p>\n<h5>D3D12_DRED_BREADCRUMB_CONTEXT<\/h5>\n<p>Provides access to the context string associated with a command list op breadcrumb.<\/p>\n<pre class=\"lang:default decode:true \">typedef struct D3D12_DRED_BREADCRUMB_CONTEXT\r\n{\r\n    UINT BreadcrumbIndex;\r\n    const wchar_t *pContextString;\r\n} D3D12_DRED_BREADCRUMB_CONTEXT;<\/pre>\n<p>BreadcrumbIndex<\/p>\n<p style=\"padding-left: 40px;\">Index of the command list operation in the command history of the associated command list.\u00a0 The command history is the array pointed to by the pCommandHistory member of the D3D12_AUTO_BREADCRUMB_NODE1 structure.<\/p>\n<p>pContextString<\/p>\n<p style=\"padding-left: 40px;\">Pointer to the null-terminated wide-character context string.<\/p>\n<\/div>\n<h4>Accessing DRED 1.2 Context Data in Code<\/h4>\n<p>Use the ID3D12DeviceRemovedExtendedDataSettings1 interface to enable DRED before creating the device:<\/p>\n<pre class=\"lang:default decode:true\">CComPtr&lt;ID3D12DeviceRemovedExtendedDataSettings1&gt; pDredSettings;\r\nThrowFailure(D3D12GetDebugInterface(IID_PPV_ARGS(&amp;pDredSettings)));\r\npDredSettings-&gt;SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);\r\npDredSettings-&gt;SetBreadcrumbContextEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);\r\npDredSettings-&gt;SetPageFaultEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);\r\n<\/pre>\n<p>After a device removed event, use the ID3D12DeviceRemovedExtendedData1::<span style=\"font-size: 1rem;\">GetAutoBreadcrumbsOutput1 method to access DRED 1.2 auto-breadcrumb data<\/span><span style=\"font-size: 1rem;\">.<\/span><\/p>\n<pre class=\"lang:default decode:true\">CComPtr&lt;ID3D12DeviceRemovedExtendedData1&gt; pDred;\r\nThrowFailure(m_pDevice-&gt;QueryInterface(&amp;pDred));\r\nD3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 AutoBreadcrumbsOutput;\r\nThrowFailure(pDred-&gt;GetAutoBreadcrumbsOutput1(&amp;AutoBreadcrumbsOutput));\r\n<\/pre>\n<h4>Post-mortem Debugging<\/h4>\n<p>The DRED data can be accessed in a user-mode debugger without requiring the application to log the DRED output.\u00a0 To support this, we&#8217;ve implemented a DRED <a href=\"https:\/\/github.com\/microsoft\/DirectX-Debugging-Tools\">open-source debugger extension<\/a> on GitHub.\u00a0 This extension has been updated to support DRED 1.2 breadcrumb context data.<\/p>\n<p>More details on how to use the debugger extension can be found in this <a href=\"https:\/\/github.com\/microsoft\/DirectX-Debugging-Tools\/blob\/master\/README.md\">README.md<\/a> in the GitHub repositiory.<\/p>\n<h4>Force Enabling\/Disabling DRED<\/h4>\n<p>Developers are no longer required to instrument application code to take advantage of DRED.\u00a0 Instead, DRED can now be forced on or off using D3DConfig.exe.<\/p>\n<p>D3DConfig.exe is a new console application in Windows 10 20H1 Release Preview that gives extended control over traditional DirectX Control Panel settings.\u00a0 More details about D3DConfig can be found <a href=\"https:\/\/devblogs.microsoft.com\/directx\/d3dconfig-a-new-tool-to-manage-directx-control-panel-settings\/\">here<\/a>.<\/p>\n<p>To set an application to use d3dconfig\/dxcpl settings use:<\/p>\n<pre class=\"lang:default decode:true \">&gt; d3dconfig apps --add myd3d12app.exe\r\n\r\napps\r\n----------------\r\nmyd3d12app.exe<\/pre>\n<p>Note, this is identical to opening the DirectX Control panel and adding &#8220;myd3d12app.exe&#8221; to the executable list.<\/p>\n<p>To view the current DRED settings use:<\/p>\n<pre class=\"lang:default decode:true\">&gt; d3dconfig dred\r\n\r\ndred\r\n----------------\r\nauto-breadcrumbs=system-controlled\r\nbreadcrumb-contexts=system-controlled\r\npage-faults=system-controlled\r\nwatson-dumps=system-controlled<\/pre>\n<p>To force DRED page-faults on use:<\/p>\n<pre class=\"lang:default decode:true \">&gt; d3dconfig dred page-faults=forced-on\r\n\r\ndred\r\n----------------\r\npage-faults=forced-on<\/pre>\n<p>It may be more useful to simply enable all DRED features:<\/p>\n<pre class=\"lang:default decode:true\">&gt; d3dconfig dred --force-on-all\r\n\r\ndred\r\n----------------\r\nauto-breadcrumbs=forced-on\r\nbreadcrumb-contexts=forced-on\r\npage-faults=forced-on\r\nwatson-dumps=forced-on<\/pre>\n<h4>The End of Mysterious TDR&#8217;s Forever?<\/h4>\n<p>No.\u00a0 Unfortunately, there are still many device removal event bugs that DRED analysis may not help solve, including driver bugs or app bugs that can result in GPU errors in non-deterministic ways.\u00a0 For example, hardware might prefetch from an invalid data-static descriptor, triggering device removal at some point before the first operation that accesses that descriptor.\u00a0 While this would likely produce auto-breadcrumb results, the location of the error could be misleading.<\/p>\n<p>We plan to continue making TDR debugging improvements.\u00a0 As such, <a href=\"https:\/\/discordapp.com\/channels\/590611987420020747\/590966519895425025\">we would like to know<\/a> if you&#8217;ve discovered a TDR-causing bug that was missed by the Debug Layer, GPU-Based Validation, PIX and DRED.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Windows 10 1903, DRED 1.1 provided D3D12 developers with the ability to diagnose device removed events using GPU page fault data and automatic breadcrumbs. As a result, TDR debugging pain has been greatly reduced.\u00a0 Hooray!\u00a0 Unfortunately, developers still struggle to pinpoint which specific GPU workloads triggered the error.\u00a0 So, we&#8217;ve made a few tweaks [&hellip;]<\/p>\n","protected":false},"author":2473,"featured_media":12651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2420","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-directx"],"acf":[],"blog_post_summary":"<p>In Windows 10 1903, DRED 1.1 provided D3D12 developers with the ability to diagnose device removed events using GPU page fault data and automatic breadcrumbs. As a result, TDR debugging pain has been greatly reduced.\u00a0 Hooray!\u00a0 Unfortunately, developers still struggle to pinpoint which specific GPU workloads triggered the error.\u00a0 So, we&#8217;ve made a few tweaks [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/2420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/users\/2473"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/comments?post=2420"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/2420\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media\/12651"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media?parent=2420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/categories?post=2420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/tags?post=2420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}