-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBearRenderInterface.cpp
More file actions
240 lines (201 loc) · 8.93 KB
/
BearRenderInterface.cpp
File metadata and controls
240 lines (201 loc) · 8.93 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#include "BearGraphics.hpp"
#include "BearRHI/BearRHIFactory.h"
#include "BearRHI/BearRHIStats.h"
BEARGRAPHICS_API BearRHI::BearRHIFactory* GFactory=0;
BEARGRAPHICS_API BearRHI::BearRHIStats* GStats = 0;
static BearStringConteniar LName;
bool BearRenderInterface::Initialize(BearStringConteniar name)
{
Destroy();
if (!BearManagerDynamicLibraries::CheckProject(name))
{
return false;
}
LName = name;
auto RHIInitialize = BearManagerDynamicLibraries::GetFunctionInProject<void(*)()>(name, TEXT("RHIInitialize"));
RHIInitialize();
if (!GFactory)
{
Destroy();
return false;
}
BEAR_CHECK(GStats);
BEAR_PRINTF(TEXT("BearGraphics build %s"), *BearLog::GetBuild(2016, 11, 27));
return true;
}
BearFactoryPointer<BearRHI::BearRHIViewport> BearRenderInterface::CreateViewport(void* handle, bsize width, bsize height, bool fullscreen, const BearViewportDescription& description, bool vsync)
{
if (GFactory)return GFactory->CreateViewport(handle, width, height, fullscreen,vsync,description);
return BearFactoryPointer<BearRHI::BearRHIViewport>();
}
BearFactoryPointer<BearRHI::BearRHIContext> BearRenderInterface::CreateContext()
{
if (GFactory)return GFactory->CreateContext();
return BearFactoryPointer<BearRHI::BearRHIContext>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateVertexShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Vertex);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreatePixelShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Pixel);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateComputeShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Compute);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateMeshShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Mesh);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateAmplificationShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Amplification);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateRayTracingShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::RayTracing);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateHullShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Hull);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateDomainShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Domain);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIShader> BearRenderInterface::CreateGeometryShader()
{
if (GFactory)return GFactory->CreateShader(BearShaderType::Geometry);
return BearFactoryPointer<BearRHI::BearRHIShader>();
}
BearFactoryPointer<BearRHI::BearRHIVertexBuffer> BearRenderInterface::CreateVertexBuffer()
{
if (GFactory)return GFactory->CreateVertexBuffer();
return BearFactoryPointer<BearRHI::BearRHIVertexBuffer>();
}
BearFactoryPointer<BearRHI::BearRHIIndexBuffer> BearRenderInterface::CreateIndexBuffer()
{
if (GFactory)return GFactory->CreateIndexBuffer();
return BearFactoryPointer<BearRHI::BearRHIIndexBuffer>();
}
BearFactoryPointer<BearRHI::BearRHIPipelineGraphics> BearRenderInterface::CreatePipelineGraphics(const BearPipelineGraphicsDescription& description)
{
if (GFactory)return GFactory->CreatePipelineGraphics(description);
return BearFactoryPointer<BearRHI::BearRHIPipelineGraphics>();
}
BearFactoryPointer<BearRHI::BearRHIPipelineMesh> BearRenderInterface::CreatePipelineMesh(const BearPipelineMeshDescription& description)
{
if (GFactory)return GFactory->CreatePipelineMesh(description);
return BearFactoryPointer<BearRHI::BearRHIPipelineMesh>();
}
BearFactoryPointer<BearRHI::BearRHIPipelineRayTracing> BearRenderInterface::CreatePipelineRayTracing(const BearPipelineRayTracingDescription& description)
{
if (GFactory)return GFactory->CreatePipelineRayTracing(description);
return BearFactoryPointer<BearRHI::BearRHIPipelineRayTracing>();
}
BearFactoryPointer<BearRHI::BearRHIRayTracingBottomLevel> BearRenderInterface::CreateRayTracingBottomLevel(const BearRayTracingBottomLevelDescription& description)
{
if (GFactory)return GFactory->CreateRayTracingBottomLevel(description);
return BearFactoryPointer<BearRHI::BearRHIRayTracingBottomLevel>();
}
BearFactoryPointer<BearRHI::BearRHIRayTracingTopLevel> BearRenderInterface::CreateRayTracingTopLevel(const BearRayTracingTopLevelDescription& description)
{
if (GFactory)return GFactory->CreateRayTracingTopLevel(description);
return BearFactoryPointer<BearRHI::BearRHIRayTracingTopLevel>();
}
BearFactoryPointer<BearRHI::BearRHIRayTracingShaderTable> BearRenderInterface::CreateRayTracingShaderTable(const BearRayTracingShaderTableDescription& description)
{
if (GFactory)return GFactory->CreateRayTracingShaderTable(description);
return BearFactoryPointer<BearRHI::BearRHIRayTracingShaderTable>();
}
BearFactoryPointer<BearRHI::BearRHIRootSignature> BearRenderInterface::CreateRootSignature(const BearRootSignatureDescription& description)
{
if (GFactory)return GFactory->CreateRootSignature(description);
return BearFactoryPointer<BearRHI::BearRHIRootSignature>();
}
BearFactoryPointer<BearRHI::BearRHIDescriptorHeap> BearRenderInterface::CreateDescriptorHeap(const BearDescriptorHeapDescription& description)
{
if (GFactory)return GFactory->CreateDescriptorHeap(description);
return BearFactoryPointer<BearRHI::BearRHIDescriptorHeap>();
}
BearFactoryPointer<BearRHI::BearRHIUniformBuffer> BearRenderInterface::CreateUniformBuffer(bsize stride, bsize count, bool dynamic)
{
if (GFactory)return GFactory->CreateUniformBuffer(stride,count,dynamic);
return BearFactoryPointer<BearRHI::BearRHIUniformBuffer>();
}
BearFactoryPointer<BearRHI::BearRHITexture2D> BearRenderInterface::CreateTexture2D(bsize width, bsize height, bsize mips, bsize count, BearTexturePixelFormat PixelFormat, BearTextureUsage type_usage , const void* data)
{
if (GFactory)return GFactory->CreateTexture2D(width, height, mips, count, PixelFormat, type_usage,const_cast<void*>( data));
return BearFactoryPointer<BearRHI::BearRHITexture2D>();
}
BearFactoryPointer<BearRHI::BearRHITextureCube> BearRenderInterface::CreateTextureCube(bsize width, bsize height, bsize mips, bsize count, BearTexturePixelFormat PixelFormat, BearTextureUsage type_usage, const void* data)
{
if (GFactory)return GFactory->CreateTextureCube(width, height, mips, count, PixelFormat, type_usage, const_cast<void*>(data));
return BearFactoryPointer<BearRHI::BearRHITextureCube>();
}
BearFactoryPointer<BearRHI::BearRHIStructuredBuffer> BearRenderInterface::CreateStructuredBuffer(bsize size, const void* data, bool uav)
{
if (GFactory)return GFactory->CreateStructuredBuffer(size, const_cast<void*>(data), uav);
return BearFactoryPointer<BearRHI::BearRHIStructuredBuffer>();
}
BearFactoryPointer<BearRHI::BearRHISampler> BearRenderInterface::CreateSampler(const BearSamplerDescription& description)
{
if (GFactory)return GFactory->CreateSampler(description);
return BearFactoryPointer<BearRHI::BearRHISampler>();
}
BearFactoryPointer<BearRHI::BearRHITexture2D> BearRenderInterface::CreateTexture2D(bsize width, bsize height, BearRenderTargetFormat rtf)
{
if (GFactory)return GFactory->CreateTexture2D(width, height, rtf);
return BearFactoryPointer<BearRHI::BearRHITexture2D>();
}
BearFactoryPointer<BearRHI::BearRHITexture2D> BearRenderInterface::CreateTexture2D(bsize width, bsize height, BearDepthStencilFormat dsf)
{
if (GFactory)return GFactory->CreateTexture2D(width, height, dsf);
return BearFactoryPointer<BearRHI::BearRHITexture2D>();
}
BearFactoryPointer<BearRHI::BearRHIRenderPass> BearRenderInterface::CreateRenderPass(const BearRenderPassDescription& description)
{
if (GFactory)return GFactory->CreateRenderPass(description);
return BearFactoryPointer<BearRHI::BearRHIRenderPass>();
}
BearFactoryPointer<BearRHI::BearRHIFrameBuffer> BearRenderInterface::CreateFrameBuffer(const BearFrameBufferDescription& description)
{
if (GFactory)return GFactory->CreateFrameBuffer(description);
return BearFactoryPointer<BearRHI::BearRHIFrameBuffer>();
}
bool BearRenderInterface::RTXSupport()
{
if (GFactory)return GFactory->SupportRayTracing();
return false;
}
bool BearRenderInterface::MeshShaderSupport()
{
if (GFactory)return GFactory->SupportMeshShader();
return false;
}
void BearRenderInterface::Destroy()
{
BearRenderStats::Cheak();
if (GFactory)bear_delete(GFactory);
if (GStats) bear_delete(GStats);
GStats = nullptr;
GFactory = nullptr;
if ((*LName)[0])
{
BearManagerDynamicLibraries::UnLoad(LName);
}
}
bool BearRenderInterface::Empty()
{
return GFactory==nullptr;
}