102 return (threadCount + localSize - 1u) / localSize;
105 template<
typename Data,
size_t N>
111 if (
entry._frameLifeTime > 0u )
113 entry._frameLifeTime -= 1u;
122 std::condition_variable
_cv;
123 std::atomic_bool _running{
false};
124 bool _hasWork{
false};
160 vertModule.
_sourceFile =
"ImmediateModeEmulation.glsl";
164 fragModule.
_sourceFile =
"ImmediateModeEmulation.glsl";
167 shaderDescriptor.
_modules.push_back( vertModule );
168 shaderDescriptor.
_modules.push_back( fragModule );
171 immediateModeShader.waitForReady(
true );
177 immediateModeShader.waitForReady(
true );
182 shaderDescriptor.
_modules.back()._defines.emplace_back(
"WORLD_PASS" );
184 immediateModeShader.waitForReady(
true );
190 immediateModeShader.waitForReady(
true );
197 shaderDescriptor.
_modules.back()._defines.emplace_back(
"OIT_PASS" );
199 immediateModeShader.waitForReady(
true );
203 shaderDescriptor.
_modules.back()._defines.emplace_back(
"NO_TEXTURE" );
205 immediateModeShader.waitForReady(
true );
206 _imWorldOITShaderNoTexture =
CreateResource( immediateModeShader );
220#pragma region Construction, destruction, initialization
274 _api->initDescriptorSets();
281 _impl._bindingCount = { 0u };
295 for (
U8 i = 0u; i < _impl._bindingCount; ++i )
299 if ( bindingEntry.
_slot == newBindingData.
_slot )
306 if ( bindingEntry != newBindingData )
308 bindingEntry = newBindingData;
316 _impl._bindings[_impl._bindingCount++] = newBindingData;
334 assert(
_api ==
nullptr &&
"GFXDevice error: initRenderingAPI called twice!" );
341 _api = std::make_unique<GL_API>( *
this );
345 _api = std::make_unique<VK_API>( *
this );
349 _api = std::make_unique<NONE_API>( *
this );
372 hardwareState =
_api->initRenderingAPI( argc,
argv, config );
378 return hardwareState;
406 const auto printMode = [&prevMode, &refreshRates]()
413 refreshRates.c_str() );
419 if ( !registeredModes.empty() )
423 prevMode = registeredModes.front();
425 for (
const auto& it : registeredModes )
436 if ( refreshRates.empty() )
446 if ( !refreshRates.empty() )
452 _rtPool = std::make_unique<GFXRTPool>( *
this );
455 if ( numLightsPerCluster < 0 )
466 config.changed(
true );
472 config.changed(
true );
488 return hardwareState;
502 s_renderThread.
_cv.wait( lock, []() {
return s_renderThread.
_hasWork || !s_renderThread.
_running; } );
507 s_renderThread.
_work();
510 s_renderThread.
_work = {};
522 s_renderThread.
_cv.notify_one();
529 _sceneData->updateSceneDescriptorSet( bufferInOut, memCmdInOut );
536 if ( targetSizeCam == 0u )
540 if ( targetSizeCullCounter == 0u )
542 targetSizeCullCounter = 1u;
548 if ( !resizeCamBuffer && !resizeCullCounter )
557 if ( resizeCamBuffer )
576 if ( resizeCullCounter )
600 std::atomic_uint loadTasks = 0;
686 screenDesc.
_name =
"Screen";
692 screenAttachment._sampler = defaultSamplerMips;
694 screenDesc.
_name =
"Screen Prev";
702 normalAttachment._sampler = defaultSamplerMips;
704 screenDesc.
_name =
"Normals Resolved";
733 screenDesc.
_name =
"BackBuffer";
749 ssaoDesc.
_name =
"SSAO Result";
766 ssrResultDesc.
_name =
"SSR Result";
797 hizRTDesc.
_name =
"HiZ";
802 hizRTDesc.
_name =
"HiZ_Reflect";
853 refDesc.
_name =
"Reflection_blur";
896 oitDesc.
_name =
"OIT";
948 refDesc.
_name =
"Reflection_Cube_Array";
955 compModule.
_defines.emplace_back(
"imageSizeIn PushData0[0].xy");
956 compModule.
_defines.emplace_back(
"imageSizeOut PushData0[0].zw");
957 compModule.
_defines.emplace_back(
"wasEven (uint(PushData0[1].x) == 1u)");
962 shaderDescriptor.
_modules.push_back( compModule );
966 descriptor1.waitForReady(
false );
982 shaderDescriptor.
_modules.push_back( compModule );
985 descriptor2.waitForReady(
false );
998 vertModule.
_variant =
"FullScreenQuad";
1005 shaderDescriptor.
_modules.push_back( vertModule );
1006 shaderDescriptor.
_modules.push_back( fragModule );
1009 previewRTShader.waitForReady(
true );
1017 vertModule.
_sourceFile =
"baseVertexShaders.glsl";
1018 vertModule.
_variant =
"FullScreenQuad";
1023 fragModule.
_variant =
"LinearDepth.ScenePlanes";
1026 shaderDescriptor.
_modules.push_back( vertModule );
1027 shaderDescriptor.
_modules.push_back( fragModule );
1030 previewReflectionRefractionDepth.waitForReady(
false );
1035 blurVertModule.
_sourceFile =
"baseVertexShaders.glsl";
1036 blurVertModule.
_variant =
"FullScreenQuad";
1042 fragModule.
_defines.emplace_back(
"layer uint(PushData0[0].x)" );
1043 fragModule.
_defines.emplace_back(
"size PushData0[0].yz");
1044 fragModule.
_defines.emplace_back(
"kernelSize int(PushData0[0].w)");
1045 fragModule.
_defines.emplace_back(
"verticalBlur uint(PushData0[1].x)");
1048 shaderDescriptorSingle.
_modules.push_back( blurVertModule );
1049 shaderDescriptorSingle.
_modules.push_back( fragModule );
1062 shaderDescriptorLayered.
_modules.push_back( blurVertModule );
1063 shaderDescriptorLayered.
_modules.push_back( fragModule );
1064 shaderDescriptorLayered.
_modules.back()._variant +=
".Layered";
1065 shaderDescriptorLayered.
_modules.back()._defines.emplace_back(
"LAYERED" );
1084 geomModule.
_defines.emplace_back(
"verticalBlur uint(PushData0[1].x)" );
1085 geomModule.
_defines.emplace_back(
"layerCount int(PushData0[1].y)" );
1086 geomModule.
_defines.emplace_back(
"layerOffsetRead int(PushData0[1].z)" );
1087 geomModule.
_defines.emplace_back(
"layerOffsetWrite int(PushData0[1].w)" );
1096 shaderDescriptorSingle.
_modules.push_back( blurVertModule );
1097 shaderDescriptorSingle.
_modules.push_back( geomModule );
1098 shaderDescriptorSingle.
_modules.push_back( fragModule );
1099 shaderDescriptorSingle.
_globalDefines.emplace_back(
"GS_MAX_INVOCATIONS 1" );
1112 shaderDescriptorLayered.
_modules.push_back( blurVertModule );
1113 shaderDescriptorLayered.
_modules.push_back( geomModule );
1114 shaderDescriptorLayered.
_modules.push_back( fragModule );
1115 shaderDescriptorLayered.
_modules.back()._variant +=
".Layered";
1116 shaderDescriptorLayered.
_modules.back()._defines.emplace_back(
"LAYERED" );
1131 _imShaders = std::make_unique<ImShaders>();
1136 vertModule.
_sourceFile =
"baseVertexShaders.glsl";
1137 vertModule.
_variant =
"FullScreenQuad";
1142 fragModule.
_defines.emplace_back(
"convertToSRGB uint(PushData0[0].x)" );
1145 shaderDescriptor.
_modules.push_back( vertModule );
1146 shaderDescriptor.
_modules.push_back( fragModule );
1159 blendState.enabled(
true );
1166 shaderDescriptor.
_modules.back()._defines.emplace_back(
"DEPTH_ONLY" );
1191 primitiveStateBlock._depthTestEnabled =
false;
1201 primitiveStateBlock._depthTestEnabled =
true;
1214 params.winGUID = mainWindow->
getGUID();
1215 params.isMainWindow =
true;
1221 _sceneData = std::make_unique<SceneShaderData>( *
this );
1230 if (
_api ==
nullptr )
1243 s_renderThread.
_cv.notify_one();
1244 s_renderThread.
_thread.join();
1289 _api->closeRenderingAPI();
1295 string list =
" [ ";
1301 list.append(
"\n ]");
1311 _api->onThreadCreated( threadID, isMainRenderThread );
1316#pragma region Main frame loop
1339 if ( !
_api->drawToWindow( window ) )
1349 _api->prepareFlushWindow( window );
1361 ResetCommandBufferQueue(queue);
1363 _api->flushWindow( window );
1394 if (
_api->frameStarted() )
1408 if ( !editorRunning )
1417 beginRenderPassCmd._name =
"Blit Backbuffer";
1423 const auto& texData =
Get(screenAtt->texture())->getView();
1425 drawTextureInViewport( texData, screenAtt->_descriptor._sampler, context().mainWindow().renderingViewport(),
false,
false,
false, *buffer );
1427 GFX::EnqueueCommand<GFX::EndRenderPassCommand>( *buffer );
1428 flushCommandBuffer(
MOV(bufferHandle) );
1431 context().app().windowManager().flushWindow();
1459 frameDrawCallsPrev( frameDrawCalls() );
1460 frameDrawCalls( 0u );
1462 if ( _gfxBuffers._needsResizeCam )
1468 const U32 currentSizeCullCounter = frameBuffers.
_cullCounter->queueLength();
1469 resizeGPUBlocks( _gfxBuffers._needsResizeCam ? currentSizeCam + TargetBufferSizeCam : currentSizeCam, currentSizeCullCounter );
1470 _gfxBuffers._needsResizeCam =
false;
1473 _gfxBuffers.onEndFrame();
1476 if (!_api->frameEnded())
1483 DecrementPrimitiveLifetime( _debugLines );
1484 DecrementPrimitiveLifetime( _debugBoxes );
1485 DecrementPrimitiveLifetime( _debugOBBs );
1486 DecrementPrimitiveLifetime( _debugFrustums );
1487 DecrementPrimitiveLifetime( _debugCones );
1488 DecrementPrimitiveLifetime( _debugSpheres );
1490 _performanceMetrics._scratchBufferQueueUsage[0] =
to_U32( _gfxBuffers.crtBuffers()._camWritesThisFrame );
1491 _performanceMetrics._scratchBufferQueueUsage[1] =
to_U32( _gfxBuffers.crtBuffers()._renderWritesThisFrame );
1499#pragma region Utility functions
1502 const U16 arrayOffset,
1515 bool isValidFB =
false;
1537 constexpr const char* PassNames[] = {
"CUBEMAP_X+",
"CUBEMAP_X-",
"CUBEMAP_Y+",
"CUBEMAP_Y-",
"CUBEMAP_Z+",
"CUBEMAP_Z-" };
1546 for (
U8 i = 0u; i < 6u; ++i )
1562 camera->
lookAt( pos, pos + (CameraDirections[i] * zPlanes.
max), CameraUpVectors[i] );
1564 passMgr->doCustomPass( camera, params, commandsInOut, memCmdInOut );
1566 if ( viewProjectionOut !=
nullptr )
1574 const U16 arrayOffset,
1589 bool isValidFB =
false;
1616 for (
U8 i = 0u; i < 2u; ++i )
1618 const U16 layer = arrayOffset + i;
1633 passMgr->doCustomPass( camera, params, bufferInOut, memCmdInOut );
1635 if ( viewProjectionOut !=
nullptr )
1647 const I32 kernelSize,
1648 const bool gaussian,
1649 const U8 layerCount,
1657 pushData.data[0]._vec[1].y =
to_F32( layerCount );
1658 pushData.data[0]._vec[1].z = 0.f;
1659 pushData.data[0]._vec[1].w = 0.f;
1661 const U8 loopCount = gaussian ? 1u : layerCount;
1664 pushData.data[0]._vec[0].x = 0.f;
1665 pushData.data[0]._vec[1].x = 0.f;
1671 renderPassCmd->
_name =
"BLUR_RENDER_TARGET_HORIZONTAL";
1679 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( bufferInOut );
1682 Set( binding.
_data, inputAttachment->texture(), inputAttachment->_descriptor._sampler );
1685 if ( !gaussian && layerCount > 1 )
1687 pushData.data[0]._vec[0].x = 0.f;
1690 for (
U8 loop = 0u; loop < loopCount; ++loop )
1692 if ( !gaussian && loop > 0u )
1694 pushData.data[0]._vec[0].x =
to_F32( loop );
1695 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut)->_fastData = pushData;
1697 GFX::EnqueueCommand<GFX::DrawCommand>( bufferInOut )->_drawCommands.emplace_back();
1703 pushData.data[0]._vec[0].x = 0.f;
1704 pushData.data[0]._vec[1].x = 1.f;
1706 pushData.data[0]._vec[2].xy.set( 1.0f /
blurTarget._rt->getResolution().width, 1.0f /
blurTarget._rt->getResolution().height );
1710 renderPassCmd->
_name =
"BLUR_RENDER_TARGET_VERTICAL";
1715 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( bufferInOut );
1718 Set( binding.
_data, bufferAttachment->texture(), bufferAttachment->_descriptor._sampler );
1720 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut )->_fastData = pushData;
1722 for (
U8 loop = 0u; loop < loopCount; ++loop )
1724 if ( !gaussian && loop > 0u )
1726 pushData.data[0]._vec[0].x =
to_F32( loop );
1727 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut )->_fastData = pushData;
1729 GFX::EnqueueCommand<GFX::DrawCommand>( bufferInOut )->_drawCommands.emplace_back();
1737#pragma region Resolution, viewport and window management
1795 const F32 aspectRatio =
to_F32( w ) / h;
1836 I32 left = 0, bottom = 0;
1840 const I32 tempWidth =
to_I32( h * currentAspectRatio );
1841 const I32 tempHeight =
to_I32( w / currentAspectRatio );
1843 const F32 newAspectRatio =
to_F32( tempWidth ) / tempHeight;
1845 if ( newAspectRatio <= currentAspectRatio )
1847 newWidth = tempWidth;
1848 left =
to_I32( (w - newWidth) * 0.5f );
1852 newHeight = tempHeight;
1853 bottom =
to_I32( (h - newHeight) * 0.5f );
1858 return COMPARE(newAspectRatio, currentAspectRatio);
1862#pragma region GPU State
1871 const vec4<F32> tempViewport{ activeViewport() };
1965 bool projectionDirty =
false, viewDirty =
false;
1984 const F32 zLogRatio = std::log( zFar / zNear );
1989 projectionDirty =
true;
1999 if ( projectionDirty || viewDirty )
2014 _gpuBlock._camNeedsUpload =
true;
2022 _gpuBlock._camNeedsUpload =
true;
2030 bool projectionDirty =
false, viewDirty =
false;
2042 projectionDirty =
true;
2045 if ( projectionDirty || viewDirty )
2053 _activeViewport.set( viewport );
2054 return _api->setViewportInternal( viewport );
2059 _activeScissor.set( scissor );
2060 return _api->setScissorInternal( scissor );
2065 _cameraSnapshotHistory[index] = snapshot;
2070 return _cameraSnapshotHistory[index];
2075 return _cameraSnapshotHistory[index];
2085 return _gpuBlock._prevFrameData[index];
2089#pragma region Command buffers, occlusion culling, etc
2111 entry._set = &set.impl();
2112 entry._usage = usage;
2113 entry._isDirty = set.dirty();
2117 _api->bindShaderResources( setEntries );
2126 AddCommandBufferToQueue( queue,
MOV(commandBuffer) );
2133 const Rect<I32> initialViewport = activeViewport();
2134 const Rect<I32> initialScissor = activeScissor();
2136 _api->preFlushCommandBuffer( commandBuffer );
2146 switch ( cmd->type() )
2160 if ( crtCmd.
_buffer !=
nullptr )
2164 _api->flushCommand( &memCmd );
2239 _api->flushCommand( cmd );
2246 BufferLock& lock = writeMemCmd._bufferLocks.emplace_back();
2250 _api->flushCommand( &writeMemCmd );
2254 _api->postFlushCommandBuffer( commandBuffer );
2276 assert( depthBuffer != HiZTarget );
2283 GFX::EnqueueCommand<GFX::BeginDebugScopeCommand>( cmdBufferInOut )->_scopeName =
"Construct Hi-Z";
2284 GFX::EnqueueCommand<GFX::BindPipelineCommand>( cmdBufferInOut )->_pipeline =
_hIZPipeline;
2286 U32 twidth = HiZTex->width();
2287 U32 theight = HiZTex->height();
2288 bool wasEven =
false;
2289 U32 owidth = twidth;
2290 U32 oheight = theight;
2292 for (
U16 i = 0u; i < HiZTex->mipCount(); ++i )
2294 twidth = twidth < 1u ? 1u : twidth;
2295 theight = theight < 1u ? 1u : theight;
2297 ImageView outImage = HiZTex->getView( { i, 1u } );
2300 : HiZTex->getView( {
to_U16(i - 1u), 1u }, { 0u, 1u });
2303 GFX::EnqueueCommand<GFX::MemoryBarrierCommand>( cmdBufferInOut )->_textureLayoutChanges.emplace_back(
TextureLayoutChange
2310 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( cmdBufferInOut );
2321 PushConstantsStruct& pushConstants = GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( cmdBufferInOut )->_fastData;
2322 pushConstants.
data[0].
_vec[0].
set( owidth, oheight, twidth, theight );
2323 pushConstants.
data[0].
_vec[1].
x = wasEven ? 1.f : 0.f;
2325 GFX::EnqueueCommand<GFX::DispatchComputeCommand>( cmdBufferInOut )->_computeGroupSize =
2327 getGroupCount( twidth, DEPTH_REDUCE_LOCAL_SIZE ),
2328 getGroupCount( theight, DEPTH_REDUCE_LOCAL_SIZE ),
2332 wasEven = twidth % 2 == 0 && theight % 2 == 0;
2338 GFX::EnqueueCommand<GFX::MemoryBarrierCommand>( cmdBufferInOut )->_textureLayoutChanges.emplace_back(
TextureLayoutChange
2346 GFX::EnqueueCommand<GFX::EndDebugScopeCommand>( cmdBufferInOut );
2355 const bool countCulledNodes,
2361 const U32 threadCount = getGroupCount( cmdCount, GROUP_SIZE_AABB );
2363 if ( threadCount == 0u || !enableOcclusionCulling() )
2365 GFX::EnqueueCommand<GFX::AddDebugMessageCommand>( bufferInOut )->_msg =
"Occlusion Culling Skipped";
2372 GFX::EnqueueCommand<GFX::BeginDebugScopeCommand>( bufferInOut )->_scopeName =
"Occlusion Cull";
2375 GFX::EnqueueCommand<GFX::BindPipelineCommand>( bufferInOut )->_pipeline =
_hIZCullPipeline;
2377 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( bufferInOut );
2380 Set( binding.
_data, hizTex->getView(), sampler );
2383 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( bufferInOut );
2386 Set( binding.
_data, cullBuffer, { 0u, 1u });
2394 auto pushConstantsCmd = GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut );
2396 pushConstantsCmd->_uniformData = passData.
_uniforms;
2402 GFX::EnqueueCommand<GFX::DispatchComputeCommand>( bufferInOut )->_computeGroupSize = { threadCount, 1, 1 };
2405 GFX::EnqueueCommand<GFX::MemoryBarrierCommand>( bufferInOut )->_bufferLocks.emplace_back(
BufferLock
2412 GFX::EnqueueCommand<GFX::EndDebugScopeCommand>( bufferInOut );
2414 if ( queryPerformanceStats() && countCulledNodes )
2417 readAtomicCounter.
_buffer = cullBuffer;
2418 readAtomicCounter.
_target = { &_lastCullCount, 4 *
sizeof(
U32 ) };
2426 clearAtomicCounter.
_buffer = cullBuffer;
2427 clearAtomicCounter._offsetElementCount = 0;
2428 clearAtomicCounter._elementCount = 1;
2434#pragma region Drawing functions
2437 GFX::EnqueueCommand<GFX::BeginDebugScopeCommand>( bufferInOut )->_scopeName =
"Draw Texture In Viewport";
2441 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( bufferInOut );
2444 Set( binding.
_data, texture, sampler );
2446 GFX::EnqueueCommand<GFX::PushViewportCommand>( bufferInOut )->_viewport = viewport;
2448 if ( !drawToDepthOnly )
2450 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut)->_fastData.data[0]._vec[0].
x = convertToSrgb ? 1.f : 0.f;
2453 GFX::EnqueueCommand<GFX::DrawCommand>( bufferInOut )->_drawCommands.emplace_back();
2454 GFX::EnqueueCommand<GFX::PopViewportCommand>( bufferInOut );
2455 GFX::EnqueueCommand<GFX::PopCameraCommand>( bufferInOut );
2456 GFX::EnqueueCommand<GFX::EndDebugScopeCommand>( bufferInOut );
2460#pragma region Debug utilities
2463 constexpr I32 padding = 5;
2468 GFX::EnqueueCommand<GFX::BeginDebugScopeCommand>( bufferInOut )->_scopeName =
"Render Debug Views";
2472 targetViewport.
y + padding,
2473 targetViewport.
z - padding,
2474 targetViewport.
w - padding ),
2479 GFX::EnqueueCommand<GFX::EndDebugScopeCommand>( bufferInOut );
2490 vertModule.
_sourceFile =
"baseVertexShaders.glsl";
2491 vertModule.
_variant =
"FullScreenQuad";
2496 fragModule.
_variant =
"LinearDepth";
2499 shaderDescriptor.
_modules.push_back( vertModule );
2500 shaderDescriptor.
_modules.push_back( fragModule );
2505 DebugView_ptr HiZ = std::make_shared<DebugView>();
2509 HiZ->_name =
"Hierarchical-Z";
2514 HiZ->_cycleMips =
true;
2516 DebugView_ptr DepthPreview = std::make_shared<DebugView>();
2520 DepthPreview->_name =
"Depth Buffer";
2524 DebugView_ptr NormalPreview = std::make_shared<DebugView>();
2528 NormalPreview->_name =
"Normals";
2535 DebugView_ptr VelocityPreview = std::make_shared<DebugView>();
2539 VelocityPreview->_name =
"Velocity Map";
2548 DebugView_ptr SSAOPreview = std::make_shared<DebugView>();
2552 SSAOPreview->_name =
"SSAO Map";
2559 DebugView_ptr AlphaAccumulationHigh = std::make_shared<DebugView>();
2563 AlphaAccumulationHigh->_name =
"Alpha Accumulation High";
2570 DebugView_ptr AlphaRevealageHigh = std::make_shared<DebugView>();
2574 AlphaRevealageHigh->_name =
"Alpha Revealage High";
2590 DebugView_ptr Luminance = std::make_shared<DebugView>();
2593 Luminance->_sampler = lumaSampler;
2594 Luminance->_name =
"Luminance";
2603 DebugView_ptr Edges = std::make_shared<DebugView>();
2607 Edges->_name =
"Edges";
2636 constexpr I32 columnCount = 6u;
2640 if ( !view->_enabled )
2646 if ( viewCount == 0 )
2651 labelStack.resize( 0 );
2653 const I32 screenWidth = targetViewport.
z - targetViewport.
x;
2654 const I32 screenHeight = targetViewport.
w - targetViewport.
y;
2655 const F32 aspectRatio =
to_F32( screenWidth ) / screenHeight;
2657 const I32 viewportWidth = (screenWidth / columnCount) - (padding * (columnCount - 1u));
2658 const I32 viewportHeight =
to_I32( viewportWidth / aspectRatio ) - padding;
2659 Rect<I32> viewport( targetViewport.
z - viewportWidth, targetViewport.
y, viewportWidth, viewportHeight );
2661 const I32 initialOffsetX = viewport.
x;
2665 pipelineDesc._shaderProgramHandle = INVALID_HANDLE<ShaderProgram>;
2668 const Rect<I32> previousViewport = activeViewport();
2682 if ( view->_cycleMips )
2684 const F32 lodLevel =
to_F32( mipTimer %
Get(view->_texture)->mipCount() );
2691 if ( crtShader != newShader )
2693 pipelineDesc._shaderProgramHandle = view->_shader;
2697 GFX::EnqueueCommand<GFX::BindPipelineCommand>( bufferInOut )->_pipeline = crtPipeline;
2698 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut )->_uniformData = &view->_shaderData;
2699 GFX::EnqueueCommand<GFX::SetViewportCommand>( bufferInOut )->_viewport.set( viewport );
2701 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( bufferInOut );
2704 Set( binding.
_data, view->_texture, view->_sampler );
2706 GFX::EnqueueCommand<GFX::DrawCommand>( bufferInOut )->_drawCommands.emplace_back();
2708 if ( !view->_name.empty() )
2710 labelStack.emplace_back( view->_name, viewport.
sizeY, viewport );
2712 if ( idx > 0 && idx % (columnCount - 1) == 0 )
2714 viewport.
y += viewportHeight + targetViewport.
y;
2715 viewport.
x = initialOffsetX;
2720 viewport.
x -= viewportWidth + targetViewport.
x;
2728 for (
const auto& [labelText, viewportOffsetY, viewportIn] : labelStack )
2730 GFX::EnqueueCommand<GFX::SetViewportCommand>( bufferInOut )->_viewport.set( viewportIn );
2732 text.position()._y._offset =
to_F32( viewportOffsetY );
2733 text.text( labelText.c_str(),
false );
2736 GFX::EnqueueCommand<GFX::PopCameraCommand>( bufferInOut );
2737 GFX::EnqueueCommand<GFX::SetViewportCommand>( bufferInOut )->_viewport.set( previousViewport );
2753 [](
const std::shared_ptr<DebugView>& a,
const std::shared_ptr<DebugView>& b )
noexcept ->
bool
2755 if ( a->_groupID == b->_groupID )
2757 return a->_sortIndex < b->_sortIndex;
2759 if ( a->_sortIndex == b->_sortIndex )
2761 return a->_groupID < b->_groupID;
2764 return a->_groupID < b->_groupID&& a->_sortIndex < b->_sortIndex;
2773 [view](
const std::shared_ptr<DebugView>&
entry )
noexcept
2775 return view !=
nullptr && view->
getGUID() ==
entry->getGUID();
2784 if ( view->_sortIndex == index )
2786 view->_enabled = state;
2797 if ( view->_groupID == group )
2799 view->_enabled = state;
2809 if ( view->_groupID == group )
2811 if ( !view->_enabled )
2823 namesOut.resize( 0 );
2828 namesOut.emplace_back( view->_name, view->_groupID, view->_sortIndex, view->_enabled );
2834 if ( descriptor.noDepth )
2836 return (descriptor.noCull ? _debugGizmoPipelineNoCullNoDepth : _debugGizmoPipelineNoDepth);
2838 else if ( descriptor.noCull )
2840 return _debugGizmoPipelineNoCull;
2843 return _debugGizmoPipeline;
2848 _debugLines.add( ID, descriptor );
2856 for (
size_t f = 0u; f < lineCount; ++f )
2859 if ( data._frameLifeTime == 0u )
2865 if ( linePrimitive ==
nullptr )
2871 linePrimitive->forceWireframe( data._descriptor.wireframe );
2872 linePrimitive->
fromLines( data._descriptor );
2873 linePrimitive->
getCommandBuffer( data._descriptor.worldMatrix, bufferInOut, memCmdInOut );
2879 _debugBoxes.add( ID, descriptor );
2886 for (
U32 f = 0u; f < boxesCount; ++f )
2889 if ( data._frameLifeTime == 0u )
2895 if ( boxPrimitive ==
nullptr )
2901 boxPrimitive->forceWireframe( data._descriptor.wireframe );
2902 boxPrimitive->
fromBox( data._descriptor );
2903 boxPrimitive->
getCommandBuffer( data._descriptor.worldMatrix, bufferInOut, memCmdInOut );
2909 _debugOBBs.add( ID, descriptor );
2916 for (
U32 f = 0u; f < boxesCount; ++f )
2919 if ( data._frameLifeTime == 0u )
2925 if ( boxPrimitive ==
nullptr )
2931 boxPrimitive->forceWireframe( data._descriptor.wireframe );
2932 boxPrimitive->
fromOBB( data._descriptor );
2933 boxPrimitive->
getCommandBuffer( data._descriptor.worldMatrix, bufferInOut, memCmdInOut );
2938 _debugSpheres.add( ID, descriptor );
2945 for (
size_t f = 0u; f < spheresCount; ++f )
2948 if ( data._frameLifeTime == 0u )
2954 if ( spherePrimitive ==
nullptr )
2960 spherePrimitive->forceWireframe( data._descriptor.wireframe );
2961 spherePrimitive->
fromSphere( data._descriptor );
2962 spherePrimitive->
getCommandBuffer( data._descriptor.worldMatrix, bufferInOut, memCmdInOut );
2968 _debugCones.add( ID, descriptor );
2976 for (
size_t f = 0u; f < conesCount; ++f )
2979 if ( data._frameLifeTime == 0u )
2985 if ( conePrimitive ==
nullptr )
2991 conePrimitive->forceWireframe( data._descriptor.wireframe );
2992 conePrimitive->
fromCone( data._descriptor );
2993 conePrimitive->
getCommandBuffer( data._descriptor.worldMatrix, bufferInOut, memCmdInOut );
2999 _debugFrustums.add( ID, descriptor );
3007 for (
size_t f = 0u; f < frustumCount; ++f )
3010 if ( data._frameLifeTime == 0u )
3016 if ( frustumPrimitive ==
nullptr )
3022 frustumPrimitive->forceWireframe( data._descriptor.wireframe );
3023 frustumPrimitive->
fromFrustum( data._descriptor );
3024 frustumPrimitive->
getCommandBuffer( data._descriptor.worldMatrix, bufferInOut, memCmdInOut );
3040#pragma region GPU Object instantiation
3043 RenderTarget_uptr ret =
_api->newRT(descriptor);
3045 if ( ret !=
nullptr )
3047 const bool valid = ret->create();
3063 if ( primitive !=
nullptr )
3067 primitive =
nullptr;
3080 const size_t hash =
GetHash( descriptor );
3098 primitive =
nullptr;
3103 return std::make_shared<VertexBuffer>( *
this, descriptor );
3123 auto readTextureCmd = GFX::EnqueueCommand<GFX::ReadTextureCommand>( bufferInOut );
3125 readTextureCmd->_pixelPackAlignment._alignment = 1u;
3128 if ( !data._data.empty() )
3141 data._numComponents,
#define WAIT_FOR_CONDITION(...)
#define PROFILE_SCOPE_AUTO(CATEGORY)
#define PROFILE_SCOPE(NAME, CATEGORY)
WindowManager & windowManager() noexcept
const mat4< F32 > & setProjection(vec2< F32 > zPlanes)
const mat4< F32 > & viewProjectionMatrix() const noexcept
Returns the most recent/up-to-date viewProjection matrix.
static Camera * GetUtilityCamera(const UtilityCamera type)
const mat4< F32 > & lookAt(const mat4< F32 > &viewMatrix)
Sets the camera's view matrix to specify the specified value by extracting the eye position,...
const CameraSnapshot & snapshot() const noexcept
Returns the internal camera snapshot data (eye, orientation, etc)
static constexpr F32 s_minNearZ
bool updateLookAt()
Return true if the cached camera state wasn't up-to-date.
vec2< U16 > getDrawableSize() const noexcept
GFX::CommandBufferQueue & getCurrentCommandBufferQueue()
const Rect< I32 > & renderingViewport() const noexcept
eastl::fixed_vector< CommandBase *, COMMAND_BUFFER_INIT_SIZE, true > CommandList
void drawTextureInViewport(const ImageView &texture, SamplerDescriptor sampler, const Rect< I32 > &viewport, bool convertToSrgb, bool drawToDepthOnly, bool drawBlend, GFX::CommandBuffer &bufferInOut)
Mutex _graphicsResourceMutex
GFX::BindPipelineCommand _blurBoxPipelineLayeredCmd
void occlusionCull(const RenderPass::PassData &passData, Handle< Texture > hizBuffer, SamplerDescriptor sampler, const CameraSnapshot &cameraSnapshot, bool countCulledNodes, GFX::CommandBuffer &bufferInOut)
void shadowingSettings(const F32 lightBleedBias, const F32 minShadowVariance) noexcept
GFXDescriptorSets _descriptorSets
static constexpr U8 s_invalidQueueSampleCount
std::array< U8, to_base(ShadowType::COUNT)> _queuedShadowSampleChange
CameraSnapshot & getCameraSnapshot(PlayerIndex index) noexcept
void debugDrawCone(const I64 ID, IM::ConeDescriptor descriptor) noexcept
void debugDrawCones(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
U8 _queuedScreenSampleChange
Handle< ShaderProgram > _hIZCullProgram
GFX::BindPipelineCommand _blurGaussianPipelineLayeredCmd
void setDepthRange(vec2< F32 > depthRange)
void renderDebugViews(Rect< I32 > targetViewport, I32 padding, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
struct Divide::GFXDevice::GFXBuffers _gfxBuffers
bool setViewport(const Rect< I32 > &viewport)
Returns true if the viewport was changed.
RenderStateBlock _stateDepthOnlyRendering
ShaderBuffer_uptr newSB(const ShaderBufferDescriptor &descriptor)
DebugPrimitiveHandler< IM::BoxDescriptor, 16u > _debugBoxes
IMPrimitive * newIMP(std::string_view name)
Create and return a new immediate mode emulation primitive.
static IMPrimitivePool s_IMPrimitivePool
void blurTarget(RenderTargetHandle &blurSource, RenderTargetHandle &blurBuffer, const RenderTargetHandle &blurTarget, RTAttachmentType att, RTColourAttachmentSlot slot, I32 kernelSize, bool gaussian, U8 layerCount, GFX::CommandBuffer &bufferInOut)
void onResolutionChange(const SizeChangeParams ¶ms)
RenderStateBlock _defaultStateNoDepthTest
The default render state but with depth testing disabled.
Pipeline * _hIZCullPipeline
static DeviceInformation s_deviceInformation
Handle< ShaderProgram > _depthShader
static bool IsSubmitCommand(GFX::CommandType type) noexcept
Handle< ShaderProgram > _hIZConstructProgram
void setCameraSnapshot(PlayerIndex index, const CameraSnapshot &snapshot) noexcept
void setClipPlanes(const FrustumClipPlanes &clipPlanes)
set a new list of clipping planes. The old one is discarded
Handle< ShaderProgram > _renderTargetDraw
GFX::BindPipelineCommand _drawFSTexturePipelineBlendCmd
static constexpr U8 MAX_CAMERA_SNAPSHOTS
void debugDrawFrustums(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
GFX::BindPipelineCommand _drawFSDepthPipelineCmd
void setShadowMSAASampleCount(ShadowType type, U8 sampleCount)
void setShadowMSAASampleCountInternal(ShadowType type, U8 sampleCount)
void setScreenMSAASampleCountInternal(U8 sampleCount)
void generateCubeMap(RenderPassParams ¶ms, U16 arrayOffset, const vec3< F32 > &pos, vec2< F32 > zPlanes, GFX::CommandBuffer &commandsInOut, GFX::MemoryBarrierCommand &memCmdInOut, mat4< F32 > *viewProjectionOut=nullptr)
Generate a cube texture and store it in the provided RenderTarget.
DebugPrimitiveHandler< IM::ConeDescriptor, 16u > _debugCones
ShaderComputeQueue & shaderComputeQueue() noexcept
ErrorCode initRenderingAPI(I32 argc, char **argv, RenderAPI API)
void update(U64 deltaTimeUSFixed, U64 deltaTimeUSApp)
GFX::BindPipelineCommand _blurBoxPipelineSingleCmd
RenderTarget_uptr newRT(const RenderTargetDescriptor &descriptor)
Create and return a new framebuffer.
void worldAOViewProjectionMatrix(const mat4< F32 > &vpMatrix) noexcept
void setScreenMSAASampleCount(U8 sampleCount)
vector< DebugView_ptr > _debugViews
PipelineDescriptor _debugGizmoPipelineNoCull
PipelineDescriptor _debugGizmoPipeline
PipelineDescriptor _debugGizmoPipelineNoCullNoDepth
F32 renderingAspectRatio() const noexcept
void closeRenderingAPI()
Revert everything that was set up in initRenderingAPI()
DebugPrimitiveHandler< IM::FrustumDescriptor, 8u > _debugFrustums
void onWindowSizeChange(const SizeChangeParams ¶ms)
The main entry point for any resolution change request.
void generateDualParaboloidMap(RenderPassParams ¶ms, U16 arrayOffset, const vec3< F32 > &pos, vec2< F32 > zPlanes, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut, mat4< F32 > *viewProjectionOut=nullptr)
RenderAPIWrapper_uptr _api
MemoryPool< IMPrimitive, 1<< 15 > IMPrimitivePool
RenderStateBlock _state2DRendering
Special render state for 2D rendering.
GFXRTPool & renderTargetPool() noexcept
FrustumClipPlanes _clippingPlanes
The interpolation factor between the current and the last frame.
std::unique_ptr< ShaderComputeQueue > _shaderComputeQueue
bool uploadGPUBlock()
Upload draw related data to the GPU (view & projection matrices, viewport settings,...
std::stack< Rect< I32 > > _viewportStack
GFX::BindPipelineCommand _blurGaussianPipelineSingleCmd
Handle< ShaderProgram > _previewDepthMapShader
shader used to preview the depth buffer
void renderFromCamera(const CameraSnapshot &cameraSnapshot)
Renderer & getRenderer() const
Mutex _queuedCommandbufferLock
std::stack< CameraSnapshot, eastl::fixed_vector< CameraSnapshot, MAX_CAMERA_SNAPSHOTS, false > > _cameraSnapshots
void idle(bool fast, U64 deltaTimeUSGame, U64 deltaTimeUSApp)
After a swap buffer call, the CPU may be idle waiting for the GPU to draw to the screen,...
ErrorCode initDescriptorSets()
CameraSnapshot _activeCameraSnapshot
DebugPrimitiveHandler< IM::SphereDescriptor, 16u > _debugSpheres
bool frameEnded(const FrameEvent &evt) noexcept override
frameEnded is called after the buffers have been swapped
bool frameStarted(const FrameEvent &evt) override
const RenderStateBlock & getNoDepthTestBlock() const noexcept
returns the standard state block
void drawToWindow(DisplayWindow &window)
Handle< ShaderProgram > _previewRenderTargetColour
PipelineDescriptor _debugGizmoPipelineNoDepth
bool destroyIMP(IMPrimitive *&primitive)
Handle< ShaderProgram > _blurGaussianShaderLayered
void debugDrawSphere(const I64 ID, IM::SphereDescriptor descriptor) noexcept
void renderDebugUI(const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Handle< ShaderProgram > _blurGaussianShaderSingle
GFX::BindPipelineCommand _drawFSTexturePipelineCmd
ErrorCode createAPIInstance(RenderAPI api)
Pipeline * newPipeline(const PipelineDescriptor &descriptor)
Create and return a new graphics pipeline. This is only used for caching and doesn't use the object a...
Handle< ShaderProgram > _blurBoxShaderSingle
void debugDraw(const SceneRenderState &sceneRenderState, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Render all of our immediate mode primitives. This isn't very optimised and most are recreated per fra...
void debugDrawFrustum(const I64 ID, IM::FrustumDescriptor descriptor) noexcept
void flushWindow(DisplayWindow &window)
void getDebugViewNames(vector< std::tuple< string, I16, I16, bool > > &namesOut)
void debugDrawOBB(const I64 ID, IM::OBBDescriptor descriptor) noexcept
void validateAndUploadDescriptorSets()
Handle< ShaderProgram > _displayShader
void setPreviousViewProjectionMatrix(PlayerIndex player, const mat4< F32 > &prevViewMatrix, const mat4< F32 > prevProjectionMatrix)
void debugDrawOBBs(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void screenshot(std::string_view fileName, GFX::CommandBuffer &bufferInOut) const
Save a screenshot in TGA format.
bool framePreRender(const FrameEvent &evt) override
framePreRenderStarted is called when we need to start processing the visual aspect of a scene
void debugDrawBox(const I64 ID, IM::BoxDescriptor descriptor) noexcept
Handle< ShaderProgram > _previewRenderTargetDepth
bool removeDebugView(DebugView *view)
VertexBuffer_ptr newVB(const VertexBuffer::Descriptor &descriptor)
Create and return a new vertex array (VAO + VB + IB).
void onThreadCreated(const std::thread::id &threadID, bool isMainRenderThread) const
void flushCommandBufferInternal(Handle< GFX::CommandBuffer > commandBuffer)
void toggleDebugGroup(I16 groupID, bool state)
void debugDrawSpheres(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void debugDrawBoxes(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
PipelineDescriptor & getDebugPipeline(const IM::BaseDescriptor &descriptor) noexcept
const RenderStateBlock & get2DStateBlock() const noexcept
const GFXShaderData::PrevFrameData & previousFrameData(PlayerIndex player) const noexcept
hashMap< size_t, Pipeline, NoHash< size_t > > _pipelineCache
GFXDescriptorSet & descriptorSet(DescriptorSetUsage usage) noexcept
bool getDebugGroupState(I16 groupID) const
ErrorCode postInitRenderingAPI(vec2< U16 > renderResolution)
void debugDrawLines(const I64 ID, IM::LineDescriptor descriptor) noexcept
std::unique_ptr< GFXRTPool > _rtPool
GFXDevice(PlatformContext &context)
DebugPrimitiveHandler< IM::LineDescriptor, 16u > _debugLines
bool fitViewportInWindow(U16 w, U16 h)
void updateSceneDescriptorSet(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) const
void flushCommandBuffer(Handle< GFX::CommandBuffer > &&commandBuffer)
std::pair< Handle< Texture >, SamplerDescriptor > constructHIZ(RenderTargetID depthBuffer, RenderTargetID HiZTarget, GFX::CommandBuffer &cmdBufferInOut)
void resizeGPUBlocks(size_t targetSizeCam, size_t targetSizeCullCounter)
DebugPrimitiveHandler< IM::OBBDescriptor, 16u > _debugOBBs
void toggleDebugView(I16 index, bool state)
DebugView * addDebugView(const std::shared_ptr< DebugView > &view)
void addRenderWork(DELEGATE< void > &&work)
const GFXShaderData::CamData & cameraData() const noexcept
bool setScissor(const Rect< I32 > &scissor)
vector< std::tuple< GraphicsResource::Type, I64, U64 > > _graphicResources
static D64 s_interpolationFactor
Handle< ShaderProgram > _blurBoxShaderLayered
vec2< U16 > _renderingResolution
RenderTarget * getRenderTarget(const RenderTargetID target) const
FORCE_INLINE I64 getGUID() const noexcept
void drawText(const TextElementBatch &batch, const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut, bool pushCamera=true)
Text rendering is handled exclusively by Mikko Mononen's FontStash library (https://github....
IMPrimitive replaces immediate mode calls to VB based rendering.
void getCommandBuffer(GFX::CommandBuffer &commandBufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void fromOBB(const IM::OBBDescriptor &box)
GFXDevice & context() noexcept
void setPipelineDescriptor(const PipelineDescriptor &descriptor)
void fromBox(const IM::BoxDescriptor &box)
void fromCone(const IM::ConeDescriptor &cone)
void fromLines(const IM::LineDescriptor &lines)
void fromFrustum(const IM::FrustumDescriptor &frustum)
static void InitStaticData()
void fromSphere(const IM::SphereDescriptor &sphere)
static void RecomputeShaders()
void setParam(HashType nameID, T &&value)
PlatformContext & context() noexcept
PlatformContext & _context
DisplayWindow & mainWindow() noexcept
DisplayWindow & activeWindow() noexcept
Application & app() noexcept
Kernel & kernel() noexcept
ParamHandler & paramHandler() noexcept
Configuration & config() noexcept
void update(U64 deltaTimeUSFixed, U64 deltaTimeUSApp)
PreRenderBatch & getFilterBatch() noexcept
RenderTargetHandle edgesRT() const noexcept
Handle< Texture > luminanceTex() const noexcept
Handle< Texture > texture() const
RTAttachmentDescriptor _descriptor
static void OnShutdown(const GFXDevice &gfx)
static void OnStartup(const GFXDevice &gfx)
RTAttachment * getAttachment(RTAttachmentType type, RTColourAttachmentSlot slot=RTColourAttachmentSlot::SLOT_0) const
U16 getWidth() const noexcept
bool hasAttachment(RTAttachmentType type, RTColourAttachmentSlot slot=RTColourAttachmentSlot::SLOT_0) const
vec2< U16 > getResolution() const noexcept
U16 getHeight() const noexcept
virtual LockableBuffer * getBufferImpl()=0
void readData(BufferRange range, std::pair< bufferPtr, size_t > outData)
BufferLock clearData(BufferRange range)
static void OnEndFrame(GFXDevice &gfx)
static void OnBeginFrame(GFXDevice &gfx)
static void DestroyStaticData()
static void RegisterSetLayoutBinding(DescriptorSetUsage usage, U8 slot, DescriptorSetBindingType type, ShaderStageVisibility visibility)
static void Idle(PlatformContext &platformContext, bool fast)
static ErrorCode OnStartup(PlatformContext &context)
static void InitStaticData()
static ErrorCode SubmitSetLayouts(GFXDevice &gfx)
static I32 ShaderProgramCount() noexcept
static void setMSAASampleCount(ShadowType type, U8 sampleCount)
size_t getHash() const override
static void OnShutdown() noexcept
static void OnStartup(GFXDevice &gfx)
void drawToWindow(DisplayWindow &window)
static mat4< T > Multiply(const mat4< T > &matrixA, const mat4< T > &matrixB) noexcept
ret = A * B
void set(std::initializer_list< T > matrix) noexcept
void set(const T *v) noexcept
set the 2 components of the vector manually using a source pointer to a (large enough) array
void set(const T *v) noexcept
set the 3 components of the vector manually using a source pointer to a (large enough) array
void set(const T *v) noexcept
set the 4 components of the vector manually using a source pointer to a (large enough) array
constexpr DEGREES< T > to_VerticalFoV(DEGREES< T > horizontalFoV, D64 aspectRatio) noexcept
constexpr bool ENABLE_EDITOR
constexpr U8 CLUSTERS_Y_THREADS
constexpr U8 CLUSTERS_X_THREADS
constexpr U8 CLUSTERS_Z_THREADS
constexpr U8 CLUSTERS_X
Controls compute shader dispatch. e.g. Dispatch Z count = CLUSTERS_Z / CLUSTERS_Z_THREADS.
constexpr U16 MAX_LIGHTS_PER_CLUSTER
Upper limit of lights used in a cluster. The lower, the better performance at the cost of pop-in/glit...
constexpr bool ENABLE_GPU_VALIDATION
Error callbacks, validations, buffer checks, etc. are controlled by this flag. Heavy performance impa...
constexpr U8 MAX_CULL_DISTANCES
constexpr U8 MAX_REFLECTIVE_NODES_IN_VIEW
constexpr U8 MAX_REFRACTIVE_NODES_IN_VIEW
Similar to MAX_REFLECTIVE_NODES_IN_VIEW but for custom refraction passes (e.g. Water,...
constexpr U8 MAX_FRAMES_IN_FLIGHT
Maximum number of active frames until we start waiting on a fence/sync.
constexpr U8 MAX_CLIP_DISTANCES
constexpr const char * DROID_SERIF_BOLD
CommandBuffer * Get(Handle< CommandBuffer > handle)
FORCE_INLINE T * EnqueueCommand(CommandBuffer &buffer)
Handle< CommandBuffer > AllocateCommandBuffer(const char *name, const size_t reservedCmdCount)
static const char * resourceTypes[]
static constexpr const char * renderStage[]
static constexpr const char * renderPassType[]
constexpr Optick::Category::Type Graphics
D64 ElapsedMilliseconds() noexcept
const char * RenderPassTypeToString(const RenderPassType pass) noexcept
RenderStage StringToRenderStage(const char *stage) noexcept
const char * GraphicResourceTypeToName(const GraphicsResource::Type type) noexcept
const char * RenderStageToString(const RenderStage stage) noexcept
RenderPassType StringToRenderPassType(const char *pass) noexcept
Str StringFormat(const char *fmt, Args &&...args)
string to_string(GET_PASS_TYPE< T > value)
static RenderThread s_renderThread
void DecrementPrimitiveLifetime(DebugPrimitiveHandler< Data, N > &container)
constexpr U32 GROUP_SIZE_AABB
constexpr size_t TargetBufferSizeCam
How many writes we can basically issue per frame to our scratch buffers before we have to sync.
FORCE_INLINE U32 getGroupCount(const U32 threadCount, U32 const localSize)
constexpr U32 MAX_INVOCATIONS_BLUR_SHADER_LAYERED
constexpr U32 DEPTH_REDUCE_LOCAL_SIZE
Handle console commands that start with a forward slash.
std::array< DescriptorSetEntry, to_base(DescriptorSetUsage::COUNT)> DescriptorSetEntries
DELEGATE_STD< Ret, Args... > DELEGATE
std::lock_guard< mutex > LockGuard
constexpr U32 nextPOW2(U32 n) noexcept
eastl::fixed_vector< ExternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false > ExternalRTAttachmentDescriptors
constexpr U32 to_U32(const T value)
FORCE_INLINE void DestroyResource(Handle< T > &handle, const bool immediate=false)
static constexpr U32 RT_DEPTH_ATTACHMENT_IDX
void Merge(BufferRange &lhs, const BufferRange &rhs) noexcept
void SetThreadName(std::string_view threadName) noexcept
void insert(eastl::vector< T, A1 > &target, const eastl::vector< T, A2 > &source)
static const vec3< F32 > WORLD_X_NEG_AXIS
static const vec3< F32 > WORLD_X_AXIS
constexpr U16 to_U16(const T value)
constexpr RenderTargetID SCREEN_TARGET_ID
constexpr U8 MAX_BINDINGS_PER_DESCRIPTOR_SET
bool DebugBreak(const bool condition) noexcept
@ RES_LOADED
The resource is available for usage.
static const vec3< F32 > WORLD_Y_NEG_AXIS
static const vec3< F32 > WORLD_Z_AXIS
std::string CurrentDateTimeString()
constexpr F32 to_F32(const T value)
constexpr D64 to_D64(const T value)
bool IsCubeTexture(TextureType texType) noexcept
bool IsArrayTexture(TextureType texType) noexcept
RTAttachmentType
This enum is used when creating render targets to define the channel that the texture will attach to.
size_t GetHash(const PropertyDescriptor< T > &descriptor) noexcept
std::unique_lock< mutex > UniqueLock
void AddImageUsageFlag(PropertyDescriptor< Texture > &descriptor, const ImageUsage usage) noexcept
FileError createDirectory(const ResourcePath &path)
eastl::vector< Type > vector
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
void Set(DescriptorSetBindingData &dataInOut, ShaderBuffer *buffer, const BufferRange range) noexcept
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
DescriptorSetBinding & AddBinding(DescriptorSet &setInOut, U8 slot, U16 stageVisibilityMask)
eastl::fixed_vector< InternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false > InternalRTAttachmentDescriptors
FORCE_INLINE Handle< T > CreateResource(const ResourceDescriptor< T > &descriptor, bool &wasInCache, std::atomic_uint &taskCounter)
constexpr RenderTargetID INVALID_RENDER_TARGET_ID
@ Vulkan
not supported yet
@ None
No rendering. Used for testing or server code.
void efficient_clear(eastl::fixed_vector< T, nodeCount, bEnableOverflow, OverflowAllocator > &fixed_vector)
constexpr U8 to_U8(const T value)
::value constexpr T CLAMPED(T n, T min, T max) noexcept
constexpr I16 to_I16(const T value)
static const vec3< F32 > WORLD_Z_NEG_AXIS
bool ValidateGPUDataStructure() noexcept
RTClearEntry DEFAULT_CLEAR_ENTRY
::value constexpr void CLAMP(T &n, T min, T max) noexcept
Clamps value n between min and max.
bool COMPARE(T X, U Y) noexcept
void DestroyIMP(IMPrimitive *&primitive)
constexpr I32 to_I32(const T value)
bool dvd_erase_if(eastl::vector< T, A > &vec, Predicate &&pred)
FORCE_INLINE T * Get(const Handle< T > handle)
Project const SceneEntry & entry
static const vec4< F32 > VECTOR4_ZERO
static const vec3< F32 > WORLD_Y_AXIS
constexpr auto to_base(const Type value) -> Type
BufferUpdateUsage _updateUsage
BufferUsageType _usageType
BufferUpdateFrequency _updateFrequency
size_t _elementSize
Buffer primitive size in bytes.
mat4< F32 > _invViewMatrix
mat4< F32 > _projectionMatrix
std::array< Plane< F32 >, 6 > _frustumPlanes
Angle::DEGREES< F32 > _fov
const std::array< bool, N > & planeState() const noexcept
const PlaneList< N > & planes() const noexcept
U16 reflectionPlaneResolution
U16 reflectionProbeResolution
struct Divide::Configuration::Rendering rendering
struct Divide::Configuration::Runtime runtime
static NO_INLINE void errorfn(const char *format, T &&... args)
static NO_INLINE void printfn(const char *format, T &&... args)
eastl::fixed_vector< DataEntry, N, true > _debugData
DescriptorSetBindingType _type
U16 _shaderStageVisibility
DescriptorSetBindingData _data
std::array< DescriptorSetBinding, MAX_BINDINGS_PER_DESCRIPTOR_SET > _bindings
static U8 ActiveDisplayCount() noexcept
static U8 MaxMSAASamples() noexcept
static const OutputDisplayPropertiesContainer & GetDisplayModes(const size_t displayIndex) noexcept
RTDrawDescriptor _descriptor
RTClearDescriptor _clearDescriptor
const Pipeline * _pipeline
eastl::fixed_vector< Entry, COMMAND_BUFFER_INIT_SIZE, true > _commandBuffers
GenericDrawCommandContainer _drawCommands
CameraSnapshot _cameraSnapshot
std::pair< bufferPtr, size_t > _target
CameraSnapshot _cameraSnapshot
FrustumClipPlanes _clippingPlanes
ShaderBuffer_uptr _cullCounter
BufferRange _camBufferWriteRange
ShaderBuffer_uptr _camDataBuffer
size_t _camWritesThisFrame
static constexpr U8 PER_FRAME_BUFFER_COUNT
void reset(const bool camBuffer, const bool cullBuffer) noexcept
PerFrameBuffers & crtBuffers() noexcept
struct Divide::GFXDevice::GFXBuffers::PerFrameBuffers _perFrameBuffers[PER_FRAME_BUFFER_COUNT]
void update(DescriptorSetUsage usage, const DescriptorSet &newBindingData)
static constexpr RTColourAttachmentSlot ALBEDO
static constexpr RTColourAttachmentSlot NORMALS
static constexpr RTColourAttachmentSlot MODULATE
static constexpr RTColourAttachmentSlot VELOCITY
static constexpr RTColourAttachmentSlot ACCUMULATION
static constexpr RTColourAttachmentSlot REVEALAGE
vec4< F32 > _cameraProperties
vec4< F32 > _lightingTweakValues
vec4< F32 > _renderTargetInfo
mat4< F32 > _projectionMatrix
mat4< F32 > _invViewMatrix
mat4< F32 > _worldAOVPMatrix
vec4< F32 > _clipPlanes[Config::MAX_CLIP_DISTANCES]
mat4< F32 > _previousViewMatrix
mat4< F32 > _previousViewProjectionMatrix
mat4< F32 > _previousProjectionMatrix
struct Divide::GFXShaderData::CamData _camData
struct Divide::GFXShaderData::PrevFrameData _prevFrameData[Config::MAX_LOCAL_PLAYER_COUNT]
PrimitiveTopology _primitiveTopology
Handle< ShaderProgram > _shaderProgramHandle
RTBlendStates _blendStates
RenderStateBlock _stateBlock
vector< ShaderModuleDescriptor > _modules
ModuleDefines _globalDefines
MipMappingState _mipMappingState
SamplerDescriptor _sampler
std::array< BlendingSettings, to_base(RTColourAttachmentSlot::COUNT)> _settings
DrawLayerEntry _writeLayers[RT_MAX_ATTACHMENT_COUNT]
RTDrawDescriptor _targetDescriptorPrePass
RTDrawDescriptor _targetDescriptorMainPass
RenderStagePass _stagePass
ComparisonFunction _zFunc
ExternalRTAttachmentDescriptors _externalAttachments
InternalRTAttachmentDescriptors _attachments
static RenderTargetID HI_Z
static RenderTargetID REFLECTION_PLANAR_BLUR
static RenderTargetID OIT
static RenderTargetID BACK_BUFFER
static RenderTargetID NORMALS_RESOLVED
static RenderTargetID OIT_REFLECT
static RenderTargetID HI_Z_REFLECT
static RenderTargetID SSAO_RESULT
static RenderTargetID SCREEN
static RenderTargetID SSR_RESULT
static RenderTargetID REFLECTION_CUBE
static std::array< RenderTargetID, Config::MAX_REFRACTIVE_NODES_IN_VIEW > REFRACTION_PLANAR
static std::array< RenderTargetID, Config::MAX_REFLECTIVE_NODES_IN_VIEW > REFLECTION_PLANAR
static RenderTargetID SCREEN_PREV
TextureFilter _minFilter
Texture filtering mode.
TextureWrap _wrapU
Texture wrap mode (Or S-R-T)
U8 _anisotropyLevel
The value must be in the range [0...255] and is automatically clamped by the max HW supported level.
TextureMipSampling _mipSampling
std::pair< bufferPtr, size_t > _initialData
BufferParams _bufferParams
bool _separateReadWrite
Use a separate read/write index based on queue length.
U16 width
The new width and height.
eastl::queue< DisplayWindow * > _windows
std::atomic_bool _running
std::condition_variable _cv