Skip to content

Commit ea74b8e

Browse files
committed
Clean up code
1 parent 2fa6306 commit ea74b8e

File tree

2 files changed

+6
-47
lines changed

2 files changed

+6
-47
lines changed

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/D3D12Quad.cpp

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,6 @@ void D3D12Quad::LoadImageTexture() {
296296
if (fileIndex > 2)
297297
fileIndex = 0;
298298

299-
// make sure we have data
300-
if (imageSize <= 0)
301-
{
302-
OutputDebugString(L"image file not found");
303-
}
304-
305299
// create a default heap where the upload heap will copy its contents into (contents being the texture)
306300
auto heap_properties_default = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
307301
ThrowIfFailed(m_device->CreateCommittedResource(
@@ -356,51 +350,26 @@ void D3D12Quad::LoadImageTexture() {
356350
// in a resource dimension buffer. This will be used for inference in ORT
357351
void D3D12Quad::CreateCurrentBuffer()
358352
{
359-
//D3D12_RESOURCE_DESC resourceDesc = {
360-
// D3D12_RESOURCE_DIMENSION_BUFFER,
361-
// 0,
362-
// static_cast<uint64_t>(800 * 600 * 3 * 4),
363-
// 1,
364-
// 1,
365-
// 1,
366-
// DXGI_FORMAT_UNKNOWN,
367-
// {1, 0},
368-
// D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
369-
// D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS
370-
//};
371-
372-
// Readback resources must be buffers
373353
auto desc = m_renderTargets[m_frameIndex]->GetDesc();
374354
D3D12_RESOURCE_DESC bufferDesc = {};
375355
bufferDesc.DepthOrArraySize = 1;
376356
bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
377357
bufferDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
378358
bufferDesc.Format = DXGI_FORMAT_UNKNOWN;
379-
//bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
380359
bufferDesc.Height = 1;
381360
bufferDesc.Width = ((desc.Width* 4 + 255) & ~255) * desc.Height;
382-
//bufferDesc.Width = static_cast<uint64_t>(800 * 600 * 3 * 4);
383361
bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
384-
//bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
385362
bufferDesc.MipLevels = 1;
386363
bufferDesc.SampleDesc.Count = 1;
387364

388-
//auto heap_properties = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
389-
const CD3DX12_HEAP_PROPERTIES readBackHeapProperties(D3D12_HEAP_TYPE_DEFAULT);
365+
const CD3DX12_HEAP_PROPERTIES heapProperties(D3D12_HEAP_TYPE_DEFAULT);
390366
auto some_hr = m_device->CreateCommittedResource(
391-
&readBackHeapProperties,
367+
&heapProperties,
392368
D3D12_HEAP_FLAG_NONE,
393369
&bufferDesc,
394370
D3D12_RESOURCE_STATE_COPY_DEST,
395371
nullptr,
396372
IID_PPV_ARGS(&currentBuffer));
397-
//ThrowIfFailed(m_device->CreateCommittedResource(
398-
// &readBackHeapProperties,
399-
// D3D12_HEAP_FLAG_NONE,
400-
// &bufferDesc,
401-
// D3D12_RESOURCE_STATE_COPY_DEST,
402-
// nullptr,
403-
// IID_PPV_ARGS(&currentBuffer)));
404373
}
405374

406375
void D3D12Quad::CopyTextureIntoCurrentBuffer()
@@ -461,15 +430,6 @@ void D3D12Quad::Reset() {
461430
// Update frame-based values.
462431
void D3D12Quad::OnUpdate()
463432
{
464-
// Change the image every 75 frame updates
465-
//updateCounter++;
466-
//justReset = false;
467-
//if (updateCounter == 75) {
468-
// Reset();
469-
// LoadImageTexture();
470-
// updateCounter = 0;
471-
// justReset = true;
472-
//}
473433
justReset = false;
474434
if (copy_texture) {
475435
Reset();
@@ -861,12 +821,12 @@ ComPtr<ID3D12Resource> D3D12Quad::GetCurrentBuffer()
861821
return currentBuffer;
862822
}
863823

824+
// Schedules the next image to be shown by setting the copy_texture
825+
// variable to true. OnUpdate will catch this variable and load the
826+
// next image then the image texture will be copied into a resource
827+
// dimension buffer at the end of PopulateCommandLists
864828
void D3D12Quad::ShowNextImage()
865829
{
866-
//justReset = false;
867-
//Reset();
868-
//LoadImageTexture();
869-
//justReset = true;
870830
copy_texture = true;
871831
}
872832

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/D3D12Quad.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,5 @@ class D3D12Quad
104104
ComPtr<ID3D12Resource> currentBuffer;
105105
int imageBytesPerRow;
106106
bool copy_texture;
107-
bool show_next_image;
108107
};
109108

0 commit comments

Comments
 (0)