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

Commit 41ddf26

Browse files
Updated readme. Many tweaks and improvements.
1 parent 5b31d04 commit 41ddf26

File tree

16 files changed

+262
-259
lines changed

16 files changed

+262
-259
lines changed

README.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,70 @@
22

33
## Introduction
44

5-
This repository contains an [MIT licensed](LICENSE) demo of _DirectX12 Sampler Feedback Streaming_, a technique using [DirectX12 Sampler Feedback](https://microsoft.github.io/DirectX-Specs/d3d/SamplerFeedback.html) to guide continuous loading and eviction of small portions (tiles) of assets allowing for much higher visual quality than previously possible by making better use of GPU memory capacity. Sampler Feedback Streaming allows scenes consisting of 100s of gigabytes of resources to be drawn on GPUs containing much less physical memory. The scene below uses just ~200MB of a 1GB heap, despite over 350GB of total texture resources. (Objects could have shared streaming resources, but the intent of the demo is to show the potential of using many unique textures).
5+
This repository contains an [MIT licensed](LICENSE) demo of _DirectX12 Sampler Feedback Streaming_, a technique using [DirectX12 Sampler Feedback](https://microsoft.github.io/DirectX-Specs/d3d/SamplerFeedback.html) to guide continuous loading and eviction of small regions (tiles) of textures - in other words, virtual texture streaming. Sampler Feedback Streaming can dramatically improve visual quality by enabling scenes consisting of 100s of gigabytes of resources to be drawn on GPUs containing much less physical memory. The scene below uses just ~200MB of a 1GB heap, despite over 350GB of total texture resources.
66

7-
The demo requires ***Windows 10 20H1 (aka May 2020 Update, build 19041)*** or later and a GPU with Sampler Feedback Support, such as Intel Iris Xe Graphics as found in 11th Generation Intel® Core™ processors and discrete GPUs (driver version **[30.0.100.9667](https://downloadcenter.intel.com/product/80939/Graphics) or later**).
8-
9-
This repository has been updated with DirectStorage 1.0.2 for Windows® from https://www.nuget.org/packages/Microsoft.Direct3D.DirectStorage/
7+
![Sample screenshot](./readme-images/sampler-feedback-streaming.jpg "Sample screenshot")
8+
Textures derived from [Hubble Images](https://www.nasa.gov/mission_pages/hubble/multimedia/index.html), see the [Hubble Copyright](https://hubblesite.org/copyright)
109

1110
Notes:
12-
- The file format has changed since large textures were provided as "releases." See the [log](#log) below.
13-
- The legacy streaming code using ReadFile() had sector alignment constraints for the file internals that are not required by DirectStorage for Windows.
11+
- while multiple objects can share the same DX texture and source file, this sample aims to demonstrate the possibility of every object having a unique resource. Hence, every texture is treated as though unique, though the same source file may be used multiple times.
12+
- not all textures shown above, which total over 13GB, are not part of the repo. A few 16k x 16k textures are available as [release 1](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/1) and [release 2](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/2)
13+
- the file format has changed since large textures were provided as "releases." See the [log](#log) below.
14+
- this repository has been updated with DirectStorage 1.0.2 for Windows® from https://www.nuget.org/packages/Microsoft.Direct3D.DirectStorage/
15+
- at build time, BCx textures (BC7 and BC1 tested) in the dds/ directory are converted into the custom .XET format and placed in the ($TargetDir)/media directory (e.g. x64/Release/media). A few dds files are included.
16+
17+
Requirements:
18+
- minimum:
19+
- Windows 10 20H1 (aka May 2020 Update, build 19041)
20+
- GPU with D3D12 Sampler Feedback Support such as Intel Iris Xe Graphics as found in 11th Generation Intel® Core™ processors and discrete GPUs (driver version **[30.0.100.9667](https://downloadcenter.intel.com/product/80939/Graphics) or later**)
21+
- recommended:
22+
- Windows 11
23+
- nvme SSD with PCIe gen4 or later
24+
- Intel Arc A770 discrete GPU or later
1425

1526
See also:
1627

1728
* [GDC 2021 video](https://software.intel.com/content/www/us/en/develop/events/gdc.html?videoid=6264595860001) [(alternate link)](https://www.youtube.com/watch?v=VDDbrfZucpQ) which provides an overview of Sampler Feedback and discusses this sample starting at about 15:30.
1829

1930
* [GDC 2021 presentation](https://software.intel.com/content/dam/develop/external/us/en/documents/pdf/july-gdc-2021-sampler-feedback-texture-space-shading-direct-storage.pdf) in PDF form
2031

21-
![Sample screenshot](./readme-images/sampler-feedback-streaming.jpg "Sample screenshot")
22-
Textures derived from [Hubble Images](https://www.nasa.gov/mission_pages/hubble/multimedia/index.html), see the [Hubble Copyright](https://hubblesite.org/copyright)
23-
24-
25-
Note the textures shown above, which total over 13GB, are not part of the repo. A few 16k x 16k textures are available as [release 1](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/1) and [release 2](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/2)
26-
27-
Test textures are provided. At build time, BCx textures (BC7 and BC1 tested) in the dds/ directory are converted into the custom .XET format and placed in the ($TargetDir)/media directory (e.g. x64/Release/media)
28-
2932
## Build Instructions
3033

31-
Download the source. Build the solution file [SamplerFeedbackStreaming.sln](SamplerFeedbackStreaming.sln) (tested with Visual Studio 2019).
34+
Download the source. Build the appropriate solution file
35+
- Visual Studio 2022: [SamplerFeedbackStreaming_vs2022.sln](SamplerFeedbackStreaming_vs2022.sln)
36+
- Visual Studio 2019: [SamplerFeedbackStreaming.sln](SamplerFeedbackStreaming.sln).
3237

3338
All executables, scripts, configurations, and media files will be found in the x64/Release or x64/Debug directories. You can run from within the Visual Studio IDE or from the command line, e.g.:
3439

3540
c:\SamplerFeedbackStreaming\x64\Release> expanse.exe
3641

37-
By default (no command line options) there will be a single object, "terrain", which allows for exploring sampler feedback streaming. In the top right find 2 windows: on the left is the raw GPU min mip feedback, on the right is the min mip map "residency map" generated by the application. Across the bottom are the mips of the texture, with mip 0 in the bottom left. Left-click drag the terrain to see sampler feedback streaming in action.
42+
By default (no command line options) there will be a single object, "terrain", which allows for exploring sampler feedback streaming. To explore sampler feedback streaming, expand "Terrain Object Feedback Viewer." In the top right find 2 windows: the raw GPU sampler feedback (min mip map of desired tiles) and to its right the "residency map" generated by the application (min mip map of tiles that have been loaded). Across the bottom are the mips of the texture, with mip 0 in the bottom left. Left-click drag the terrain to see sampler feedback streaming in action. Note that navigation in this mode has the up direction locked, which can be disabled in the UI.
3843
![default startup](./readme-images/default-startup.jpg "default startup")
3944

40-
Press the DEMO MODE button or run the batch file _demo.bat_ to see streaming in action. Press "page up" or to click _Color MinMip_ to toggle a visualization of the tiles loading, best viewed in _Roller Coaster_ mode. Note keyboard controls are inactive while the _Camera_ slider is non-zero.
45+
Press the DEMO MODE button or run the batch file _demo.bat_ to see streaming in action. Press "page up" or to click _Tile Min Mip Overlay_ to toggle a visualization of the tiles loading. Toggle _Roller Coaster_ mode (page up) to fly through the scene. Note keyboard controls are inactive while the _Camera_ slider is non-zero.
4146

4247
c:\SamplerFeedbackStreaming\x64\Release> demo.bat
4348

4449
![demo batch file](./readme-images/demo-bat.jpg "demo.bat")
4550

46-
The high-resolution textures in the first "release" package, [hubble-16k.zip](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/1), work with "demo-hubble.bat", including a sky and earth. Make sure the mediadir in the batch file is set properly, or override it on the command line as follows:
51+
Benchmark mode generates massive disk traffic by cranking up the animation rate, dialing up the sampler bias, and rapidly switching between two camera paths to force eviction of all the current texture tiles. This mode is designed to stress the whole platform, from storage to PCIe interface to CPU and GPU.
52+
53+
Two sets of high resolution textures are available for use with "demo-hubble.bat": [hubble-16k.zip](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/1) and [hubble-16k-bc1.zip](https://github.com/GameTechDev/SamplerFeedbackStreaming/releases/tag/2)). BUT they are in an older file format. Simply drop them into the "dds" directory and rebuild DdsToXet, or convert them to the new file format with `convert.bat` (see below). Make sure the mediadir in the batch file is set properly, or override it on the command line as follows:
4754

4855
c:\SamplerFeedbackStreaming\x64\Release> demo-hubble.bat -mediadir c:\hubble-16k
4956

5057
## Keyboard controls
5158

5259
* `qwe / asd` : strafe left, forward, strafe right / rotate left, back, rotate right
5360
* `z c` : levitate up and down
54-
* `x` : toggles "up lock". When hovering over the "terrain" object, locking the up direction "feels right" with mouse navigation. Otherwise, it should be turned off.
5561
* `v b` : rotate around the look direction (z axis)
5662
* `arrow keys` : rotate left/right, pitch down/up
5763
* `shift` : move faster
5864
* `mouse left-click drag` : rotate view
59-
* `page up` : toggle the min mip map viewer for the "terrain" geometry in the center of the universe
65+
* `page up` : toggle the min mip map overlay onto every object (visualize tiles loading)
6066
* `page down` : while camera animation is non-zero, toggles fly-through "rollercoaster" vs. fly-around "orbit"
6167
* `space` : toggles camera animation on/off.
6268
* `home` : toggles UI. Hold "shift" while UI is enabled to toggle mini UI mode.
63-
* `end` : toggle overlay of min mip map onto every object
6469
* `insert` : toggles frustum visualization
6570
* `esc` : while windowed, exit. while full-screen, return to windowed mode
6671

@@ -94,6 +99,11 @@ The batch file [convert.bat](scripts/convert.bat) will read all the DDS files in
9499

95100
c:> convert c:\myDdsFiles c:\myXetFiles
96101

102+
A new DirectStorage trace capture and playback utility has been added so DirectStorage performance can be analyzed without the overhead of rendering. For example, to capture and play back the DirectStorage requests and submits for 500 "stressful" frames with a staging buffer size of 128MB, cd to the build directory and:
103+
```
104+
stress.bat -timingstart 200 -timingstop 700 -capturetrace
105+
traceplayer.exe -file uploadTraceFile_1.json -mediadir media -staging 128
106+
```
97107
## TileUpdateManager: a library for streaming textures
98108

99109
The sample includes a library *TileUpdateManager* with a minimal set of APIs defined in [SamplerFeedbackStreaming.h](TileUpdateManager/SamplerFeedbackStreaming.h). The central object, *TileUpdateManager*, allows for the creation of streaming textures and heaps to contain them. These objects handle all the feedback resource creation, readback, processing, and file/IO.

TileUpdateManager/FileStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace Streaming
7070
UINT64 m_copyFenceValue{ 0 };
7171

7272
// Visualization
73-
VisualizationMode m_visualizationMode;
73+
VisualizationMode m_visualizationMode{ VisualizationMode::DATA_VIZ_NONE };
7474

7575
// get visualization colors
7676
void* GetVisualizationData(const D3D12_TILED_RESOURCE_COORDINATE& in_coord, DXGI_FORMAT in_format);

TileUpdateManager/StreamingHeap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Streaming::Heap::Heap(ID3D12CommandQueue* in_pQueue, UINT in_maxNumTilesHeap) :
172172

173173
// create a heap to store streaming tiles
174174
// should be smaller than the entire surface
175-
const UINT heapSize = in_maxNumTilesHeap * D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
175+
const UINT64 heapSize = UINT64(in_maxNumTilesHeap) * D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
176176
CD3DX12_HEAP_DESC heapDesc(heapSize, D3D12_HEAP_TYPE_DEFAULT, 0, D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES);
177177
ThrowIfFailed(device->CreateHeap(&heapDesc, IID_PPV_ARGS(&m_tileHeap)));
178178
}

config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"rollerCoaster": false, // fly through, vs. orbiting, planets
2424

2525
"mediaDir": "media", // media directory
26-
"texture": "", // setting this overrides all textures, invalidates mediadir
2726
"skyTexture": "", // add a sky sphere. path relative to mediadir
2827
"earthTexture": "earth", // when a texture containing this string is encountered, treat it as a mercator projection (no uv mirror)
2928
"terrainTexture": "4kTiles.xet", // use this texture only for the terrain, no planets
29+
3030
"maxNumObjects": 985, // maximum total number of objects in the scene
3131
"numSpheres": 0, // number of objects besides the terrain
3232
"lightFromView": false, // light direction is look direction

include/DebugHelper.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,6 @@
2323
// DEALINGS IN THE SOFTWARE.
2424
//
2525
//*********************************************************
26-
27-
/*-----------------------------------------------------------------------------
28-
ArgParser
29-
30-
Parse arguments to a Windows application
31-
On finding a match, calls custom code
32-
Case is ignored while parsing
33-
34-
example:
35-
This creates the parser, then searches for a few values.
36-
The value is expected to follow the token.
37-
38-
runprogram.exe gRaVity 20.27 upIsDown dothing
39-
40-
float m_float = 0;
41-
bool m_flipGravity = false;
42-
43-
ArgParser argParser;
44-
argParser.AddArg(L"gravity", m_float);
45-
argParser.AddArg(L"upisdown", m_flipGravity); // inverts m_flipGravity
46-
argParser.AddArg(L"downisup", L"whoops!", m_flipGravity); // inverts current value, includes help message
47-
argParser.AddArg(L"dothing", [=](std::wstring) { DoTheThing(); } ); // call custom function to handle param
48-
argParser.AddArg(L"option", L"a function", [=](std::wstring) { DoOption(); } ); // custom function with help message
49-
argParser.Parse();
50-
51-
after running, m_float=20.27 and m_flipGravity=true
52-
53-
-----------------------------------------------------------------------------*/
5426
#pragma once
5527

5628
//==================================================

readme-images/default-startup.jpg

5.62 KB
Loading

readme-images/demo-bat.jpg

-1.83 MB
Loading

src/CommandLineArgs.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,28 @@
3333

3434
struct CommandLineArgs
3535
{
36-
UINT m_windowWidth{ 1280 };
37-
UINT m_windowHeight{ 800 };
38-
UINT m_sampleCount{ 4 };
39-
float m_lodBias{ 0 };
36+
enum class PreferredArchitecture
37+
{
38+
NONE = 0,
39+
DISCRETE,
40+
INTEGRATED
41+
};
42+
PreferredArchitecture m_preferredArchitecture{ PreferredArchitecture::NONE };
43+
std::wstring m_adapterDescription; // e.g. "intel", will pick the GPU with this substring in the adapter description (not case sensitive)
4044

41-
std::wstring m_textureFilename;
42-
std::wstring m_mediaDir;
43-
bool m_vsyncEnabled{ false };
45+
bool m_useDirectStorage{ true };
46+
UINT m_stagingSizeMB{ 128 }; // size of the staging buffer for DirectStorage or reference streaming code
4447

4548
std::wstring m_terrainTexture;
4649
std::wstring m_skyTexture;
4750
std::wstring m_earthTexture;
48-
std::vector<std::wstring> m_textures; // textures for things other than the terrain
51+
std::wstring m_mediaDir;
52+
53+
bool m_vsyncEnabled{ false };
54+
UINT m_windowWidth{ 1280 };
55+
UINT m_windowHeight{ 800 };
56+
UINT m_sampleCount{ 4 };
57+
float m_lodBias{ 0 };
4958

5059
bool m_startFullScreen{ false };
5160
bool m_cameraRollerCoaster{ false };
@@ -77,16 +86,13 @@ struct CommandLineArgs
7786
UINT m_timingStopFrame{ 0 };
7887
std::wstring m_timingFrameFileName; // where to write per-frame statistics
7988
std::wstring m_exitImageFileName; // write an image on exit
80-
8189
bool m_waitForAssetLoad{ false }; // wait for assets to load before progressing frame #
82-
std::wstring m_adapterDescription; // e.g. "intel", will pick the GPU with this substring in the adapter description (not case sensitive)
83-
84-
bool m_useDirectStorage{ false };
85-
UINT m_stagingSizeMB{ 64 }; // size of the staging buffer for DirectStorage or reference streaming code
8690

8791
//-------------------------------------------------------
8892
// state that is not settable from command line:
8993
//-------------------------------------------------------
94+
std::vector<std::wstring> m_textures; // textures for things other than the terrain
95+
9096
UINT m_maxTileUpdatesPerApiCall{ 512 }; // max #tiles (regions) in call to UpdateTileMappings()
9197
bool m_enableTileUpdates{ true }; // toggle enabling tile uploads/evictions
9298
int m_visualizationBaseMip{ 0 };

0 commit comments

Comments
 (0)