Nameless Engine
Loading...
Searching...
No Matches
ne::VulkanRenderer Class Reference

#include <VulkanRenderer.h>

Inheritance diagram for ne::VulkanRenderer:
ne::Renderer

Classes

struct  QueueFamilyIndices
 
struct  SwapChainImageSemaphores
 
struct  SwapChainSupportDetails
 

Public Member Functions

 VulkanRenderer (const VulkanRenderer &)=delete
 
VulkanRendereroperator= (const VulkanRenderer &)=delete
 
VkSampler getTextureSampler ()
 
virtual std::vector< std::string > getSupportedGpuNames () const override
 
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, ErrorgetSupportedRenderResolutions () const override
 
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, ErrorgetSupportedRefreshRates () const override
 
virtual RendererType getType () const override
 
virtual std::string getUsedApiVersion () const override
 
virtual std::string getCurrentlyUsedGpuName () const override
 
virtual void waitForGpuToFinishWorkUpToThisPoint () override
 
std::variant< VkCommandBuffer, ErrorcreateOneTimeSubmitCommandBuffer ()
 
std::optional< ErrorsubmitWaitDestroyOneTimeSubmitCommandBuffer (VkCommandBuffer pOneTimeSubmitCommandBuffer)
 
std::optional< ErrortransitionImageLayout (VkImage pImage, VkFormat imageFormat, VkImageAspectFlags aspect, uint32_t levelCount, uint32_t layerCount, VkImageLayout oldLayout, VkImageLayout newLayout)
 
virtual std::pair< unsigned int, unsigned int > getRenderTargetSize () const override
 
VkDevice getLogicalDevice () const
 
VkPhysicalDevice getPhysicalDevice () const
 
VkInstance getInstance () const
 
VkRenderPass getMainRenderPass () const
 
VkRenderPass getDepthOnlyRenderPass () const
 
VkRenderPass getShadowMappingRenderPass (bool bIsForPointLights) const
 
VkCommandPool getCommandPool () const
 
VkQueue getGraphicsQueue () const
 
VkSampler getComputeTextureSampler () const
 
VkSampler getShadowTextureSampler () const
 
std::optional< VkExtent2D > getSwapChainExtent () const
 
VkSampleCountFlagBits getMsaaSampleCount () const
 
virtual GpuResourcegetDepthTextureNoMultisampling () override
 
- Public Member Functions inherited from ne::Renderer
 Renderer (const Renderer &)=delete
 
Rendereroperator= (const Renderer &)=delete
 
virtual std::vector< std::string > getSupportedGpuNames () const =0
 
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, ErrorgetSupportedRenderResolutions () const =0
 
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, ErrorgetSupportedRefreshRates () const =0
 
virtual RendererType getType () const =0
 
virtual std::string getUsedApiVersion () const =0
 
std::pair< std::recursive_mutex *, RenderSettings * > getRenderSettings ()
 
RenderStatisticsgetRenderStatistics ()
 
virtual std::string getCurrentlyUsedGpuName () const =0
 
size_t getTotalVideoMemoryInMb () const
 
size_t getUsedVideoMemoryInMb () const
 
virtual void waitForGpuToFinishWorkUpToThisPoint ()=0
 
virtual std::pair< unsigned int, unsigned int > getRenderTargetSize () const =0
 
WindowgetWindow () const
 
GameManagergetGameManager () const
 
ShaderManagergetShaderManager () const
 
PipelineManagergetPipelineManager () const
 
GpuResourceManagergetResourceManager () const
 
FrameResourceManagergetFrameResourceManager () const
 
ShaderCpuWriteResourceBindingManagergetShaderCpuWriteResourceManager () const
 
ShaderTextureResourceBindingManagergetShaderTextureResourceManager () const
 
LightingShaderResourceManagergetLightingShaderResourceManager () const
 
GlobalShaderResourceBindingManagergetGlobalShaderResourceBindingManager () const
 
std::recursive_mutex * getRenderResourcesMutex ()
 
virtual GpuResourcegetDepthTextureNoMultisampling ()=0
 

Static Public Member Functions

static uint32_t getUsedVulkanVersion ()
 
static constexpr VkFormat getDepthImageFormat ()
 
static constexpr VkFormat getShadowMapFormat ()
 
static constexpr VkFormat getShadowMappingPointLightColorTargetFormat ()
 
static std::variant< std::unique_ptr< Renderer >, std::pair< Error, std::string > > create (GameManager *pGameManager, const std::vector< std::string > &vBlacklistedGpuNames)
 
static void setObjectDebugOnlyName (Renderer *pRenderer, void *pObject, VkObjectType objectType, const std::string &sResourceName)
 
- Static Public Member Functions inherited from ne::Renderer
static constexpr float getMinDepth ()
 
static constexpr float getMaxDepth ()
 
static std::variant< std::unique_ptr< Renderer >, Errorcreate (GameManager *pGameManager, std::optional< RendererType > preferredRenderer)
 

Protected Member Functions

 VulkanRenderer (GameManager *pGameManager)
 
virtual std::variant< AntialiasingQuality, ErrorgetMaxSupportedAntialiasingQuality () const override
 
virtual void onFramebufferSizeChangedDerived (int iWidth, int iHeight) override
 
virtual std::optional< ErroronRenderSettingsChangedDerived () override
 
virtual void waitForGpuToFinishUsingFrameResource (FrameResource *pFrameResource) override
 
virtual bool isInitialized () const override
 
- Protected Member Functions inherited from ne::Renderer
 Renderer (GameManager *pGameManager)
 
std::optional< ErrorcompileEngineShaders () const
 
void updateFrameConstantsBuffer (FrameResource *pCurrentFrameResource, CameraProperties *pCameraProperties)
 
void resetGpuResourceManager ()
 
void resetPipelineManager ()
 
void resetFrameResourceManager ()
 
void resetLightingShaderResourceManager ()
 
virtual std::variant< AntialiasingQuality, ErrorgetMaxSupportedAntialiasingQuality () const =0
 
void onFramebufferSizeChanged (int iWidth, int iHeight)
 
virtual void onFramebufferSizeChangedDerived (int iWidth, int iHeight)
 
void drawNextFrame ()
 
virtual void prepareRenderTargetForNextFrame ()
 
virtual void prepareForDrawingNextFrame (CameraProperties *pCameraProperties, FrameResource *pCurrentFrameResource)=0
 
virtual void drawShadowMappingPass (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, GraphicsPipelineRegistry *pGraphicsPipelines)=0
 
virtual void drawMeshesDepthPrepass (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines)=0
 
virtual void executeComputeShadersOnGraphicsQueue (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, ComputeExecutionStage stage)=0
 
virtual void drawMeshesMainPass (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vTransparentPipelines)=0
 
virtual void present (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex)=0
 
std::optional< ErroronRenderSettingsChanged (bool bShadowMapSizeChanged=false)
 
virtual std::optional< ErroronRenderSettingsChangedDerived ()=0
 
virtual void waitForGpuToFinishUsingFrameResource (FrameResource *pFrameResource)=0
 
virtual bool isInitialized () const =0
 
std::optional< ErrorinitializeRenderer ()
 
std::optional< ErrorinitializeResourceManagers ()
 
std::optional< ErrorclampSettingsToMaxSupported ()
 
std::optional< ErrorrecalculateLightTileFrustums ()
 
MeshesInFrustumgetMeshesInCameraFrustum (CameraProperties *pActiveCameraProperties, GraphicsPipelineRegistry *pGraphicsPipelines)
 
void cullLightsOutsideCameraFrustum (CameraProperties *pActiveCameraProperties, size_t iCurrentFrameResourceIndex)
 
std::pair< std::mutex, FrameConstants > * getFrameConstants ()
 
std::atomic< size_t > * getDrawCallCounter ()
 

Private Member Functions

std::optional< Errorinitialize (const std::vector< std::string > &vBlacklistedGpuNames)
 
std::optional< ErrorinitializeVulkan (const std::vector< std::string > &vBlacklistedGpuNames)
 
std::optional< ErrorcreateVulkanInstance ()
 
std::optional< ErrorcreateWindowSurface ()
 
size_t rateGpuSuitability (VkPhysicalDevice pGpuDevice)
 
std::variant< std::string, ErrorisDeviceSuitable (VkPhysicalDevice pGpu)
 
std::variant< SwapChainSupportDetails, ErrorquerySwapChainSupportDetails (VkPhysicalDevice pGpu)
 
std::variant< VulkanRenderer::QueueFamilyIndices, ErrorqueryQueueFamilyIndices (VkPhysicalDevice pGpu)
 
std::variant< std::string, ErrorisGpuSupportsSwapChain (VkPhysicalDevice pGpu)
 
std::optional< ErrorpickPhysicalDevice (const std::vector< std::string > &vBlacklistedGpuNames)
 
std::optional< ErrorcreateLogicalDevice ()
 
std::optional< ErrorcreateSwapChain ()
 
std::optional< ErrorcreateCommandPool ()
 
std::variant< VkExtent2D, ErrorpickSwapChainExtent (const VkSurfaceCapabilitiesKHR &surfaceCapabilities)
 
std::optional< ErrorcreateRenderPasses (bool bIsRendererInitialization)
 
std::optional< ErrorcreateMainRenderPass ()
 
std::optional< ErrorcreateDepthOnlyRenderPass ()
 
std::optional< ErrorcreateShadowMappingRenderPasses ()
 
void destroySwapChainAndDependentResources (bool bDestroyPipelineManager)
 
std::optional< ErrorcreateTextureSampler ()
 
std::optional< ErrorcreateComputeTextureSampler ()
 
std::optional< ErrorcreateShadowTextureSampler ()
 
bool isUsedDepthImageFormatSupported ()
 
std::optional< ErrorcreateDepthImage ()
 
std::optional< ErrorcreateMsaaImage ()
 
std::optional< ErrorrecreateSwapChainAndDependentResources ()
 
std::optional< ErrorcreateSwapChainFramebuffers ()
 
virtual void prepareRenderTargetForNextFrame () override
 
virtual void prepareForDrawingNextFrame (CameraProperties *pCameraProperties, FrameResource *pCurrentFrameResource) override
 
void startMainRenderPass (VkCommandBuffer pCommandBuffer, size_t iAcquiredImageIndex)
 
void startDepthOnlyRenderPass (VkCommandBuffer pCommandBuffer, size_t iAcquiredImageIndex)
 
virtual void drawShadowMappingPass (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, GraphicsPipelineRegistry *pGraphicsPipelines) override
 
virtual void drawMeshesDepthPrepass (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines) override
 
virtual void executeComputeShadersOnGraphicsQueue (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, ComputeExecutionStage stage) override
 
virtual void drawMeshesMainPass (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vTransparentPipelines) override
 
virtual void present (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex) override
 
void drawMeshesMainPassSpecificPipelines (const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &pipelinesOfSpecificType, VkCommandBuffer pCommandBuffer, size_t iCurrentFrameResourceIndex)
 
std::optional< ErrorupdateMsaaSampleCount ()
 

Static Private Member Functions

static std::variant< std::vector< const char * >, ErrorgetRequiredVulkanInstanceExtensions ()
 
static std::variant< std::string, ErrorisGpuSupportsUsedDeviceExtensions (VkPhysicalDevice pGpuDevice)
 
static void startShadowMappingRenderPass (VkRenderPass pShadowMappingRenderPass, VkCommandBuffer pCommandBuffer, VkFramebuffer pFramebufferToUse, uint32_t iShadowMapSize)
 
static bool dispatchComputeShadersOnGraphicsQueue (VulkanFrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, std::unordered_map< Pipeline *, std::unordered_set< ComputeShaderInterface * > > &computePipelinesToSubmit)
 

Private Attributes

VkInstance pInstance = nullptr
 
VkSurfaceKHR pWindowSurface = nullptr
 
VkPhysicalDevice pPhysicalDevice = nullptr
 
VkDevice pLogicalDevice = nullptr
 
VkQueue pGraphicsQueue = nullptr
 
VkQueue pPresentQueue = nullptr
 
VkSwapchainKHR pSwapChain = nullptr
 
std::unique_ptr< VulkanResourcepDepthImage = nullptr
 
std::unique_ptr< VulkanResourcepDepthImageNoMultisampling = nullptr
 
std::unique_ptr< VulkanResourcepMsaaImage = nullptr
 
VkRenderPass pDepthOnlyRenderPass = nullptr
 
VkRenderPass pMainRenderPass = nullptr
 
VkRenderPass pShadowMappingDirectionalSpotRenderPass = nullptr
 
VkRenderPass pShadowMappingPointRenderPass = nullptr
 
VkCommandPool pCommandPool = nullptr
 
VkSampler pTextureSampler = nullptr
 
VkSampler pComputeTextureSampler = nullptr
 
VkSampler pShadowTextureSampler = nullptr
 
std::vector< VkImage > vSwapChainImages
 
std::vector< VkImageView > vSwapChainImageViews
 
std::vector< VkFramebuffer > vSwapChainFramebuffersMainRenderPass
 
std::vector< VkFramebuffer > vSwapChainFramebuffersDepthOnlyRenderPass
 
std::vector< std::pair< VkFence, size_t > > vSwapChainImageFenceRefs
 
std::vector< SwapChainImageSemaphoresvImageSemaphores
 
size_t iCurrentImageSemaphore = 0
 
std::vector< std::string > vSupportedGpuNames
 
std::string sUsedGpuName
 
QueueFamilyIndices physicalDeviceQueueFamilyIndices
 
std::optional< VkExtent2D > swapChainExtent
 
VkSampleCountFlagBits msaaSampleCount = VK_SAMPLE_COUNT_1_BIT
 
uint32_t iSwapChainImageCount = 0
 
uint32_t iLastAcquiredImageIndex = 0
 
bool bIsVulkanInitialized = false
 
bool bNeedToRecreateSwapchain = false
 
bool bIsUsingMsaaRenderTarget = false
 
bool bIsBeingDestroyed = false
 

Static Private Attributes

static constexpr size_t iMainRenderPassColorAttachmentIndex = 0
 
static constexpr size_t iMainRenderPassDepthAttachmentIndex = 1
 
static constexpr size_t iMainRenderPassColorResolveTargetAttachmentIndex = 2
 
static constexpr size_t iDepthOnlyRenderPassDepthImageAttachmentIndex = 0
 
static constexpr size_t iDepthOnlyRenderPassDepthResolveTargetAttachmentIndex = 1
 
static constexpr auto swapChainImageFormat = VK_FORMAT_B8G8R8A8_UNORM
 
static constexpr auto swapChainImageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
 
static constexpr auto depthImageFormat = VK_FORMAT_D32_SFLOAT
 
static constexpr auto shadowMapFormat = VK_FORMAT_D32_SFLOAT
 
static constexpr auto shadowMappingPointLightColorTargetFormat = VK_FORMAT_R32_SFLOAT
 
static constexpr auto depthImageTiling = VK_IMAGE_TILING_OPTIMAL
 
static constexpr auto indexTypeFormat = VK_INDEX_TYPE_UINT32
 
static constexpr auto depthResolveMode = VK_RESOLVE_MODE_MAX_BIT
 
static constexpr auto stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT
 
static constexpr uint32_t iUsedVulkanVersion = VK_API_VERSION_1_2
 
static const std::vector< const char * > vUsedDeviceExtensionNames
 

Additional Inherited Members

- Static Protected Member Functions inherited from ne::Renderer
static consteval unsigned int getRecommendedSwapChainBufferCount ()
 
static void getDirectionalLightNodeShadowMappingInfo (DirectionalLightNode *pNode, ShadowMapHandle *&pShadowMapHandle, unsigned int &iShadowPassLightInfoArrayIndex)
 
static void getSpotlightNodeShadowMappingInfo (SpotlightNode *pNode, ShadowMapHandle *&pShadowMapHandle, unsigned int &iShadowPassLightInfoArrayIndex)
 
static unsigned int getPointLightShadowPassLightInfoArrayIndex (PointLightNode *pNode, size_t iCubemapFaceIndex)
 
static ShadowMapHandlegetPointLightNodeShadowMapHandle (PointLightNode *pNode)
 

Detailed Description

Renderer made with Vulkan API.

Constructor & Destructor Documentation

◆ VulkanRenderer()

ne::VulkanRenderer::VulkanRenderer ( GameManager pGameManager)
protected

Creates an empty (uninitialized) renderer.

Remarks
Use initialize to initialize the renderer.
Parameters
pGameManagerGameManager object that owns this renderer.

Member Function Documentation

◆ create()

std::variant< std::unique_ptr< Renderer >, std::pair< Error, std::string > > ne::VulkanRenderer::create ( GameManager pGameManager,
const std::vector< std::string > &  vBlacklistedGpuNames 
)
static

Creates a new DirectX renderer.

Parameters
pGameManagerGameManager object that owns this renderer.
vBlacklistedGpuNamesNames of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong.
Returns
Created renderer if successful, otherwise multiple values in a pair: error and a name of the GPU that the renderer tried to use (can be empty if failed before picking a GPU or if all supported GPUs are blacklisted).

◆ createCommandPool()

std::optional< Error > ne::VulkanRenderer::createCommandPool ( )
private

Creates pCommandPool.

Warning
Expects pLogicalDevice to be valid.
Returns
Error if something went wrong.

◆ createComputeTextureSampler()

std::optional< Error > ne::VulkanRenderer::createComputeTextureSampler ( )
private

Creates pComputeTextureSampler.

Warning
Expects that pLogicalDevice is valid.
Expected to be called only once so that this sampler will never be re-created.
Returns
Error if something went wrong.

◆ createDepthImage()

std::optional< Error > ne::VulkanRenderer::createDepthImage ( )
private

Creates pDepthImage.

Warning
Expects that GPU resource manager and swapChainExtent are valid.
Returns
Error if something went wrong.

◆ createDepthOnlyRenderPass()

std::optional< Error > ne::VulkanRenderer::createDepthOnlyRenderPass ( )
private

Creates pDepthOnlyRenderPass (z-prepass) using the current msaaSampleCount.

Warning
Expects pLogicalDevice to be valid.
Returns
Error if something went wrong.

◆ createLogicalDevice()

std::optional< Error > ne::VulkanRenderer::createLogicalDevice ( )
private

Creates pLogicalDevice.

Warning
Expects pPhysicalDevice to be valid.
Returns
Error if something went wrong.

◆ createMainRenderPass()

std::optional< Error > ne::VulkanRenderer::createMainRenderPass ( )
private

Creates pMainRenderPass using the current msaaSampleCount.

Warning
Expects pLogicalDevice to be valid.
Returns
Error if something went wrong.

◆ createMsaaImage()

std::optional< Error > ne::VulkanRenderer::createMsaaImage ( )
private

Creates pMsaaImage using the current msaaSampleCount (does nothing if only 1 sample is used).

Warning
Expects that GPU resource manager and swapChainExtent are valid.
Returns
Error if something went wrong.

◆ createOneTimeSubmitCommandBuffer()

std::variant< VkCommandBuffer, Error > ne::VulkanRenderer::createOneTimeSubmitCommandBuffer ( )

Creates a new one-time submit command buffer to be later used with submitWaitDestroyOneTimeSubmitCommandBuffer.

Returns
Error if something went wrong, otherwise created command buffer.

◆ createRenderPasses()

std::optional< Error > ne::VulkanRenderer::createRenderPasses ( bool  bIsRendererInitialization)
private

Creates render passes using the current msaaSampleCount.

Warning
Expects pLogicalDevice to be valid.
Parameters
bIsRendererInitializationSpecify true if the renderer is doing initialization, false if some render settings (or similar) was changed and the renderer re-creates resources that may depend on changed settings/parameters.
Returns
Error if something went wrong.

◆ createShadowMappingRenderPasses()

std::optional< Error > ne::VulkanRenderer::createShadowMappingRenderPasses ( )
private

Creates render passes used in shadow mapping.

Warning
Expects pLogicalDevice to be valid.
Returns
Error if something went wrong.

◆ createShadowTextureSampler()

std::optional< Error > ne::VulkanRenderer::createShadowTextureSampler ( )
private

Creates sampler for shadow mapping.

Warning
Expects that pLogicalDevice is valid.
Expected to be called only once so that this sampler will never be re-created.
Returns
Error if something went wrong.

◆ createSwapChain()

std::optional< Error > ne::VulkanRenderer::createSwapChain ( )
private

Creates pSwapChain.

Warning
Expects pPhysicalDevice to be valid.
Returns
Error if something went wrong.

◆ createSwapChainFramebuffers()

std::optional< Error > ne::VulkanRenderer::createSwapChainFramebuffers ( )
private

Creates swap chain framebuffers.

Returns
Error if something went wrong.

◆ createTextureSampler()

std::optional< Error > ne::VulkanRenderer::createTextureSampler ( )
private

Creates pTextureSampler using the current texture filtering mode from the render settings.

Warning
Expects that pLogicalDevice is valid.
Returns
Error if something went wrong.

◆ createVulkanInstance()

std::optional< Error > ne::VulkanRenderer::createVulkanInstance ( )
private

Creates Vulkan API instance.

Returns
Error if something went wrong.

◆ createWindowSurface()

std::optional< Error > ne::VulkanRenderer::createWindowSurface ( )
private

Creates Vulkan window representation object.

Remarks
Should be called after createVulkanInstance but before pickPhysicalDevice as window surface is used when picking a device.
Returns
Error if something went wrong.

◆ destroySwapChainAndDependentResources()

void ne::VulkanRenderer::destroySwapChainAndDependentResources ( bool  bDestroyPipelineManager)
private

Destroys swap chain, framebuffers, graphics pipeline, render pass, image views, frees command buffers and other objects that depend on the swap chain images.

Parameters
bDestroyPipelineManagertrue to destroy the pipeline manager, this is generally used when the renderer is being destroyed, otherwise if you just want to recreate some resources specify false and make sure all pipeline resources were released and will not be restored before this function is finished.

◆ dispatchComputeShadersOnGraphicsQueue()

bool ne::VulkanRenderer::dispatchComputeShadersOnGraphicsQueue ( VulkanFrameResource pCurrentFrameResource,
size_t  iCurrentFrameResourceIndex,
std::unordered_map< Pipeline *, std::unordered_set< ComputeShaderInterface * > > &  computePipelinesToSubmit 
)
staticprivate

Submits compute dispatch commands using pGraphicsQueue.

Parameters
pCurrentFrameResourceCurrent frame resource.
iCurrentFrameResourceIndexIndex of the current frame resource.
computePipelinesToSubmitCompute shaders and their pipelines to dispatch.
Returns
true if dispatched some shaders, false if nothing to dispatch.

◆ drawMeshesDepthPrepass()

void ne::VulkanRenderer::drawMeshesDepthPrepass ( FrameResource pCurrentFrameResource,
size_t  iCurrentFrameResourceIndex,
const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &  vOpaquePipelines 
)
overrideprivatevirtual

Submits commands to draw meshes and the specified depth only (vertex shader only) pipelines.

Parameters
pCurrentFrameResourceFrame resource of the frame being submitted.
iCurrentFrameResourceIndexIndex of the current frame resource.
vOpaquePipelinesOpaque pipelines (depth pipeline will be retrieved from them).

Implements ne::Renderer.

◆ drawMeshesMainPass()

void ne::VulkanRenderer::drawMeshesMainPass ( FrameResource pCurrentFrameResource,
size_t  iCurrentFrameResourceIndex,
const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &  vOpaquePipelines,
const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &  vTransparentPipelines 
)
overrideprivatevirtual

Submits commands to draw meshes for main (color) pass.

Parameters
pCurrentFrameResourceFrame resource of the frame being submitted.
iCurrentFrameResourceIndexIndex of the current frame resource.
vOpaquePipelinesOpaque pipelines to draw.
vTransparentPipelinesTransparent pipelines to draw.

Implements ne::Renderer.

◆ drawMeshesMainPassSpecificPipelines()

void ne::VulkanRenderer::drawMeshesMainPassSpecificPipelines ( const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &  pipelinesOfSpecificType,
VkCommandBuffer  pCommandBuffer,
size_t  iCurrentFrameResourceIndex 
)
private

Submits commands to draw meshes and pipelines of specific types (only opaque or transparent).

Parameters
pipelinesOfSpecificTypePipelines to use.
pCommandBufferCommand buffer to use.
iCurrentFrameResourceIndexIndex of the current frame resource.

◆ drawShadowMappingPass()

void ne::VulkanRenderer::drawShadowMappingPass ( FrameResource pCurrentFrameResource,
size_t  iCurrentFrameResourceIndex,
GraphicsPipelineRegistry pGraphicsPipelines 
)
overrideprivatevirtual

Submits commands to draw world from the perspective of all spawned light sources to capture shadow maps.

Parameters
pCurrentFrameResourceFrame resource of the frame being submitted.
iCurrentFrameResourceIndexIndex of the current frame resource.
pGraphicsPipelinesGraphics pipelines to draw.

Implements ne::Renderer.

◆ executeComputeShadersOnGraphicsQueue()

void ne::VulkanRenderer::executeComputeShadersOnGraphicsQueue ( FrameResource pCurrentFrameResource,
size_t  iCurrentFrameResourceIndex,
ComputeExecutionStage  stage 
)
overrideprivatevirtual

Executes compute shaders of the specified stage.

Warning
Expects that mutex for compute shaders is locked.
Parameters
pCurrentFrameResourceFrame resource of the frame being submitted.
iCurrentFrameResourceIndexIndex of the current frame resource.
stageStage of compute shaders to execute.

Implements ne::Renderer.

◆ getCommandPool()

VkCommandPool ne::VulkanRenderer::getCommandPool ( ) const

Returns Vulkan command pool used in the renderer.

Returns
nullptr if command pool is not created yet, otherwise used command pool.

◆ getComputeTextureSampler()

VkSampler ne::VulkanRenderer::getComputeTextureSampler ( ) const

Returns Vulkan texture sampler for fetching texels in compute shaders.

Remarks
Used for compute shaders that need to read textures.
Guaranteed to never be re-created.
Returns
nullptr if not created yet, otherwise valid sampler.

◆ getCurrentlyUsedGpuName()

std::string ne::VulkanRenderer::getCurrentlyUsedGpuName ( ) const
overridevirtual

Returns the name of the GPU that is being currently used.

Returns
Name of the GPU.

Implements ne::Renderer.

◆ getDepthImageFormat()

static constexpr VkFormat ne::VulkanRenderer::getDepthImageFormat ( )
inlinestaticconstexpr

Returns format used for depth image.

Returns
Format.

◆ getDepthOnlyRenderPass()

VkRenderPass ne::VulkanRenderer::getDepthOnlyRenderPass ( ) const

Returns depth only render pass (z-prepass).

Returns
nullptr if render pass is not created yet, otherwise valid pointer.

◆ getDepthTextureNoMultisampling()

GpuResource * ne::VulkanRenderer::getDepthTextureNoMultisampling ( )
overridevirtual

Returns pointer to the texture resource that represents renderer's depth texture without multisampling (resolved resource).

Warning
If MSAA is enabled this function will return one resource (pointer to a separate depth resolved resource), if it's disabled it will return the other resource (pointer to depth texture). So it may be a good idea to query this pointer every time you need it instead of saving it and reusing it because every frame this pointer may change (due to other reasons such as render target resize and etc).
Returns
Pointer to depth texture.

Implements ne::Renderer.

◆ getGraphicsQueue()

VkQueue ne::VulkanRenderer::getGraphicsQueue ( ) const

Returns Vulkan graphics queue used in the renderer.

Returns
nullptr if graphics queue is not created yet, otherwise used graphics queue.

◆ getInstance()

VkInstance ne::VulkanRenderer::getInstance ( ) const

Returns Vulkan instance used in the renderer.

Returns
nullptr if Vulkan instance is not created yet, otherwise used Vulkan instance.

◆ getLogicalDevice()

VkDevice ne::VulkanRenderer::getLogicalDevice ( ) const

Returns logical device used in the renderer.

Returns
nullptr if logical device is not created yet, otherwise used logical device.

◆ getMainRenderPass()

VkRenderPass ne::VulkanRenderer::getMainRenderPass ( ) const

Returns main render pass.

Returns
nullptr if render pass is not created yet, otherwise valid pointer.

◆ getMaxSupportedAntialiasingQuality()

std::variant< AntialiasingQuality, Error > ne::VulkanRenderer::getMaxSupportedAntialiasingQuality ( ) const
overrideprotectedvirtual

Returns the maximum anti-aliasing quality that can be used on the picked GPU (getCurrentlyUsedGpuName).

Remarks
Note that the maximum supported AA quality can differ depending on the used GPU/renderer.
Returns
Error if something went wrong, otherwise DISABLED if AA is not supported or the maximum supported AA quality.

Implements ne::Renderer.

◆ getMsaaSampleCount()

VkSampleCountFlagBits ne::VulkanRenderer::getMsaaSampleCount ( ) const

Returns sample count of the current MSAA quality.

Returns
MSAA sample count.

◆ getPhysicalDevice()

VkPhysicalDevice ne::VulkanRenderer::getPhysicalDevice ( ) const

Returns physical device used in the renderer.

Returns
nullptr if physical device is not created yet, otherwise used physical device.

◆ getRenderTargetSize()

std::pair< unsigned int, unsigned int > ne::VulkanRenderer::getRenderTargetSize ( ) const
overridevirtual

Returns size of the render target (size of the underlying render image).

Returns
Render image size in pixels (width and height).

Implements ne::Renderer.

◆ getRequiredVulkanInstanceExtensions()

std::variant< std::vector< const char * >, Error > ne::VulkanRenderer::getRequiredVulkanInstanceExtensions ( )
staticprivate

Returns names of essential Vulkan instance extensions that the renderer will use.

Returns
Names of Vulkan instance extension.

◆ getShadowMapFormat()

static constexpr VkFormat ne::VulkanRenderer::getShadowMapFormat ( )
inlinestaticconstexpr

Returns texture format used for shadow maps.

Returns
Shadow map format.

◆ getShadowMappingPointLightColorTargetFormat()

static constexpr VkFormat ne::VulkanRenderer::getShadowMappingPointLightColorTargetFormat ( )
inlinestaticconstexpr

Returns texture format used for point lights as "color" target (does not actually store color) during shadow pass.

Returns
Shadow map format.

◆ getShadowMappingRenderPass()

VkRenderPass ne::VulkanRenderer::getShadowMappingRenderPass ( bool  bIsForPointLights) const

Returns render pass used for shadow mapping.

Parameters
bIsForPointLightsSpecify false if you need render pass for shadow mapping of directional and spot lights, otherwise specify true to get render pass for shadow mapping of point lights.
Returns
nullptr if render pass is not created yet, otherwise valid pointer.

◆ getShadowTextureSampler()

VkSampler ne::VulkanRenderer::getShadowTextureSampler ( ) const

Returns Vulkan texture sampler for sampling shadow textures.

Remarks
Guaranteed to never be re-created.
Returns
nullptr if not created yet, otherwise valid sampler.

◆ getSupportedGpuNames()

std::vector< std::string > ne::VulkanRenderer::getSupportedGpuNames ( ) const
overridevirtual

Looks for video adapters (GPUs) that support this renderer.

Remarks
Note that returned array might differ depending on the used renderer.
Returns
Empty array if no GPU supports used renderer, otherwise array with GPU names that can be used for this renderer.

Implements ne::Renderer.

◆ getSupportedRefreshRates()

std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > ne::VulkanRenderer::getSupportedRefreshRates ( ) const
overridevirtual

Returns a list of supported screen refresh rates (pairs of numerator and denominator).

Remarks
The list of supported refresh rates depends on the currently used GPU, so if changing used GPU this list might return different values.
Returns
Error if something went wrong, otherwise refresh rates.

Implements ne::Renderer.

◆ getSupportedRenderResolutions()

std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > ne::VulkanRenderer::getSupportedRenderResolutions ( ) const
overridevirtual

Returns a list of supported render resolution (pairs of width and height).

Returns
Error if something went wrong, otherwise render resolutions.

Implements ne::Renderer.

◆ getSwapChainExtent()

std::optional< VkExtent2D > ne::VulkanRenderer::getSwapChainExtent ( ) const

Returns the size of images in the swap chain.

Returns
Empty if the swap chain is not initialized, otherwise the size of images in the swap chain.

◆ getTextureSampler()

VkSampler ne::VulkanRenderer::getTextureSampler ( )

Returns sampler for textures.

Returns
nullptr if not created yet, otherwise valid pointer.

◆ getType()

RendererType ne::VulkanRenderer::getType ( ) const
overridevirtual

Returns renderer's type.

Returns
Renderer's type.

Implements ne::Renderer.

◆ getUsedApiVersion()

std::string ne::VulkanRenderer::getUsedApiVersion ( ) const
overridevirtual

Returns API version or a feature level that the renderer uses.

For example DirectX renderer will return used feature level and Vulkan renderer will return used Vulkan API version.

Returns
Used API version.

Implements ne::Renderer.

◆ getUsedVulkanVersion()

uint32_t ne::VulkanRenderer::getUsedVulkanVersion ( )
static

Returns used Vulkan API version.

Returns
Vulkan API version that the renderer uses.

◆ initialize()

std::optional< Error > ne::VulkanRenderer::initialize ( const std::vector< std::string > &  vBlacklistedGpuNames)
private

Initializes the renderer.

Remarks
This function is usually called after constructing a new empty (uninitialized) Vulkan renderer.
Parameters
vBlacklistedGpuNamesNames of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong.
Returns
Error if something went wrong (for ex. if the hardware does not support this renderer).

◆ initializeVulkan()

std::optional< Error > ne::VulkanRenderer::initializeVulkan ( const std::vector< std::string > &  vBlacklistedGpuNames)
private

Initializes essential Vulkan entities.

Parameters
vBlacklistedGpuNamesNames of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong.
Returns
Error if something went wrong.

◆ isDeviceSuitable()

std::variant< std::string, Error > ne::VulkanRenderer::isDeviceSuitable ( VkPhysicalDevice  pGpu)
private

Checks if the specified GPU fits all essential requirements of the renderer.

Parameters
pGpuGPU to test.
Returns
Empty string if the GPU is suitable, non-empty string with description on what the specified GPU does not support, error message if an internal error occurred.

◆ isGpuSupportsSwapChain()

std::variant< std::string, Error > ne::VulkanRenderer::isGpuSupportsSwapChain ( VkPhysicalDevice  pGpu)
private

Checks if the specified GPU supports all used swap chain formats/modes.

Warning
Make sure to check that device extension VK_KHR_SWAPCHAIN_EXTENSION_NAME is supported before calling this function.
Remarks
Expects pWindowSurface to be valid.
Parameters
pGpuGPU to test.
Returns
Empty string if the GPU suits swap chain requirements, non-empty string with description on what the specified GPU does not support, error message if an internal error occurred.

◆ isGpuSupportsUsedDeviceExtensions()

std::variant< std::string, Error > ne::VulkanRenderer::isGpuSupportsUsedDeviceExtensions ( VkPhysicalDevice  pGpuDevice)
staticprivate

Checks if the specified physical device supports used device extensions.

Parameters
pGpuDeviceGPU to check.
Returns
Empty string if the GPU supports all used device extensions, non-empty string with device extension name that the specified GPU does not support, error message if an internal error occurred.

◆ isInitialized()

bool ne::VulkanRenderer::isInitialized ( ) const
overrideprotectedvirtual

Tells whether the renderer is initialized or not.

Initialized renderer means that the hardware supports it and it's safe to use renderer functionality such as onRenderSettingsChanged.

Returns
Whether the renderer is initialized or not.

Implements ne::Renderer.

◆ isUsedDepthImageFormatSupported()

bool ne::VulkanRenderer::isUsedDepthImageFormatSupported ( )
private

Tells if depthImageFormat is supported by the hardware.

Returns
true if supported, false otherwise.

◆ onFramebufferSizeChangedDerived()

void ne::VulkanRenderer::onFramebufferSizeChangedDerived ( int  iWidth,
int  iHeight 
)
overrideprotectedvirtual

Called when the framebuffer size was changed.

Parameters
iWidthNew width of the framebuffer (in pixels).
iHeightNew height of the framebuffer (in pixels).

Reimplemented from ne::Renderer.

◆ onRenderSettingsChangedDerived()

std::optional< Error > ne::VulkanRenderer::onRenderSettingsChangedDerived ( )
overrideprotectedvirtual

Called after some render setting is changed to recreate internal resources to match the current settings.

Returns
Error if something went wrong.

Implements ne::Renderer.

◆ pickPhysicalDevice()

std::optional< Error > ne::VulkanRenderer::pickPhysicalDevice ( const std::vector< std::string > &  vBlacklistedGpuNames)
private

Picks the first GPU that fits renderer's needs.

Warning
Expects pInstance to be valid.
Parameters
vBlacklistedGpuNamesNames of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong.
Returns
Error if something went wrong.

◆ pickSwapChainExtent()

std::variant< VkExtent2D, Error > ne::VulkanRenderer::pickSwapChainExtent ( const VkSurfaceCapabilitiesKHR &  surfaceCapabilities)
private

Chooses the appropriate swap chain size.

Parameters
surfaceCapabilitiesPhysical device surface's swap chain surface capabilities.
Returns
Error if something went wrong, otherwise swap chain size to use.

◆ prepareForDrawingNextFrame()

void ne::VulkanRenderer::prepareForDrawingNextFrame ( CameraProperties pCameraProperties,
FrameResource pCurrentFrameResource 
)
overrideprivatevirtual

Setups everything for render commands to be recorded (resets command buffers and etc.).

Warning
Expects that render resources mutex is locked.
Remarks
When this function is called this means that the current frame resource is no longer used by the GPU.
Parameters
pCameraPropertiesCamera properties to use.
pCurrentFrameResourceFrame resource of the frame being submitted.

Implements ne::Renderer.

◆ prepareRenderTargetForNextFrame()

void ne::VulkanRenderer::prepareRenderTargetForNextFrame ( )
overrideprivatevirtual

Called before prepareForDrawingNextFrame to do early frame preparations.

Remarks
It's expected that render target's size will not change after this function is finished and before a new frame is submitted.

Reimplemented from ne::Renderer.

◆ present()

void ne::VulkanRenderer::present ( FrameResource pCurrentFrameResource,
size_t  iCurrentFrameResourceIndex 
)
overrideprivatevirtual

Does the final frame rendering logic to present the frame on the screen.

Parameters
pCurrentFrameResourceFrame resource of the frame being submitted.
iCurrentFrameResourceIndexIndex of the current frame resource.

Implements ne::Renderer.

◆ queryQueueFamilyIndices()

std::variant< VulkanRenderer::QueueFamilyIndices, Error > ne::VulkanRenderer::queryQueueFamilyIndices ( VkPhysicalDevice  pGpu)
private

Retrieves the information about used queue families and their indices.

Parameters
pGpuGPU to query for queue families.
Remarks
Expects pWindowSurface to be valid.
Returns
Error if something went wrong, otherwise indices of used queue families returned by vkGetPhysicalDeviceQueueFamilyProperties.

◆ querySwapChainSupportDetails()

std::variant< VulkanRenderer::SwapChainSupportDetails, Error > ne::VulkanRenderer::querySwapChainSupportDetails ( VkPhysicalDevice  pGpu)
private

Queries swap chain support details from the specified GPU.

Warning
Make sure to check that device extension VK_KHR_SWAPCHAIN_EXTENSION_NAME is supported before calling this function.
Remarks
Expects pWindowSurface to be valid.
Parameters
pGpuGPU to test.
Returns
Error if something went wrong, otherwise swap chain support details.

◆ rateGpuSuitability()

size_t ne::VulkanRenderer::rateGpuSuitability ( VkPhysicalDevice  pGpuDevice)
private

Tells how good the specified GPU suits the renderer's needs.

Parameters
pGpuDeviceGPU to test.
Returns
Zero if this GPU cannon be used (see logs for description), otherwise GPU's score (to compare with others).

◆ recreateSwapChainAndDependentResources()

std::optional< Error > ne::VulkanRenderer::recreateSwapChainAndDependentResources ( )
private

Recreates pSwapChain and all dependent resources after it was created using createSwapChain.

Returns
Error if something went wrong.

◆ setObjectDebugOnlyName()

void ne::VulkanRenderer::setObjectDebugOnlyName ( Renderer pRenderer,
void *  pObject,
VkObjectType  objectType,
const std::string &  sResourceName 
)
static

Sets name of the object for debugging purposes using Vulkan's debugging utils extension.

Remarks
Does nothing in release builds.
Parameters
pRendererVulkan renderer.
pObjectObject to name.
objectTypeType of the object.
sResourceNameName to set.

◆ startDepthOnlyRenderPass()

void ne::VulkanRenderer::startDepthOnlyRenderPass ( VkCommandBuffer  pCommandBuffer,
size_t  iAcquiredImageIndex 
)
private

Adds render pass start commands to the specified command buffer with pDepthOnlyRenderPass.

Parameters
pCommandBufferCommand buffer to modify.
iAcquiredImageIndexIndex of the framebuffer to use.

◆ startMainRenderPass()

void ne::VulkanRenderer::startMainRenderPass ( VkCommandBuffer  pCommandBuffer,
size_t  iAcquiredImageIndex 
)
private

Adds render pass start commands to the specified command buffer with pMainRenderPass.

Parameters
pCommandBufferCommand buffer to modify.
iAcquiredImageIndexIndex of the framebuffer to use.

◆ startShadowMappingRenderPass()

void ne::VulkanRenderer::startShadowMappingRenderPass ( VkRenderPass  pShadowMappingRenderPass,
VkCommandBuffer  pCommandBuffer,
VkFramebuffer  pFramebufferToUse,
uint32_t  iShadowMapSize 
)
staticprivate

Adds render pass start commands to the specified command buffer with the specified shadow mapping render pass.

Parameters
pShadowMappingRenderPasspShadowMappingDirectionalSpotRenderPass or pShadowMappingPointRenderPass.
pCommandBufferCommand buffer to modify.
pFramebufferToUseFramebuffer to use.
iShadowMapSizeSize of the framebuffer image.

◆ submitWaitDestroyOneTimeSubmitCommandBuffer()

std::optional< Error > ne::VulkanRenderer::submitWaitDestroyOneTimeSubmitCommandBuffer ( VkCommandBuffer  pOneTimeSubmitCommandBuffer)

Submits a one-time submit command buffer created by createOneTimeSubmitCommandBuffer, then waits for a temporary fence to be signaled (meaning that submitted commands were executed on the GPU) and destroys the command buffer.

Parameters
pOneTimeSubmitCommandBufferCommand buffer created by createOneTimeSubmitCommandBuffer with recorded commands to submit.
Returns
Error if something went wrong.

◆ transitionImageLayout()

std::optional< Error > ne::VulkanRenderer::transitionImageLayout ( VkImage  pImage,
VkFormat  imageFormat,
VkImageAspectFlags  aspect,
uint32_t  levelCount,
uint32_t  layerCount,
VkImageLayout  oldLayout,
VkImageLayout  newLayout 
)

Creates a one-time submit command buffer to change image layout.

Parameters
pImageImage to use.
imageFormatImage format.
aspectAspect of the image that will be affected.
levelCountDefines how much mipmaps will be affected.
layerCountDefines how much image layers will be affected.
oldLayoutOld (current) image layout.
newLayoutNew image layout.
Returns
Error if something went wrong.

◆ updateMsaaSampleCount()

std::optional< Error > ne::VulkanRenderer::updateMsaaSampleCount ( )
private

Queries the current render settings for MSAA quality and updates msaaSampleCount.

Returns
Error if something went wrong.

◆ waitForGpuToFinishUsingFrameResource()

void ne::VulkanRenderer::waitForGpuToFinishUsingFrameResource ( FrameResource pFrameResource)
overrideprotectedvirtual

Blocks the current thread until the GPU is finished using the specified frame resource.

Remarks
Generally the current frame resource will be passed and so the current frame resource mutex will be locked at the time of calling and until the function is not finished it will not be unlocked.
Parameters
pFrameResourceFrame resource to wait for.

Implements ne::Renderer.

◆ waitForGpuToFinishWorkUpToThisPoint()

void ne::VulkanRenderer::waitForGpuToFinishWorkUpToThisPoint ( )
overridevirtual

Blocks the current thread until the GPU finishes executing all queued commands up to this point.

Remarks
Typically used with getRenderResourcesMutex.

Implements ne::Renderer.

Member Data Documentation

◆ bIsBeingDestroyed

bool ne::VulkanRenderer::bIsBeingDestroyed = false
private

Marked as true when entered destructor.

◆ bIsUsingMsaaRenderTarget

bool ne::VulkanRenderer::bIsUsingMsaaRenderTarget = false
private

Tells if MSAA is enabled or not and whether we are using multisampled render target or not.

◆ bIsVulkanInitialized

bool ne::VulkanRenderer::bIsVulkanInitialized = false
private

Tells if initializeVulkan was finished successfully or not.

◆ bNeedToRecreateSwapchain

bool ne::VulkanRenderer::bNeedToRecreateSwapchain = false
private

true if we received VK_SUBOPTIMAL_KHR and need to re-create the swapchain, false otherwise.

◆ depthImageFormat

constexpr auto ne::VulkanRenderer::depthImageFormat = VK_FORMAT_D32_SFLOAT
staticconstexprprivate

Format of pDepthImage.

◆ depthImageTiling

constexpr auto ne::VulkanRenderer::depthImageTiling = VK_IMAGE_TILING_OPTIMAL
staticconstexprprivate

Tiling option for pDepthImage.

◆ depthResolveMode

constexpr auto ne::VulkanRenderer::depthResolveMode = VK_RESOLVE_MODE_MAX_BIT
staticconstexprprivate

Used mode for resolving multisampled depth image.

◆ iCurrentImageSemaphore

size_t ne::VulkanRenderer::iCurrentImageSemaphore = 0
private

Index into vImageSemaphores.

◆ iDepthOnlyRenderPassDepthImageAttachmentIndex

constexpr size_t ne::VulkanRenderer::iDepthOnlyRenderPassDepthImageAttachmentIndex = 0
staticconstexprprivate

◆ iDepthOnlyRenderPassDepthResolveTargetAttachmentIndex

constexpr size_t ne::VulkanRenderer::iDepthOnlyRenderPassDepthResolveTargetAttachmentIndex = 1
staticconstexprprivate

◆ iLastAcquiredImageIndex

uint32_t ne::VulkanRenderer::iLastAcquiredImageIndex = 0
private

Index of the last acquired image from the swap chain.

◆ iMainRenderPassColorAttachmentIndex

constexpr size_t ne::VulkanRenderer::iMainRenderPassColorAttachmentIndex = 0
staticconstexprprivate

Index of the color attachment in pMainRenderPass.

◆ iMainRenderPassColorResolveTargetAttachmentIndex

constexpr size_t ne::VulkanRenderer::iMainRenderPassColorResolveTargetAttachmentIndex = 2
staticconstexprprivate

Index of the color resolve target attachment in pMainRenderPass.

◆ iMainRenderPassDepthAttachmentIndex

constexpr size_t ne::VulkanRenderer::iMainRenderPassDepthAttachmentIndex = 1
staticconstexprprivate

Index of the depth attachment in pMainRenderPass.

◆ indexTypeFormat

constexpr auto ne::VulkanRenderer::indexTypeFormat = VK_INDEX_TYPE_UINT32
staticconstexprprivate

Format of indices.

◆ iSwapChainImageCount

uint32_t ne::VulkanRenderer::iSwapChainImageCount = 0
private

The number of swap chain images that we have in pSwapChain.

◆ iUsedVulkanVersion

constexpr uint32_t ne::VulkanRenderer::iUsedVulkanVersion = VK_API_VERSION_1_2
staticconstexprprivate

Version of the Vulkan API that the renderer uses.

◆ msaaSampleCount

VkSampleCountFlagBits ne::VulkanRenderer::msaaSampleCount = VK_SAMPLE_COUNT_1_BIT
private

Used MSAA sample count.

◆ pCommandPool

VkCommandPool ne::VulkanRenderer::pCommandPool = nullptr
private

Used to create command buffers.

◆ pComputeTextureSampler

VkSampler ne::VulkanRenderer::pComputeTextureSampler = nullptr
private

Texture sampler with nearest filtering and mipmapping for fetching texels in compute shader.

Remarks
Always valid and not re-created when texture filtering (render setting) is changed.

◆ pDepthImage

std::unique_ptr<VulkanResource> ne::VulkanRenderer::pDepthImage = nullptr
private

Depth buffer.

◆ pDepthImageNoMultisampling

std::unique_ptr<VulkanResource> ne::VulkanRenderer::pDepthImageNoMultisampling = nullptr
private

Depth buffer without multisampling (for light culing compute shader).

Warning
When pDepthImage does not use multisampling this buffer is not used and does not store contents of pDepthImage.
Remarks
Stores non-multisampled depth data from pDepthImage for shaders.

◆ pDepthOnlyRenderPass

VkRenderPass ne::VulkanRenderer::pDepthOnlyRenderPass = nullptr
private

Render pass for z-prepass.

◆ pGraphicsQueue

VkQueue ne::VulkanRenderer::pGraphicsQueue = nullptr
private

Graphics queue.

◆ physicalDeviceQueueFamilyIndices

QueueFamilyIndices ne::VulkanRenderer::physicalDeviceQueueFamilyIndices
private

Queue family indices of current pPhysicalDevice.

◆ pInstance

VkInstance ne::VulkanRenderer::pInstance = nullptr
private

Vulkan API instance.

◆ pLogicalDevice

VkDevice ne::VulkanRenderer::pLogicalDevice = nullptr
private

Logical device to interface with pPhysicalDevice.

◆ pMainRenderPass

VkRenderPass ne::VulkanRenderer::pMainRenderPass = nullptr
private

Render pass for main pass.

◆ pMsaaImage

std::unique_ptr<VulkanResource> ne::VulkanRenderer::pMsaaImage = nullptr
private

Image with multiple samples per pixel for MSAA.

◆ pPhysicalDevice

VkPhysicalDevice ne::VulkanRenderer::pPhysicalDevice = nullptr
private

GPU that is being used by this renderer.

◆ pPresentQueue

VkQueue ne::VulkanRenderer::pPresentQueue = nullptr
private

Presentation queue.

◆ pShadowMappingDirectionalSpotRenderPass

VkRenderPass ne::VulkanRenderer::pShadowMappingDirectionalSpotRenderPass = nullptr
private

Render pass for shadow mapping of directional and spot lights.

◆ pShadowMappingPointRenderPass

VkRenderPass ne::VulkanRenderer::pShadowMappingPointRenderPass = nullptr
private

Render pass for shadow mapping of point lights.

◆ pShadowTextureSampler

VkSampler ne::VulkanRenderer::pShadowTextureSampler = nullptr
private

Texture sampler for directional and spot shadow maps.

Remarks
Always valid and not re-created when texture filtering (render setting) is changed.

◆ pSwapChain

VkSwapchainKHR ne::VulkanRenderer::pSwapChain = nullptr
private

Swap chain.

◆ pTextureSampler

VkSampler ne::VulkanRenderer::pTextureSampler = nullptr
private

Texture sampler.

◆ pWindowSurface

VkSurfaceKHR ne::VulkanRenderer::pWindowSurface = nullptr
private

Vulkan window representation.

◆ shadowMapFormat

constexpr auto ne::VulkanRenderer::shadowMapFormat = VK_FORMAT_D32_SFLOAT
staticconstexprprivate

Format used for shadow maps.

◆ shadowMappingPointLightColorTargetFormat

constexpr auto ne::VulkanRenderer::shadowMappingPointLightColorTargetFormat = VK_FORMAT_R32_SFLOAT
staticconstexprprivate

Format used for point lights as "color" target (does not actually store color) during shadow pass.

◆ stencilResolveMode

constexpr auto ne::VulkanRenderer::stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT
staticconstexprprivate

Used mode for resolving multisampled depth image.

◆ sUsedGpuName

std::string ne::VulkanRenderer::sUsedGpuName
private

Name of the pPhysicalDevice.

◆ swapChainExtent

std::optional<VkExtent2D> ne::VulkanRenderer::swapChainExtent
private

Size of images in the swap chain.

◆ swapChainImageColorSpace

constexpr auto ne::VulkanRenderer::swapChainImageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
staticconstexprprivate

Color space of vSwapChainImages.

◆ swapChainImageFormat

constexpr auto ne::VulkanRenderer::swapChainImageFormat = VK_FORMAT_B8G8R8A8_UNORM
staticconstexprprivate

Format of vSwapChainImages.

◆ vImageSemaphores

std::vector<SwapChainImageSemaphores> ne::VulkanRenderer::vImageSemaphores
private

Semaphores related to swap chain images.

Remarks
Size of this array is equal to iSwapChainImageCount.

◆ vSupportedGpuNames

std::vector<std::string> ne::VulkanRenderer::vSupportedGpuNames
private

List of supported GPUs, filled during pickPhysicalDevice.

◆ vSwapChainFramebuffersDepthOnlyRenderPass

std::vector<VkFramebuffer> ne::VulkanRenderer::vSwapChainFramebuffersDepthOnlyRenderPass
private

Framebuffers that point to vSwapChainImageViews and reference depth only render pass.

Remarks
Size of this array is equal to iSwapChainImageCount.

◆ vSwapChainFramebuffersMainRenderPass

std::vector<VkFramebuffer> ne::VulkanRenderer::vSwapChainFramebuffersMainRenderPass
private

Framebuffers that point to vSwapChainImageViews and reference main render pass.

Remarks
Size of this array is equal to iSwapChainImageCount.

◆ vSwapChainImageFenceRefs

std::vector<std::pair<VkFence, size_t> > ne::VulkanRenderer::vSwapChainImageFenceRefs
private

Stores pairs of "references to fences of a frame resources" - "frame resource index".

Remarks
Used to synchronize vkAcquireNextImageKHR calls and wait for a frame resource that uses the swap chain image.
Size of this array is equal to iSwapChainImageCount.

◆ vSwapChainImages

std::vector<VkImage> ne::VulkanRenderer::vSwapChainImages
private

Swap chain images.

Remarks
Size of this array is equal to iSwapChainImageCount.

◆ vSwapChainImageViews

std::vector<VkImageView> ne::VulkanRenderer::vSwapChainImageViews
private

Views to vSwapChainImages.

Remarks
Size of this array is equal to iSwapChainImageCount.

◆ vUsedDeviceExtensionNames

const std::vector<const char*> ne::VulkanRenderer::vUsedDeviceExtensionNames
inlinestaticprivate
Initial value:
= {
VK_KHR_SWAPCHAIN_EXTENSION_NAME}

Array of physical device extensions that we use.


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