RetroArch
Macros | Functions | Variables
vulkan_common.c File Reference
#include <retro_assert.h>
#include <dynamic/dylib.h>
#include <string/stdstring.h>
#include "vulkan_common.h"
#include "../../libretro-common/include/retro_timers.h"
#include "../../configuration.h"
#include "../include/vulkan/vulkan.h"
#include "vksym.h"
#include "../../libretro-common/include/libretro_vulkan.h"
#include "../../libretro-common/include/retro_math.h"
Include dependency graph for vulkan_common.c:

Macros

#define VENDOR_ID_AMD   0x1002
 
#define VENDOR_ID_NV   0x10DE
 
#define VENDOR_ID_INTEL   0x8086
 
#define GOTO_FAIL()
 

Functions

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)
 
static void vulkan_emulated_mailbox_loop (void *userdata)
 
bool vulkan_emulated_mailbox_init (struct vulkan_emulated_mailbox *mailbox, VkDevice device, VkSwapchainKHR swapchain)
 
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)
 
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_copy_staging_to_dynamic (vk_t *vk, VkCommandBuffer cmd, struct vk_texture *dynamic, struct vk_texture *staging)
 
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)
 
static unsigned vulkan_num_miplevels (unsigned width, unsigned height)
 
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_destroy_texture (VkDevice device, struct vk_texture *tex)
 
static void vulkan_write_quad_descriptors (VkDevice device, VkDescriptorSet set, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range, const struct vk_texture *texture, VkSampler sampler)
 
void vulkan_transition_texture (vk_t *vk, VkCommandBuffer cmd, struct vk_texture *texture)
 
static void vulkan_check_dynamic_state (vk_t *vk)
 
void vulkan_draw_triangles (vk_t *vk, const struct vk_draw_triangles *call)
 
void vulkan_draw_quad (vk_t *vk, const struct vk_draw_quad *quad)
 
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)
 
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)
 
static struct vk_descriptor_poolvulkan_alloc_descriptor_pool (VkDevice device, const struct vk_descriptor_manager *manager)
 
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)
 
static void vulkan_buffer_chain_step (struct vk_buffer_chain *chain)
 
static bool vulkan_buffer_chain_suballoc (struct vk_buffer_chain *chain, size_t size, struct vk_buffer_range *range)
 
static struct vk_buffer_nodevulkan_buffer_chain_alloc_node (const struct vulkan_context *context, size_t size, VkBufferUsageFlags usage)
 
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)
 
static bool vulkan_load_instance_symbols (gfx_ctx_vulkan_data_t *vk)
 
static bool vulkan_load_device_symbols (gfx_ctx_vulkan_data_t *vk)
 
static bool vulkan_find_extensions (const char **exts, unsigned num_exts, const VkExtensionProperties *properties, unsigned property_count)
 
static bool vulkan_find_instance_extensions (const char **exts, unsigned num_exts)
 
static bool vulkan_find_device_extensions (VkPhysicalDevice gpu, const char **enabled, unsigned *enabled_count, const char **exts, unsigned num_exts, const char **optional_exts, unsigned num_optional_exts)
 
static bool vulkan_context_init_gpu (gfx_ctx_vulkan_data_t *vk)
 
static bool vulkan_context_init_device (gfx_ctx_vulkan_data_t *vk)
 
bool vulkan_context_init (gfx_ctx_vulkan_data_t *vk, enum vulkan_wsi_type type)
 
static bool vulkan_update_display_mode (unsigned *width, unsigned *height, const VkDisplayModePropertiesKHR *mode, const struct vulkan_display_surface_info *info)
 
static bool vulkan_create_display_surface (gfx_ctx_vulkan_data_t *vk, unsigned *width, unsigned *height, const struct vulkan_display_surface_info *info)
 
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)
 
static void vulkan_destroy_swapchain (gfx_ctx_vulkan_data_t *vk)
 
void vulkan_present (gfx_ctx_vulkan_data_t *vk, unsigned index)
 
void vulkan_context_destroy (gfx_ctx_vulkan_data_t *vk, bool destroy_surface)
 
static void vulkan_acquire_clear_fences (gfx_ctx_vulkan_data_t *vk)
 
static void vulkan_acquire_wait_fences (gfx_ctx_vulkan_data_t *vk)
 
static void vulkan_create_wait_fences (gfx_ctx_vulkan_data_t *vk)
 
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)
 

Variables

static dylib_t vulkan_library
 
static VkInstance cached_instance_vk
 
static VkDevice cached_device_vk
 
static retro_vulkan_destroy_device_t cached_destroy_device_vk
 

Macro Definition Documentation

◆ GOTO_FAIL

#define GOTO_FAIL ( )
Value:
do { \
ret = false; \
goto end; \
} while(0)
GLuint GLuint end
Definition: glext.h:6292

◆ VENDOR_ID_AMD

#define VENDOR_ID_AMD   0x1002

◆ VENDOR_ID_INTEL

#define VENDOR_ID_INTEL   0x8086

◆ VENDOR_ID_NV

#define VENDOR_ID_NV   0x10DE

Function Documentation

◆ vulkan_acquire_clear_fences()

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

◆ 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_acquire_wait_fences()

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

◆ vulkan_alloc_descriptor_pool()

static struct vk_descriptor_pool* vulkan_alloc_descriptor_pool ( VkDevice  device,
const struct vk_descriptor_manager manager 
)
static
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_alloc_node()

static struct vk_buffer_node* vulkan_buffer_chain_alloc_node ( const struct vulkan_context context,
size_t  size,
VkBufferUsageFlags  usage 
)
static
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_buffer_chain_step()

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

◆ vulkan_buffer_chain_suballoc()

static bool vulkan_buffer_chain_suballoc ( struct vk_buffer_chain chain,
size_t  size,
struct vk_buffer_range range 
)
static
Here is the caller graph for this function:

◆ vulkan_check_dynamic_state()

static void vulkan_check_dynamic_state ( vk_t vk)
static
Here is the call graph for this function:
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_context_init_device()

static bool vulkan_context_init_device ( gfx_ctx_vulkan_data_t vk)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_context_init_gpu()

static bool vulkan_context_init_gpu ( gfx_ctx_vulkan_data_t vk)
static
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_display_surface()

static bool vulkan_create_display_surface ( gfx_ctx_vulkan_data_t vk,
unsigned *  width,
unsigned *  height,
const struct vulkan_display_surface_info info 
)
static
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_create_wait_fences()

static void vulkan_create_wait_fences ( gfx_ctx_vulkan_data_t vk)
static
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_swapchain()

static void vulkan_destroy_swapchain ( gfx_ctx_vulkan_data_t vk)
static
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_emulated_mailbox_loop()

static void vulkan_emulated_mailbox_loop ( void userdata)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_find_device_extensions()

static bool vulkan_find_device_extensions ( VkPhysicalDevice  gpu,
const char **  enabled,
unsigned *  enabled_count,
const char **  exts,
unsigned  num_exts,
const char **  optional_exts,
unsigned  num_optional_exts 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_find_extensions()

static bool vulkan_find_extensions ( const char **  exts,
unsigned  num_exts,
const VkExtensionProperties properties,
unsigned  property_count 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_find_instance_extensions()

static bool vulkan_find_instance_extensions ( const char **  exts,
unsigned  num_exts 
)
static
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_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_load_device_symbols()

static bool vulkan_load_device_symbols ( gfx_ctx_vulkan_data_t vk)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vulkan_load_instance_symbols()

static bool vulkan_load_instance_symbols ( gfx_ctx_vulkan_data_t vk)
static
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_num_miplevels()

static unsigned vulkan_num_miplevels ( unsigned  width,
unsigned  height 
)
static
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_update_display_mode()

static bool vulkan_update_display_mode ( unsigned *  width,
unsigned *  height,
const VkDisplayModePropertiesKHR mode,
const struct vulkan_display_surface_info info 
)
static
Here is the caller graph for this function:

◆ vulkan_write_quad_descriptors()

static void vulkan_write_quad_descriptors ( VkDevice  device,
VkDescriptorSet  set,
VkBuffer  buffer,
VkDeviceSize  offset,
VkDeviceSize  range,
const struct vk_texture texture,
VkSampler  sampler 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cached_destroy_device_vk

retro_vulkan_destroy_device_t cached_destroy_device_vk
static

◆ cached_device_vk

VkDevice cached_device_vk
static

◆ cached_instance_vk

VkInstance cached_instance_vk
static

◆ vulkan_library

dylib_t vulkan_library
static