Performance Calculation between DX12 and Vulkan

Performance issue is one of the most important factors which needs consideration by graphic APIs. Besides, what is more important is related to GPU bound instead of CPU. So, due to the fact that Vulkan and DX12 provided a similar solution to calculate the timing consumption for GPU bound which called “timestamp” as “TS” for short.

DX12
DX12 used query to write timestamp and then resolve the timestamp data from query. After the command buffer had been executed (ExecuteCommandLists), map the query buffer data to CPU for reading.

Details for DX12
Need to create query heap before using query to write timestamp. Following codes illustrate how to create query heap (CreateQueryHeap) which used for timestamp.

Besides, need to create a buffer by calling method CreateCommittedResource which aimed to store the timestamp query data.
Then, need to call EndQuery and ResolveQueryData of ID3D12GraphicsCommandList to write timestamp. Just use DrawInstanced for example:

At last, need to map the timestamp data by calling Map method of ID3D12Resource for reading.

Vulkan
Unlike DX12, Vulkan just used command call to write timestamp instead of query. Then, map the query buffer data for timestamp after command buffer executed (vkQueueSubmit).

Details for Vulkan
Need to create query pool before using query to write timestamp. Following codes illustrate how to create query pool (vkCreateQueryPool) which used for timestamp.

Besides, need to create a buffer by calling method vkCreateBuffer which aimed to store the timestamp query data.
Then, need to call vkCmdWriteTimestamp to write timestamp. Just use vkCmdDraw for example:

At last, need to map the timestamp data by calling vkMapMemory method for reading.

Conclusion
Even there’s a little difference between DX12 and Vulkan, but they could get GPU time consumption correspondingly. And the most important is that DX12 and Vulkan are designed to allow advanced applications to drive modern GPUs to their fullest capacity. So, it’s a good start to catch up the next-generation API.

赞 (7)

5 thoughts on “Performance Calculation between DX12 and Vulkan

    1. Vulkan本来就是被设计成下一代图形API,在Khronos组织的带动下,会越来越发展完善,不过目前还不太可能完全取代OpenGL,但是之后还是会有很大希望的。

发表评论

电子邮件地址不会被公开。 必填项已用*标注