MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
mxvk_resource.hpp File Reference

Reusable Vulkan buffer, image, upload, and one-shot command helpers. More...

#include "mxvk_context.hpp"
#include <volk/volk.h>
#include <SDL3/SDL.h>
#include <cstddef>
#include <string>

Go to the source code of this file.

Classes

struct  mxvk::BufferResource
 Owned Vulkan buffer allocation with optional persistent host mapping. More...
struct  mxvk::TextureResource
 Owned sampled 2D texture resources. More...

Namespaces

namespace  mxvk
 Utilities for loading and saving PNG images.

Functions

VkCommandBuffer mxvk::begin_one_time_commands (const VulkanContext &context)
 Allocate and begin a primary one-time command buffer.
void mxvk::copy_buffer (const VulkanContext &context, VkBuffer source, VkBuffer destination, VkDeviceSize size)
 Copy one buffer into another with a one-shot Vulkan 1.3 copy command.
void mxvk::copy_buffer_to_image (VkCommandBuffer command_buffer, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height)
 Record a Vulkan 1.3 vkCmdCopyBufferToImage2 copy for a full 2D image.
void mxvk::create_buffer (const VulkanContext &context, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, BufferResource &buffer)
 Create and bind a Vulkan buffer allocation.
void mxvk::create_image (const VulkanContext &context, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage &image, VkDeviceMemory &memory)
 Create a 2D VkImage and allocate/bind its memory.
VkImageView mxvk::create_image_view (VkDevice device, VkImage image, VkFormat format, VkImageAspectFlags aspect)
 Create a 2D image view for an image.
void mxvk::create_texture_from_png (const VulkanContext &context, const std::string &path, TextureResource &texture, VkFormat format=VK_FORMAT_R8G8B8A8_UNORM)
 Load a PNG and upload it into a sampled 2D texture.
void mxvk::create_texture_from_surface (const VulkanContext &context, SDL_Surface *surface, TextureResource &texture, VkFormat format=VK_FORMAT_R8G8B8A8_UNORM)
 Upload an SDL surface into a sampled 2D texture.
void mxvk::destroy_buffer (VkDevice device, BufferResource &buffer)
 Unmap and destroy a BufferResource.
void mxvk::destroy_texture (VkDevice device, TextureResource &texture)
 Destroy every Vulkan handle owned by a TextureResource.
void mxvk::end_one_time_commands (const VulkanContext &context, VkCommandBuffer command_buffer)
 End, submit with vkQueueSubmit2, wait idle, and free a one-time command buffer.
uint32_t mxvk::find_memory_type (VkPhysicalDevice physical_device, uint32_t type_filter, VkMemoryPropertyFlags properties)
 Find a memory type satisfying a Vulkan memory type mask and property set.
void mxvk::map_buffer (VkDevice device, BufferResource &buffer)
 Persistently map a host-visible buffer allocation.
void mxvk::transition_image_layout (VkCommandBuffer command_buffer, VkImage image, VkImageLayout old_layout, VkImageLayout new_layout, VkImageAspectFlags aspect=VK_IMAGE_ASPECT_COLOR_BIT)
 Record a Vulkan 1.3 synchronization2 image layout transition.
void mxvk::unmap_buffer (VkDevice device, BufferResource &buffer)
 Unmap a BufferResource if it is currently mapped.

Detailed Description

Reusable Vulkan buffer, image, upload, and one-shot command helpers.

Definition in file mxvk_resource.hpp.