Nameless Engine
|
#include <VulkanRenderer.h>
Classes | |
struct | QueueFamilyIndices |
struct | SwapChainImageSemaphores |
struct | SwapChainSupportDetails |
Public Member Functions | |
VulkanRenderer (const VulkanRenderer &)=delete | |
VulkanRenderer & | operator= (const VulkanRenderer &)=delete |
VkSampler | getTextureSampler () |
virtual std::vector< std::string > | getSupportedGpuNames () const override |
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > | getSupportedRenderResolutions () const override |
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > | getSupportedRefreshRates () 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, Error > | createOneTimeSubmitCommandBuffer () |
std::optional< Error > | submitWaitDestroyOneTimeSubmitCommandBuffer (VkCommandBuffer pOneTimeSubmitCommandBuffer) |
std::optional< Error > | transitionImageLayout (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 GpuResource * | getDepthTextureNoMultisampling () override |
Public Member Functions inherited from ne::Renderer | |
Renderer (const Renderer &)=delete | |
Renderer & | operator= (const Renderer &)=delete |
virtual std::vector< std::string > | getSupportedGpuNames () const =0 |
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > | getSupportedRenderResolutions () const =0 |
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > | getSupportedRefreshRates () const =0 |
virtual RendererType | getType () const =0 |
virtual std::string | getUsedApiVersion () const =0 |
std::pair< std::recursive_mutex *, RenderSettings * > | getRenderSettings () |
RenderStatistics * | getRenderStatistics () |
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 |
Window * | getWindow () const |
GameManager * | getGameManager () const |
ShaderManager * | getShaderManager () const |
PipelineManager * | getPipelineManager () const |
GpuResourceManager * | getResourceManager () const |
FrameResourceManager * | getFrameResourceManager () const |
ShaderCpuWriteResourceBindingManager * | getShaderCpuWriteResourceManager () const |
ShaderTextureResourceBindingManager * | getShaderTextureResourceManager () const |
LightingShaderResourceManager * | getLightingShaderResourceManager () const |
GlobalShaderResourceBindingManager * | getGlobalShaderResourceBindingManager () const |
std::recursive_mutex * | getRenderResourcesMutex () |
virtual GpuResource * | getDepthTextureNoMultisampling ()=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 >, Error > | create (GameManager *pGameManager, std::optional< RendererType > preferredRenderer) |
Protected Member Functions | |
VulkanRenderer (GameManager *pGameManager) | |
virtual std::variant< std::optional< AntialiasingQuality >, Error > | getMaxSupportedAntialiasingQuality () const override |
virtual void | onFramebufferSizeChangedDerived (int iWidth, int iHeight) override |
virtual std::optional< Error > | onRenderSettingsChangedDerived () override |
virtual void | waitForGpuToFinishUsingFrameResource (FrameResource *pFrameResource) override |
virtual bool | isInitialized () const override |
Protected Member Functions inherited from ne::Renderer | |
Renderer (GameManager *pGameManager) | |
std::optional< Error > | compileEngineShaders () const |
void | updateFrameConstantsBuffer (FrameResource *pCurrentFrameResource, CameraProperties *pCameraProperties) |
void | resetGpuResourceManager () |
void | resetPipelineManager () |
void | resetFrameResourceManager () |
void | resetLightingShaderResourceManager () |
virtual std::variant< std::optional< AntialiasingQuality >, Error > | getMaxSupportedAntialiasingQuality () 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< Error > | onRenderSettingsChanged (bool bShadowMapSizeChanged=false) |
virtual std::optional< Error > | onRenderSettingsChangedDerived ()=0 |
virtual void | waitForGpuToFinishUsingFrameResource (FrameResource *pFrameResource)=0 |
virtual bool | isInitialized () const =0 |
std::optional< Error > | initializeRenderer () |
std::optional< Error > | initializeResourceManagers () |
std::optional< Error > | clampSettingsToMaxSupported () |
std::optional< Error > | recalculateLightTileFrustums () |
MeshesInFrustum * | getMeshesInCameraFrustum (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< Error > | initialize (const std::vector< std::string > &vBlacklistedGpuNames) |
std::optional< Error > | initializeVulkan (const std::vector< std::string > &vBlacklistedGpuNames) |
std::optional< Error > | createVulkanInstance () |
std::optional< Error > | createWindowSurface () |
size_t | rateGpuSuitability (VkPhysicalDevice pGpuDevice) |
std::variant< std::string, Error > | isDeviceSuitable (VkPhysicalDevice pGpu) |
std::variant< SwapChainSupportDetails, Error > | querySwapChainSupportDetails (VkPhysicalDevice pGpu) |
std::variant< VulkanRenderer::QueueFamilyIndices, Error > | queryQueueFamilyIndices (VkPhysicalDevice pGpu) |
std::variant< std::string, Error > | isGpuSupportsSwapChain (VkPhysicalDevice pGpu) |
std::optional< Error > | pickPhysicalDevice (const std::vector< std::string > &vBlacklistedGpuNames) |
std::optional< Error > | createLogicalDevice () |
std::optional< Error > | createSwapChain () |
std::optional< Error > | createCommandPool () |
std::variant< VkExtent2D, Error > | pickSwapChainExtent (const VkSurfaceCapabilitiesKHR &surfaceCapabilities) |
std::optional< Error > | createRenderPasses (bool bIsRendererInitialization) |
std::optional< Error > | createMainRenderPass () |
std::optional< Error > | createDepthOnlyRenderPass () |
std::optional< Error > | createShadowMappingRenderPasses () |
void | destroySwapChainAndDependentResources (bool bDestroyPipelineManager) |
std::optional< Error > | createTextureSampler () |
std::optional< Error > | createComputeTextureSampler () |
std::optional< Error > | createShadowTextureSampler () |
bool | isUsedDepthImageFormatSupported () |
std::optional< Error > | createDepthImage () |
std::optional< Error > | createMsaaImage () |
std::optional< Error > | recreateSwapChainAndDependentResources () |
std::optional< Error > | createSwapChainFramebuffers () |
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< Error > | updateMsaaSampleCount () |
Static Private Member Functions | |
static std::variant< std::vector< const char * >, Error > | getRequiredVulkanInstanceExtensions () |
static std::variant< std::string, Error > | isGpuSupportsUsedDeviceExtensions (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< VulkanResource > | pDepthImage = nullptr |
std::unique_ptr< VulkanResource > | pDepthImageNoMultisampling = nullptr |
std::unique_ptr< VulkanResource > | pMsaaImage = 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< SwapChainImageSemaphores > | vImageSemaphores |
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 ShadowMapHandle * | getPointLightNodeShadowMapHandle (PointLightNode *pNode) |
Renderer made with Vulkan API.
|
protected |
Creates an empty (uninitialized) renderer.
pGameManager | GameManager object that owns this renderer. |
|
static |
Creates a new DirectX renderer.
pGameManager | GameManager object that owns this renderer. |
vBlacklistedGpuNames | Names of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong. |
|
private |
Creates pCommandPool.
|
private |
Creates pComputeTextureSampler.
|
private |
Creates pDepthImage.
|
private |
Creates pDepthOnlyRenderPass (z-prepass) using the current msaaSampleCount.
|
private |
Creates pLogicalDevice.
|
private |
Creates pMainRenderPass using the current msaaSampleCount.
|
private |
Creates pMsaaImage using the current msaaSampleCount (does nothing if only 1 sample is used).
std::variant< VkCommandBuffer, Error > ne::VulkanRenderer::createOneTimeSubmitCommandBuffer | ( | ) |
Creates a new one-time submit command buffer to be later used with submitWaitDestroyOneTimeSubmitCommandBuffer.
|
private |
Creates render passes using the current msaaSampleCount.
bIsRendererInitialization | Specify 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. |
|
private |
Creates render passes used in shadow mapping.
|
private |
Creates sampler for shadow mapping.
|
private |
Creates pSwapChain.
|
private |
Creates swap chain framebuffers.
|
private |
Creates pTextureSampler using the current texture filtering mode from the render settings.
|
private |
Creates Vulkan API instance.
|
private |
Creates Vulkan window representation object.
|
private |
Destroys swap chain, framebuffers, graphics pipeline, render pass, image views, frees command buffers and other objects that depend on the swap chain images.
bDestroyPipelineManager | true 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. |
|
staticprivate |
Submits compute dispatch commands using pGraphicsQueue.
pCurrentFrameResource | Current frame resource. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
computePipelinesToSubmit | Compute shaders and their pipelines to dispatch. |
true
if dispatched some shaders, false
if nothing to dispatch.
|
overrideprivatevirtual |
Submits commands to draw meshes and the specified depth only (vertex shader only) pipelines.
pCurrentFrameResource | Frame resource of the frame being submitted. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
vOpaquePipelines | Opaque pipelines (depth pipeline will be retrieved from them). |
Implements ne::Renderer.
|
overrideprivatevirtual |
Submits commands to draw meshes for main (color) pass.
pCurrentFrameResource | Frame resource of the frame being submitted. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
vOpaquePipelines | Opaque pipelines to draw. |
vTransparentPipelines | Transparent pipelines to draw. |
Implements ne::Renderer.
|
private |
Submits commands to draw meshes and pipelines of specific types (only opaque or transparent).
pipelinesOfSpecificType | Pipelines to use. |
pCommandBuffer | Command buffer to use. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
|
overrideprivatevirtual |
Submits commands to draw world from the perspective of all spawned light sources to capture shadow maps.
pCurrentFrameResource | Frame resource of the frame being submitted. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
pGraphicsPipelines | Graphics pipelines to draw. |
Implements ne::Renderer.
|
overrideprivatevirtual |
Executes compute shaders of the specified stage.
pCurrentFrameResource | Frame resource of the frame being submitted. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
stage | Stage of compute shaders to execute. |
Implements ne::Renderer.
VkCommandPool ne::VulkanRenderer::getCommandPool | ( | ) | const |
Returns Vulkan command pool used in the renderer.
nullptr
if command pool is not created yet, otherwise used command pool. VkSampler ne::VulkanRenderer::getComputeTextureSampler | ( | ) | const |
Returns Vulkan texture sampler for fetching texels in compute shaders.
nullptr
if not created yet, otherwise valid sampler.
|
overridevirtual |
Returns the name of the GPU that is being currently used.
Implements ne::Renderer.
|
inlinestaticconstexpr |
Returns format used for depth image.
VkRenderPass ne::VulkanRenderer::getDepthOnlyRenderPass | ( | ) | const |
Returns depth only render pass (z-prepass).
nullptr
if render pass is not created yet, otherwise valid pointer.
|
overridevirtual |
Returns pointer to the texture resource that represents renderer's depth texture without multisampling (resolved resource).
Implements ne::Renderer.
VkQueue ne::VulkanRenderer::getGraphicsQueue | ( | ) | const |
Returns Vulkan graphics queue used in the renderer.
nullptr
if graphics queue is not created yet, otherwise used graphics queue. VkInstance ne::VulkanRenderer::getInstance | ( | ) | const |
Returns Vulkan instance used in the renderer.
nullptr
if Vulkan instance is not created yet, otherwise used Vulkan instance. VkDevice ne::VulkanRenderer::getLogicalDevice | ( | ) | const |
Returns logical device used in the renderer.
nullptr
if logical device is not created yet, otherwise used logical device. VkRenderPass ne::VulkanRenderer::getMainRenderPass | ( | ) | const |
Returns main render pass.
nullptr
if render pass is not created yet, otherwise valid pointer.
|
overrideprotectedvirtual |
Returns the maximum anti-aliasing quality that can be used on the picked GPU (getCurrentlyUsedGpuName).
Implements ne::Renderer.
VkSampleCountFlagBits ne::VulkanRenderer::getMsaaSampleCount | ( | ) | const |
Returns sample count of the current MSAA quality.
VkPhysicalDevice ne::VulkanRenderer::getPhysicalDevice | ( | ) | const |
Returns physical device used in the renderer.
nullptr
if physical device is not created yet, otherwise used physical device.
|
overridevirtual |
Returns size of the render target (size of the underlying render image).
Implements ne::Renderer.
|
staticprivate |
Returns names of essential Vulkan instance extensions that the renderer will use.
|
inlinestaticconstexpr |
Returns texture format used for shadow maps.
|
inlinestaticconstexpr |
Returns texture format used for point lights as "color" target (does not actually store color) during shadow pass.
VkRenderPass ne::VulkanRenderer::getShadowMappingRenderPass | ( | bool | bIsForPointLights | ) | const |
Returns render pass used for shadow mapping.
bIsForPointLights | Specify 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. |
nullptr
if render pass is not created yet, otherwise valid pointer. VkSampler ne::VulkanRenderer::getShadowTextureSampler | ( | ) | const |
Returns Vulkan texture sampler for sampling shadow textures.
nullptr
if not created yet, otherwise valid sampler.
|
overridevirtual |
Looks for video adapters (GPUs) that support this renderer.
Implements ne::Renderer.
|
overridevirtual |
Returns a list of supported screen refresh rates (pairs of numerator and denominator).
Implements ne::Renderer.
|
overridevirtual |
Returns a list of supported render resolution (pairs of width and height).
Implements ne::Renderer.
std::optional< VkExtent2D > ne::VulkanRenderer::getSwapChainExtent | ( | ) | const |
Returns the size of images in the swap chain.
VkSampler ne::VulkanRenderer::getTextureSampler | ( | ) |
Returns sampler for textures.
nullptr
if not created yet, otherwise valid pointer.
|
overridevirtual |
|
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.
Implements ne::Renderer.
|
static |
Returns used Vulkan API version.
|
private |
Initializes the renderer.
vBlacklistedGpuNames | Names of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong. |
|
private |
Initializes essential Vulkan entities.
vBlacklistedGpuNames | Names of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong. |
|
private |
Checks if the specified GPU fits all essential requirements of the renderer.
pGpu | GPU to test. |
|
private |
Checks if the specified GPU supports all used swap chain formats/modes.
VK_KHR_SWAPCHAIN_EXTENSION_NAME
is supported before calling this function.pGpu | GPU to test. |
|
staticprivate |
Checks if the specified physical device supports used device extensions.
pGpuDevice | GPU to check. |
|
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.
Implements ne::Renderer.
|
private |
Tells if depthImageFormat is supported by the hardware.
true
if supported, false
otherwise.
|
overrideprotectedvirtual |
Called when the framebuffer size was changed.
iWidth | New width of the framebuffer (in pixels). |
iHeight | New height of the framebuffer (in pixels). |
Reimplemented from ne::Renderer.
|
overrideprotectedvirtual |
Called after some render setting is changed to recreate internal resources to match the current settings.
Implements ne::Renderer.
|
private |
Picks the first GPU that fits renderer's needs.
vBlacklistedGpuNames | Names of GPUs that should not be used, generally this means that these GPUs were previously used to create the renderer but something went wrong. |
|
private |
Chooses the appropriate swap chain size.
surfaceCapabilities | Physical device surface's swap chain surface capabilities. |
|
overrideprivatevirtual |
Setups everything for render commands to be recorded (resets command buffers and etc.).
pCameraProperties | Camera properties to use. |
pCurrentFrameResource | Frame resource of the frame being submitted. |
Implements ne::Renderer.
|
overrideprivatevirtual |
Called before prepareForDrawingNextFrame to do early frame preparations.
Reimplemented from ne::Renderer.
|
overrideprivatevirtual |
Does the final frame rendering logic to present the frame on the screen.
pCurrentFrameResource | Frame resource of the frame being submitted. |
iCurrentFrameResourceIndex | Index of the current frame resource. |
Implements ne::Renderer.
|
private |
Retrieves the information about used queue families and their indices.
pGpu | GPU to query for queue families. |
vkGetPhysicalDeviceQueueFamilyProperties
.
|
private |
Queries swap chain support details from the specified GPU.
VK_KHR_SWAPCHAIN_EXTENSION_NAME
is supported before calling this function.pGpu | GPU to test. |
|
private |
Tells how good the specified GPU suits the renderer's needs.
pGpuDevice | GPU to test. |
|
private |
Recreates pSwapChain and all dependent resources after it was created using createSwapChain.
|
static |
Sets name of the object for debugging purposes using Vulkan's debugging utils extension.
pRenderer | Vulkan renderer. |
pObject | Object to name. |
objectType | Type of the object. |
sResourceName | Name to set. |
|
private |
Adds render pass start commands to the specified command buffer with pDepthOnlyRenderPass.
pCommandBuffer | Command buffer to modify. |
iAcquiredImageIndex | Index of the framebuffer to use. |
|
private |
Adds render pass start commands to the specified command buffer with pMainRenderPass.
pCommandBuffer | Command buffer to modify. |
iAcquiredImageIndex | Index of the framebuffer to use. |
|
staticprivate |
Adds render pass start commands to the specified command buffer with the specified shadow mapping render pass.
pShadowMappingRenderPass | pShadowMappingDirectionalSpotRenderPass or pShadowMappingPointRenderPass. |
pCommandBuffer | Command buffer to modify. |
pFramebufferToUse | Framebuffer to use. |
iShadowMapSize | Size of the framebuffer image. |
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.
pOneTimeSubmitCommandBuffer | Command buffer created by createOneTimeSubmitCommandBuffer with recorded commands to submit. |
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.
pImage | Image to use. |
imageFormat | Image format. |
aspect | Aspect of the image that will be affected. |
levelCount | Defines how much mipmaps will be affected. |
layerCount | Defines how much image layers will be affected. |
oldLayout | Old (current) image layout. |
newLayout | New image layout. |
|
private |
Queries the current render settings for MSAA quality and updates msaaSampleCount.
|
overrideprotectedvirtual |
Blocks the current thread until the GPU is finished using the specified frame resource.
pFrameResource | Frame resource to wait for. |
Implements ne::Renderer.
|
overridevirtual |
Blocks the current thread until the GPU finishes executing all queued commands up to this point.
Implements ne::Renderer.
|
private |
Marked as true
when entered destructor.
|
private |
Tells if MSAA is enabled or not and whether we are using multisampled render target or not.
|
private |
Tells if initializeVulkan was finished successfully or not.
|
private |
true
if we received VK_SUBOPTIMAL_KHR
and need to re-create the swapchain, false
otherwise.
|
staticconstexprprivate |
Format of pDepthImage.
|
staticconstexprprivate |
Tiling option for pDepthImage.
|
staticconstexprprivate |
Used mode for resolving multisampled depth image.
|
private |
Index into vImageSemaphores.
|
staticconstexprprivate |
Index of pDepthImage in pDepthOnlyRenderPass.
|
staticconstexprprivate |
Index of pDepthImageNoMultisampling in pDepthOnlyRenderPass.
|
private |
Index of the last acquired image from the swap chain.
|
staticconstexprprivate |
Index of the color attachment in pMainRenderPass.
|
staticconstexprprivate |
Index of the color resolve target attachment in pMainRenderPass.
|
staticconstexprprivate |
Index of the depth attachment in pMainRenderPass.
|
staticconstexprprivate |
Format of indices.
|
private |
The number of swap chain images that we have in pSwapChain.
|
staticconstexprprivate |
Version of the Vulkan API that the renderer uses.
|
private |
Used MSAA sample count.
|
private |
Used to create command buffers.
|
private |
Texture sampler with nearest filtering and mipmapping for fetching texels in compute shader.
|
private |
Depth buffer.
|
private |
Depth buffer without multisampling (for light culing compute shader).
|
private |
Render pass for z-prepass.
|
private |
Graphics queue.
|
private |
Queue family indices of current pPhysicalDevice.
|
private |
Vulkan API instance.
|
private |
Logical device to interface with pPhysicalDevice.
|
private |
Render pass for main pass.
|
private |
Image with multiple samples per pixel for MSAA.
|
private |
GPU that is being used by this renderer.
|
private |
Presentation queue.
|
private |
Render pass for shadow mapping of directional and spot lights.
|
private |
Render pass for shadow mapping of point lights.
|
private |
Texture sampler for directional and spot shadow maps.
|
private |
Swap chain.
|
private |
Texture sampler.
|
private |
Vulkan window representation.
|
staticconstexprprivate |
Format used for shadow maps.
|
staticconstexprprivate |
Format used for point lights as "color" target (does not actually store color) during shadow pass.
|
staticconstexprprivate |
Used mode for resolving multisampled depth image.
|
private |
Name of the pPhysicalDevice.
|
private |
Size of images in the swap chain.
|
staticconstexprprivate |
Color space of vSwapChainImages.
|
staticconstexprprivate |
Format of vSwapChainImages.
|
private |
Semaphores related to swap chain images.
|
private |
List of supported GPUs, filled during pickPhysicalDevice.
|
private |
Framebuffers that point to vSwapChainImageViews and reference depth only render pass.
|
private |
Framebuffers that point to vSwapChainImageViews and reference main render pass.
|
private |
Stores pairs of "references to fences of a frame resources" - "frame resource index".
vkAcquireNextImageKHR
calls and wait for a frame resource that uses the swap chain image.
|
private |
Swap chain images.
|
private |
Views to vSwapChainImages.
|
inlinestaticprivate |
Array of physical device extensions that we use.