This repository has been archived by the owner on Dec 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
FileStreamer.h
101 lines (83 loc) · 3.57 KB
/
FileStreamer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//*********************************************************
//
// Copyright 2020 Intel Corporation
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files(the "Software"), to deal in the Software
// without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to
// whom the Software is furnished to do so, subject to the
// following conditions :
// The above copyright notice and this permission notice shall
// be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//*********************************************************
#pragma once
#include "Streaming.h"
#include "ConfigurationParser.h"
#include <unordered_map>
namespace Streaming
{
struct UpdateList;
// file handle internals different between reference and DS FileStreamers
class FileHandle
{
public:
virtual ~FileHandle() {}
};
class FileStreamer
{
public:
FileStreamer(ID3D12Device* in_pDevice);
virtual ~FileStreamer();
virtual FileHandle* OpenFile(const std::wstring& in_path) = 0;
virtual void StreamTexture(Streaming::UpdateList& in_updateList) = 0;
virtual void Signal() = 0;
enum class VisualizationMode
{
DATA_VIZ_NONE,
DATA_VIZ_MIP,
DATA_VIZ_TILE
};
void SetVisualizationMode(UINT in_mode) { m_visualizationMode = (VisualizationMode)in_mode; }
bool GetCompleted(const UpdateList& in_updateList) const;
void CaptureTraceFile(bool in_captureTrace) { m_captureTrace = in_captureTrace; } // enable/disable writing requests/submits to a trace file
protected:
// copy queue fence
ComPtr<ID3D12Fence> m_copyFence;
UINT64 m_copyFenceValue{ 0 };
// Visualization
VisualizationMode m_visualizationMode{ VisualizationMode::DATA_VIZ_NONE };
// get visualization colors
void* GetVisualizationData(const D3D12_TILED_RESOURCE_COORDINATE& in_coord, DXGI_FORMAT in_format);
static const UINT m_lutSize{ 16 };
static float m_lut[m_lutSize][3];
static BYTE m_BC7[m_lutSize][D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES];
void InitializeBC7();
static BYTE m_BC1[m_lutSize][D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES];
void InitializeBC1();
// trace file
bool m_captureTrace{ false };
void TraceRequest(
ID3D12Resource* in_pDstResource, const D3D12_TILED_RESOURCE_COORDINATE& in_dstCoord,
const std::wstring& in_srcFilename, UINT64 in_srcOffset, UINT32 in_srcNumBytes, UINT32 in_compressionFormat);
void TraceSubmit();
private:
bool m_firstSubmit{ true };
ConfigurationParser m_trace; // array of submits, each submit is an array of requests
UINT m_traceSubmitIndex{ 0 };
UINT m_traceRequestIndex{ 0 };
std::unordered_map<ID3D12Resource*, D3D12_RESOURCE_DESC> m_tracingResources;
};
}