例如:

在 Pass1: 我從光源渲染了一張depth map

在 Pass2: 我繪製出了shadow

完畢。

那麼我想 準確獲得 Pass1消耗的時間 T1 和 Pass2消耗時間 T2。

(注意:這裡要全部繪製draw結束時間,不是指令被執行時間)

我應該怎麼做?用什麼方法?


jonasmr/microprofile?

github.com圖標

推薦這個庫,支持各種圖形 API。

Example code

  • noframes: Using microprofile to profile an application without any concept of frames. dumps a capture at the end. No live view.
  • noui: frame based implementation. with live view. No gpu timing
  • noui_d3d11: frame based implementation, with live view and D3D11 gpu timers
  • noui_d3d12: frame based implementation, with live view and D3D12 gpu timers
  • noui_d3d12_multithreading: frame based implementation, with live view and D3D12 gpu timers, with gpu timings generated from multiple threads.
  • noui_vulkan: Copy of the vulkan Hologram sample, fixed to use microprofile cpu and gpu markers. Only tested on windows.

不過個人是不推薦另造輪子的,有現成的工具為啥不用呢?

以下是我在個人網站上收集了一些圖形開發的工具,算是夾帶私貨。

Collections?

www.vinjn.com


意思是想獲取GPU實際的執行時間吧?沒實際寫過相關代碼,之前零零星星看過一點

你看看是否符合你的需求

DirectX 11 中有個ID3D11Query介面用於查詢GPU狀態

ID3D11Query?

docs.microsoft.com圖標

就是通過打上Begin,End標記,然後通過GetData來查詢數據

ID3D11DeviceContext::GetData?

docs.microsoft.com圖標

可查詢的類型:

D3D11_QUERY?

docs.microsoft.com圖標

一個使用示例:

DirectX 11 GPU Profile Blog?

reedbeta.com


曾經用過amd提供過一個叫做perfstudio的工具,可以抓出來所有的api call,並且給出每個api在gpu中執行的時間。同時還給出了其他挺多信息。但他好像只支持amd顯卡。

下面地址是這個官網,好像dx12的支持比較好,vulkan也有,dx11不記得了,你可以看一看。

GPU PerfStudio


這個為什麼要邀請我來回答?讓我答司法拍賣房我沒有問題。編程?太抬舉我咯!


如果是DirectX 用Pix吧,Ms自家的東西,PixelEventBegin(),你值得擁有


使用nvdia nsight 可以看到每個指令的耗時


推薦閱讀:
查看原文 >>
相关文章