Visual Studio 圖形診斷Visual Studio Graphics Diagnostics

注意

Visual Studio 針對 DirectX 12 遊戲建議 Windows 上的 PIX。Visual Studio recommends PIX on Windows for DirectX 12 games. Windows 上的 PIX 是可完全支援 DirectX 12 的效能調整和偵錯工具。PIX on Windows is a performance tuning and debugging tool that fully supports DirectX 12. 請參閱這裡的詳細資訊下載Find out more information or download here.

Visual Studio 圖形診斷是一組工具,用來記錄並分析 Direct3D 應用程式中的轉譯和效能問題。Visual Studio Graphics Diagnostics is a set of tools for recording and then analyzing rendering and performance problems in Direct3D apps. 圖形診斷可以用於 Windows 電腦、Windows 裝置模擬器或者遠端電腦或裝置上本機執行的應用程式。Graphics Diagnostics can be used on apps that are running locally on your Windows PC, in a Windows device emulator, or on a remote PC or device.

圖形診斷工作流程會開始擷取您應用程式如何使用 Direct3D 的一筆記錄 (執行時為即時),以立即分析、共用或儲存其行為以供稍後使用。The Graphics Diagnostics workflow begins by capturing a record of how your app uses Direct3D—live, as it runs—so that its behavior can be analyzed immediately, shared, or saved for later. 您可以從 Visual Studio 或使用命令列捕捉工具 dxcap.exe,手動起始和控制 Capture 會話。Capture sessions can be initiated and controlled manually from Visual Studio or with the command-line capture tool dxcap.exe. 您也可以使用圖形診斷 capture Api,以程式設計方式起始和控制 Capture 會話。Capture sessions can also be initiated and controlled programmatically by using the Graphics Diagnostics capture APIs.

記錄擷取工作階段之後,Visual Studio「圖形分析器」隨時都可以播放其內容,方法是使用完全相同資源並轉譯應用程式所使用的命令來重建所擷取畫面格。After a capture session has been recorded its contents can be played back by Visual Studio Graphics Analyzer at any time, recreating the captured frames by using the exact same resources and rendering commands the app used. 然後,使用 [圖形分析器] 視窗中提供的工具,可以詳細分析任何已捕捉的畫面格。Then, using the tools provided in the Graphics Analyzer window, any of the captured frames can be analyzed in detail. 這些工具可以用來檢查任何 Direct3D API 呼叫、資源、管線狀態物件、管線階段,甚至所擷取畫面格中任何像素的完整歷史記錄。These tools can be used to examine any Direct3D API call, resource, pipeline state object, pipeline stage, or even the complete history of any pixel in a captured frame. 透過搭配使用這些工具,可以直覺式探索轉譯問題,這是從它如何出現在所擷取的畫面格中開始,並向下鑽研至其在應用程式原始程式碼、著色器或圖形資產中的根本原因。By using these tools in concert, a rendering problem can be explored intuitively, starting from how it appears in a captured frame and drilling down to its root cause in the app's source code, shaders, or graphics assets.

若要診斷效能問題,可以使用「畫面分析」工具分析所擷取的畫面格。To diagnose performance problems, a captured frame can be analyzed by using the Frame Analysis tool. 這項工具透過自動變更應用程式使用 Direct3D 的方式,並對所有變化進行基準測試,來探索潛在的效能最佳化。This tool explores potential performance optimizations by automatically changing the way the app uses Direct3D and benchmarking all the variations for you. 過去,您可能已經手動進行這些類型的變更並只對其進行基準測試,以找出哪些變更造成差異。In the past, you might have made and benchmarked these kinds of changes manually just to find out which ones made a difference. 使用畫面格分析,您只需要進行已知道成功的變更。With Frame Analysis, you only need to make the changes you already know will pay off.

圖形診斷有助於您具有豐富圖形之 Direct3D 應用程式的外觀而且執行效果最佳。Graphics Diagnostics helps your graphically-rich Direct3D app look and run its best.

繼續進行 總覽 ,深入瞭解圖形診斷提供的 Visual Studio。Continue to Overview to learn more about what Visual Studio Graphics Diagnostics offers.

本節內容In This Section

總覽 介紹圖形診斷的工作流程和工具。Overview Introduces the Graphics Diagnostics workflow and tools.

開始使用 在本節中,您將瞭解如何安裝 Visual Studio 圖形診斷,以及如何開始搭配使用圖形診斷與 Direct3D 應用程式。Getting Started In this section, you'll learn how to install Visual Studio Graphics Diagnostics and how to start using Graphics Diagnostics with your Direct3D app.

捕獲圖形資訊 若要使用圖形診斷檢查應用程式中的轉譯問題,您必須先記錄應用程式如何使用 DirectX 的相關資訊。Capturing Graphics Information To use Graphics Diagnostics to examine a rendering problem in your app, you first record information about how the app uses DirectX. 在記錄工作階段期間,如果您的應用程式正常地執行,請「擷取」(亦即選取) 感興趣的畫面格。During the recording session, as your app runs normally, you capture (that is, select) the frames that you're interested in. 擷取包含如何呈現畫面格的詳細資訊。The captures contain detailed information about how the frames are rendered. 您可以將擷取到的資訊儲存為圖形記錄文件,以供稍後再檢查,或與您小組的其他成員共用。You can save the captured information as a graphics log document to examine later or share with other members of your team.

GPU 使用量 若要使用圖形診斷來分析您的應用程式,請使用 [GPU 使用量] 工具。GPU Usage To use Graphics Diagnostics to profile your app, use the GPU Usage tool. GPU 使用量可以用於與其他程式碼剖析工具 (例如 CPU 使用量) 搭配使用,以關聯可能造成應用程式中效能問題的 CPU 和 GPU 活動。GPU usage can be used in concert with other profiling tools, such as CPU Usage, to correlate CPU and GPU activity that might contribute to performance problems in your app.

圖形記錄檔 若要開始檢查所記錄的圖形記錄,請使用圖形記錄文件視窗來選取已捕捉的框架(或甚至是特定圖元),讓您可以詳細檢查 事件 (也就是 DirectX API 會呼叫影響它的) 。Graphics Log Document To start the examination of a recorded graphics log, you use the Graphics Log document window to select a captured frame—or even a specific pixel—so that you can examine in detail the events (that is, the DirectX API calls) that affect it.

畫面格分析 選取畫面格之後,您可以使用圖形畫面格分析來檢查和調整轉譯效能。Frame Analysis After you select a frame, you use Graphics Frame Analysis to examine and tune your rendering performance.

事件清單 選取框架之後,您可以使用 [ 圖形事件清單 ] 來檢查其事件,以判斷它們是否與轉譯問題相關。Event List After you select a frame, you use the Graphics Event List to examine its events to determine whether they are related to the rendering problem.

狀態 [狀態] 視窗可協助您瞭解在目前事件時作用的圖形狀態。State The State window helps you understand the graphics state that is active at the time of the current event.

管線階段 在 [ 圖形管線階段 ] 視窗中,您可以調查圖形管線的每個階段如何處理目前選取的事件,讓您可以識別呈現問題第一次出現的位置。Pipeline Stages In the Graphics Pipeline Stages window, you investigate how the currently selected event is processed by each stage of the graphics pipeline so that you can identify where the rendering problem first appears. 如果物件因轉換錯誤而未出現,或其中一個階段產生不符合下個階段所預期的輸出,則檢查管線階段會特別有用。Examining the pipeline stages is particularly helpful when an object doesn't appear because of an incorrect transformation, or when one of the stages produces output that doesn't match what the next stage expects.

事件呼叫堆疊 您可以使用 [ 圖形事件呼叫堆疊 ] 檢查目前所選取事件的呼叫堆疊,以便流覽至與轉譯問題相關的應用程式程式碼。Event Call Stack You use the Graphics Event Call Stack to examine the call stack of the currently selected event so that you can navigate to app code that's related to the rendering problem.

圖元歷程記錄 藉由使用 [ 圖形圖元歷史記錄 ] 視窗來分析受影響的事件,目前選取的圖元如何受到影響,您可以識別導致特定類型之轉譯問題的事件或事件組合。Pixel History By using the Graphics Pixel History window to analyze how the currently selected pixel is affected by the events that influenced it, you can identify the event or combination of events that cause certain kinds of rendering problems. 如果因像素著色器輸出不正確,或已錯誤地與畫面格緩衝區合併,導致錯誤地呈現物件;或者,如果因為在物件像素到達畫面格緩衝區之前捨棄物件像素,使得物件未顯示,則像素歷史記錄特別有用。The pixel history is particularly helpful when an object is rendered incorrectly because pixel shader output is either incorrect or has been combined incorrectly with the frame buffer, or when an object doesn't even appear because its pixels have been discarded before they reach the frame buffer.

物件資料表 您可以使用 [ 繪圖物件表 ] 來檢查特定 Direct3D 物件的屬性和內容,以及目前所選事件的有效資源。Object Table You use the Graphics Object Table to examine the properties and contents of specific Direct3D objects and resources that are in effect for the currently selected event. 物件表可以協助您判斷在事件期間使用中的圖形裝置內容,以及檢查圖形資源的內容 (例如常數緩衝區、端點緩衝區和紋理)。The object table can help you determine the graphics device context that's active during an event, and examine the contents of graphics resources such as constant buffers, vertex buffers, and textures.

HLSL 偵錯工具 若要檢查著色器程式碼針對目前所選取事件和圖形管線階段的行為方式,您可以使用 HLSL 偵錯工具 來逐步執行程式碼、檢查變數內容,以及執行其他一般的偵錯工具。HLSL Debugger To examine how the shader code for the currently selected event and graphics pipeline stage behaves, you use the HLSL Debugger to step through code, examine the contents of variables, and perform other typical debugging tasks. 您也可以使用 HLSL 偵錯工具,檢查計算著色器程式碼,不論圖形管線是否進一步處理結果,或應用程式是否讀回結果。You can also use the HLSL debugger to examine compute shader code, regardless of whether the results are further processed by the graphics pipeline or are just read back by your app.

命令列捕獲工具 使用命令列捕捉工具可快速捕捉和播放圖形資訊,而不需使用 Visual Studio 或程式設計的捕捉。Command-Line Capture Tool Use the command-line capture tool to quickly capture and play back graphics information without using Visual Studio or programmatic capture. 特別是,您可以使用命令列的擷取工具自動化,或在測試環境中使用。In particular, you can use the command-line capture tool for automation, or in a test environment.

範例 數個範例示範如何搭配使用圖形診斷工具來診斷不同種類的轉譯問題。Examples Several examples demonstrate how to use the Graphics Diagnostics tools together to diagnose different kinds of rendering problems.

標題Title 描述Description
偵錯工具功能導覽Debugger Feature Tour 介紹 Visual StudioVisual Studio 中的偵錯功能。Introduces the debugging functionality in Visual StudioVisual Studio.
DirectX 圖形與遊戲DirectX Graphics and Gaming 提供討論 DirectX 圖形技術的文章。Provides articles that discuss DirectX graphics technologies.
Visual Studio 中的 DirectX 12 支援DirectX 12 Support in Visual Studio 瞭解 Visual Studio 中的 DirectX 12 支援Learn about DirectX 12 support in Visual Studio