Skip to content

Commit 775d5e7

Browse files
committed
Schedule texture copy
1 parent f53a1e2 commit 775d5e7

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/D3D12Quad.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void D3D12Quad::OnInit()
4343
LoadPipeline();
4444
LoadAssets();
4545
is_initialized = true;
46+
copy_texture = false;
4647
}
4748

4849
// Load the rendering pipeline dependencies.
@@ -532,6 +533,12 @@ void D3D12Quad::PopulateCommandList()
532533
auto render_to_present = CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT);
533534
m_commandList->ResourceBarrier(1, &render_to_present);
534535

536+
if (copy_texture)
537+
{
538+
CopyTextureIntoCurrentBuffer();
539+
copy_texture = false;
540+
}
541+
535542
ThrowIfFailed(m_commandList->Close());
536543
}
537544

@@ -850,3 +857,8 @@ ComPtr<ID3D12Resource> D3D12Quad::GetCurrentBuffer()
850857
return currentBuffer;
851858
}
852859

860+
void D3D12Quad::ScheduleTextureCopy()
861+
{
862+
copy_texture = true;
863+
}
864+

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/D3D12Quad.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class D3D12Quad
2222
const WCHAR* GetTitle() const { return m_title.c_str(); }
2323

2424
ComPtr<ID3D12Resource> GetCurrentBuffer();
25+
void ScheduleTextureCopy();
2526

2627
bool is_initialized = false;
2728

@@ -102,5 +103,6 @@ class D3D12Quad
102103
// a resource dimension buffer that will be used by ORT for inference
103104
ComPtr<ID3D12Resource> currentBuffer;
104105
int imageBytesPerRow;
106+
bool copy_texture;
105107
};
106108

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/DXResourceBinding.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ namespace winrt::WinMLSamplesGalleryNative::implementation
222222
// Classify the image using EfficientNet and return the results
223223
winrt::com_array<float> results = Eval(*inferenceSession, preprocessedInput);
224224

225+
sample.ScheduleTextureCopy();
226+
225227
return results;
226228
}
227229

0 commit comments

Comments
 (0)