Prof-Butts / xwa_ddraw_d3d11

Direct3D 11 implementation of DDraw.dll for XWA with VR support and New Shaders
MIT License
6 stars 4 forks source link

Add D3D user annotations for profiling and debug #66

Closed morallo closed 2 years ago

morallo commented 2 years ago

Cherrypick from https://github.com/JeremyAnsel/xwa_ddraw_d3d11/pull/7

GPU performance events can be used to instrument your game by labeling regions and marking important occurrences. A performance event represents a logical, hierarchical grouping of work, consisting of a begin/end marker pair. In Direct3D 11.1 and above, the ID3DUserDefinedAnnotation interface is the recommended way to define those events.

https://docs.microsoft.com/en-us/windows/win32/api/d3d11_1/nn-d3d11_1-id3duserdefinedannotation https://developer.nvidia.com/blog/best-practices-gpu-performance-events/

These annotations can be used by different profiling tools, like Intel GPA, PIX, RenderDoc, NVIDIA Nsight... I could only do a capture with Intel GPA though.

image

The methods of ID3DUserDefinedAnnotation have no effect when the calling application is not running under a Direct3D-specific profiling tool.

To make them work I had to include d3d11_1.h. I added a new property in DeviceResources that should be available everywhere that this functionality is needed. I added some events for the high level functions that are performing draw calls.