Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
foray::base::DefaultAppBase Class Reference

Intended as base class for demo applications. Compared to MinimalAppBase it offers a complete simple vulkan setup. More...

#include <foray_defaultappbase.hpp>

Public Member Functions

 DefaultAppBase ()
 
virtual ~DefaultAppBase ()=default
 
int32_t Run ()
 Runs through the entire application lifetime.
 

Protected Member Functions

virtual void ApiBeforeInit ()
 Called before any initialization happens.
 
virtual void ApiBeforeWindowCreate (osi::Window &window)
 Override this method to alter vulkan instance creation parameters via the instance builder.
 
virtual void ApiBeforeInstanceCreate (vkb::InstanceBuilder &instanceBuilder)
 Override this method to alter vulkan instance creation parameters via the instance builder.
 
virtual void ApiBeforeDeviceSelection (vkb::PhysicalDeviceSelector &pds)
 Alter physical device selection.
 
virtual void ApiBeforeDeviceBuilding (vkb::DeviceBuilder &deviceBuilder)
 Alter device selection.
 
virtual void ApiBeforeSwapchainBuilding (vkb::SwapchainBuilder &swapchainBuilder)
 Before building the swapchain.
 
virtual void ApiInit ()
 Called after all DefaultAppBase members have been initialized, but before the renderloop starts. Initialize your application here.
 
virtual void ApiOnResized (VkExtent2D size)
 Called whenever the swapchain has been resized.
 
virtual void ApiOnEvent (const osi::Event *event)
 Override this method to react to events.
 
virtual void ApiRender (FrameRenderInfo &renderInfo)
 Called once every frame. Render your application here.
 
virtual void ApiFrameFinishedExecuting (uint64_t frameIndex)
 Called back once the frame of the index has finished executing on the GPU, so QueryResults etc. are ready to be obtained.
 
virtual void ApiOnShadersRecompiled (std::unordered_set< uint64_t > &recompiledShaderKeys)
 Called whenever the shader compiler has detected a change and shaders have successfully been recompiled.
 
virtual void ApiDestroy ()
 Called after the application has been requested to shut down but before DefaultAppBase finalizes itself.
 
virtual void RegisterRenderStage (stages::RenderStage *stage)
 Call this with a renderstage for automatic OnResized/OnShadersRecompiled calls. Register order is maintained for callbacks.
 
virtual void UnregisterRenderStage (stages::RenderStage *stage)
 Call this with a renderstage to unsubscribe from automatic calls.
 
virtual void Init ()
 [Internal] Initializes DefaultAppBase
 
virtual void InitGetQueue ()
 [Internal] Initializes Queue
 
virtual void InitCommandPool ()
 [Internal] Initializes Command Pool
 
virtual void InitCreateVma ()
 [Internal] Initializes VmaAllocator
 
virtual void InitSyncObjects ()
 [Internal] Initializes Synchronization Objects (InFlightFrame vector)
 
virtual void RecreateSwapchain ()
 [Internal] Recreates the swapchain
 
void OnResized (VkExtent2D size)
 [Internal] Handler for swapchain resize
 
virtual void PollEvents ()
 [Internal] Polls and distributes events from the SDL subsystem
 
virtual bool CanRenderNextFrame ()
 [Internal] Checks next frames InFlightFrame object for completed execution
 
virtual void Render (RenderLoop::RenderInfo &renderInfo)
 [Internal] Image Acquire, Image Present
 
virtual void OnShadersRecompiled (std::unordered_set< uint64_t > &recompiledShaderKeys)
 [Internal] Shader recompile handler
 
virtual void Destroy ()
 [Internal] Finalizer
 

Protected Attributes

RenderLoop mRenderLoop
 
osi::OsManager mOsManager
 
VulkanInstance mInstance
 
VulkanDevice mDevice
 
VulkanWindowSwapchain mWindowSwapchain
 
core::SamplerCollection mSamplerCollection
 
core::Context mContext
 
core::ShaderManager mShaderManager
 
uint32_t mAuxiliaryCommandBufferCount = 0
 Increase this in an early init method to get auxiliary command buffers.
 
std::array< InFlightFrame, INFLIGHT_FRAME_COUNTmInFlightFrames
 
uint32_t mInFlightFrameIndex = 0
 
uint64_t mRenderedFrameCount = 0
 
std::vector< stages::RenderStage * > mRegisteredStages
 
fp64_t mLastShadersCheckedTimestamp = 0.0
 
bool mEnableFrameRecordBenchmark = false
 
bench::HostBenchmark mHostFrameRecordBenchmark
 

Static Protected Attributes

static const char *const FRAMERECORDBENCH_WAITONFENCE = "Wait On Fence"
 
static const char *const FRAMERECORDBENCH_ACQUIRESWAPIMAGE = "Acquire Swapimage"
 
static const char *const FRAMERECORDBENCH_RECORDCMDBUFFERS = "Record CmdBuffers"
 
static const char *const FRAMERECORDBENCH_PRESENT = "Present"
 

Detailed Description

Intended as base class for demo applications. Compared to MinimalAppBase it offers a complete simple vulkan setup.

Constructor & Destructor Documentation

◆ DefaultAppBase()

foray::base::DefaultAppBase::DefaultAppBase ( )

◆ ~DefaultAppBase()

virtual foray::base::DefaultAppBase::~DefaultAppBase ( )
virtualdefault

Member Function Documentation

◆ ApiBeforeDeviceBuilding()

virtual void foray::base::DefaultAppBase::ApiBeforeDeviceBuilding ( vkb::DeviceBuilder &  deviceBuilder)
inlineprotectedvirtual

Alter device selection.

◆ ApiBeforeDeviceSelection()

virtual void foray::base::DefaultAppBase::ApiBeforeDeviceSelection ( vkb::PhysicalDeviceSelector &  pds)
inlineprotectedvirtual

Alter physical device selection.

◆ ApiBeforeInit()

virtual void foray::base::DefaultAppBase::ApiBeforeInit ( )
inlineprotectedvirtual

Called before any initialization happens.

◆ ApiBeforeInstanceCreate()

virtual void foray::base::DefaultAppBase::ApiBeforeInstanceCreate ( vkb::InstanceBuilder &  instanceBuilder)
inlineprotectedvirtual

Override this method to alter vulkan instance creation parameters via the instance builder.

◆ ApiBeforeSwapchainBuilding()

virtual void foray::base::DefaultAppBase::ApiBeforeSwapchainBuilding ( vkb::SwapchainBuilder &  swapchainBuilder)
inlineprotectedvirtual

Before building the swapchain.

◆ ApiBeforeWindowCreate()

virtual void foray::base::DefaultAppBase::ApiBeforeWindowCreate ( osi::Window window)
inlineprotectedvirtual

Override this method to alter vulkan instance creation parameters via the instance builder.

◆ ApiDestroy()

virtual void foray::base::DefaultAppBase::ApiDestroy ( )
inlineprotectedvirtual

Called after the application has been requested to shut down but before DefaultAppBase finalizes itself.

◆ ApiFrameFinishedExecuting()

virtual void foray::base::DefaultAppBase::ApiFrameFinishedExecuting ( uint64_t  frameIndex)
inlineprotectedvirtual

Called back once the frame of the index has finished executing on the GPU, so QueryResults etc. are ready to be obtained.

Parameters
frameIndexIndex of the frame that has finished executing

◆ ApiInit()

virtual void foray::base::DefaultAppBase::ApiInit ( )
inlineprotectedvirtual

Called after all DefaultAppBase members have been initialized, but before the renderloop starts. Initialize your application here.

◆ ApiOnEvent()

virtual void foray::base::DefaultAppBase::ApiOnEvent ( const osi::Event event)
inlineprotectedvirtual

Override this method to react to events.

◆ ApiOnResized()

virtual void foray::base::DefaultAppBase::ApiOnResized ( VkExtent2D  size)
inlineprotectedvirtual

Called whenever the swapchain has been resized.

Parameters
sizeNew size of the swapchain

◆ ApiOnShadersRecompiled()

virtual void foray::base::DefaultAppBase::ApiOnShadersRecompiled ( std::unordered_set< uint64_t > &  recompiledShaderKeys)
inlineprotectedvirtual

Called whenever the shader compiler has detected a change and shaders have successfully been recompiled.

Parameters
recompiledShaderKeysShader compilation keys as provided by the ShaderManager

◆ ApiRender()

virtual void foray::base::DefaultAppBase::ApiRender ( FrameRenderInfo renderInfo)
inlineprotectedvirtual

Called once every frame. Render your application here.

Parameters
renderInfoFrame specific information

Used command buffers must be fully recorded and submitted by the overrider. The swapchain image must be prepared for present In one of these command buffers!

◆ CanRenderNextFrame()

virtual bool foray::base::DefaultAppBase::CanRenderNextFrame ( )
protectedvirtual

[Internal] Checks next frames InFlightFrame object for completed execution

◆ Destroy()

virtual void foray::base::DefaultAppBase::Destroy ( )
protectedvirtual

[Internal] Finalizer

◆ Init()

virtual void foray::base::DefaultAppBase::Init ( )
protectedvirtual

[Internal] Initializes DefaultAppBase

◆ InitCommandPool()

virtual void foray::base::DefaultAppBase::InitCommandPool ( )
protectedvirtual

[Internal] Initializes Command Pool

◆ InitCreateVma()

virtual void foray::base::DefaultAppBase::InitCreateVma ( )
protectedvirtual

[Internal] Initializes VmaAllocator

◆ InitGetQueue()

virtual void foray::base::DefaultAppBase::InitGetQueue ( )
protectedvirtual

[Internal] Initializes Queue

◆ InitSyncObjects()

virtual void foray::base::DefaultAppBase::InitSyncObjects ( )
protectedvirtual

[Internal] Initializes Synchronization Objects (InFlightFrame vector)

◆ OnResized()

void foray::base::DefaultAppBase::OnResized ( VkExtent2D  size)
inlineprotected

[Internal] Handler for swapchain resize

◆ OnShadersRecompiled()

virtual void foray::base::DefaultAppBase::OnShadersRecompiled ( std::unordered_set< uint64_t > &  recompiledShaderKeys)
protectedvirtual

[Internal] Shader recompile handler

◆ PollEvents()

virtual void foray::base::DefaultAppBase::PollEvents ( )
protectedvirtual

[Internal] Polls and distributes events from the SDL subsystem

◆ RecreateSwapchain()

virtual void foray::base::DefaultAppBase::RecreateSwapchain ( )
protectedvirtual

[Internal] Recreates the swapchain

◆ RegisterRenderStage()

virtual void foray::base::DefaultAppBase::RegisterRenderStage ( stages::RenderStage stage)
protectedvirtual

Call this with a renderstage for automatic OnResized/OnShadersRecompiled calls. Register order is maintained for callbacks.

◆ Render()

virtual void foray::base::DefaultAppBase::Render ( RenderLoop::RenderInfo renderInfo)
protectedvirtual

[Internal] Image Acquire, Image Present

◆ Run()

int32_t foray::base::DefaultAppBase::Run ( )

Runs through the entire application lifetime.

◆ UnregisterRenderStage()

virtual void foray::base::DefaultAppBase::UnregisterRenderStage ( stages::RenderStage stage)
protectedvirtual

Call this with a renderstage to unsubscribe from automatic calls.

Member Data Documentation

◆ FRAMERECORDBENCH_ACQUIRESWAPIMAGE

const char* const foray::base::DefaultAppBase::FRAMERECORDBENCH_ACQUIRESWAPIMAGE = "Acquire Swapimage"
inlinestaticprotected

◆ FRAMERECORDBENCH_PRESENT

const char* const foray::base::DefaultAppBase::FRAMERECORDBENCH_PRESENT = "Present"
inlinestaticprotected

◆ FRAMERECORDBENCH_RECORDCMDBUFFERS

const char* const foray::base::DefaultAppBase::FRAMERECORDBENCH_RECORDCMDBUFFERS = "Record CmdBuffers"
inlinestaticprotected

◆ FRAMERECORDBENCH_WAITONFENCE

const char* const foray::base::DefaultAppBase::FRAMERECORDBENCH_WAITONFENCE = "Wait On Fence"
inlinestaticprotected

◆ mAuxiliaryCommandBufferCount

uint32_t foray::base::DefaultAppBase::mAuxiliaryCommandBufferCount = 0
protected

Increase this in an early init method to get auxiliary command buffers.

◆ mContext

core::Context foray::base::DefaultAppBase::mContext
protected

◆ mDevice

VulkanDevice foray::base::DefaultAppBase::mDevice
protected

◆ mEnableFrameRecordBenchmark

bool foray::base::DefaultAppBase::mEnableFrameRecordBenchmark = false
protected

◆ mHostFrameRecordBenchmark

bench::HostBenchmark foray::base::DefaultAppBase::mHostFrameRecordBenchmark
protected

◆ mInFlightFrameIndex

uint32_t foray::base::DefaultAppBase::mInFlightFrameIndex = 0
protected

◆ mInFlightFrames

std::array<InFlightFrame, INFLIGHT_FRAME_COUNT> foray::base::DefaultAppBase::mInFlightFrames
protected

◆ mInstance

VulkanInstance foray::base::DefaultAppBase::mInstance
protected

◆ mLastShadersCheckedTimestamp

fp64_t foray::base::DefaultAppBase::mLastShadersCheckedTimestamp = 0.0
protected

◆ mOsManager

osi::OsManager foray::base::DefaultAppBase::mOsManager
protected

◆ mRegisteredStages

std::vector<stages::RenderStage*> foray::base::DefaultAppBase::mRegisteredStages
protected

◆ mRenderedFrameCount

uint64_t foray::base::DefaultAppBase::mRenderedFrameCount = 0
protected

◆ mRenderLoop

RenderLoop foray::base::DefaultAppBase::mRenderLoop
protected

◆ mSamplerCollection

core::SamplerCollection foray::base::DefaultAppBase::mSamplerCollection
protected

◆ mShaderManager

core::ShaderManager foray::base::DefaultAppBase::mShaderManager
protected

◆ mWindowSwapchain

VulkanWindowSwapchain foray::base::DefaultAppBase::mWindowSwapchain
protected

The documentation for this class was generated from the following file: