![]() |
Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
|
Vulkan-based implementation of the IRenderer interface. More...
#include <vulkan_renderer.hpp>
Inherits rendering_engine::IRenderer.
Public Member Functions | |
| VulkanRenderer (IWindowSystem &windowSystem) | |
| Constructs a VulkanRenderer bound to a specific window system. | |
| void | InitializeRenderer () override |
| Initializes all rendering subsystems and GPU resources. | |
| void | DrawFrame () override |
| Executes a full frame rendering cycle. | |
| bool | BeginFrame () override |
| Begins frame rendering operations. | |
| void | BeginRenderPass () override |
| Begins the active render pass for the current frame. | |
| void | EndRenderPass () override |
| Ends the active render pass. | |
| void | EndFrame () override |
| Completes the current frame rendering and presents the result. | |
| void | WaitIdle () override |
| Waits until the GPU has finished all pending rendering operations. | |
| void | ShutdownRenderer () override |
| Destroys and cleans up all rendering resources. | |
| void | RegisterObserver (IRendererObserver *notifier) override |
| Registers an observer for rendering events. | |
| void | UnregisterObserver (IRendererObserver *notifier) override |
| Unregisters a previously registered observer. | |
| IRenderResources * | ProvideRenderResources () const override |
| Provides access to the general rendering resource manager. | |
| ITextureRenderResources * | ProvideTextureRenderResources () const override |
| Provides access to texture-related GPU resources. | |
| IMaterialRenderResources * | ProvideMaterialRenderResources () const override |
| Provides access to material-related GPU resources. | |
| IMeshRenderResources * | ProvideMeshRenderResources () const override |
| Provides access to mesh-related GPU resources. | |
| void | CreateBuffer (VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VkDeviceMemory &bufferMemory) |
| Creates a new Vulkan buffer with the specified usage and memory properties. | |
| void | CopyBuffer (VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size) |
| Copies data from one buffer to another using a temporary command buffer. | |
| VkDevice & | GetLogicalDevice () |
| Returns reference to the logical Vulkan device. | |
| void | TransitionImageLayout (VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, std::uint32_t mipmapLevels) |
| Transitions the image layout for a given Vulkan image. | |
| void | CopyBufferToImage (VkBuffer buffer, VkImage image, uint32_t width, uint32_t height) |
| Copies buffer data into an image (used for uploading texture data). | |
| void | GenerateMipmaps (VkImage image, VkFormat imageFormat, int32_t texWidth, int32_t texHeight, uint32_t mipLevels) |
| Generates mipmaps for a given image resource. | |
| uint32_t | FindMemoryType (uint32_t typeFilter, VkMemoryPropertyFlags properties) |
| Finds a suitable memory type for a given allocation. | |
| VkPhysicalDevice & | GetPhysicalDevice () |
| Returns reference to the physical device. | |
| VkPhysicalDeviceFeatures & | GetPhysDevSupportedFeatures () |
| Returns reference to the physical device�s supported features. | |
| VkDescriptorSetLayout | CreateDescriptorSetLayout (Material *material) |
| Creates a descriptor set layout corresponding to a given material. | |
| size_t | GetCurrentFrame () const |
| Returns the index of the currently active frame in flight. | |
| std::vector< VkCommandBuffer > | GetComandBuffers () |
| Returns the collection of command buffers used for rendering. | |
| std::pair< VkPipelineLayout, VkPipeline > | CreateGraphicsPipeline (Material *material, VkDescriptorSetLayout &descriptorSetLayout, std::vector< char > &spvVertShaderCode, std::vector< char > &spvFragShaderCode) |
| Creates a Vulkan graphics pipeline based on material and shader inputs. | |
| Public Member Functions inherited from rendering_engine::IRenderer | |
| virtual | ~IRenderer ()=default |
| Virtual destructor for safe polymorphic deletion. | |
Static Public Member Functions | |
| template<typename T> | |
| static VkVertexInputBindingDescription | GetBindingDescription () |
| Returns a vertex input binding description for a specific vertex type. | |
| template<typename T> | |
| static std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
| Returns vertex attribute descriptions for a specific vertex type. | |
| template<> | |
| std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
| template<> | |
| std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
| template<> | |
| std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
| template<> | |
| std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
| template<> | |
| std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
| template<> | |
| std::vector< VkVertexInputAttributeDescription > | GetAttributeDescriptions () |
Vulkan-based implementation of the IRenderer interface.
This class encapsulates the initialization and management of Vulkan rendering resources, including device selection, swap chain management, render pass setup, frame synchronization, and command buffer submission. It serves as the core rendering backend for all graphics operations performed by the engine.
Definition at line 58 of file vulkan_renderer.hpp.
| rendering_engine::VulkanRenderer::VulkanRenderer | ( | IWindowSystem & | windowSystem | ) |
Constructs a VulkanRenderer bound to a specific window system.
| windowSystem | Reference to the window system used for surface creation and event handling. |
Definition at line 38 of file vulkan_renderer.cpp.
|
overridevirtual |
Begins frame rendering operations.
Implements rendering_engine::IRenderer.
Definition at line 143 of file vulkan_renderer.cpp.
|
overridevirtual |
Begins the active render pass for the current frame.
Implements rendering_engine::IRenderer.
Definition at line 169 of file vulkan_renderer.cpp.
| void rendering_engine::VulkanRenderer::CopyBuffer | ( | VkBuffer | srcBuffer, |
| VkBuffer | dstBuffer, | ||
| VkDeviceSize | size ) |
Copies data from one buffer to another using a temporary command buffer.
| srcBuffer | Source buffer. |
| dstBuffer | Destination buffer. |
| size | Size of data to copy in bytes. |
Definition at line 351 of file vulkan_renderer.cpp.
| void rendering_engine::VulkanRenderer::CopyBufferToImage | ( | VkBuffer | buffer, |
| VkImage | image, | ||
| uint32_t | width, | ||
| uint32_t | height ) |
Copies buffer data into an image (used for uploading texture data).
| buffer | Source buffer containing pixel data. |
| image | Destination image. |
| width | Image width in pixels. |
| height | Image height in pixels. |
Definition at line 442 of file vulkan_renderer.cpp.
| void rendering_engine::VulkanRenderer::CreateBuffer | ( | VkDeviceSize | size, |
| VkBufferUsageFlags | usage, | ||
| VkMemoryPropertyFlags | properties, | ||
| VkBuffer & | buffer, | ||
| VkDeviceMemory & | bufferMemory ) |
Creates a new Vulkan buffer with the specified usage and memory properties.
| size | Size of the buffer in bytes. |
| usage | Bitmask specifying intended buffer usage. |
| properties | Memory property flags defining allocation type. |
| buffer | Output handle to the created buffer. |
| bufferMemory | Output handle to the allocated buffer memory. |
Definition at line 321 of file vulkan_renderer.cpp.
| VkDescriptorSetLayout rendering_engine::VulkanRenderer::CreateDescriptorSetLayout | ( | Material * | material | ) |
Creates a descriptor set layout corresponding to a given material.
The layout defines how shader resources (uniform buffers, custom parameters, textures) are bound to the pipeline. By the local convention of this engine:
This convention ensures consistent descriptor bindings across all shaders and materials.
| material | Pointer to the material defining binding structure. |
Definition at line 1323 of file vulkan_renderer.cpp.
| std::pair< VkPipelineLayout, VkPipeline > rendering_engine::VulkanRenderer::CreateGraphicsPipeline | ( | Material * | material, |
| VkDescriptorSetLayout & | descriptorSetLayout, | ||
| std::vector< char > & | spvVertShaderCode, | ||
| std::vector< char > & | spvFragShaderCode ) |
Creates a Vulkan graphics pipeline based on material and shader inputs.
| material | Pointer to the material configuration. |
| descriptorSetLayout | Descriptor set layout used in the pipeline. |
| spvVertShaderCode | Compiled SPIR-V vertex shader bytecode. |
| spvFragShaderCode | Compiled SPIR-V fragment shader bytecode. |
Definition at line 1386 of file vulkan_renderer.cpp.
|
overridevirtual |
Executes a full frame rendering cycle.
Implements rendering_engine::IRenderer.
Definition at line 67 of file vulkan_renderer.cpp.
|
overridevirtual |
Completes the current frame rendering and presents the result.
Implements rendering_engine::IRenderer.
Definition at line 203 of file vulkan_renderer.cpp.
|
overridevirtual |
Ends the active render pass.
Implements rendering_engine::IRenderer.
Definition at line 198 of file vulkan_renderer.cpp.
| uint32_t rendering_engine::VulkanRenderer::FindMemoryType | ( | uint32_t | typeFilter, |
| VkMemoryPropertyFlags | properties ) |
Finds a suitable memory type for a given allocation.
| typeFilter | Bitmask of compatible memory types. |
| properties | Desired memory property flags. |
Definition at line 1297 of file vulkan_renderer.cpp.
| void rendering_engine::VulkanRenderer::GenerateMipmaps | ( | VkImage | image, |
| VkFormat | imageFormat, | ||
| int32_t | texWidth, | ||
| int32_t | texHeight, | ||
| uint32_t | mipLevels ) |
Generates mipmaps for a given image resource.
| image | Vulkan image handle. |
| imageFormat | Image format (must support linear blitting). |
| texWidth | Texture width in pixels. |
| texHeight | Texture height in pixels. |
| mipLevels | Number of mipmap levels to generate. |
Definition at line 475 of file vulkan_renderer.cpp.
|
static |
Returns vertex attribute descriptions for a specific vertex type.
| T | Vertex type (e.g., Vertex2D, VertexPositionColorTexture, etc.). |
|
static |
|
static |
|
static |
|
static |
Definition at line 1767 of file vulkan_renderer.cpp.
|
static |
Definition at line 1767 of file vulkan_renderer.cpp.
|
static |
Definition at line 1767 of file vulkan_renderer.cpp.
|
static |
Returns a vertex input binding description for a specific vertex type.
| T | Vertex type (e.g., Vertex2D, VertexPositionColorTexture, etc.). |
Definition at line 1767 of file vulkan_renderer.cpp.
| std::vector< VkCommandBuffer > rendering_engine::VulkanRenderer::GetComandBuffers | ( | ) |
Returns the collection of command buffers used for rendering.
Definition at line 1381 of file vulkan_renderer.cpp.
|
inline |
Returns the index of the currently active frame in flight.
Definition at line 180 of file vulkan_renderer.hpp.
| VkDevice & rendering_engine::VulkanRenderer::GetLogicalDevice | ( | ) |
Returns reference to the logical Vulkan device.
Definition at line 364 of file vulkan_renderer.cpp.
| VkPhysicalDeviceFeatures & rendering_engine::VulkanRenderer::GetPhysDevSupportedFeatures | ( | ) |
Returns reference to the physical device�s supported features.
Definition at line 1318 of file vulkan_renderer.cpp.
| VkPhysicalDevice & rendering_engine::VulkanRenderer::GetPhysicalDevice | ( | ) |
Returns reference to the physical device.
Definition at line 1313 of file vulkan_renderer.cpp.
|
overridevirtual |
Initializes all rendering subsystems and GPU resources.
Implements rendering_engine::IRenderer.
Definition at line 44 of file vulkan_renderer.cpp.
|
overridevirtual |
Provides access to material-related GPU resources.
Implements rendering_engine::IRenderer.
Definition at line 306 of file vulkan_renderer.cpp.
|
overridevirtual |
Provides access to mesh-related GPU resources.
Implements rendering_engine::IRenderer.
Definition at line 311 of file vulkan_renderer.cpp.
|
overridevirtual |
Provides access to the general rendering resource manager.
Implements rendering_engine::IRenderer.
Definition at line 316 of file vulkan_renderer.cpp.
|
overridevirtual |
Provides access to texture-related GPU resources.
Implements rendering_engine::IRenderer.
Definition at line 301 of file vulkan_renderer.cpp.
|
overridevirtual |
Registers an observer for rendering events.
| notifier | Pointer to the observer to register. |
Implements rendering_engine::IRenderer.
Definition at line 288 of file vulkan_renderer.cpp.
|
overridevirtual |
Destroys and cleans up all rendering resources.
Implements rendering_engine::IRenderer.
Definition at line 266 of file vulkan_renderer.cpp.
| void rendering_engine::VulkanRenderer::TransitionImageLayout | ( | VkImage | image, |
| VkFormat | format, | ||
| VkImageLayout | oldLayout, | ||
| VkImageLayout | newLayout, | ||
| std::uint32_t | mipmapLevels ) |
Transitions the image layout for a given Vulkan image.
| image | Image handle. |
| format | Image format. |
| oldLayout | Current image layout. |
| newLayout | Desired image layout. |
| mipmapLevels | Number of mipmap levels to transition. |
Definition at line 369 of file vulkan_renderer.cpp.
|
overridevirtual |
Unregisters a previously registered observer.
| notifier | Pointer to the observer to remove. |
Implements rendering_engine::IRenderer.
Definition at line 296 of file vulkan_renderer.cpp.
|
overridevirtual |
Waits until the GPU has finished all pending rendering operations.
Implements rendering_engine::IRenderer.
Definition at line 261 of file vulkan_renderer.cpp.