3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/external/bgfx/ClearQuad.h"
7#include "mc/external/bgfx/DynamicIndexBuffer.h"
8#include "mc/external/bgfx/DynamicIndexBufferHandle.h"
9#include "mc/external/bgfx/DynamicVertexBuffer.h"
10#include "mc/external/bgfx/DynamicVertexBufferHandle.h"
11#include "mc/external/bgfx/Frame.h"
12#include "mc/external/bgfx/GuardedHandleAllocPagedT.h"
13#include "mc/external/bgfx/GuardedPagedHeapBackedArray.h"
14#include "mc/external/bgfx/IndexBuffer.h"
15#include "mc/external/bgfx/Init.h"
16#include "mc/external/bgfx/InitResult.h"
17#include "mc/external/bgfx/InitState.h"
18#include "mc/external/bgfx/NonLocalAllocator.h"
19#include "mc/external/bgfx/OcclusionQueryHandle.h"
20#include "mc/external/bgfx/ShaderHandle.h"
21#include "mc/external/bgfx/Stats.h"
22#include "mc/external/bgfx/TextVideoMemBlitter.h"
23#include "mc/external/bgfx/TextureHandle.h"
24#include "mc/external/bgfx/UpdateBatchT.h"
25#include "mc/external/bgfx/VertexBuffer.h"
26#include "mc/external/bgfx/VertexDeclRef.h"
27#include "mc/external/bgfx/View.h"
28#include "mc/external/bgfx/ViewStats.h"
29#include "mc/external/bgfx/acceleration_structure_build_flags/Enum.h"
30#include "mc/external/bgfx/backbuffer_ratio/Enum.h"
31#include "mc/external/bgfx/render_frame/Enum.h"
32#include "mc/external/bgfx/renderer_type/Enum.h"
33#include "mc/external/bgfx/texture_format/Enum.h"
34#include "mc/external/bgfx/uniform_type/Enum.h"
35#include "mc/external/bx/HandleAllocT.h"
36#include "mc/external/bx/HandleHashMapT.h"
37#include "mc/external/bx/Mutex.h"
38#include "mc/external/bx/Semaphore.h"
39#include "mc/external/bx/Thread.h"
47namespace bgfx {
struct Encoder; }
52namespace bgfx {
struct Memory; }
90 ::ll::TypedStorage<8, 8, uint64> m_ptr;
91 ::ll::TypedStorage<4, 4, uint> m_offset;
92 ::ll::TypedStorage<8, 8, uint64> m_totalSize;
100 ::ll::TypedStorage<8, 8, ::bgfx::UniformHandle*> m_uniforms;
101 ::ll::TypedStorage<8, 16, ::bx::StringT> m_name;
102 ::ll::TypedStorage<4, 4, uint> m_hash;
103 ::ll::TypedStorage<2, 2, short> m_refCount;
104 ::ll::TypedStorage<2, 2, ushort> m_num;
112 ::ll::TypedStorage<2, 2, ::bgfx::ShaderHandle> m_vsh;
113 ::ll::TypedStorage<2, 2, ::bgfx::ShaderHandle> m_fsh;
114 ::ll::TypedStorage<2, 2, short> m_refCount;
122 ::ll::TypedStorage<8, 16, ::bx::StringT> m_name;
123 ::ll::TypedStorage<4, 4, ::bgfx::UniformType::Enum> m_type;
124 ::ll::TypedStorage<2, 2, ushort> m_num;
125 ::ll::TypedStorage<2, 2, short> m_refCount;
133 ::ll::TypedStorage<8, 16, ::bx::StringT> m_name;
134 ::ll::TypedStorage<8, 8, void*> m_ptr;
135 ::ll::TypedStorage<4, 4, uint> m_storageSize;
136 ::ll::TypedStorage<2, 2, short> m_refCount;
137 ::ll::TypedStorage<1, 1, uchar> m_bbRatio;
138 ::ll::TypedStorage<1, 1, uchar> m_format;
139 ::ll::TypedStorage<1, 1, uchar> m_numMips;
140 ::ll::TypedStorage<2, 2, ushort> m_numLayers;
141 ::ll::TypedStorage<1, 1, bool> m_owned;
142 ::ll::TypedStorage<1, 1, bool> m_immutable;
143 ::ll::TypedStorage<1, 1, bool> m_rt;
151 ::ll::TypedStorage<8, 16, ::bx::StringT> m_name;
152 ::ll::TypedStorage<8, 8, void*> m_ptr;
153 ::ll::TypedStorage<4, 4, uint> m_stride;
154 ::ll::TypedStorage<4, 4, uint> m_count;
155 ::ll::TypedStorage<2, 2, short> m_refCount;
166 ::ll::TypedStorage<2, 16, ::bgfx::TextureHandle[8]> m_th;
167 ::ll::TypedStorage<8, 16, void*> m_nwh;
174 ::ll::TypedStorage<8, 16, ::bgfx::Context::FrameBufferRef::un>
un;
175 ::ll::TypedStorage<1, 1, bool> m_window;
179 using UniformHashMap = ::bx::HandleHashMapT<1024, uint>;
181 using ShaderHashMap = ::bx::HandleHashMapT<8192, uint>;
183 using ProgramHashMap = ::bx::HandleHashMapT<4096, uint>;
185 using TextureUpdateBatch = ::bgfx::UpdateBatchT<256>;
190 ::ll::TypedStorage<1, 128, ::bx::Semaphore> m_renderSem;
191 ::ll::TypedStorage<1, 128, ::bx::Semaphore> m_apiSem;
192 ::ll::TypedStorage<1, 128, ::bx::Semaphore> m_encoderEndSem;
193 ::ll::TypedStorage<1, 64, ::bx::Mutex> m_encoderApiLock;
194 ::ll::TypedStorage<1, 64, ::bx::Mutex> m_resourceApiLock;
195 ::ll::TypedStorage<8, 464, ::bx::Thread> m_thread;
196 ::ll::TypedStorage<1, 64, ::bx::Mutex> m_perfStatsApiLock;
197 ::ll::TypedStorage<8, 208, ::bgfx::Stats> m_lastPerfStats;
198 ::ll::TypedStorage<2, 2, ushort> m_lastNumViewStats;
199 ::ll::TypedStorage<8, 79872, ::bgfx::ViewStats[256]> m_lastViewStats;
200 ::ll::TypedStorage<2, 2, ushort> m_lastNumEncoderStats;
201 ::ll::TypedStorage<8, 8, ::bgfx::EncoderStats*> m_lastEncoderStats;
202 ::ll::TypedStorage<2, 2, ushort> m_numEncoderStats;
203 ::ll::TypedStorage<8, 8, ::bgfx::EncoderStats*> m_encoderStats;
204 ::ll::TypedStorage<8, 8, ::bgfx::Encoder*> m_encoder0;
205 ::ll::TypedStorage<8, 8, ::bgfx::EncoderImpl*> m_encoder;
206 ::ll::TypedStorage<8, 40, ::bx::HandleAlloc*> m_encoderHandle;
207 ::ll::TypedStorage<8, 206541568, ::bgfx::Frame[2]> m_frame;
208 ::ll::TypedStorage<8, 8, ::bgfx::Frame*> m_render;
209 ::ll::TypedStorage<8, 8, ::bgfx::Frame*> m_submit;
210 ::ll::TypedStorage<8, 524280, uint64[65535]> m_tempKeys;
211 ::ll::TypedStorage<2, 131070, ushort[65535]> m_tempValues;
212 ::ll::TypedStorage<4, 16384, ::bgfx::IndexBuffer[4096]> m_indexBuffers;
213 ::ll::TypedStorage<4, 32768, ::bgfx::VertexBuffer[4096]> m_vertexBuffers;
214 ::ll::TypedStorage<4, 81920, ::bgfx::DynamicIndexBuffer[4096]> m_dynamicIndexBuffers;
215 ::ll::TypedStorage<4, 114688, ::bgfx::DynamicVertexBuffer[4096]> m_dynamicVertexBuffers;
216 ::ll::TypedStorage<2, 2, ushort> m_numFreeDynamicIndexBufferHandles;
217 ::ll::TypedStorage<2, 2, ushort> m_numFreeDynamicVertexBufferHandles;
218 ::ll::TypedStorage<2, 2, ushort> m_numFreeOcclusionQueryHandles;
219 ::ll::TypedStorage<2, 8192, ::bgfx::DynamicIndexBufferHandle[4096]> m_freeDynamicIndexBufferHandle;
220 ::ll::TypedStorage<2, 8192, ::bgfx::DynamicVertexBufferHandle[4096]> m_freeDynamicVertexBufferHandle;
221 ::ll::TypedStorage<2, 512, ::bgfx::OcclusionQueryHandle[256]> m_freeOcclusionQueryHandle;
222 ::ll::TypedStorage<8, 56, ::bgfx::NonLocalAllocator> m_dynIndexBufferAllocator;
223 ::ll::TypedStorage<2, 16388, ::bx::HandleAllocT<4096>> m_dynamicIndexBufferHandle;
224 ::ll::TypedStorage<8, 56, ::bgfx::NonLocalAllocator> m_dynVertexBufferAllocator;
225 ::ll::TypedStorage<2, 16388, ::bx::HandleAllocT<4096>> m_dynamicVertexBufferHandle;
226 ::ll::TypedStorage<2, 16388, ::bx::HandleAllocT<4096>> m_indexBufferHandle;
227 ::ll::TypedStorage<2, 260, ::bx::HandleAllocT<64>> m_vertexDeclHandle;
228 ::ll::TypedStorage<2, 16388, ::bx::HandleAllocT<4096>> m_vertexBufferHandle;
229 ::ll::TypedStorage<2, 16388, ::bx::HandleAllocT<4096>> m_shaderHandle;
230 ::ll::TypedStorage<2, 8196, ::bx::HandleAllocT<2048>> m_programHandle;
231 ::ll::TypedStorage<8, 16424, ::bgfx::GuardedHandleAllocPagedT<4096, 4096, ushort, ::bgfx::AllocationContext>>
233 ::ll::TypedStorage<2, 16388, ::bx::HandleAllocT<4096>> m_shaderBufferHandle;
234 ::ll::TypedStorage<2, 516, ::bx::HandleAllocT<128>> m_frameBufferHandle;
235 ::ll::TypedStorage<2, 2052, ::bx::HandleAllocT<512>> m_uniformHandle;
236 ::ll::TypedStorage<2, 1028, ::bx::HandleAllocT<256>> m_occlusionQueryHandle;
237 ::ll::TypedStorage<2, 131076, ::bx::HandleAllocT<32768>> m_accelerationStructureBufferHandle;
238 ::ll::TypedStorage<4, 6152, ::bx::HandleHashMapT<1024, uint>> m_uniformHashMap;
239 ::ll::TypedStorage<8, 12288, ::bgfx::Context::UniformRef[512]> m_uniformRef;
240 ::ll::TypedStorage<4, 49160, ::bx::HandleHashMapT<8192, uint>> m_shaderHashMap;
241 ::ll::TypedStorage<8, 131072, ::bgfx::Context::ShaderRef[4096]> m_shaderRef;
242 ::ll::TypedStorage<4, 24584, ::bx::HandleHashMapT<4096, uint>> m_programHashMap;
243 ::ll::TypedStorage<2, 12288, ::bgfx::Context::ProgramRef[2048]> m_programRef;
244 ::ll::TypedStorage<8, 163872, ::bgfx::GuardedPagedHeapBackedArray<::bgfx::Context::TextureRef, 4096>> m_textureRef;
245 ::ll::TypedStorage<8, 163840, ::bgfx::Context::ShaderBufferRef[4096]> m_shaderBufferRef;
246 ::ll::TypedStorage<8, 3072, ::bgfx::Context::FrameBufferRef[128]> m_frameBufferRef;
247 ::ll::TypedStorage<4, 17288, ::bgfx::VertexDeclRef> m_declRef;
248 ::ll::TypedStorage<2, 512, ushort[256]> m_viewRemap;
249 ::ll::TypedStorage<4, 1056, uint[256]> m_seq;
250 ::ll::TypedStorage<4, 114688, ::bgfx::View[256]> m_view;
251 ::ll::TypedStorage<4, 256, float[16][4]> m_clearColor;
252 ::ll::TypedStorage<1, 1, uchar> m_colorPaletteDirty;
253 ::ll::TypedStorage<8, 64, ::bgfx::Init> m_init;
254 ::ll::TypedStorage<8, 8, int64> m_frameTimeLast;
255 ::ll::TypedStorage<4, 4, uint> m_debug;
256 ::ll::TypedStorage<8, 8, int64> m_rtMemoryUsed;
257 ::ll::TypedStorage<8, 8, int64> m_textureMemoryUsed;
258 ::ll::TypedStorage<8, 8, int64> m_shaderBufferMemoryUsed;
259 ::ll::TypedStorage<8, 112, ::bgfx::TextVideoMemBlitter> m_textVideoMemBlitter;
260 ::ll::TypedStorage<8, 112, ::bgfx::ClearQuad> m_clearQuad;
261 ::ll::TypedStorage<8, 8, ::bgfx::RendererContextI*> m_renderCtx;
262 ::ll::TypedStorage<8, 8, ::bgfx::RendererContextI*> m_renderMain;
263 ::ll::TypedStorage<8, 8, ::bgfx::RendererContextI*> m_renderNoop;
264 ::ll::TypedStorage<4, 4, ::bgfx::InitState> m_initState;
265 ::ll::TypedStorage<1, 1, bool> m_rendererInitialized;
266 ::ll::TypedStorage<1, 1, bool> m_skipFlip;
267 ::ll::TypedStorage<1, 1, bool> m_suspended;
268 ::ll::TypedStorage<1, 1, bool> m_exit;
269 ::ll::TypedStorage<1, 1, bool> m_flipAfterRender;
270 ::ll::TypedStorage<1, 1, bool> m_singleThreaded;
271 ::ll::TypedStorage<1, 1, bool> m_initSyncOptional;
272 ::ll::TypedStorage<1, 13, bool> m_texturesGuarded;
273 ::ll::TypedStorage<4, 2112, ::bgfx::UpdateBatchT<256>> m_textureUpdateBatch;
281 MCAPI
void _initBegin();
283 MCAPI
bool _initFinalize();
285 MCAPI
void _initPending(
bool async);
287 MCAPI
void _shutdownBegin();
289 MCAPI
void _shutdownFinalize();
291 MCAPI uint64 allocDynamicIndexBuffer(uint _size, ushort _flags);
293 MCAPI ::bgfx::Context::DynamicVertexAllocation
294 allocDynamicVertexBuffer(uint _size, ushort _flags, ushort _aligment);
296 MCAPI ::bgfx::Encoder* begin();
298 MCAPI ::bgfx::InitResult continueInit(
bool async);
300 MCAPI ::bgfx::AccelerationStructureHandle createBottomLevelAccelerationStructure(
301 ::bgfx::AccelerationStructureHandle _handle,
302 ::bgfx::DynamicVertexBufferHandle _vertexBufferHandle,
303 ::bgfx::VertexDeclHandle _vertexDeclHandle,
306 ::bgfx::IndexBufferHandle _indexBufferHandle,
309 ::bgfx::AccelerationStructureBuildFlags::Enum _flags
312 MCAPI ::bgfx::AccelerationStructureHandle createBottomLevelAccelerationStructure(
313 ::bgfx::AccelerationStructureHandle _handle,
314 ::bgfx::VertexBufferHandle _vertexBufferHandle,
315 ::bgfx::VertexDeclHandle _vertexDeclHandle,
318 ::bgfx::IndexBufferHandle _indexBufferHandle,
321 ::bgfx::AccelerationStructureBuildFlags::Enum _flags
324 MCAPI ::bgfx::DynamicIndexBufferHandle createDynamicIndexBuffer(::bgfx::Memory
const* _mem, ushort _flags);
326 MCAPI ::bgfx::DynamicIndexBufferHandle createDynamicIndexBuffer(uint _num, ushort _flags);
328 MCAPI ::bgfx::DynamicVertexBufferHandle
329 createDynamicVertexBuffer(::bgfx::Memory
const* _mem, ::bgfx::VertexDecl
const& _decl, ushort _flags);
331 MCAPI ::bgfx::DynamicVertexBufferHandle
332 createDynamicVertexBuffer(uint _num, ::bgfx::VertexDecl
const& _decl, ushort _flags);
334 MCAPI ::bgfx::FrameBufferHandle
335 createFrameBuffer(uchar _num, ::bgfx::Attachment
const* _attachment,
bool _destroyTextures);
337 MCAPI ::bgfx::FrameBufferHandle
338 createFrameBuffer(
void* _nwh, ushort _width, ushort _height, ::bgfx::TextureFormat::Enum _depthFormat);
340 MCAPI ::bgfx::IndexBufferHandle createIndexBuffer(::bgfx::Memory
const* _mem, ushort _flags);
342 MCAPI ::bgfx::ProgramHandle createProgram(::bgfx::ShaderHandle _vsh,
bool _destroyShader);
344 MCAPI ::bgfx::ProgramHandle
345 createProgram(::bgfx::ShaderHandle _vsh, ::bgfx::ShaderHandle _fsh,
bool _destroyShaders);
347 MCAPI ::bgfx::ShaderHandle createShader(::bgfx::Memory
const* _mem);
349 MCAPI ::bgfx::ShaderBufferHandle createShaderBuffer(::bgfx::Memory
const* _mem, uint _stride, ushort _flags);
351 MCAPI ::bgfx::ShaderBufferHandle createShaderBuffer(uint _num, uint _stride, ushort _flags);
353 MCAPI ::bgfx::TextureHandle createTexture(
354 ::bgfx::Memory
const* _mem,
357 ::bgfx::TextureInfo* _info,
358 ::bgfx::BackbufferRatio::Enum _ratio,
362 MCAPI ::bgfx::AccelerationStructureHandle createTopLevelAccelerationStructure(
363 ::bgfx::AccelerationStructureHandle _handle,
365 ::bgfx::TopLevelInstanceDesc* instanceDescs
368 MCAPI ::bgfx::TransientIndexBuffer* createTransientIndexBuffer(uint _size);
370 MCAPI ::bgfx::TransientVertexBuffer* createTransientVertexBuffer(uint _size, ::bgfx::VertexDecl
const* _decl);
372 MCAPI ::bgfx::UniformHandle createUniform(
char const* _name, ::bgfx::UniformType::Enum _type, ushort _num);
374 MCAPI ::bgfx::VertexBufferHandle
375 createVertexBuffer(::bgfx::Memory
const* _mem, ::bgfx::VertexDecl
const& _decl, ushort _flags);
377 MCAPI ::bgfx::VertexDeclHandle createVertexDecl(::bgfx::VertexDecl
const& _decl);
379 MCAPI
void destroyAccelerationStructure(::bgfx::AccelerationStructureHandle _handle);
381 MCAPI
void destroyDynamicIndexBufferInternal(::bgfx::DynamicIndexBufferHandle _handle);
383 MCAPI
void destroyDynamicVertexBufferInternal(::bgfx::DynamicVertexBufferHandle _handle);
385 MCAPI
void destroyFrameBuffer(::bgfx::FrameBufferHandle _handle);
387 MCAPI
void destroyIndexBuffer(::bgfx::IndexBufferHandle _handle);
389 MCAPI
void destroyProgram(::bgfx::ProgramHandle _handle);
391 MCAPI
void destroyUniform(::bgfx::UniformHandle _handle);
393 MCAPI
void destroyVertexBuffer(::bgfx::VertexBufferHandle _handle);
395 MCAPI
void destroyVertexBufferInternal(::bgfx::VertexBufferHandle _handle);
397 MCAPI ::bgfx::VertexDeclHandle findVertexDecl(::bgfx::VertexDecl
const& _decl);
399 MCAPI
void flushTextureUpdateBatch(::bgfx::CommandBuffer& _cmdbuf);
401 MCAPI uint frame(uint _flags);
403 MCAPI
void freeAllHandles(::bgfx::Frame* _frame);
405 MCAPI ::bgfx::Stats
const getPerfStats();
407 MCAPI ushort getPerfViewStats(ushort _numViewStats, ::bgfx::ViewStats* _viewStats);
409 MCAPI
void getUniformInfo(::bgfx::UniformHandle _handle, ::bgfx::UniformInfo& _info);
411 MCAPI uint readTexture(::bgfx::TextureHandle _handle,
void* _data, uchar _mip);
413 MCAPI ::bgfx::RenderFrame::Enum renderFrame(
int _msecs);
415 MCAPI
void rendererExecCommands(::bgfx::CommandBuffer& _cmdbuf);
417 MCAPI
void reset(uint _width, uint _height, uint _flags);
420 resizeTexture(::bgfx::TextureHandle _handle, ushort _width, ushort _height, uchar _numMips, ushort _numLayers);
422 MCAPI
void setName(::bgfx::TextureHandle _handle, ::bx::StringView
const& _name);
424 MCAPI
void setName(::bgfx::ShaderHandle _handle, ::bx::StringView
const& _name);
426 MCAPI
void setName(::bgfx::ShaderBufferHandle _handle, ::bx::StringView
const& _name);
428 MCAPI
void setViewName(ushort _id,
char const* _name);
430 MCAPI
void shaderBufferDecRef(::bgfx::ShaderBufferHandle _handle);
432 MCAPI
void shaderDecRef(::bgfx::ShaderHandle _handle);
436 MCAPI
void textureDecRef(::bgfx::TextureHandle _handle);
438 MCAPI
void update(::bgfx::ShaderBufferHandle _handle, uint _offset, ::bgfx::Memory
const* _mem);
440 MCAPI
void update(::bgfx::DynamicIndexBufferHandle _handle, uint _startIndex, ::bgfx::Memory
const* _mem);
442 MCAPI
void update(::bgfx::DynamicVertexBufferHandle _handle, uint _startVertex, ::bgfx::Memory
const* _mem);
445 updateOffset(::bgfx::DynamicIndexBufferHandle _handle, uint _offset, uint _declStride, ::bgfx::Memory
const* _mem);
448 updateOffset(::bgfx::DynamicVertexBufferHandle _handle, uint _offset, uint _declStride, ::bgfx::Memory
const* _mem);
450 MCAPI
void updatePerfStats();
452 MCAPI
void updateTexture(
453 ::bgfx::TextureHandle _handle,
463 ::bgfx::Memory
const* _mem
466 MCAPI ::bgfx::TextureHandle wrapExternalTexture(::bgfx::RendererType::Enum _type,
void* _texturePtr);
474 MCAPI
static int renderThread(::bx::Thread*,
void*);
Definition CommandBuffer.h:7
Definition HandleAlloc.h:7
Definition StringView.h:7
Definition AccelerationStructureHandle.h:7
Definition AllocationContext.h:7
Definition Attachment.h:7
Definition EncoderImpl.h:7
Definition EncoderStats.h:7
Definition FrameBufferHandle.h:7
Definition IndexBufferHandle.h:7
Definition ProgramHandle.h:7
Definition RendererContextI.h:7
Definition ShaderBufferHandle.h:7
Definition TextureInfo.h:7
Definition TopLevelInstanceDesc.h:7
Definition TransientIndexBuffer.h:7
Definition TransientVertexBuffer.h:7
Definition VertexBufferHandle.h:7
Definition VertexDeclHandle.h:7
Definition VertexDecl.h:7