RetroArch
Classes | Macros | Typedefs | Enumerations | Functions
vulkan_common.h File Reference
#include "vksym.h"
#include <boolean.h>
#include <retro_inline.h>
#include <retro_common_api.h>
#include <retro_miscellaneous.h>
#include <gfx/math/matrix_4x4.h>
#include <gfx/scaler/scaler.h>
#include <rthreads/rthreads.h>
#include <formats/image.h>
#include <libretro.h>
#include <libretro_vulkan.h>
#include "../../driver.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../font_driver.h"
#include "../video_driver.h"
#include "../drivers_shader/shader_vulkan.h"
#include "../include/vulkan/vulkan.h"
Include dependency graph for vulkan_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  vulkan_context
 
struct  vulkan_emulated_mailbox
 
struct  gfx_ctx_vulkan_data
 
struct  vulkan_display_surface_info
 
struct  vk_color
 
struct  vk_vertex
 
struct  vk_image
 
struct  vk_texture
 
struct  vk_buffer
 
struct  vk_buffer_node
 
struct  vk_buffer_chain
 
struct  vk_buffer_range
 
struct  vk_descriptor_pool
 
struct  vk_descriptor_manager
 
struct  vk_per_frame
 
struct  vk_draw_quad
 
struct  vk_draw_triangles
 
struct  vk
 

Macros

#define VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS   16
 
#define VULKAN_MAX_DESCRIPTOR_POOL_SIZES   16
 
#define VULKAN_BUFFER_BLOCK_SIZE   (64 * 1024)
 
#define VULKAN_MAX_SWAPCHAIN_IMAGES   8
 
#define VULKAN_DIRTY_DYNAMIC_BIT   0x0001
 

Typedefs

typedef struct vulkan_context vulkan_context_t
 
typedef struct gfx_ctx_vulkan_data gfx_ctx_vulkan_data_t
 
typedef struct vk vk_t
 

Enumerations

enum  vk_texture_type {
  VULKAN_TEXTURE_STREAMED = 0, VULKAN_TEXTURE_STAGING, VULKAN_TEXTURE_DYNAMIC, VULKAN_TEXTURE_STATIC,
  VULKAN_TEXTURE_READBACK
}
 
enum  vulkan_wsi_type {
  VULKAN_WSI_NONE = 0, VULKAN_WSI_WAYLAND, VULKAN_WSI_MIR, VULKAN_WSI_ANDROID,
  VULKAN_WSI_WIN32, VULKAN_WSI_XCB, VULKAN_WSI_XLIB, VULKAN_WSI_DISPLAY,
  VULKAN_WSI_MVK_MACOS, VULKAN_WSI_MVK_IOS
}
 

Functions

bool vulkan_emulated_mailbox_init (struct vulkan_emulated_mailbox *mailbox, VkDevice device, VkSwapchainKHR swapchain)
 
void vulkan_emulated_mailbox_deinit (struct vulkan_emulated_mailbox *mailbox)
 
VkResult vulkan_emulated_mailbox_acquire_next_image (struct vulkan_emulated_mailbox *mailbox, unsigned *index)
 
VkResult vulkan_emulated_mailbox_acquire_next_image_blocking (struct vulkan_emulated_mailbox *mailbox, unsigned *index)
 
struct vk_buffer_chain vulkan_buffer_chain_init (VkDeviceSize block_size, VkDeviceSize alignment, VkBufferUsageFlags usage)
 
void vulkan_buffer_chain_discard (struct vk_buffer_chain *chain)
 
bool vulkan_buffer_chain_alloc (const struct vulkan_context *context, struct vk_buffer_chain *chain, size_t size, struct vk_buffer_range *range)
 
void vulkan_buffer_chain_free (VkDevice device, struct vk_buffer_chain *chain)
 
uint32_t vulkan_find_memory_type (const VkPhysicalDeviceMemoryProperties *mem_props, uint32_t device_reqs, uint32_t host_reqs)
 
uint32_t vulkan_find_memory_type_fallback (const VkPhysicalDeviceMemoryProperties *mem_props, uint32_t device_reqs, uint32_t host_reqs_first, uint32_t host_reqs_second)
 
struct vk_texture vulkan_create_texture (vk_t *vk, struct vk_texture *old, unsigned width, unsigned height, VkFormat format, const void *initial, const VkComponentMapping *swizzle, enum vk_texture_type type)
 
void vulkan_sync_texture_to_gpu (vk_t *vk, const struct vk_texture *tex)
 
void vulkan_sync_texture_to_cpu (vk_t *vk, const struct vk_texture *tex)
 
void vulkan_transition_texture (vk_t *vk, VkCommandBuffer cmd, struct vk_texture *texture)
 
void vulkan_transfer_image_ownership (VkCommandBuffer cmd, VkImage image, VkImageLayout layout, VkPipelineStageFlags src_stages, VkPipelineStageFlags dst_stages, uint32_t src_queue_family, uint32_t dst_queue_family)
 
void vulkan_map_persistent_texture (VkDevice device, struct vk_texture *texture)
 
void vulkan_destroy_texture (VkDevice device, struct vk_texture *tex)
 
void vulkan_copy_staging_to_dynamic (vk_t *vk, VkCommandBuffer cmd, struct vk_texture *dynamic, struct vk_texture *staging)
 
void vulkan_draw_quad (vk_t *vk, const struct vk_draw_quad *quad)
 
void vulkan_draw_triangles (vk_t *vk, const struct vk_draw_triangles *call)
 
void vulkan_image_layout_transition (vk_t *vk, VkCommandBuffer cmd, VkImage image, VkImageLayout old_layout, VkImageLayout new_layout, VkAccessFlags srcAccess, VkAccessFlags dstAccess, VkPipelineStageFlags srcStages, VkPipelineStageFlags dstStages)
 
void vulkan_image_layout_transition_levels (VkCommandBuffer cmd, VkImage image, uint32_t levels, VkImageLayout old_layout, VkImageLayout new_layout, VkAccessFlags src_access, VkAccessFlags dst_access, VkPipelineStageFlags src_stages, VkPipelineStageFlags dst_stages)
 
static INLINE unsigned vulkan_format_to_bpp (VkFormat format)
 
static INLINE void vulkan_write_quad_vbo (struct vk_vertex *pv, float x, float y, float width, float height, float tex_x, float tex_y, float tex_width, float tex_height, const struct vk_color *color)
 
struct vk_buffer vulkan_create_buffer (const struct vulkan_context *context, size_t size, VkBufferUsageFlags usage)
 
void vulkan_destroy_buffer (VkDevice device, struct vk_buffer *buffer)
 
VkDescriptorSet vulkan_descriptor_manager_alloc (VkDevice device, struct vk_descriptor_manager *manager)
 
void vulkan_descriptor_manager_restart (struct vk_descriptor_manager *manager)
 
struct vk_descriptor_manager vulkan_create_descriptor_manager (VkDevice device, const VkDescriptorPoolSize *sizes, unsigned num_sizes, VkDescriptorSetLayout set_layout)
 
void vulkan_destroy_descriptor_manager (VkDevice device, struct vk_descriptor_manager *manager)
 
bool vulkan_context_init (gfx_ctx_vulkan_data_t *vk, enum vulkan_wsi_type type)
 
void vulkan_context_destroy (gfx_ctx_vulkan_data_t *vk, bool destroy_surface)
 
bool vulkan_surface_create (gfx_ctx_vulkan_data_t *vk, enum vulkan_wsi_type type, void *display, void *surface, unsigned width, unsigned height, unsigned swap_interval)
 
void vulkan_present (gfx_ctx_vulkan_data_t *vk, unsigned index)
 
void vulkan_acquire_next_image (gfx_ctx_vulkan_data_t *vk)
 
bool vulkan_create_swapchain (gfx_ctx_vulkan_data_t *vk, unsigned width, unsigned height, unsigned swap_interval)
 

Macro Definition Documentation

◆ VULKAN_BUFFER_BLOCK_SIZE

#define VULKAN_BUFFER_BLOCK_SIZE   (64 * 1024)

◆ VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS

#define VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS   16

◆ VULKAN_DIRTY_DYNAMIC_BIT

#define VULKAN_DIRTY_DYNAMIC_BIT   0x0001

◆ VULKAN_MAX_DESCRIPTOR_POOL_SIZES

#define VULKAN_MAX_DESCRIPTOR_POOL_SIZES   16

◆ VULKAN_MAX_SWAPCHAIN_IMAGES

#define VULKAN_MAX_SWAPCHAIN_IMAGES   8

Typedef Documentation

◆ gfx_ctx_vulkan_data_t

◆ vk_t

typedef struct vk vk_t

◆ vulkan_context_t

Enumeration Type Documentation

◆ vk_texture_type

Enumerator
VULKAN_TEXTURE_STREAMED 
VULKAN_TEXTURE_STAGING 
VULKAN_TEXTURE_DYNAMIC 
VULKAN_TEXTURE_STATIC 
VULKAN_TEXTURE_READBACK 

◆ vulkan_wsi_type

Enumerator
VULKAN_WSI_NONE 
VULKAN_WSI_WAYLAND 
VULKAN_WSI_MIR 
VULKAN_WSI_ANDROID 
VULKAN_WSI_WIN32 
VULKAN_WSI_XCB 
VULKAN_WSI_XLIB 
VULKAN_WSI_DISPLAY 
VULKAN_WSI_MVK_MACOS 
VULKAN_WSI_MVK_IOS 

Function Documentation

◆ vulkan_acquire_next_image()

void vulkan_acquire_next_image ( gfx_ctx_vulkan_data_t vk)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_buffer_chain_alloc()

bool vulkan_buffer_chain_alloc ( const struct vulkan_context context,
struct vk_buffer_chain chain,
size_t  size,
struct vk_buffer_range range 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_buffer_chain_discard()

void vulkan_buffer_chain_discard ( struct vk_buffer_chain chain)
Here is the caller graph for this function:

◆ vulkan_buffer_chain_free()

void vulkan_buffer_chain_free ( VkDevice  device,
struct vk_buffer_chain chain 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_buffer_chain_init()

struct vk_buffer_chain vulkan_buffer_chain_init ( VkDeviceSize  block_size,
VkDeviceSize  alignment,
VkBufferUsageFlags  usage 
)
Here is the caller graph for this function:

◆ vulkan_context_destroy()

void vulkan_context_destroy ( gfx_ctx_vulkan_data_t vk,
bool  destroy_surface 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_context_init()

bool vulkan_context_init ( gfx_ctx_vulkan_data_t vk,
enum vulkan_wsi_type  type 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_copy_staging_to_dynamic()

void vulkan_copy_staging_to_dynamic ( vk_t vk,
VkCommandBuffer  cmd,
struct vk_texture dynamic,
struct vk_texture staging 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_create_buffer()

struct vk_buffer vulkan_create_buffer ( const struct vulkan_context context,
size_t  size,
VkBufferUsageFlags  usage 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_create_descriptor_manager()

struct vk_descriptor_manager vulkan_create_descriptor_manager ( VkDevice  device,
const VkDescriptorPoolSize sizes,
unsigned  num_sizes,
VkDescriptorSetLayout  set_layout 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_create_swapchain()

bool vulkan_create_swapchain ( gfx_ctx_vulkan_data_t vk,
unsigned  width,
unsigned  height,
unsigned  swap_interval 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_create_texture()

struct vk_texture vulkan_create_texture ( vk_t vk,
struct vk_texture old,
unsigned  width,
unsigned  height,
VkFormat  format,
const void initial,
const VkComponentMapping swizzle,
enum vk_texture_type  type 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_descriptor_manager_alloc()

VkDescriptorSet vulkan_descriptor_manager_alloc ( VkDevice  device,
struct vk_descriptor_manager manager 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_descriptor_manager_restart()

void vulkan_descriptor_manager_restart ( struct vk_descriptor_manager manager)
Here is the caller graph for this function:

◆ vulkan_destroy_buffer()

void vulkan_destroy_buffer ( VkDevice  device,
struct vk_buffer buffer 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_destroy_descriptor_manager()

void vulkan_destroy_descriptor_manager ( VkDevice  device,
struct vk_descriptor_manager manager 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_destroy_texture()

void vulkan_destroy_texture ( VkDevice  device,
struct vk_texture tex 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_draw_quad()

void vulkan_draw_quad ( vk_t vk,
const struct vk_draw_quad quad 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_draw_triangles()

void vulkan_draw_triangles ( vk_t vk,
const struct vk_draw_triangles call 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_emulated_mailbox_acquire_next_image()

VkResult vulkan_emulated_mailbox_acquire_next_image ( struct vulkan_emulated_mailbox mailbox,
unsigned *  index 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_emulated_mailbox_acquire_next_image_blocking()

VkResult vulkan_emulated_mailbox_acquire_next_image_blocking ( struct vulkan_emulated_mailbox mailbox,
unsigned *  index 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_emulated_mailbox_deinit()

void vulkan_emulated_mailbox_deinit ( struct vulkan_emulated_mailbox mailbox)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_emulated_mailbox_init()

bool vulkan_emulated_mailbox_init ( struct vulkan_emulated_mailbox mailbox,
VkDevice  device,
VkSwapchainKHR  swapchain 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_find_memory_type()

uint32_t vulkan_find_memory_type ( const VkPhysicalDeviceMemoryProperties mem_props,
uint32_t  device_reqs,
uint32_t  host_reqs 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_find_memory_type_fallback()

uint32_t vulkan_find_memory_type_fallback ( const VkPhysicalDeviceMemoryProperties mem_props,
uint32_t  device_reqs,
uint32_t  host_reqs_first,
uint32_t  host_reqs_second 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_format_to_bpp()

static INLINE unsigned vulkan_format_to_bpp ( VkFormat  format)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_image_layout_transition()

void vulkan_image_layout_transition ( vk_t vk,
VkCommandBuffer  cmd,
VkImage  image,
VkImageLayout  old_layout,
VkImageLayout  new_layout,
VkAccessFlags  srcAccess,
VkAccessFlags  dstAccess,
VkPipelineStageFlags  srcStages,
VkPipelineStageFlags  dstStages 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_image_layout_transition_levels()

void vulkan_image_layout_transition_levels ( VkCommandBuffer  cmd,
VkImage  image,
uint32_t  levels,
VkImageLayout  old_layout,
VkImageLayout  new_layout,
VkAccessFlags  src_access,
VkAccessFlags  dst_access,
VkPipelineStageFlags  src_stages,
VkPipelineStageFlags  dst_stages 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_map_persistent_texture()

void vulkan_map_persistent_texture ( VkDevice  device,
struct vk_texture texture 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_present()

void vulkan_present ( gfx_ctx_vulkan_data_t vk,
unsigned  index 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_surface_create()

bool vulkan_surface_create ( gfx_ctx_vulkan_data_t vk,
enum vulkan_wsi_type  type,
void display,
void surface,
unsigned  width,
unsigned  height,
unsigned  swap_interval 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_sync_texture_to_cpu()

void vulkan_sync_texture_to_cpu ( vk_t vk,
const struct vk_texture tex 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_sync_texture_to_gpu()

void vulkan_sync_texture_to_gpu ( vk_t vk,
const struct vk_texture tex 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_transfer_image_ownership()

void vulkan_transfer_image_ownership ( VkCommandBuffer  cmd,
VkImage  image,
VkImageLayout  layout,
VkPipelineStageFlags  src_stages,
VkPipelineStageFlags  dst_stages,
uint32_t  src_queue_family,
uint32_t  dst_queue_family 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_transition_texture()

void vulkan_transition_texture ( vk_t vk,
VkCommandBuffer  cmd,
struct vk_texture texture 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_write_quad_vbo()

static INLINE void vulkan_write_quad_vbo ( struct vk_vertex pv,
float  x,
float  y,
float  width,
float  height,
float  tex_x,
float  tex_y,
float  tex_width,
float  tex_height,
const struct vk_color color 
)
static
Here is the caller graph for this function: