Skip to content

Commit 5fe0e06

Browse files
author
REDMOND\jingf
committed
N/A
1 parent 85e35c3 commit 5fe0e06

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/WinMLHelper.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,23 @@ VideoFrame LoadImageFile(hstring filePath)
4848
return imageFrame;
4949
}
5050

51-
void BindModel(ID3D12CommandQueue* commandQueue)
51+
void CreateSession(ID3D12CommandQueue* commandQueue)
5252
{
5353
printf("Binding the model...\n");
54-
DWORD ticks = GetTickCount();
5554

5655
winrt::com_ptr<::IUnknown> spUnk;
5756
auto factory = winrt::get_activation_factory<LearningModelDevice, ILearningModelDeviceFactoryNative>();
5857
factory->CreateFromD3D12CommandQueue(commandQueue, spUnk.put());
5958
LearningModelDevice dmlDeviceCustom = spUnk.as<LearningModelDevice>();
6059

61-
// now create a session and binding
60+
// now create a session
6261
session = LearningModelSession{ model, dmlDeviceCustom };
62+
}
63+
64+
void BindModel(ID3D12CommandQueue* commandQueue)
65+
{
66+
printf("Binding the model...\n");
67+
DWORD ticks = GetTickCount();
6368
binding = LearningModelBinding{ session };
6469
// bind the intput image
6570
binding.Bind(L"data_0", ImageFeatureValue::CreateFromVideoFrame(imageFrame));

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/WinMLHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static vector<string> labels;
2727
// Forward declarations
2828
void LoadModel();
2929
VideoFrame LoadImageFile(hstring filePath);
30+
void CreateSession(ID3D12CommandQueue* commandQueue);
3031
void BindModel(ID3D12CommandQueue* commandQueue);
3132
void EvaluateModel();
3233
void PrintResults(IVectorView<float> results);

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static hstring pixCaptureFilePath = L".\\PIXCapture\\capture.wpix";
1616
ID3D12Device* m_d3d12Device;
1717
ID3D12CommandList* m_commandList;
1818
ID3D12CommandQueue* m_commandQueue;
19+
UINT m_color = PIX_COLOR(255, 0, 0);
1920

2021
void GetHardwareAdapter(IDXGIFactory4* pFactory, IDXGIAdapter1** ppAdapter)
2122
{
@@ -75,16 +76,19 @@ void GetD3D12CommandAssets()
7576
void LoadAndEvaluate(ID3D12CommandQueue* commandQueue)
7677
{
7778
// Setting markers for each step, these markers will split the commands into sections for easier debugging
78-
PIXSetMarker(commandQueue, 0, "Start loading model...");
79+
PIXSetMarker(commandQueue, m_color, "Start loading model...");
7980
LoadModel();
8081

81-
PIXSetMarker(commandQueue, 0, "Start loading image...");
82+
PIXSetMarker(commandQueue, m_color, "Start loading image...");
8283
LoadImageFile(imagePath);
8384

84-
PIXSetMarker(commandQueue, 0, "Start binding model...");
85+
PIXSetMarker(commandQueue, m_color, "Start creating session...");
86+
CreateSession(commandQueue);
87+
88+
PIXSetMarker(commandQueue, m_color, "Start binding model...");
8589
BindModel(commandQueue);
8690

87-
PIXSetMarker(commandQueue, 0, "Start evaluating model...");
91+
PIXSetMarker(commandQueue, m_color, "Start evaluating model...");
8892
EvaluateModel();
8993

9094
}
@@ -103,7 +107,7 @@ void CaptureWithUserSetMarker()
103107
PIXBeginCaptureRedist(PIX_CAPTURE_GPU, &capParams);
104108

105109
// Start PIX event, markers can only be set within Being and End event sections
106-
PIXBeginEvent(m_commandQueue, 0, "WinMLPIXSample");
110+
PIXBeginEvent(m_commandQueue, m_color, "WinMLPIXSample");
107111

108112
// Do the ML computation
109113
LoadAndEvaluate(m_commandQueue);

0 commit comments

Comments
 (0)