Skip to content

Commit

Permalink
Merge pull request #286 from bbernhar/pix
Browse files Browse the repository at this point in the history
Enable PIX Capture for debug builds.
  • Loading branch information
fujunwei authored Aug 4, 2022
2 parents 525a858 + c5e5b32 commit 46fb78a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/webnn/native/dmlx/GraphDMLX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ namespace webnn::native::dmlx {
gpuPreference = DXGI_GPU_PREFERENCE::DXGI_GPU_PREFERENCE_UNSPECIFIED;
}
# if defined(_DEBUG)
mDevice.reset(new ::pydml::Device(useGpu, true, gpuPreference));
mDevice.reset(new ::pydml::Device(useGpu, true, true, gpuPreference));
# else
mDevice.reset(new ::pydml::Device(useGpu, false, gpuPreference));
# endif
Expand Down
12 changes: 11 additions & 1 deletion src/webnn/native/dmlx/deps/src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "precomp.h"

#include <DXProgrammableCapture.h>

#pragma warning(push)
#pragma warning(disable:4238)

Expand All @@ -23,7 +25,7 @@ ID3D12DescriptorHeap* SVDescriptorHeap::GetDescriptorHeap() const {
return descriptorHeap.Get();
}

Device::Device(bool useGpu, bool useDebugLayer, DXGI_GPU_PREFERENCE gpuPreference) : m_useGpu(useGpu), m_useDebugLayer(useDebugLayer), m_gpuPreference(gpuPreference) {}
Device::Device(bool useGpu, bool useDebugLayer, bool beginCaptureOnStartup, DXGI_GPU_PREFERENCE gpuPreference) : m_useGpu(useGpu), m_useDebugLayer(useDebugLayer), m_beginCaptureOnStartup(beginCaptureOnStartup), m_gpuPreference(gpuPreference) {}

// An adapter called the "Microsoft Basic Render Driver" is always present. This adapter is a render-only device that has no display outputs.
HRESULT IsWarpAdapter(IDXGIAdapter1* pAdapter, bool* isWarpAdapter) {
Expand Down Expand Up @@ -53,6 +55,14 @@ HRESULT Device::Init()
}
}


if (m_beginCaptureOnStartup){
ComPtr<IDXGraphicsAnalysis> graphicsAnalysis;
if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&graphicsAnalysis)))) {
graphicsAnalysis->BeginCapture();
}
}

Microsoft::WRL::ComPtr<IDXGIAdapter1> dxgiAdapter;
if(m_useGpu)
{
Expand Down
3 changes: 2 additions & 1 deletion src/webnn/native/dmlx/deps/src/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace pydml
class Device
{
public:
explicit Device(bool useGpu = true, bool useDebugLayer = false, DXGI_GPU_PREFERENCE gpuPreference = DXGI_GPU_PREFERENCE::DXGI_GPU_PREFERENCE_UNSPECIFIED);
explicit Device(bool useGpu = true, bool useDebugLayer = false, bool beginCaptureOnStartup = false, DXGI_GPU_PREFERENCE gpuPreference = DXGI_GPU_PREFERENCE::DXGI_GPU_PREFERENCE_UNSPECIFIED);

HRESULT Init();

Expand Down Expand Up @@ -103,6 +103,7 @@ namespace pydml
bool m_useCpuCustomHeapResources = false;
bool m_useGpu = true;
bool m_useDebugLayer = false;
bool m_beginCaptureOnStartup = false;
DXGI_GPU_PREFERENCE m_gpuPreference;
};
}

0 comments on commit 46fb78a

Please sign in to comment.