This repository has been archived by the owner on Dec 25, 2023. It is now read-only.
/
TextureViewer.h
73 lines (65 loc) · 2.97 KB
/
TextureViewer.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
//*********************************************************
//
// 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
// creates a windows per mip of a texture
// screen coordinate system: (0, 0) is bottom-left. like normalized device space, (1, 1) is top-right
// u,v coordinates: (0, 0) is top-left. like images, byte 0 is top left
class TextureViewer
{
public:
template<typename T> using ComPtr = Microsoft::WRL::ComPtr<T>;
TextureViewer(ID3D12Resource* in_pResource,
const DXGI_FORMAT in_swapChainFormat,
// optionally provide a descriptor heap and an offset into that heap
// if not provided, will create a descriptor heap just for that texture
ID3D12DescriptorHeap* in_pDescriptorHeap = nullptr,
INT in_descriptorOffset = 0);
virtual ~TextureViewer();
void Draw(ID3D12GraphicsCommandList* in_pCL,
DirectX::XMFLOAT2 in_position,
DirectX::XMFLOAT2 in_windowDim,
D3D12_VIEWPORT in_viewPort,
int in_visualizationBaseMip, int in_numMips, bool in_vertical);
protected:
static const unsigned int MIN_WINDOW_DIM = 8;
TextureViewer() {}
void CreateResources(
ID3D12Resource* in_pResource, D3D12_SHADER_RESOURCE_VIEW_DESC& in_desc,
const DXGI_FORMAT in_swapChainFormat,
ID3D12DescriptorHeap* in_pDescriptorHeap, INT in_descriptorOffset,
const wchar_t* in_pShaderFileName, const char* in_psEntryPoint = "ps");
void DrawWindows(ID3D12GraphicsCommandList* in_pCL, D3D12_VIEWPORT in_viewPort,
UINT in_numWindows);
ComPtr<ID3D12Device> m_device;
ComPtr<ID3D12DescriptorHeap> m_descriptorHeap;
INT m_descriptorOffset{ 0 };
std::vector<UINT32> m_constants;
private:
ComPtr<ID3D12RootSignature> m_rootSignature;
ComPtr<ID3D12PipelineState> m_pipelineState;
ID3D12Resource* m_pResource{ nullptr };
int m_numMips{ 0 };
};