Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions Core/inc/EvoVulkan/Types/RenderPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,56 @@
#include <EvoVulkan/Types/Device.h>
#include <EvoVulkan/Types/MultisampleTarget.h>

namespace EvoVulkan::Types {
/**
* Lightweight wrapper for a Vulkan render pass handle and its attachment counts.
*
* Encapsulates a VkRenderPass handle and the total number of attachments and color attachments.
*/

/**
* Destroy a Vulkan render pass and reset the wrapper state.
*
* @param device Vulkan device used to destroy the render pass.
* @param renderPass Pointer to the RenderPass wrapper to destroy; ignored if null or not ready.
*/

/**
* Create a legacy (VkRenderPass) render pass from modern attachment/subpass/dependency descriptions.
*
* Converts provided VkAttachmentDescription2, VkAttachmentReference2 and VkSubpassDependency2 inputs
* into legacy Vulkan structures and calls vkCreateRenderPass. On failure returns VK_NULL_HANDLE.
*
* @param device Vulkan device to create the render pass on.
* @param attachments Vector of attachment descriptions (VkAttachmentDescription2).
* @param inputAttachments Vector of input attachment references (VkAttachmentReference2).
* @param colorReferences Vector of color attachment references (VkAttachmentReference2).
* @param resolveReferences Vector of resolve attachment references (VkAttachmentReference2).
* @param depthReference Depth attachment reference (VkAttachmentReference2).
* @param dependencies Vector of subpass dependencies (VkSubpassDependency2).
* @param multisampling True if multisampling is used.
* @param depth True if a depth attachment is used.
* @param subpassDescription Subpass description (VkSubpassDescription2) to use for the single subpass.
* @returns A VkRenderPass handle on success, or VK_NULL_HANDLE on failure.
*/

/**
* Create a RenderPass object configured for the provided swapchain, attachments and sampling.
*
* Builds attachments, subpass description, and subpass dependencies appropriate for the requested
* sample count and depth usage, attempts to use vkCreateRenderPass2KHR (falling back to an older
* creation path if unavailable), and returns a RenderPass wrapper containing the created handle
* and attachment counts. On failure returns an empty RenderPass (IsReady() will be false).
*
* @param device Vulkan device used to create the render pass.
* @param swapchain Swapchain providing the color format for default attachment creation.
* @param attachments Attachment descriptions (VkAttachmentDescription2). May be empty to use the default swapchain path.
* @param inputAttachments Input attachment references (VkAttachmentReference2).
* @param sampleCount Number of samples per pixel (1 means no multisampling).
* @param depthAspect Image aspect flags indicating depth/stencil usage.
* @param depthFormat Format to use for depth attachments when applicable.
* @returns A RenderPass containing the created VkRenderPass and attachment counts, or an empty RenderPass on failure.
*/
namespace EvoVulkan::Types {
struct DLL_EVK_EXPORT RenderPass {
VkRenderPass m_self;
uint32_t m_countAttachments;
Expand Down Expand Up @@ -538,4 +587,4 @@ namespace EvoVulkan::Types {

}

#endif //EVOVULKAN_RENDERPASS_H
#endif //EVOVULKAN_RENDERPASS_H
15 changes: 13 additions & 2 deletions Core/inc/EvoVulkan/VulkanKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ namespace EvoVulkan::Core {
Suboptimal
};

enum class RenderResult : uint8_t {
/**
* Perform a single render pass for the current frame.
*
* Implementations should execute rendering for the active frame and report the outcome.
*
* @returns `RenderResult::Success` if rendering completed successfully,
* `RenderResult::Error` for a recoverable rendering error,
* `RenderResult::Fatal` for an unrecoverable failure,
* `RenderResult::DeviceLost` if the Vulkan device was lost,
* `RenderResult::None` if rendering was skipped or not performed.
*/
enum class RenderResult : uint8_t {
None,
Success,
Error,
Expand Down Expand Up @@ -251,4 +262,4 @@ namespace EvoVulkan::Core {
};
}

#endif //EVOVULKAN_VULKANKERNEL_H
#endif //EVOVULKAN_VULKANKERNEL_H
31 changes: 31 additions & 0 deletions Core/src/EvoVulkan/Tools/VulkanTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ namespace EvoVulkan::Tools {
return pipelineCache;
}

/**
* @brief Create a Vulkan semaphore on the given device.
*
* @param device Vulkan logical device to create the semaphore on.
* @return VkSemaphore Handle to the created semaphore, or `VK_NULL_HANDLE` if creation failed.
*/
VkSemaphore CreateVulkanSemaphore(const VkDevice& device) {
VkSemaphore semaphore = VK_NULL_HANDLE;
VkSemaphoreCreateInfo semaphoreCreateInfo = Initializers::SemaphoreCreateInfo();
Expand All @@ -166,6 +172,13 @@ namespace EvoVulkan::Tools {
return semaphore;
}

/**
* @brief Create a Vulkan fence with the specified creation flags.
*
* @param device Logical Vulkan device used to create the fence.
* @param flags Bitmask of VkFenceCreateFlags that control fence behavior.
* @return VkFence A newly created fence handle, or `VK_NULL_HANDLE` if creation failed.
*/
VkFence CreateVulkanFence(const VkDevice& device, VkFenceCreateFlags flags) {
VkFence fence = VK_NULL_HANDLE;
VkFenceCreateInfo fenceCreateInfo = Initializers::FenceCreateInfo(flags);
Expand All @@ -177,13 +190,31 @@ namespace EvoVulkan::Tools {
return fence;
}

/**
* @brief Destroys a Vulkan fence handle and resets it to VK_NULL_HANDLE.
*
* Destroys the fence referenced by |fence| using |device| if |fence| is non-null
* and the handle is not VK_NULL_HANDLE. After destruction the caller's handle
* is set to VK_NULL_HANDLE. If |fence| is null or already VK_NULL_HANDLE, the
* function does nothing.
*
* @param device Vulkan device used to destroy the fence.
* @param fence Pointer to the VkFence handle to destroy and reset.
*/
void DestroyVulkanFence(const VkDevice& device, VkFence* fence) {
if (fence && *fence != VK_NULL_HANDLE) {
vkDestroyFence(device, *fence, nullptr);
*fence = VK_NULL_HANDLE;
}
}

/**
* @brief Destroy a Vulkan semaphore and reset its handle.
*
* If `semaphore` is null or already `VK_NULL_HANDLE`, the function does nothing.
*
* @param semaphore Pointer to the VkSemaphore handle to destroy; on success the value pointed to will be set to `VK_NULL_HANDLE`.
*/
void DestroyVulkanSemaphore(const VkDevice& device, VkSemaphore* semaphore) {
if (semaphore && *semaphore != VK_NULL_HANDLE) {
vkDestroySemaphore(device, *semaphore, nullptr);
Expand Down
Loading