This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
FGApp.h
155 lines (120 loc) · 3.65 KB
/
FGApp.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE'
#pragma once
#include "framework/Window/IWindow.h"
#include "framework/Vulkan/VulkanDevice.h"
#include "framegraph/FG.h"
#include "stl/Algorithms/StringUtils.h"
namespace FG
{
//
// Frame Graph Test Application
//
class FGApp final : public IWindowEventListener
{
// types
private:
using TestFunc_t = bool (FGApp::*) ();
using TestQueue_t = Deque<Pair< TestFunc_t, uint >>;
using VPipelineCompilerPtr = SharedPtr< class VPipelineCompiler >;
using DeviceProperties = IFrameGraph::DeviceProperties;
// variables
private:
#ifdef FG_ENABLE_VULKAN
VulkanDeviceInitializer _vulkan;
#endif
WindowPtr _window;
FrameGraph _frameGraph;
VPipelineCompilerPtr _pplnCompiler;
SwapchainID _swapchainId;
TestQueue_t _tests;
uint _testInvocations = 0;
uint _testsPassed = 0;
uint _testsFailed = 0;
bool _hasShaderDebugger;
DeviceProperties _properties;
// methods
public:
FGApp ();
~FGApp ();
static void Run (void* nativeHandle);
// IWindowEventListener
private:
void OnResize (const uint2 &size) override;
void OnRefresh () override {}
void OnDestroy () override {}
void OnUpdate () override {}
void OnKey (StringView, EKeyAction) override {}
void OnMouseMove (const float2 &) override {}
// helpers
private:
bool _Initialize (WindowPtr &&wnd);
bool _InitializeForVulkan (WindowPtr &&wnd);
bool _Update ();
void _Destroy ();
bool Visualize (StringView name) const;
bool CompareDumps (StringView filename) const;
bool SavePNG (const String &filename, const ImageView &imageData) const;
template <typename Arg0, typename ...Args>
void DeleteResources (Arg0 &arg0, Args& ...args);
ND_ Array<uint8_t> CreateData (BytesU size) const;
ND_ static String GetFuncName (StringView src);
// implementation tests
private:
bool ImplTest_Scene1 ();
bool ImplTest_CacheOverflow1 ();
bool ImplTest_Multithreading1 ();
bool ImplTest_Multithreading2 ();
bool ImplTest_Multithreading3 ();
bool ImplTest_Multithreading4 ();
// drawing tests
private:
bool Test_CopyBuffer1 ();
bool Test_CopyImage1 ();
bool Test_CopyImage2 ();
bool Test_CopyImage3 ();
bool Test_PushConst1 ();
bool Test_Compute1 (); // compute + specialization
bool Test_Compute2 ();
bool Test_DynamicOffset (); // buffer dynamic offset
bool Test_Draw1 ();
bool Test_Draw2 (); // with swapchain
bool Test_Draw3 (); // with scissor
bool Test_Draw4 ();
bool Test_Draw5 ();
bool Test_Draw6 ();
bool Test_Draw7 (); // multi render target
bool Test_RawDraw1 (); // with vulkan api calls
bool Test_ExternalCmdBuf1 (); // with vulkan api calls
bool Test_InvalidID ();
bool Test_ReadAttachment1 ();
bool Test_AsyncCompute1 ();
bool Test_AsyncCompute2 ();
bool Test_ShaderDebugger1 ();
bool Test_ShaderDebugger2 ();
bool Test_ArrayOfTextures1 ();
bool Test_ArrayOfTextures2 ();
// RTX only
bool Test_DrawMeshes1 ();
bool Test_TraceRays1 ();
bool Test_TraceRays2 ();
bool Test_TraceRays3 ();
bool Test_ShadingRate1 ();
bool Test_RayTracingDebugger1 ();
};
template <typename Arg0, typename ...Args>
inline void FGApp::DeleteResources (Arg0 &arg0, Args& ...args)
{
_frameGraph->ReleaseResource( INOUT arg0 );
if constexpr ( CountOf<Args...>() )
DeleteResources( std::forward<Args&>( args )... );
}
inline String FGApp::GetFuncName (StringView src)
{
size_t pos = src.find_last_of( "::" );
if ( pos != StringView::npos )
return String{ src.substr( pos+1 )};
else
return String{ src };
}
# define TEST_NAME GetFuncName( FG_FUNCTION_NAME )
} // FG