Skip to content
This repository was archived by the owner on Dec 25, 2023. It is now read-only.

Commit 5b31d04

Browse files
Added playback utility for DirectStorage traces with enchaned capture capability (it works properly now). Many fixes and improvements.
1 parent 580a263 commit 5b31d04

28 files changed

+1270
-128
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ ID3D12CommandList* pCommandLists[] = { commandLists.m_beforeDrawCommands, m_comm
284284
285285
## Log
286286
287+
- 2022-10-24: Added DirectStorage trace playback utility to measure performance of file upload independent of rendering. For example, to capture and playback the DirectStorage requests and submits for 500 "stressful" frames with a staging buffer size of 128MB, cd to the build directory and:
288+
```
289+
stress.bat -timingstart 200 -timingstop 700 -capturetrace
290+
traceplayer.exe -file uploadTraceFile_1.json -mediadir media -staging 128
291+
```
287292
- 2022-06-10: File format (.xet) change. DdsToXet can upgrade old Xet files to the new format. Assets in the DDS directory are exported at build time into media directory. Upgrade to DirectStorage v1.0.2. Many misc. improvements.
288293
- 2022-05-05: Workaround for rare race condition. Many tweaks and improvements.
289294
- 2022-03-14: DirectStorage 1.0.0 integrated into mainline

SamplerFeedbackStreaming.sln

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29920.165
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Expanse", "src\Expanse.vcxproj", "{E9BCC846-C1E9-402F-AC99-0E72195202AC}"
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Expanse", "src\Expanse.vcxproj", "{A92A871F-FFF6-4A14-A3A2-EA583C0EA015}"
77
ProjectSection(ProjectDependencies) = postProject
8+
{273A5112-7D55-4A16-829A-E4F73E4BACE7} = {273A5112-7D55-4A16-829A-E4F73E4BACE7}
89
{45087328-C272-4BB6-BB09-95D899D2276A} = {45087328-C272-4BB6-BB09-95D899D2276A}
910
{12A36A45-4A15-48E3-B886-257E81FD57C6} = {12A36A45-4A15-48E3-B886-257E81FD57C6}
11+
{369039E2-4C18-40D9-A7FE-E3D87BA23149} = {369039E2-4C18-40D9-A7FE-E3D87BA23149}
1012
EndProjectSection
1113
EndProject
1214
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgui", "imgui\imgui.vcxproj", "{45087328-C272-4BB6-BB09-95D899D2276A}"
@@ -17,17 +19,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{EB9EA81E
1719
EndProject
1820
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DdsToXet", "DdsToXet\DdsToXet.vcxproj", "{369039E2-4C18-40D9-A7FE-E3D87BA23149}"
1921
EndProject
22+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tracePlayer_2019", "tracePlayer\tracePlayer_2019.vcxproj", "{273A5112-7D55-4A16-829A-E4F73E4BACE7}"
23+
EndProject
2024
Global
2125
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2226
Debug|x64 = Debug|x64
2327
Release|x64 = Release|x64
2428
EndGlobalSection
2529
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26-
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Debug|x64.ActiveCfg = Debug|x64
27-
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Debug|x64.Build.0 = Debug|x64
28-
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Debug|x64.Deploy.0 = Debug|x64
29-
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Release|x64.ActiveCfg = Release|x64
30-
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Release|x64.Build.0 = Release|x64
30+
{A92A871F-FFF6-4A14-A3A2-EA583C0EA015}.Debug|x64.ActiveCfg = Debug|x64
31+
{A92A871F-FFF6-4A14-A3A2-EA583C0EA015}.Debug|x64.Build.0 = Debug|x64
32+
{A92A871F-FFF6-4A14-A3A2-EA583C0EA015}.Debug|x64.Deploy.0 = Debug|x64
33+
{A92A871F-FFF6-4A14-A3A2-EA583C0EA015}.Release|x64.ActiveCfg = Release|x64
34+
{A92A871F-FFF6-4A14-A3A2-EA583C0EA015}.Release|x64.Build.0 = Release|x64
3135
{45087328-C272-4BB6-BB09-95D899D2276A}.Debug|x64.ActiveCfg = Debug|x64
3236
{45087328-C272-4BB6-BB09-95D899D2276A}.Debug|x64.Build.0 = Debug|x64
3337
{45087328-C272-4BB6-BB09-95D899D2276A}.Release|x64.ActiveCfg = Release|x64
@@ -40,12 +44,17 @@ Global
4044
{369039E2-4C18-40D9-A7FE-E3D87BA23149}.Debug|x64.Build.0 = Debug|x64
4145
{369039E2-4C18-40D9-A7FE-E3D87BA23149}.Release|x64.ActiveCfg = Release|x64
4246
{369039E2-4C18-40D9-A7FE-E3D87BA23149}.Release|x64.Build.0 = Release|x64
47+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Debug|x64.ActiveCfg = Debug|x64
48+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Debug|x64.Build.0 = Debug|x64
49+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Release|x64.ActiveCfg = Release|x64
50+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Release|x64.Build.0 = Release|x64
4351
EndGlobalSection
4452
GlobalSection(SolutionProperties) = preSolution
4553
HideSolutionNode = FALSE
4654
EndGlobalSection
4755
GlobalSection(NestedProjects) = preSolution
4856
{369039E2-4C18-40D9-A7FE-E3D87BA23149} = {EB9EA81E-AD7B-4F2F-B8A9-AFC9282303C9}
57+
{273A5112-7D55-4A16-829A-E4F73E4BACE7} = {EB9EA81E-AD7B-4F2F-B8A9-AFC9282303C9}
4958
EndGlobalSection
5059
GlobalSection(ExtensibilityGlobals) = postSolution
5160
SolutionGuid = {CECC8215-A95C-44A3-94DC-6A6AEE5A841B}

SamplerFeedbackStreaming_vs2022.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ EndProject
1414
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Expanse", "src\Expanse_vs2022.vcxproj", "{E9BCC846-C1E9-402F-AC99-0E72195202AC}"
1515
ProjectSection(ProjectDependencies) = postProject
1616
{12A36A45-4A15-48E3-B886-257E81FD57C6} = {12A36A45-4A15-48E3-B886-257E81FD57C6}
17+
{273A5112-7D55-4A16-829A-E4F73E4BACE7} = {273A5112-7D55-4A16-829A-E4F73E4BACE7}
1718
{369039E2-4C18-40D9-A7FE-E3D87BA23149} = {369039E2-4C18-40D9-A7FE-E3D87BA23149}
1819
{45087328-C272-4BB6-BB09-95D899D2276A} = {45087328-C272-4BB6-BB09-95D899D2276A}
1920
EndProjectSection
2021
EndProject
22+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tracePlayer", "tracePlayer\tracePlayer.vcxproj", "{273A5112-7D55-4A16-829A-E4F73E4BACE7}"
23+
EndProject
2124
Global
2225
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2326
Debug|x64 = Debug|x64
@@ -40,12 +43,17 @@ Global
4043
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Debug|x64.Build.0 = Debug|x64
4144
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Release|x64.ActiveCfg = Release|x64
4245
{E9BCC846-C1E9-402F-AC99-0E72195202AC}.Release|x64.Build.0 = Release|x64
46+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Debug|x64.ActiveCfg = Debug|x64
47+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Debug|x64.Build.0 = Debug|x64
48+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Release|x64.ActiveCfg = Release|x64
49+
{273A5112-7D55-4A16-829A-E4F73E4BACE7}.Release|x64.Build.0 = Release|x64
4350
EndGlobalSection
4451
GlobalSection(SolutionProperties) = preSolution
4552
HideSolutionNode = FALSE
4653
EndGlobalSection
4754
GlobalSection(NestedProjects) = preSolution
4855
{369039E2-4C18-40D9-A7FE-E3D87BA23149} = {EB9EA81E-AD7B-4F2F-B8A9-AFC9282303C9}
56+
{273A5112-7D55-4A16-829A-E4F73E4BACE7} = {EB9EA81E-AD7B-4F2F-B8A9-AFC9282303C9}
4957
EndGlobalSection
5058
GlobalSection(ExtensibilityGlobals) = postSolution
5159
SolutionGuid = {CECC8215-A95C-44A3-94DC-6A6AEE5A841B}

TileUpdateManager/FileStreamer.cpp

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ Streaming::FileStreamer::~FileStreamer()
101101
// write trace file
102102
if (m_captureTrace)
103103
{
104+
UINT resourceIndex = 0;
105+
for (const auto& d : m_tracingResources)
106+
{
107+
auto& r = m_trace.GetRoot()["resources"][resourceIndex];
108+
r["rsrc"] = (UINT64)d.first;
109+
r["fmt"] = (UINT32)d.second.Format;
110+
r["dim"][0] = (UINT32)d.second.Width;
111+
r["dim"][1] = (UINT32)d.second.Height;
112+
r["dim"][2] = (UINT32)d.second.MipLevels;
113+
resourceIndex++;
114+
}
115+
104116
int index = 0;
105117
while (1)
106118
{
@@ -117,16 +129,31 @@ Streaming::FileStreamer::~FileStreamer()
117129
//-----------------------------------------------------------------------------
118130
// append an upload request to the trace file
119131
//-----------------------------------------------------------------------------
120-
void Streaming::FileStreamer::TraceRequest(const D3D12_TILED_RESOURCE_COORDINATE& in_coord,
121-
UINT64 in_offset, UINT64 in_fileHandle, UINT32 in_numBytes)
132+
void Streaming::FileStreamer::TraceRequest(
133+
ID3D12Resource* in_pDstResource, const D3D12_TILED_RESOURCE_COORDINATE& in_dstCoord,
134+
const std::wstring& in_srcFilename, UINT64 in_srcOffset, UINT32 in_srcNumBytes, UINT32 in_compressionFormat)
122135
{
123136
auto& r = m_trace.GetRoot()["submits"][m_traceSubmitIndex][m_traceRequestIndex++];
124-
r["coord"][0] = in_coord.X;
125-
r["coord"][1] = in_coord.Y;
126-
r["coord"][2] = in_coord.Subresource;
127-
r["off"] = in_offset;
128-
r["file"] = in_fileHandle;
129-
r["size"] = in_numBytes;
137+
r["rsrc"] = (UINT64)in_pDstResource;
138+
r["coord"][0] = in_dstCoord.X;
139+
r["coord"][1] = in_dstCoord.Y;
140+
r["coord"][2] = in_dstCoord.Subresource;
141+
142+
std::string filename;
143+
int buf_len = ::WideCharToMultiByte(CP_UTF8, 0, in_srcFilename.c_str(), -1, NULL, 0, NULL, NULL);
144+
filename.resize(buf_len);
145+
::WideCharToMultiByte(CP_UTF8, 0, in_srcFilename.c_str(), -1, filename.data(), buf_len, NULL, NULL);
146+
r["file"] = filename;
147+
148+
r["off"] = in_srcOffset;
149+
r["size"] = in_srcNumBytes;
150+
if (in_compressionFormat) { r["comp"] = in_compressionFormat; }
151+
152+
auto desc = m_tracingResources.find(in_pDstResource);
153+
if (m_tracingResources.end() == desc)
154+
{
155+
m_tracingResources[in_pDstResource] = in_pDstResource->GetDesc();
156+
}
130157
}
131158

132159
//-----------------------------------------------------------------------------

TileUpdateManager/FileStreamer.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "Streaming.h"
3030
#include "ConfigurationParser.h"
31+
#include <unordered_map>
3132

3233
namespace Streaming
3334
{
@@ -86,13 +87,15 @@ namespace Streaming
8687
// trace file
8788
bool m_captureTrace{ false };
8889

89-
void TraceRequest(const D3D12_TILED_RESOURCE_COORDINATE& in_coord,
90-
UINT64 in_offset, UINT64 in_fileHandle, UINT32 in_numBytes);
90+
void TraceRequest(
91+
ID3D12Resource* in_pDstResource, const D3D12_TILED_RESOURCE_COORDINATE& in_dstCoord,
92+
const std::wstring& in_srcFilename, UINT64 in_srcOffset, UINT32 in_srcNumBytes, UINT32 in_compressionFormat);
9193
void TraceSubmit();
9294
private:
9395
bool m_firstSubmit{ true };
9496
ConfigurationParser m_trace; // array of submits, each submit is an array of requests
9597
UINT m_traceSubmitIndex{ 0 };
9698
UINT m_traceRequestIndex{ 0 };
99+
std::unordered_map<ID3D12Resource*, D3D12_RESOURCE_DESC> m_tracingResources;
97100
};
98101
}

TileUpdateManager/FileStreamerDS.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
#pragma once
1+
//*********************************************************
2+
//
3+
// Copyright 2020 Intel Corporation
4+
//
5+
// Permission is hereby granted, free of charge, to any
6+
// person obtaining a copy of this software and associated
7+
// documentation files(the "Software"), to deal in the Software
8+
// without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense,
10+
// and/or sell copies of the Software, and to permit persons to
11+
// whom the Software is furnished to do so, subject to the
12+
// following conditions :
13+
// The above copyright notice and this permission notice shall
14+
// be included in all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
// NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
// DEALINGS IN THE SOFTWARE.
24+
//
25+
//*********************************************************
226

327
#include "pch.h"
428

@@ -88,7 +112,11 @@ void Streaming::FileStreamerDS::StreamTexture(Streaming::UpdateList& in_updateLi
88112

89113
if (m_captureTrace)
90114
{
91-
TraceRequest(coord, request.Source.File.Offset, (UINT64)request.Source.File.Source, (UINT32)request.Source.File.Size);
115+
std::wstring fileName = std::filesystem::path(in_updateList.m_pStreamingResource->GetFileName()).filename();
116+
TraceRequest(pAtlas, coord, fileName,
117+
request.Source.File.Offset,
118+
(UINT32)request.Source.File.Size,
119+
(UINT32)request.Options.CompressionFormat);
92120
}
93121
}
94122
}

TileUpdateManager/FileStreamerDS.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
//*********************************************************
2+
//
3+
// Copyright 2020 Intel Corporation
4+
//
5+
// Permission is hereby granted, free of charge, to any
6+
// person obtaining a copy of this software and associated
7+
// documentation files(the "Software"), to deal in the Software
8+
// without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense,
10+
// and/or sell copies of the Software, and to permit persons to
11+
// whom the Software is furnished to do so, subject to the
12+
// following conditions :
13+
// The above copyright notice and this permission notice shall
14+
// be included in all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
// NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
// DEALINGS IN THE SOFTWARE.
24+
//
25+
//*********************************************************
126
#pragma once
227
#include <dstorage.h>
328

TileUpdateManager/FileStreamerReference.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "StreamingResourceDU.h"
3333
#include "StreamingHeap.h"
3434

35+
static const D3D12_COMMAND_LIST_TYPE g_commandListType = D3D12_COMMAND_LIST_TYPE_COPY;
36+
3537
//-----------------------------------------------------------------------------
3638
// Constructor
3739
//-----------------------------------------------------------------------------
@@ -47,7 +49,7 @@ Streaming::FileStreamerReference::FileStreamerReference(ID3D12Device* in_pDevice
4749

4850
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
4951
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
50-
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_COPY;
52+
queueDesc.Type = g_commandListType;
5153
ThrowIfFailed(in_pDevice->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_copyCommandQueue)));
5254
m_copyCommandQueue->SetName(L"FileStreamerReference::m_copyCommandQueue");
5355

@@ -66,7 +68,7 @@ Streaming::FileStreamerReference::FileStreamerReference(ID3D12Device* in_pDevice
6668
copyBatchIndex++;
6769
}
6870

69-
ThrowIfFailed(in_pDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COPY, m_copyBatches[0].GetCommandAllocator(), nullptr, IID_PPV_ARGS(&m_copyCommandList)));
71+
ThrowIfFailed(in_pDevice->CreateCommandList(0, queueDesc.Type, m_copyBatches[0].GetCommandAllocator(), nullptr, IID_PPV_ARGS(&m_copyCommandList)));
7072
m_copyCommandList->SetName(L"FileStreamerReference::m_copyCommandList");
7173
m_copyCommandList->Close();
7274

@@ -98,7 +100,7 @@ Streaming::FileStreamerReference::~FileStreamerReference()
98100
//=============================================================================
99101
void Streaming::FileStreamerReference::CopyBatch::Init(ID3D12Device* in_pDevice)
100102
{
101-
ThrowIfFailed(in_pDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_COPY, IID_PPV_ARGS(&m_commandAllocator)));
103+
ThrowIfFailed(in_pDevice->CreateCommandAllocator(g_commandListType, IID_PPV_ARGS(&m_commandAllocator)));
102104
}
103105

104106

TileUpdateManager/StreamingHeap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ UINT Streaming::Atlas::CreateAtlas(
101101
// Layout must be D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE when creating reserved resources
102102
rd.Layout = D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE;
103103

104-
// this will only every be a copy dest
104+
// this will only ever be a copy dest
105105
ThrowIfFailed(device->CreateReservedResource(&rd, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&out_pDst)));
106106
out_pDst->SetName(L"DataUploader::m_atlas");
107107

TileUpdateManager/StreamingResourceBase.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ namespace Streaming
155155
UINT GetNumTilesHeight() const { return m_tileReferencesHeight; }
156156

157157
protected:
158+
const std::wstring m_filename;
159+
158160
// object that streams data from a file
159161
std::unique_ptr<Streaming::XeTexture> m_pTextureFileInfo;
160162
std::unique_ptr<Streaming::InternalResources> m_resources;
@@ -256,9 +258,6 @@ namespace Streaming
256258
std::atomic<bool> m_setZeroRefCounts{ false };
257259

258260
private:
259-
260-
const std::wstring m_filename;
261-
262261
// do not immediately decmap:
263262
// need to withhold until in-flight command buffers have completed
264263
class EvictionDelay

0 commit comments

Comments
 (0)