PeriDyno 1.0.0
Loading...
Searching...
No Matches
VkApp Class Reference

#include <VkApp.h>

Collaboration diagram for VkApp:

Classes

struct  Settings
 Example settings that can be changed e.g. by command line arguments. More...
 

Public Member Functions

 VkApp (bool enableValidation=false)
 
virtual ~VkApp ()
 
bool initVulkan ()
 Setup the vulkan instance, enable required extensions and connect to the physical device (GPU)
 
virtual void render ()
 (Pure virtual) Render function to be implemented by the sample application
 
virtual void viewChanged ()
 (Virtual) Called when the camera view has changed
 
virtual void keyPressed (uint32_t)
 (Virtual) Called after a key was pressed, can be used to do custom key handling
 
virtual void mouseMoved (double x, double y, bool &handled)
 (Virtual) Called after the mouse cursor moved and before internal events (like camera rotation) is handled
 
virtual void windowResized ()
 (Virtual) Called when the window has been resized, can be used by the sample application to recreate resources
 
virtual void buildCommandBuffers ()
 (Virtual) Called when resources have been recreated that require a rebuild of the command buffers (e.g. frame buffer), to be implemented by the sample application
 
virtual void setupDepthStencil ()
 (Virtual) Setup default depth and stencil views
 
virtual void setupFrameBuffer ()
 (Virtual) Setup default framebuffers for all requested swapchain images
 
virtual void setupRenderPass ()
 (Virtual) Setup a default renderpass
 
virtual void getEnabledFeatures ()
 (Virtual) Called after the physical device features have been read, can be used to set features to enable on the device
 
virtual void prepare ()
 Prepares all Vulkan resources and functions required to run the sample.
 
VkPipelineShaderStageCreateInfo loadShader (std::string fileName, VkShaderStageFlagBits stage)
 Loads a SPIR-V shader file for the given shader stage.
 
void renderLoop ()
 Entry point for the main render loop.
 
void drawUI (const VkCommandBuffer commandBuffer)
 Adds the drawing commands for the ImGui overlay to the given command buffer.
 
void prepareFrame ()
 
void submitFrame ()
 Presents the current image to the swap chain.
 
virtual void renderFrame ()
 (Virtual) Default image acquire + submission and command buffer submission function
 
virtual void OnUpdateUIOverlay (vks::UIOverlay *overlay)
 (Virtual) Called when the UI overlay is updating, can be used to add custom elements to the overlay
 
void buildCustomCommandBuffer (VkCommandBuffer commandBuffer)
 
void prepare (VkRenderPass renderPass)
 
void setWindowTitle (std::string name)
 
void setSceneGraph (std::shared_ptr< dyno::SceneGraph > scn)
 

Public Attributes

bool swapChainCleaned = false
 
bool prepared = false
 
bool resized = false
 
uint32_t width = 1280
 
uint32_t height = 720
 
vks::UIOverlay UIOverlay
 
float frameTimer = 1.0f
 Last frame time measured using a high performance timer (if available)
 
dyno::VkContextctx
 
struct VkApp::Settings settings
 
VkClearColorValue defaultClearColor = { { 0.025f, 0.025f, 0.025f, 1.0f } }
 
float timer = 0.0f
 
float timerSpeed = 0.25f
 
bool paused = false
 
Camera camera
 
glm::vec2 mousePos
 
std::string title = "Vulkan Example"
 
std::string name = "vulkanExample"
 
uint32_t apiVersion = VK_API_VERSION_1_0
 
struct { 
 
   VkImage   image 
 
   VkDeviceMemory   mem 
 
   VkImageView   view 
 
depthStencil 
 
struct { 
 
   glm::vec2   axisLeft = glm::vec2(0.0f) 
 
   glm::vec2   axisRight = glm::vec2(0.0f) 
 
gamePadState 
 
struct { 
 
   bool   left = false 
 
   bool   right = false 
 
   bool   middle = false 
 
mouseButtons 
 

Static Public Attributes

static std::vector< const char * > args
 

Protected Member Functions

std::string getShadersPath () const
 

Protected Attributes

uint32_t frameCounter = 0
 
uint32_t lastFPS = 0
 
std::chrono::time_point< std::chrono::high_resolution_clock > lastTimestamp
 
std::vector< const char * > enabledDeviceExtensions
 Set of device extensions to be enabled for this example (must be set in the derived constructor)
 
std::vector< const char * > enabledInstanceExtensions
 
void * deviceCreatepNextChain = nullptr
 Optional pNext structure for passing extension structures to device creation.
 
VkFormat depthFormat
 Logical device, application's view of the physical device (GPU)
 
VkCommandPool cmdPool
 
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
 Pipeline stages used to wait at for graphics queue submissions.
 
VkSubmitInfo submitInfo
 
std::vector< VkCommandBuffer > drawCmdBuffers
 
VkRenderPass renderPass
 
std::vector< VkFramebuffer > frameBuffers
 
uint32_t currentBuffer = 0
 
VkDescriptorPool descriptorPool = VK_NULL_HANDLE
 
std::vector< VkShaderModule > shaderModules
 
VulkanSwapChain swapChain
 
struct { 
 
   VkSemaphore   presentComplete 
 
   VkSemaphore   renderComplete 
 
semaphores 
 
std::vector< VkFence > waitFences
 

Private Member Functions

std::string getWindowTitle ()
 
void windowResize ()
 
void handleMouseMove (int32_t x, int32_t y)
 
void nextFrame ()
 
void updateOverlay ()
 
void createCommandPool ()
 
void createSynchronizationPrimitives ()
 
void initSwapchain ()
 
void setupSwapChain ()
 
void createCommandBuffers ()
 
void destroyCommandBuffers ()
 

Private Attributes

bool viewUpdated = false
 
uint32_t destWidth
 
uint32_t destHeight
 
bool resizing = false
 
std::string shaderDir = "glsl"
 

Detailed Description

Definition at line 71 of file VkApp.h.

Constructor & Destructor Documentation

◆ VkApp()

VkApp::VkApp ( bool enableValidation = false)

Definition at line 385 of file VkApp.cpp.

Here is the call graph for this function:

◆ ~VkApp()

VkApp::~VkApp ( )
virtual

Definition at line 426 of file VkApp.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ buildCommandBuffers()

void VkApp::buildCommandBuffers ( )
virtual

(Virtual) Called when resources have been recreated that require a rebuild of the command buffers (e.g. frame buffer), to be implemented by the sample application

Definition at line 1034 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buildCustomCommandBuffer()

void VkApp::buildCustomCommandBuffer ( VkCommandBuffer commandBuffer)

Definition at line 1342 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCommandBuffers()

void VkApp::createCommandBuffers ( )
private

Definition at line 35 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCommandPool()

void VkApp::createCommandPool ( )
private

Definition at line 1089 of file VkApp.cpp.

Here is the caller graph for this function:

◆ createSynchronizationPrimitives()

void VkApp::createSynchronizationPrimitives ( )
private

Definition at line 1079 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroyCommandBuffers()

void VkApp::destroyCommandBuffers ( )
private

Definition at line 49 of file VkApp.cpp.

Here is the caller graph for this function:

◆ drawUI()

void VkApp::drawUI ( const VkCommandBuffer commandBuffer)

Adds the drawing commands for the ImGui overlay to the given command buffer.

Definition at line 345 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEnabledFeatures()

void VkApp::getEnabledFeatures ( )
virtual

(Virtual) Called after the physical device features have been read, can be used to set features to enable on the device

Definition at line 1237 of file VkApp.cpp.

◆ getShadersPath()

std::string VkApp::getShadersPath ( ) const
protected

Definition at line 54 of file VkApp.cpp.

Here is the caller graph for this function:

◆ getWindowTitle()

std::string VkApp::getWindowTitle ( )
private

Definition at line 24 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleMouseMove()

void VkApp::handleMouseMove ( int32_t x,
int32_t y )
private

Definition at line 1291 of file VkApp.cpp.

Here is the call graph for this function:

◆ initSwapchain()

void VkApp::initSwapchain ( )
private

Definition at line 1326 of file VkApp.cpp.

Here is the caller graph for this function:

◆ initVulkan()

bool VkApp::initVulkan ( )

Setup the vulkan instance, enable required extensions and connect to the physical device (GPU)

Definition at line 468 of file VkApp.cpp.

Here is the call graph for this function:

◆ keyPressed()

void VkApp::keyPressed ( uint32_t )
virtual

(Virtual) Called after a key was pressed, can be used to do custom key handling

Definition at line 1030 of file VkApp.cpp.

◆ loadShader()

VkPipelineShaderStageCreateInfo VkApp::loadShader ( std::string fileName,
VkShaderStageFlagBits stage )

Loads a SPIR-V shader file for the given shader stage.

Definition at line 99 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseMoved()

void VkApp::mouseMoved ( double x,
double y,
bool & handled )
virtual

(Virtual) Called after the mouse cursor moved and before internal events (like camera rotation) is handled

Definition at line 1032 of file VkApp.cpp.

Here is the caller graph for this function:

◆ nextFrame()

void VkApp::nextFrame ( )
private

Definition at line 111 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnUpdateUIOverlay()

void VkApp::OnUpdateUIOverlay ( vks::UIOverlay * overlay)
virtual

(Virtual) Called when the UI overlay is updating, can be used to add custom elements to the overlay

Definition at line 1340 of file VkApp.cpp.

Here is the caller graph for this function:

◆ prepare() [1/2]

void VkApp::prepare ( )
virtual

Prepares all Vulkan resources and functions required to run the sample.

Definition at line 59 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare() [2/2]

void VkApp::prepare ( VkRenderPass renderPass)

Definition at line 1361 of file VkApp.cpp.

Here is the call graph for this function:

◆ prepareFrame()

void VkApp::prepareFrame ( )

Prepare the next frame for workload submission by acquiring the next swap chain image

Definition at line 357 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render()

void VkApp::render ( )
virtual

(Pure virtual) Render function to be implemented by the sample application

Definition at line 990 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderFrame()

void VkApp::renderFrame ( )
virtual

(Virtual) Default image acquire + submission and command buffer submission function

Definition at line 15 of file VkApp.cpp.

Here is the call graph for this function:

◆ renderLoop()

void VkApp::renderLoop ( )

Entry point for the main render loop.

Definition at line 156 of file VkApp.cpp.

Here is the call graph for this function:

◆ setSceneGraph()

void VkApp::setSceneGraph ( std::shared_ptr< dyno::SceneGraph > scn)

Definition at line 1384 of file VkApp.cpp.

Here is the call graph for this function:

◆ setupDepthStencil()

void VkApp::setupDepthStencil ( )
virtual

(Virtual) Setup default depth and stencil views

Definition at line 1098 of file VkApp.cpp.

Here is the caller graph for this function:

◆ setupFrameBuffer()

void VkApp::setupFrameBuffer ( )
virtual

(Virtual) Setup default framebuffers for all requested swapchain images

Definition at line 1139 of file VkApp.cpp.

Here is the caller graph for this function:

◆ setupRenderPass()

void VkApp::setupRenderPass ( )
virtual

(Virtual) Setup a default renderpass

Definition at line 1165 of file VkApp.cpp.

Here is the caller graph for this function:

◆ setupSwapChain()

void VkApp::setupSwapChain ( )
private

Definition at line 1335 of file VkApp.cpp.

Here is the caller graph for this function:

◆ setWindowTitle()

void VkApp::setWindowTitle ( std::string name)

Definition at line 1379 of file VkApp.cpp.

◆ submitFrame()

void VkApp::submitFrame ( )

Presents the current image to the swap chain.

Definition at line 370 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateOverlay()

void VkApp::updateOverlay ( )
private

Definition at line 295 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ viewChanged()

void VkApp::viewChanged ( )
virtual

(Virtual) Called when the camera view has changed

Definition at line 1013 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ windowResize()

void VkApp::windowResize ( )
private

Definition at line 1239 of file VkApp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ windowResized()

void VkApp::windowResized ( )
virtual

(Virtual) Called when the window has been resized, can be used by the sample application to recreate resources

Definition at line 1324 of file VkApp.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ apiVersion

uint32_t VkApp::apiVersion = VK_API_VERSION_1_0

Definition at line 183 of file VkApp.h.

◆ args

std::vector<const char*> VkApp::args
static

Definition at line 169 of file VkApp.h.

◆ axisLeft

glm::vec2 VkApp::axisLeft = glm::vec2(0.0f)

Definition at line 192 of file VkApp.h.

◆ axisRight

glm::vec2 VkApp::axisRight = glm::vec2(0.0f)

Definition at line 193 of file VkApp.h.

◆ camera

Camera VkApp::camera

Definition at line 178 of file VkApp.h.

◆ cmdPool

VkCommandPool VkApp::cmdPool
protected

Definition at line 112 of file VkApp.h.

◆ ctx

dyno::VkContext* VkApp::ctx

Definition at line 153 of file VkApp.h.

◆ currentBuffer

uint32_t VkApp::currentBuffer = 0
protected

Definition at line 124 of file VkApp.h.

◆ defaultClearColor

VkClearColorValue VkApp::defaultClearColor = { { 0.025f, 0.025f, 0.025f, 1.0f } }

Definition at line 167 of file VkApp.h.

◆ depthFormat

VkFormat VkApp::depthFormat
protected

Logical device, application's view of the physical device (GPU)

Definition at line 110 of file VkApp.h.

◆ [struct]

struct { ... } VkApp::depthStencil

◆ descriptorPool

VkDescriptorPool VkApp::descriptorPool = VK_NULL_HANDLE
protected

Definition at line 126 of file VkApp.h.

◆ destHeight

uint32_t VkApp::destHeight
private

Definition at line 77 of file VkApp.h.

◆ destWidth

uint32_t VkApp::destWidth
private

Definition at line 76 of file VkApp.h.

◆ deviceCreatepNextChain

void* VkApp::deviceCreatepNextChain = nullptr
protected

Optional pNext structure for passing extension structures to device creation.

Definition at line 104 of file VkApp.h.

◆ drawCmdBuffers

std::vector<VkCommandBuffer> VkApp::drawCmdBuffers
protected

Definition at line 118 of file VkApp.h.

◆ enabledDeviceExtensions

std::vector<const char*> VkApp::enabledDeviceExtensions
protected

Set of device extensions to be enabled for this example (must be set in the derived constructor)

Definition at line 101 of file VkApp.h.

◆ enabledInstanceExtensions

std::vector<const char*> VkApp::enabledInstanceExtensions
protected

Definition at line 102 of file VkApp.h.

◆ frameBuffers

std::vector<VkFramebuffer> VkApp::frameBuffers
protected

Definition at line 122 of file VkApp.h.

◆ frameCounter

uint32_t VkApp::frameCounter = 0
protected

Definition at line 95 of file VkApp.h.

◆ frameTimer

float VkApp::frameTimer = 1.0f

Last frame time measured using a high performance timer (if available)

Definition at line 151 of file VkApp.h.

◆ [struct]

struct { ... } VkApp::gamePadState

◆ height

uint32_t VkApp::height = 720

Definition at line 146 of file VkApp.h.

◆ image

VkImage VkApp::image

Definition at line 186 of file VkApp.h.

◆ lastFPS

uint32_t VkApp::lastFPS = 0
protected

Definition at line 96 of file VkApp.h.

◆ lastTimestamp

std::chrono::time_point<std::chrono::high_resolution_clock> VkApp::lastTimestamp
protected

Definition at line 97 of file VkApp.h.

◆ left

bool VkApp::left = false

Definition at line 197 of file VkApp.h.

◆ mem

VkDeviceMemory VkApp::mem

Definition at line 187 of file VkApp.h.

◆ middle

bool VkApp::middle = false

Definition at line 199 of file VkApp.h.

◆ [struct]

struct { ... } VkApp::mouseButtons

◆ mousePos

glm::vec2 VkApp::mousePos

Definition at line 179 of file VkApp.h.

◆ name

std::string VkApp::name = "vulkanExample"

Definition at line 182 of file VkApp.h.

◆ paused

bool VkApp::paused = false

Definition at line 176 of file VkApp.h.

◆ prepared

bool VkApp::prepared = false

Definition at line 143 of file VkApp.h.

◆ presentComplete

VkSemaphore VkApp::presentComplete

Definition at line 136 of file VkApp.h.

◆ renderComplete

VkSemaphore VkApp::renderComplete

Definition at line 138 of file VkApp.h.

◆ renderPass

VkRenderPass VkApp::renderPass
protected

Definition at line 120 of file VkApp.h.

◆ resized

bool VkApp::resized = false

Definition at line 144 of file VkApp.h.

◆ resizing

bool VkApp::resizing = false
private

Definition at line 78 of file VkApp.h.

◆ right

bool VkApp::right = false

Definition at line 198 of file VkApp.h.

◆ [struct]

struct { ... } VkApp::semaphores

◆ settings

struct VkApp::Settings VkApp::settings

◆ shaderDir

std::string VkApp::shaderDir = "glsl"
private

Definition at line 89 of file VkApp.h.

◆ shaderModules

std::vector<VkShaderModule> VkApp::shaderModules
protected

Definition at line 128 of file VkApp.h.

◆ submitInfo

VkSubmitInfo VkApp::submitInfo
protected

Definition at line 116 of file VkApp.h.

◆ submitPipelineStages

VkPipelineStageFlags VkApp::submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
protected

Pipeline stages used to wait at for graphics queue submissions.

Definition at line 114 of file VkApp.h.

◆ swapChain

VulkanSwapChain VkApp::swapChain
protected

Definition at line 132 of file VkApp.h.

◆ swapChainCleaned

bool VkApp::swapChainCleaned = false

Definition at line 142 of file VkApp.h.

◆ timer

float VkApp::timer = 0.0f

Definition at line 173 of file VkApp.h.

◆ timerSpeed

float VkApp::timerSpeed = 0.25f

Definition at line 175 of file VkApp.h.

◆ title

std::string VkApp::title = "Vulkan Example"

Definition at line 181 of file VkApp.h.

◆ UIOverlay

vks::UIOverlay VkApp::UIOverlay

Definition at line 148 of file VkApp.h.

◆ view

VkImageView VkApp::view

Definition at line 188 of file VkApp.h.

◆ viewUpdated

bool VkApp::viewUpdated = false
private

Definition at line 75 of file VkApp.h.

◆ waitFences

std::vector<VkFence> VkApp::waitFences
protected

Definition at line 140 of file VkApp.h.

◆ width

uint32_t VkApp::width = 1280

Definition at line 145 of file VkApp.h.


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