Nameless Engine
Loading...
Searching...
No Matches
VulkanRenderer.h
1#pragma once
2
3// Standard.
4#include <vector>
5
6// Custom.
7#include "render/Renderer.h"
8#include "render/general/resource/frame/FrameResourceManager.h"
9#include "render/vulkan/resource/VulkanResource.h"
10#include "material/Material.h"
11
12// External.
13#include "vulkan/vulkan.h"
14#include "VulkanMemoryAllocator/include/vk_mem_alloc.h"
15
16namespace ne {
17 class CameraProperties;
18 class VulkanPipeline;
19 struct VulkanFrameResource;
20 struct QueuedForExecutionComputeShaders;
21 class ComputeShaderInterface;
22 class MeshNode;
23 class Pipeline;
24
26 class VulkanRenderer : public Renderer {
27 public:
28 VulkanRenderer() = delete;
29 VulkanRenderer(const VulkanRenderer&) = delete;
30 VulkanRenderer& operator=(const VulkanRenderer&) = delete;
31
32 virtual ~VulkanRenderer() override;
33
39 static uint32_t getUsedVulkanVersion();
40
46 static constexpr VkFormat getDepthImageFormat() { return depthImageFormat; }
47
53 static constexpr VkFormat getShadowMapFormat() { return shadowMapFormat; }
54
61 static constexpr VkFormat getShadowMappingPointLightColorTargetFormat() {
63 }
64
76 static std::variant<std::unique_ptr<Renderer>, std::pair<Error, std::string>>
77 create(GameManager* pGameManager, const std::vector<std::string>& vBlacklistedGpuNames);
78
89 static void setObjectDebugOnlyName(
90 Renderer* pRenderer, void* pObject, VkObjectType objectType, const std::string& sResourceName);
91
97 VkSampler getTextureSampler();
98
107 virtual std::vector<std::string> getSupportedGpuNames() const override;
108
114 virtual std::variant<std::set<std::pair<unsigned int, unsigned int>>, Error>
115 getSupportedRenderResolutions() const override;
116
125 virtual std::variant<std::set<std::pair<unsigned int, unsigned int>>, Error>
126 getSupportedRefreshRates() const override;
127
133 virtual RendererType getType() const override;
134
143 virtual std::string getUsedApiVersion() const override;
144
150 virtual std::string getCurrentlyUsedGpuName() const override;
151
157 virtual void waitForGpuToFinishWorkUpToThisPoint() override;
158
165 std::variant<VkCommandBuffer, Error> createOneTimeSubmitCommandBuffer();
166
177 [[nodiscard]] std::optional<Error>
178 submitWaitDestroyOneTimeSubmitCommandBuffer(VkCommandBuffer pOneTimeSubmitCommandBuffer);
179
193 [[nodiscard]] std::optional<Error> transitionImageLayout(
194 VkImage pImage,
195 VkFormat imageFormat,
196 VkImageAspectFlags aspect,
197 uint32_t levelCount,
198 uint32_t layerCount,
199 VkImageLayout oldLayout,
200 VkImageLayout newLayout);
201
207 virtual std::pair<unsigned int, unsigned int> getRenderTargetSize() const override;
208
214 VkDevice getLogicalDevice() const;
215
221 VkPhysicalDevice getPhysicalDevice() const;
222
228 VkInstance getInstance() const;
229
235 VkRenderPass getMainRenderPass() const;
236
242 VkRenderPass getDepthOnlyRenderPass() const;
243
253 VkRenderPass getShadowMappingRenderPass(bool bIsForPointLights) const;
254
260 VkCommandPool getCommandPool() const;
261
267 VkQueue getGraphicsQueue() const;
268
278 VkSampler getComputeTextureSampler() const;
279
287 VkSampler getShadowTextureSampler() const;
288
295 std::optional<VkExtent2D> getSwapChainExtent() const;
296
302 VkSampleCountFlagBits getMsaaSampleCount() const;
303
317
318 protected:
327
337 virtual std::variant<AntialiasingQuality, Error> getMaxSupportedAntialiasingQuality() const override;
338
345 virtual void onFramebufferSizeChangedDerived(int iWidth, int iHeight) override;
346
353 [[nodiscard]] virtual std::optional<Error> onRenderSettingsChangedDerived() override;
354
364 virtual void waitForGpuToFinishUsingFrameResource(FrameResource* pFrameResource) override;
365
374 virtual bool isInitialized() const override;
375
376 private:
380 VkSurfaceCapabilitiesKHR capabilities;
381
383 std::vector<VkSurfaceFormatKHR> vSupportedFormats;
384
386 std::vector<VkPresentModeKHR> vSupportedPresentModes;
387 };
388
394 QueueFamilyIndices() = default;
395
401 bool isComplete() const {
402 return iGraphicsFamilyIndex.has_value() && iPresentFamilyIndex.has_value();
403 }
404
406 std::optional<uint32_t> iGraphicsFamilyIndex;
407
412 std::optional<uint32_t> iPresentFamilyIndex;
413 };
414
422 VkSemaphore pAcquireImageSemaphore = nullptr;
423
429 VkSemaphore pQueueSubmitSemaphore = nullptr;
430
436 };
437
443 static std::variant<std::vector<const char*>, Error> getRequiredVulkanInstanceExtensions();
444
454 static std::variant<std::string, Error>
455 isGpuSupportsUsedDeviceExtensions(VkPhysicalDevice pGpuDevice);
456
468 VkRenderPass pShadowMappingRenderPass,
469 VkCommandBuffer pCommandBuffer,
470 VkFramebuffer pFramebufferToUse,
471 uint32_t iShadowMapSize);
472
473#if defined(DEBUG)
480 [[nodiscard]] static std::optional<Error> makeSureUsedValidationLayersSupported();
481
492 static VkResult createDebugUtilsMessengerEXT(
493 VkInstance pInstance,
494 const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
495 const VkAllocationCallbacks* pAllocator,
496 VkDebugUtilsMessengerEXT* pDebugMessenger);
497
505 static void destroyDebugUtilsMessengerEXT(
506 VkInstance pInstance,
507 VkDebugUtilsMessengerEXT pDebugMessenger,
508 const VkAllocationCallbacks* pAllocator);
509
517 static PFN_vkCmdBeginDebugUtilsLabelEXT requestVkCmdBeginDebugUtilsLabelEXT(VkInstance pInstance);
518
526 static PFN_vkCmdEndDebugUtilsLabelEXT requestVkCmdEndDebugUtilsLabelEXT(VkInstance pInstance);
527#endif
528
541 [[nodiscard]] std::optional<Error> initialize(const std::vector<std::string>& vBlacklistedGpuNames);
542
551 [[nodiscard]] std::optional<Error>
552 initializeVulkan(const std::vector<std::string>& vBlacklistedGpuNames);
553
559 [[nodiscard]] std::optional<Error> createVulkanInstance();
560
569 [[nodiscard]] std::optional<Error> createWindowSurface();
570
579 size_t rateGpuSuitability(VkPhysicalDevice pGpuDevice);
580
590 std::variant<std::string, Error> isDeviceSuitable(VkPhysicalDevice pGpu);
591
604 std::variant<SwapChainSupportDetails, Error> querySwapChainSupportDetails(VkPhysicalDevice pGpu);
605
616 std::variant<VulkanRenderer::QueueFamilyIndices, Error>
617 queryQueueFamilyIndices(VkPhysicalDevice pGpu);
618
633 std::variant<std::string, Error> isGpuSupportsSwapChain(VkPhysicalDevice pGpu);
634
645 [[nodiscard]] std::optional<Error>
646 pickPhysicalDevice(const std::vector<std::string>& vBlacklistedGpuNames);
647
655 [[nodiscard]] std::optional<Error> createLogicalDevice();
656
664 [[nodiscard]] std::optional<Error> createSwapChain();
665
673 [[nodiscard]] std::optional<Error> createCommandPool();
674
682 std::variant<VkExtent2D, Error>
683 pickSwapChainExtent(const VkSurfaceCapabilitiesKHR& surfaceCapabilities);
684
696 [[nodiscard]] std::optional<Error> createRenderPasses(bool bIsRendererInitialization);
697
705 [[nodiscard]] std::optional<Error> createMainRenderPass();
706
714 [[nodiscard]] std::optional<Error> createDepthOnlyRenderPass();
715
723 [[nodiscard]] std::optional<Error> createShadowMappingRenderPasses();
724
734 void destroySwapChainAndDependentResources(bool bDestroyPipelineManager);
735
743 [[nodiscard]] std::optional<Error> createTextureSampler();
744
754 [[nodiscard]] std::optional<Error> createComputeTextureSampler();
755
765 [[nodiscard]] std::optional<Error> createShadowTextureSampler();
766
773
781 [[nodiscard]] std::optional<Error> createDepthImage();
782
791 [[nodiscard]] std::optional<Error> createMsaaImage();
792
799 [[nodiscard]] std::optional<Error> recreateSwapChainAndDependentResources();
800
806 [[nodiscard]] std::optional<Error> createSwapChainFramebuffers();
807
814 virtual void prepareRenderTargetForNextFrame() override;
815
827 virtual void prepareForDrawingNextFrame(
828 CameraProperties* pCameraProperties, FrameResource* pCurrentFrameResource) override;
829
836 void startMainRenderPass(VkCommandBuffer pCommandBuffer, size_t iAcquiredImageIndex);
837
844 void startDepthOnlyRenderPass(VkCommandBuffer pCommandBuffer, size_t iAcquiredImageIndex);
845
854 virtual void drawShadowMappingPass(
855 FrameResource* pCurrentFrameResource,
856 size_t iCurrentFrameResourceIndex,
857 GraphicsPipelineRegistry* pGraphicsPipelines) override;
858
866 virtual void drawMeshesDepthPrepass(
867 FrameResource* pCurrentFrameResource,
868 size_t iCurrentFrameResourceIndex,
869 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& vOpaquePipelines) override;
870
881 FrameResource* pCurrentFrameResource,
882 size_t iCurrentFrameResourceIndex,
883 ComputeExecutionStage stage) override;
884
893 virtual void drawMeshesMainPass(
894 FrameResource* pCurrentFrameResource,
895 size_t iCurrentFrameResourceIndex,
896 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& vOpaquePipelines,
897 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& vTransparentPipelines)
898 override;
899
906 virtual void
907 present(FrameResource* pCurrentFrameResource, size_t iCurrentFrameResourceIndex) override;
908
917 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& pipelinesOfSpecificType,
918 VkCommandBuffer pCommandBuffer,
919 size_t iCurrentFrameResourceIndex);
920
926 [[nodiscard]] std::optional<Error> updateMsaaSampleCount();
927
938 VulkanFrameResource* pCurrentFrameResource,
939 size_t iCurrentFrameResourceIndex,
940 std::unordered_map<Pipeline*, std::unordered_set<ComputeShaderInterface*>>&
941 computePipelinesToSubmit);
942
944 VkInstance pInstance = nullptr;
945
947 VkSurfaceKHR pWindowSurface = nullptr;
948
950 VkPhysicalDevice pPhysicalDevice = nullptr;
951
953 VkDevice pLogicalDevice = nullptr;
954
956 VkQueue pGraphicsQueue = nullptr;
957
959 VkQueue pPresentQueue = nullptr;
960
962 VkSwapchainKHR pSwapChain = nullptr;
963
965 std::unique_ptr<VulkanResource> pDepthImage = nullptr;
966
975 std::unique_ptr<VulkanResource> pDepthImageNoMultisampling = nullptr;
976
978 std::unique_ptr<VulkanResource> pMsaaImage = nullptr;
979
981 VkRenderPass pDepthOnlyRenderPass = nullptr;
982
984 VkRenderPass pMainRenderPass = nullptr;
985
988
990 VkRenderPass pShadowMappingPointRenderPass = nullptr;
991
993 VkCommandPool pCommandPool = nullptr;
994
996 VkSampler pTextureSampler = nullptr;
997
1003 VkSampler pComputeTextureSampler = nullptr;
1004
1010 VkSampler pShadowTextureSampler = nullptr;
1011
1012#if defined(DEBUG)
1017 VkDebugUtilsMessengerEXT pValidationLayerDebugMessenger = nullptr;
1018#endif
1019
1025 std::vector<VkImage> vSwapChainImages;
1026
1032 std::vector<VkImageView> vSwapChainImageViews;
1033
1039 std::vector<VkFramebuffer> vSwapChainFramebuffersMainRenderPass;
1040
1047
1056 std::vector<std::pair<VkFence, size_t>> vSwapChainImageFenceRefs;
1057
1063 std::vector<SwapChainImageSemaphores> vImageSemaphores;
1064
1067
1069 std::vector<std::string> vSupportedGpuNames;
1070
1072 std::string sUsedGpuName;
1073
1076
1078 std::optional<VkExtent2D> swapChainExtent;
1079
1081 VkSampleCountFlagBits msaaSampleCount = VK_SAMPLE_COUNT_1_BIT;
1082
1085
1088
1091
1097
1100
1102 bool bIsBeingDestroyed = false;
1103
1105 static constexpr size_t iMainRenderPassColorAttachmentIndex = 0;
1106
1108 static constexpr size_t iMainRenderPassDepthAttachmentIndex = 1;
1109
1112
1115
1118
1120 static constexpr auto swapChainImageFormat = VK_FORMAT_B8G8R8A8_UNORM;
1121
1123 static constexpr auto swapChainImageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
1124
1126 static constexpr auto depthImageFormat = VK_FORMAT_D32_SFLOAT;
1127
1129 static constexpr auto shadowMapFormat = VK_FORMAT_D32_SFLOAT;
1130
1134 static constexpr auto shadowMappingPointLightColorTargetFormat = VK_FORMAT_R32_SFLOAT;
1135
1137 static constexpr auto depthImageTiling = VK_IMAGE_TILING_OPTIMAL;
1138
1140 static constexpr auto indexTypeFormat = VK_INDEX_TYPE_UINT32;
1141
1143 static constexpr auto depthResolveMode = VK_RESOLVE_MODE_MAX_BIT;
1144
1146 static constexpr auto stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1147
1149 static constexpr uint32_t iUsedVulkanVersion = VK_API_VERSION_1_2;
1150
1152 static inline const std::vector<const char*> vUsedDeviceExtensionNames = {
1153 VK_KHR_SWAPCHAIN_EXTENSION_NAME};
1154
1155#if defined(DEBUG)
1161 static inline const std::vector<const char*> vUsedValidationLayerNames = {
1162 "VK_LAYER_KHRONOS_validation"};
1163#endif
1164 };
1165} // namespace ne
Definition: CameraProperties.h:22
Definition: Error.h:27
Definition: GameManager.h:34
Definition: GpuResource.h:16
Definition: Pipeline.h:20
Definition: Renderer.h:43
GameManager * pGameManager
Definition: Renderer.h:870
Definition: VulkanRenderer.h:26
std::vector< VkImageView > vSwapChainImageViews
Definition: VulkanRenderer.h:1032
std::variant< std::string, Error > isGpuSupportsSwapChain(VkPhysicalDevice pGpu)
Definition: VulkanRenderer.cpp:816
virtual std::optional< Error > onRenderSettingsChangedDerived() override
Definition: VulkanRenderer.cpp:3989
virtual void executeComputeShadersOnGraphicsQueue(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, ComputeExecutionStage stage) override
Definition: VulkanRenderer.cpp:3500
VkInstance getInstance() const
Definition: VulkanRenderer.cpp:2760
VkRenderPass pShadowMappingPointRenderPass
Definition: VulkanRenderer.h:990
VkSampler getTextureSampler()
Definition: VulkanRenderer.cpp:2680
std::optional< Error > createSwapChain()
Definition: VulkanRenderer.cpp:1214
std::variant< VulkanRenderer::QueueFamilyIndices, Error > queryQueueFamilyIndices(VkPhysicalDevice pGpu)
Definition: VulkanRenderer.cpp:761
std::optional< Error > createComputeTextureSampler()
Definition: VulkanRenderer.cpp:2018
virtual void present(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex) override
Definition: VulkanRenderer.cpp:3602
std::optional< Error > createSwapChainFramebuffers()
Definition: VulkanRenderer.cpp:2316
static constexpr size_t iMainRenderPassColorAttachmentIndex
Definition: VulkanRenderer.h:1105
virtual void drawShadowMappingPass(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, GraphicsPipelineRegistry *pGraphicsPipelines) override
Definition: VulkanRenderer.cpp:3000
static constexpr VkFormat getShadowMappingPointLightColorTargetFormat()
Definition: VulkanRenderer.h:61
VkRenderPass getDepthOnlyRenderPass() const
Definition: VulkanRenderer.cpp:2764
VkRenderPass getShadowMappingRenderPass(bool bIsForPointLights) const
Definition: VulkanRenderer.cpp:2766
void destroySwapChainAndDependentResources(bool bDestroyPipelineManager)
Definition: VulkanRenderer.cpp:1871
bool bIsVulkanInitialized
Definition: VulkanRenderer.h:1090
bool bNeedToRecreateSwapchain
Definition: VulkanRenderer.h:1096
virtual GpuResource * getDepthTextureNoMultisampling() override
Definition: VulkanRenderer.cpp:2785
VkCommandPool pCommandPool
Definition: VulkanRenderer.h:993
static constexpr auto depthImageFormat
Definition: VulkanRenderer.h:1126
std::optional< VkExtent2D > swapChainExtent
Definition: VulkanRenderer.h:1078
std::optional< Error > pickPhysicalDevice(const std::vector< std::string > &vBlacklistedGpuNames)
Definition: VulkanRenderer.cpp:892
static constexpr VkFormat getShadowMapFormat()
Definition: VulkanRenderer.h:53
std::optional< Error > createShadowMappingRenderPasses()
Definition: VulkanRenderer.cpp:1743
VkRenderPass getMainRenderPass() const
Definition: VulkanRenderer.cpp:2762
uint32_t iSwapChainImageCount
Definition: VulkanRenderer.h:1084
std::optional< Error > transitionImageLayout(VkImage pImage, VkFormat imageFormat, VkImageAspectFlags aspect, uint32_t levelCount, uint32_t layerCount, VkImageLayout oldLayout, VkImageLayout newLayout)
Definition: VulkanRenderer.cpp:2886
std::unique_ptr< VulkanResource > pDepthImage
Definition: VulkanRenderer.h:965
virtual void waitForGpuToFinishWorkUpToThisPoint() override
Definition: VulkanRenderer.cpp:2709
std::optional< Error > createDepthImage()
Definition: VulkanRenderer.cpp:2138
std::optional< Error > initialize(const std::vector< std::string > &vBlacklistedGpuNames)
Definition: VulkanRenderer.cpp:203
VkSampleCountFlagBits getMsaaSampleCount() const
Definition: VulkanRenderer.cpp:2783
std::optional< Error > initializeVulkan(const std::vector< std::string > &vBlacklistedGpuNames)
Definition: VulkanRenderer.cpp:224
size_t rateGpuSuitability(VkPhysicalDevice pGpuDevice)
Definition: VulkanRenderer.cpp:494
std::variant< SwapChainSupportDetails, Error > querySwapChainSupportDetails(VkPhysicalDevice pGpu)
Definition: VulkanRenderer.cpp:690
static constexpr auto swapChainImageColorSpace
Definition: VulkanRenderer.h:1123
VkDevice pLogicalDevice
Definition: VulkanRenderer.h:953
VkCommandPool getCommandPool() const
Definition: VulkanRenderer.cpp:2773
bool bIsBeingDestroyed
Definition: VulkanRenderer.h:1102
void startDepthOnlyRenderPass(VkCommandBuffer pCommandBuffer, size_t iAcquiredImageIndex)
Definition: VulkanRenderer.cpp:2606
virtual std::variant< AntialiasingQuality, Error > getMaxSupportedAntialiasingQuality() const override
Definition: VulkanRenderer.cpp:97
bool isUsedDepthImageFormatSupported()
Definition: VulkanRenderer.cpp:2123
std::unique_ptr< VulkanResource > pMsaaImage
Definition: VulkanRenderer.h:978
VkQueue pPresentQueue
Definition: VulkanRenderer.h:959
std::optional< Error > createWindowSurface()
Definition: VulkanRenderer.cpp:466
static constexpr auto depthImageTiling
Definition: VulkanRenderer.h:1137
VkSampler pComputeTextureSampler
Definition: VulkanRenderer.h:1003
std::optional< Error > submitWaitDestroyOneTimeSubmitCommandBuffer(VkCommandBuffer pOneTimeSubmitCommandBuffer)
Definition: VulkanRenderer.cpp:2836
std::vector< std::string > vSupportedGpuNames
Definition: VulkanRenderer.h:1069
static constexpr auto depthResolveMode
Definition: VulkanRenderer.h:1143
virtual std::string getCurrentlyUsedGpuName() const override
Definition: VulkanRenderer.cpp:2707
VkDevice getLogicalDevice() const
Definition: VulkanRenderer.cpp:2756
virtual std::vector< std::string > getSupportedGpuNames() const override
Definition: VulkanRenderer.cpp:2682
VkRenderPass pShadowMappingDirectionalSpotRenderPass
Definition: VulkanRenderer.h:987
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > getSupportedRenderResolutions() const override
Definition: VulkanRenderer.cpp:2685
std::variant< VkCommandBuffer, Error > createOneTimeSubmitCommandBuffer()
Definition: VulkanRenderer.cpp:2798
std::unique_ptr< VulkanResource > pDepthImageNoMultisampling
Definition: VulkanRenderer.h:975
VkSampler pTextureSampler
Definition: VulkanRenderer.h:996
static bool dispatchComputeShadersOnGraphicsQueue(VulkanFrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, std::unordered_map< Pipeline *, std::unordered_set< ComputeShaderInterface * > > &computePipelinesToSubmit)
Definition: VulkanRenderer.cpp:3941
static std::variant< std::unique_ptr< Renderer >, std::pair< Error, std::string > > create(GameManager *pGameManager, const std::vector< std::string > &vBlacklistedGpuNames)
Definition: VulkanRenderer.cpp:2665
std::optional< Error > createTextureSampler()
Definition: VulkanRenderer.cpp:1934
static void setObjectDebugOnlyName(Renderer *pRenderer, void *pObject, VkObjectType objectType, const std::string &sResourceName)
Definition: VulkanRenderer.cpp:3304
bool bIsUsingMsaaRenderTarget
Definition: VulkanRenderer.h:1099
static constexpr size_t iDepthOnlyRenderPassDepthImageAttachmentIndex
Definition: VulkanRenderer.h:1114
static const std::vector< const char * > vUsedDeviceExtensionNames
Definition: VulkanRenderer.h:1152
uint32_t iLastAcquiredImageIndex
Definition: VulkanRenderer.h:1087
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > getSupportedRefreshRates() const override
Definition: VulkanRenderer.cpp:2695
std::variant< std::string, Error > isDeviceSuitable(VkPhysicalDevice pGpu)
Definition: VulkanRenderer.cpp:550
VkSampler getComputeTextureSampler() const
Definition: VulkanRenderer.cpp:2777
static constexpr VkFormat getDepthImageFormat()
Definition: VulkanRenderer.h:46
QueueFamilyIndices physicalDeviceQueueFamilyIndices
Definition: VulkanRenderer.h:1075
virtual RendererType getType() const override
Definition: VulkanRenderer.cpp:2700
std::optional< Error > updateMsaaSampleCount()
Definition: VulkanRenderer.cpp:3883
static constexpr auto shadowMappingPointLightColorTargetFormat
Definition: VulkanRenderer.h:1134
std::vector< SwapChainImageSemaphores > vImageSemaphores
Definition: VulkanRenderer.h:1063
static constexpr size_t iMainRenderPassDepthAttachmentIndex
Definition: VulkanRenderer.h:1108
static constexpr auto indexTypeFormat
Definition: VulkanRenderer.h:1140
std::optional< Error > createVulkanInstance()
Definition: VulkanRenderer.cpp:367
virtual void drawMeshesDepthPrepass(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines) override
Definition: VulkanRenderer.cpp:3358
VkSampleCountFlagBits msaaSampleCount
Definition: VulkanRenderer.h:1081
std::optional< Error > createMsaaImage()
Definition: VulkanRenderer.cpp:2197
VkPhysicalDevice getPhysicalDevice() const
Definition: VulkanRenderer.cpp:2758
static constexpr size_t iDepthOnlyRenderPassDepthResolveTargetAttachmentIndex
Definition: VulkanRenderer.h:1117
VkPhysicalDevice pPhysicalDevice
Definition: VulkanRenderer.h:950
virtual void drawMeshesMainPass(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vTransparentPipelines) override
Definition: VulkanRenderer.cpp:3567
std::vector< VkFramebuffer > vSwapChainFramebuffersDepthOnlyRenderPass
Definition: VulkanRenderer.h:1046
std::optional< Error > recreateSwapChainAndDependentResources()
Definition: VulkanRenderer.cpp:2241
std::optional< Error > createRenderPasses(bool bIsRendererInitialization)
Definition: VulkanRenderer.cpp:1452
static std::variant< std::string, Error > isGpuSupportsUsedDeviceExtensions(VkPhysicalDevice pGpuDevice)
Definition: VulkanRenderer.cpp:4067
virtual bool isInitialized() const override
Definition: VulkanRenderer.cpp:4038
VkQueue getGraphicsQueue() const
Definition: VulkanRenderer.cpp:2775
static constexpr auto stencilResolveMode
Definition: VulkanRenderer.h:1146
void startMainRenderPass(VkCommandBuffer pCommandBuffer, size_t iAcquiredImageIndex)
Definition: VulkanRenderer.cpp:2575
std::optional< Error > createLogicalDevice()
Definition: VulkanRenderer.cpp:1126
std::optional< Error > createMainRenderPass()
Definition: VulkanRenderer.cpp:1482
std::string sUsedGpuName
Definition: VulkanRenderer.h:1072
virtual void onFramebufferSizeChangedDerived(int iWidth, int iHeight) override
Definition: VulkanRenderer.cpp:3858
std::variant< VkExtent2D, Error > pickSwapChainExtent(const VkSurfaceCapabilitiesKHR &surfaceCapabilities)
Definition: VulkanRenderer.cpp:1417
VkSwapchainKHR pSwapChain
Definition: VulkanRenderer.h:962
std::optional< VkExtent2D > getSwapChainExtent() const
Definition: VulkanRenderer.cpp:2781
static uint32_t getUsedVulkanVersion()
Definition: VulkanRenderer.cpp:201
std::vector< VkImage > vSwapChainImages
Definition: VulkanRenderer.h:1025
static std::variant< std::vector< const char * >, Error > getRequiredVulkanInstanceExtensions()
Definition: VulkanRenderer.cpp:4040
size_t iCurrentImageSemaphore
Definition: VulkanRenderer.h:1066
virtual std::string getUsedApiVersion() const override
Definition: VulkanRenderer.cpp:2702
static void startShadowMappingRenderPass(VkRenderPass pShadowMappingRenderPass, VkCommandBuffer pCommandBuffer, VkFramebuffer pFramebufferToUse, uint32_t iShadowMapSize)
Definition: VulkanRenderer.cpp:2634
VkSurfaceKHR pWindowSurface
Definition: VulkanRenderer.h:947
std::optional< Error > createCommandPool()
Definition: VulkanRenderer.cpp:1400
static constexpr size_t iMainRenderPassColorResolveTargetAttachmentIndex
Definition: VulkanRenderer.h:1111
static constexpr auto shadowMapFormat
Definition: VulkanRenderer.h:1129
VkInstance pInstance
Definition: VulkanRenderer.h:944
VkSampler getShadowTextureSampler() const
Definition: VulkanRenderer.cpp:2779
static constexpr auto swapChainImageFormat
Definition: VulkanRenderer.h:1120
std::optional< Error > createDepthOnlyRenderPass()
Definition: VulkanRenderer.cpp:1610
VkRenderPass pMainRenderPass
Definition: VulkanRenderer.h:984
virtual void prepareRenderTargetForNextFrame() override
Definition: VulkanRenderer.cpp:2465
virtual void prepareForDrawingNextFrame(CameraProperties *pCameraProperties, FrameResource *pCurrentFrameResource) override
Definition: VulkanRenderer.cpp:2487
VkRenderPass pDepthOnlyRenderPass
Definition: VulkanRenderer.h:981
std::vector< std::pair< VkFence, size_t > > vSwapChainImageFenceRefs
Definition: VulkanRenderer.h:1056
static constexpr uint32_t iUsedVulkanVersion
Definition: VulkanRenderer.h:1149
std::vector< VkFramebuffer > vSwapChainFramebuffersMainRenderPass
Definition: VulkanRenderer.h:1039
VkQueue pGraphicsQueue
Definition: VulkanRenderer.h:956
void drawMeshesMainPassSpecificPipelines(const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &pipelinesOfSpecificType, VkCommandBuffer pCommandBuffer, size_t iCurrentFrameResourceIndex)
Definition: VulkanRenderer.cpp:3714
virtual void waitForGpuToFinishUsingFrameResource(FrameResource *pFrameResource) override
Definition: VulkanRenderer.cpp:4024
std::optional< Error > createShadowTextureSampler()
Definition: VulkanRenderer.cpp:2069
virtual std::pair< unsigned int, unsigned int > getRenderTargetSize() const override
Definition: VulkanRenderer.cpp:2993
VkSampler pShadowTextureSampler
Definition: VulkanRenderer.h:1010
Definition: FrameResource.h:15
Definition: PipelineRegistry.hpp:31
Definition: VulkanFrameResource.h:17
Definition: VulkanRenderer.h:393
std::optional< uint32_t > iPresentFamilyIndex
Definition: VulkanRenderer.h:412
bool isComplete() const
Definition: VulkanRenderer.h:401
std::optional< uint32_t > iGraphicsFamilyIndex
Definition: VulkanRenderer.h:406
Definition: VulkanRenderer.h:416
VkSemaphore pQueueSubmitSemaphore
Definition: VulkanRenderer.h:429
size_t iUsedFrameResourceIndex
Definition: VulkanRenderer.h:435
VkSemaphore pAcquireImageSemaphore
Definition: VulkanRenderer.h:422
Definition: VulkanRenderer.h:378
std::vector< VkPresentModeKHR > vSupportedPresentModes
Definition: VulkanRenderer.h:386
std::vector< VkSurfaceFormatKHR > vSupportedFormats
Definition: VulkanRenderer.h:383
VkSurfaceCapabilitiesKHR capabilities
Definition: VulkanRenderer.h:380