RetroArch
vulkan_common.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2016-2017 - Hans-Kristian Arntzen
3  *
4  * RetroArch is free software: you can redistribute it and/or modify it under the terms
5  * of the GNU General Public License as published by the Free Software Found-
6  * ation, either version 3 of the License, or (at your option) any later version.
7  *
8  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  * PURPOSE. See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along with RetroArch.
13  * If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef VULKAN_COMMON_H__
17 #define VULKAN_COMMON_H__
18 
19 #ifdef HAVE_CONFIG_H
20 #include "../../config.h"
21 #endif
22 
23 #define VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS 16
24 #define VULKAN_MAX_DESCRIPTOR_POOL_SIZES 16
25 #define VULKAN_BUFFER_BLOCK_SIZE (64 * 1024)
26 
27 #define VULKAN_MAX_SWAPCHAIN_IMAGES 8
28 
29 #define VULKAN_DIRTY_DYNAMIC_BIT 0x0001
30 
31 #include "vksym.h"
32 
33 #include <boolean.h>
34 #include <retro_inline.h>
35 #include <retro_common_api.h>
36 #include <retro_miscellaneous.h>
37 #include <gfx/math/matrix_4x4.h>
38 #include <gfx/scaler/scaler.h>
39 #include <rthreads/rthreads.h>
40 #include <formats/image.h>
41 
42 #include <libretro.h>
43 #include <libretro_vulkan.h>
44 
45 #include "../../driver.h"
46 #include "../../retroarch.h"
47 #include "../../verbosity.h"
48 #include "../font_driver.h"
49 #include "../video_driver.h"
50 #include "../drivers_shader/shader_vulkan.h"
51 #include "../../libretro-common/include/gfx/math/matrix_4x4.h"
52 #include "../include/vulkan/vulkan.h"
53 #include "../../libretro-common/include/gfx/scaler/scaler.h"
54 #include "../../libretro-common/include/libretro_vulkan.h"
55 
57 
59 {
60  /* We will use the texture as a sampled linear texture. */
62 
63  /* We will use the texture as a linear texture, but only
64  * for copying to a DYNAMIC texture. */
66 
67  /* We will use the texture as an optimally tiled texture,
68  * and we will update the texture by copying from STAGING
69  * textures. */
71 
72  /* We will upload content once. */
74 
75  /* We will use the texture for reading back transfers from GPU. */
77 };
78 
80 {
91 };
92 
93 typedef struct vulkan_context
94 {
96  /* Used by screenshot to get blits with correct colorspace. */
100 
101  unsigned swapchain_width;
103  unsigned swap_interval;
104 
108 
109  VkInstance instance;
110  VkPhysicalDevice gpu;
111  VkDevice device;
112  VkQueue queue;
113 
116 
122 
125 
126 #ifdef VULKAN_DEBUG
127  VkDebugReportCallbackEXT debug_callback;
128 #endif
130 
132 {
134  VkDevice device;
135  VkSwapchainKHR swapchain;
138 
139  unsigned index;
140  bool acquired;
142  bool dead;
145 };
146 
148  VkDevice device, VkSwapchainKHR swapchain);
152 
153 typedef struct gfx_ctx_vulkan_data
154 {
160  VkSurfaceKHR vk_surface;
161  VkSwapchainKHR swapchain;
162 
164  /* Used to check if we need to use mailbox emulation or not.
165  * Only relevant on Windows for now. */
168 
170 {
171  unsigned width;
172  unsigned height;
173  unsigned monitor_index;
174 };
175 
176 struct vk_color
177 {
178  float r, g, b, a;
179 };
180 
181 struct vk_vertex
182 {
183  float x, y;
184  float tex_x, tex_y;
185  struct vk_color color;
186 };
187 
188 struct vk_image
189 {
190  VkImage image;
191  VkImageView view;
192  VkFramebuffer framebuffer;
193 };
194 
196 {
200  bool mipmap;
202  unsigned width, height;
203  size_t offset;
204  size_t stride;
205  size_t size;
206 
207  void *mapped;
208 
209  VkImage image;
210  VkImageView view;
211  VkDeviceMemory memory;
212  VkBuffer buffer;
213 
215 
217 
219 };
220 
221 struct vk_buffer
222 {
223  VkBuffer buffer;
224  VkDeviceMemory memory;
226  void *mapped;
227 };
228 
230 {
233 };
234 
236 {
243 };
244 
246 {
248  VkBuffer buffer;
250 };
251 
256 
257 void vulkan_buffer_chain_discard(struct vk_buffer_chain *chain);
258 
259 bool vulkan_buffer_chain_alloc(const struct vulkan_context *context,
260  struct vk_buffer_chain *chain, size_t size,
261  struct vk_buffer_range *range);
262 
264  VkDevice device,
265  struct vk_buffer_chain *chain);
266 
267 
269 {
270  VkDescriptorPool pool;
273 };
274 
276 {
279  unsigned count;
280 
282  VkDescriptorSetLayout set_layout;
283  unsigned num_sizes;
284 };
285 
287 {
294 
295  VkCommandPool cmd_pool;
296  VkCommandBuffer cmd;
297 };
298 
300 {
301  VkPipeline pipeline;
303  VkSampler sampler;
305  struct vk_color color;
306 };
307 
309 {
310  unsigned vertices;
311  size_t uniform_size;
312  const void *uniform;
313  const struct vk_buffer_range *vbo;
315  VkPipeline pipeline;
316  VkSampler sampler;
317 };
318 
319 typedef struct vk
320 {
321  bool vsync;
324  bool quitting;
326 
327  unsigned tex_w, tex_h;
329  unsigned rotation;
332 
335  void *ctx_data;
337 
341  VkRenderPass render_pass;
346 
347  /* Currently active command buffer. */
348  VkCommandBuffer cmd;
349  /* Staging pool for doing buffer transfers on GPU. */
350  VkCommandPool staging_pool;
351 
352  struct
353  {
354  bool pending;
355  bool streamed;
358  } readback;
359 
360  struct
361  {
362  bool enable;
364  unsigned count;
366  struct vk_vertex *vertex;
367  } overlay;
368 
369  struct
370  {
371  VkPipeline alpha_blend;
372  VkPipeline font;
373  VkDescriptorSetLayout set_layout;
374  VkPipelineLayout layout;
375  VkPipelineCache cache;
376  } pipelines;
377 
378  struct
379  {
380  bool blend;
381  VkPipeline pipelines[7 * 2];
383  } display;
384 
385  struct
386  {
387  bool enable;
388  bool full_screen;
389  unsigned last_index;
390  float alpha;
394  } menu;
395 
396  struct
397  {
398  VkSampler linear;
399  VkSampler nearest;
400  VkSampler mipmap_nearest;
401  VkSampler mipmap_linear;
402  } samplers;
403 
404  struct
405  {
406  bool enable;
408 
409  unsigned capacity_cmd;
410  unsigned last_width;
411  unsigned last_height;
415 
417  const struct retro_vulkan_image *image;
418  const VkSemaphore *semaphores;
419  VkSemaphore signal_semaphore;
421  VkCommandBuffer *cmd;
422  } hw;
423 
424  struct
425  {
429  VkPipeline pipeline;
430  VkImageView view;
431  VkSampler sampler;
433  } tracker;
434 
436 } vk_t;
437 
439  const VkPhysicalDeviceMemoryProperties *mem_props,
440  uint32_t device_reqs, uint32_t host_reqs);
441 
443  const VkPhysicalDeviceMemoryProperties *mem_props,
444  uint32_t device_reqs, uint32_t host_reqs_first,
445  uint32_t host_reqs_second);
446 
447 
449  struct vk_texture *old,
450  unsigned width, unsigned height,
452  const void *initial, const VkComponentMapping *swizzle,
453  enum vk_texture_type type);
454 
455 void vulkan_sync_texture_to_gpu(vk_t *vk, const struct vk_texture *tex);
456 void vulkan_sync_texture_to_cpu(vk_t *vk, const struct vk_texture *tex);
457 
458 void vulkan_transition_texture(vk_t *vk, VkCommandBuffer cmd, struct vk_texture *texture);
459 
460 void vulkan_transfer_image_ownership(VkCommandBuffer cmd,
461  VkImage image, VkImageLayout layout,
462  VkPipelineStageFlags src_stages,
463  VkPipelineStageFlags dst_stages,
464  uint32_t src_queue_family,
465  uint32_t dst_queue_family);
466 
468  VkDevice device,
469  struct vk_texture *texture);
470 
472  VkDevice device,
473  struct vk_texture *tex);
474 
475 void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd,
476  struct vk_texture *dynamic,
477  struct vk_texture *staging);
478 
479 /* VBO will be written to here. */
480 void vulkan_draw_quad(vk_t *vk, const struct vk_draw_quad *quad);
481 
482 /* The VBO needs to be written to before calling this.
483  * Use vulkan_buffer_chain_alloc.
484  */
485 void vulkan_draw_triangles(vk_t *vk, const struct vk_draw_triangles *call);
486 
488  VkCommandBuffer cmd, VkImage image,
489  VkImageLayout old_layout, VkImageLayout new_layout,
490  VkAccessFlags srcAccess, VkAccessFlags dstAccess,
491  VkPipelineStageFlags srcStages, VkPipelineStageFlags dstStages);
492 
494  VkCommandBuffer cmd, VkImage image, uint32_t levels,
495  VkImageLayout old_layout, VkImageLayout new_layout,
496  VkAccessFlags src_access, VkAccessFlags dst_access,
497  VkPipelineStageFlags src_stages, VkPipelineStageFlags dst_stages);
498 
500 {
501  switch (format)
502  {
504  return 4;
505 
509  return 2;
510 
511  case VK_FORMAT_R8_UNORM:
512  return 1;
513 
514  default:
515  RARCH_ERR("[Vulkan]: Unknown format.\n");
516  abort();
517  }
518 }
519 
520 static INLINE void vulkan_write_quad_vbo(struct vk_vertex *pv,
521  float x, float y, float width, float height,
522  float tex_x, float tex_y, float tex_width, float tex_height,
523  const struct vk_color *color)
524 {
525  unsigned i;
526  static const float strip[2 * 6] = {
527  0.0f, 0.0f,
528  0.0f, 1.0f,
529  1.0f, 0.0f,
530  1.0f, 1.0f,
531  1.0f, 0.0f,
532  0.0f, 1.0f,
533  };
534 
535  for (i = 0; i < 6; i++)
536  {
537  pv[i].x = x + strip[2 * i + 0] * width;
538  pv[i].y = y + strip[2 * i + 1] * height;
539  pv[i].tex_x = tex_x + strip[2 * i + 0] * tex_width;
540  pv[i].tex_y = tex_y + strip[2 * i + 1] * tex_height;
541  pv[i].color = *color;
542  }
543 }
544 
546  const struct vulkan_context *context,
547  size_t size, VkBufferUsageFlags usage);
548 
550  VkDevice device,
551  struct vk_buffer *buffer);
552 
553 VkDescriptorSet vulkan_descriptor_manager_alloc(
554  VkDevice device,
555  struct vk_descriptor_manager *manager);
556 
558  struct vk_descriptor_manager *manager);
559 
561  VkDevice device,
563  VkDescriptorSetLayout set_layout);
564 
566  VkDevice device,
567  struct vk_descriptor_manager *manager);
568 
570  enum vulkan_wsi_type type);
571 
573  bool destroy_surface);
574 
576  enum vulkan_wsi_type type,
577  void *display, void *surface,
578  unsigned width, unsigned height,
579  unsigned swap_interval);
580 
582 
584 
586  unsigned width, unsigned height,
587  unsigned swap_interval);
588 
590 
591 #endif
592 
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:6559
Definition: vulkan_core.h:525
bool acquired
Definition: vulkan_common.h:140
struct scaler_ctx scaler
Definition: vulkan_common.h:356
size_t offset
Definition: vulkan_common.h:203
VkFramebuffer framebuffer
Definition: vulkan_common.h:192
#define VULKAN_MAX_SWAPCHAIN_IMAGES
Definition: vulkan_common.h:27
VkSampler nearest
Definition: vulkan_common.h:399
struct vk vk_t
scond_t * cond
Definition: vulkan_common.h:137
VkDevice device
Definition: vulkan_common.h:111
bool should_resize
Definition: vulkan_common.h:325
unsigned monitor_index
Definition: vulkan_common.h:173
struct vk::@219 tracker
bool quitting
Definition: vulkan_common.h:324
VkSampler mipmap_linear
Definition: vulkan_common.h:401
unsigned vp_out_height
Definition: vulkan_common.h:328
size_t uniform_size
Definition: vulkan_common.h:311
unsigned rotation
Definition: vulkan_common.h:329
void vulkan_transition_texture(vk_t *vk, VkCommandBuffer cmd, struct vk_texture *texture)
Definition: vulkan_common.c:942
VkBufferUsageFlags usage
Definition: vulkan_common.h:240
Definition: matrix_4x4.h:40
VkPhysicalDeviceProperties gpu_properties
Definition: vulkan_common.h:114
VkResult result
Definition: vulkan_common.h:144
struct vk_texture texture_optimal
Definition: vulkan_common.h:290
VkFlags VkBufferUsageFlags
Definition: vulkan_core.h:1447
#define const
Definition: zconf.h:217
unsigned count
Definition: vulkan_common.h:279
#define INLINE
Definition: retro_inline.h:35
VkPipeline pipeline
Definition: vulkan_common.h:301
float b
Definition: vulkan_common.h:178
Definition: vulkan_common.h:299
bool valid_semaphore
Definition: vulkan_common.h:407
slock_t * lock
Definition: vulkan_common.h:136
unsigned num_sizes
Definition: vulkan_common.h:283
VkPipeline pipeline
Definition: vulkan_common.h:429
VkCommandPool cmd_pool
Definition: vulkan_common.h:295
VkCommandBuffer cmd
Definition: vulkan_common.h:348
Definition: vulkan_core.h:2428
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
VkSampler sampler
Definition: vulkan_common.h:303
Definition: vulkan_common.h:176
unsigned last_height
Definition: vulkan_common.h:411
unsigned height
Definition: vulkan_common.h:202
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)
Definition: vulkan_common.c:2285
struct vk_buffer_node * next
Definition: vulkan_common.h:232
bool swap_interval_emulation_lock
Definition: vulkan_common.h:98
struct vk_image backbuffer
Definition: vulkan_common.h:288
struct vk_descriptor_pool * head
Definition: vulkan_common.h:277
Definition: vulkan_common.h:131
unsigned tex_w
Definition: vulkan_common.h:327
Definition: vulkan_common.h:81
void vulkan_buffer_chain_discard(struct vk_buffer_chain *chain)
Definition: vulkan_common.c:1403
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)
Definition: vulkan_common.c:306
struct vk_buffer_chain ubo
Definition: vulkan_common.h:292
void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
Definition: vulkan_common.c:2668
Definition: rthreads.c:88
Definition: vulkan_common.h:73
bool fullscreen
Definition: vulkan_common.h:166
VkDeviceSize alignment
Definition: vulkan_common.h:238
unsigned vp_out_width
Definition: vulkan_common.h:328
bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:393
uint32_t memory_type
Definition: vulkan_common.h:201
const gfx_ctx_driver_t * ctx_driver
Definition: vulkan_common.h:336
unsigned width
Definition: vulkan_common.h:202
VkDeviceSize offset
Definition: vulkan_common.h:249
unsigned tex_h
Definition: vulkan_common.h:327
GLenum GLint * range
Definition: glext.h:8206
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)
Definition: vulkan_common.c:1177
bool need_manual_cache_management
Definition: vulkan_common.h:199
VkImageView view
Definition: vulkan_common.h:430
GLsizeiptr size
Definition: glext.h:6559
VkDevice device
Definition: vulkan_common.h:134
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)
Definition: vulkan_common.h:520
VkQueue queue
Definition: vulkan_common.h:112
float a
Definition: vulkan_common.h:178
Definition: vulkan_common.h:82
VkImage swapchain_images[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:117
Definition: vulkan_common.h:86
Definition: vulkan_core.h:485
Definition: vulkan_common.h:70
static unsigned swap_interval
Definition: config.def.h:183
struct vk::@214 pipelines
VkBuffer buffer
Definition: vulkan_common.h:248
Definition: vulkan_common.h:169
VkDescriptorSet sets[VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS]
Definition: vulkan_common.h:271
VkBuffer buffer
Definition: vulkan_common.h:212
VkCommandBuffer * cmd
Definition: vulkan_common.h:421
slock_t * queue_lock
Definition: vulkan_common.h:123
GLuint GLenum swizzle
Definition: glext.h:10418
bool has_pending_request
Definition: vulkan_common.h:143
VkDescriptorSetLayout set_layout
Definition: vulkan_common.h:282
Definition: vulkan_common.h:93
VkSwapchainKHR swapchain
Definition: vulkan_common.h:135
VkFormat
Definition: vulkan_core.h:480
bool default_smooth
Definition: vulkan_common.h:198
Definition: vulkan_common.h:76
#define VULKAN_MAX_DESCRIPTOR_POOL_SIZES
Definition: vulkan_common.h:24
const VkSemaphore * semaphores
Definition: vulkan_common.h:418
unsigned last_valid_index
Definition: vulkan_common.h:331
VkDeviceSize memory_size
Definition: vulkan_common.h:216
struct vk_texture default_texture
Definition: vulkan_common.h:345
VkPipelineStageFlags * wait_dst_stages
Definition: vulkan_common.h:420
void * mapped
Definition: vulkan_common.h:226
VkPipelineCache cache
Definition: vulkan_common.h:375
typedefRETRO_BEGIN_DECLS struct sthread sthread_t
Definition: rthreads.h:35
Definition: scaler.h:62
struct vk_buffer vulkan_create_buffer(const struct vulkan_context *context, size_t size, VkBufferUsageFlags usage)
Definition: vulkan_common.c:1205
Definition: vulkan_core.h:2123
uint32_t num_semaphores
Definition: vulkan_common.h:412
struct vk_per_frame * chain
Definition: vulkan_common.h:343
const math_matrix_4x4 * mvp
Definition: vulkan_common.h:304
uint64_t dirty
Definition: vulkan_common.h:426
VkPhysicalDeviceMemoryProperties memory_properties
Definition: vulkan_common.h:115
Definition: libretro_vulkan.h:139
bool has_acquired_swapchain
Definition: vulkan_common.h:99
VkSwapchainKHR swapchain
Definition: vulkan_common.h:161
bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, struct vk_buffer_chain *chain, size_t size, struct vk_buffer_range *range)
Definition: vulkan_common.c:1409
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:120
bool vulkan_emulated_mailbox_init(struct vulkan_emulated_mailbox *mailbox, VkDevice device, VkSwapchainKHR swapchain)
Definition: vulkan_common.c:247
size_t stride
Definition: vulkan_common.h:204
struct video_viewport vp
Definition: vulkan_common.h:342
struct vk_descriptor_pool * current
Definition: vulkan_common.h:278
VkImageLayout
Definition: vulkan_core.h:798
bool dead
Definition: vulkan_common.h:142
void vulkan_descriptor_manager_restart(struct vk_descriptor_manager *manager)
Definition: vulkan_common.c:1303
sthread_t * thread
Definition: vulkan_common.h:133
void vulkan_destroy_descriptor_manager(VkDevice device, struct vk_descriptor_manager *manager)
Definition: vulkan_common.c:1327
VkFence swapchain_fences[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:118
VkDescriptorSet vulkan_descriptor_manager_alloc(VkDevice device, struct vk_descriptor_manager *manager)
Definition: vulkan_common.c:1282
video_info_t video
Definition: vulkan_common.h:334
VkDescriptorSetLayout set_layout
Definition: vulkan_common.h:373
struct vk_texture * texture
Definition: vulkan_common.h:314
GLenum type
Definition: glext.h:6233
bool enable
Definition: vulkan_common.h:362
uint32_t num_cmd
Definition: vulkan_common.h:413
bool created_new_swapchain
Definition: vulkan_common.h:156
float g
Definition: vulkan_common.h:178
VkResult vulkan_emulated_mailbox_acquire_next_image(struct vulkan_emulated_mailbox *mailbox, unsigned *index)
Definition: vulkan_common.c:140
const void * uniform
Definition: vulkan_common.h:312
VkPhysicalDevice gpu
Definition: vulkan_common.h:110
bool fullscreen
Definition: vulkan_common.h:323
ubyte cmd
Definition: wiiuse_internal.h:319
VkDeviceMemory memory
Definition: vulkan_common.h:224
Definition: vulkan_common.h:84
void vulkan_sync_texture_to_gpu(vk_t *vk, const struct vk_texture *tex)
Definition: vulkan_common.c:430
bool request_acquire
Definition: vulkan_common.h:141
Definition: vulkan_common.h:85
float x
Definition: vulkan_common.h:183
bool keep_aspect
Definition: vulkan_common.h:322
bool mipmap
Definition: vulkan_common.h:200
Definition: vulkan_common.h:88
const struct retro_vulkan_image * image
Definition: vulkan_common.h:417
float r
Definition: vulkan_common.h:178
bool pending
Definition: vulkan_common.h:354
Definition: vulkan_common.h:83
void vulkan_destroy_texture(VkDevice device, struct vk_texture *tex)
Definition: vulkan_common.c:880
Definition: vulkan_core.h:1869
struct vk::@218 hw
Definition: vulkan_common.h:195
void vulkan_draw_quad(vk_t *vk, const struct vk_draw_quad *quad)
Definition: vulkan_common.c:1061
math_matrix_4x4 mvp
Definition: vulkan_common.h:339
bool invalid_swapchain
Definition: vulkan_common.h:95
struct vk_buffer_node * current
Definition: vulkan_common.h:242
Definition: vulkan_core.h:490
Definition: vulkan_common.h:90
Definition: vulkan_core.h:2245
struct vk_texture * images
Definition: vulkan_common.h:365
struct vk::@217 samplers
void vulkan_map_persistent_texture(VkDevice device, struct vk_texture *texture)
Definition: vulkan_common.c:331
struct vk_buffer_chain vulkan_buffer_chain_init(VkDeviceSize block_size, VkDeviceSize alignment, VkBufferUsageFlags usage)
Definition: vulkan_common.c:1386
VkBuffer buffer
Definition: vulkan_common.h:223
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)
Definition: vulkan_common.c:466
Definition: vulkan_core.h:2226
VkInstance instance
Definition: vulkan_common.h:109
bool use_scissor
Definition: vulkan_common.h:428
static INLINE unsigned vulkan_format_to_bpp(VkFormat format)
Definition: vulkan_common.h:499
VkPipeline font
Definition: vulkan_common.h:372
VkImage image
Definition: vulkan_common.h:209
Definition: vulkan_common.h:61
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:6305
struct vk_descriptor_manager vulkan_create_descriptor_manager(VkDevice device, const VkDescriptorPoolSize *sizes, unsigned num_sizes, VkDescriptorSetLayout set_layout)
Definition: vulkan_common.c:1309
Definition: video_driver.h:513
Definition: libretro_vulkan.h:32
float y
Definition: vulkan_common.h:183
VkFormat tex_fmt
Definition: vulkan_common.h:338
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
Definition: video_driver.h:332
VkPipelineLayout layout
Definition: vulkan_common.h:374
void * filter_chain
Definition: vulkan_common.h:435
bool need_new_swapchain
Definition: vulkan_common.h:155
struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:357
struct vk_buffer_chain vbo
Definition: vulkan_common.h:291
unsigned last_index
Definition: vulkan_common.h:389
Definition: vulkan_common.h:268
Definition: vulkan_common.h:65
VkDeviceSize block_size
Definition: vulkan_common.h:237
bool emulating_mailbox
Definition: vulkan_common.h:158
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
Definition: rthreads.c:106
unsigned width
Definition: vulkan_common.h:171
VkImage image
Definition: vulkan_common.h:190
bool streamed
Definition: vulkan_common.h:355
VkSampler mipmap_nearest
Definition: vulkan_common.h:400
unsigned swap_interval
Definition: vulkan_common.h:103
VkImageView view
Definition: vulkan_common.h:191
Definition: vulkan_common.h:89
GLsizei levels
Definition: glext.h:8551
float alpha
Definition: vulkan_common.h:390
VkResult
Definition: vulkan_core.h:124
enum vk_texture_type type
Definition: vulkan_common.h:197
unsigned num_swapchain_images
Definition: vulkan_common.h:330
Definition: vulkan_core.h:484
unsigned vertices
Definition: vulkan_common.h:310
struct vk::@213 overlay
VkSampler sampler
Definition: vulkan_common.h:431
bool blend
Definition: vulkan_common.h:380
struct vk::@216 menu
vulkan_context_t * context
Definition: vulkan_common.h:333
const GLuint * pipelines
Definition: glext.h:8291
vk_texture_type
Definition: vulkan_common.h:58
VkFormat format
Definition: vulkan_common.h:214
struct retro_hw_render_interface_vulkan iface
Definition: vulkan_common.h:416
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
void(* retro_vulkan_destroy_device_t)(void)
Definition: libretro_vulkan.h:79
void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index)
Definition: vulkan_common.c:2524
void * mapped
Definition: vulkan_common.h:207
uint32_t src_queue_family
Definition: vulkan_common.h:414
VkImageLayout layout
Definition: vulkan_common.h:218
Definition: vulkan_common.h:319
struct vk_texture blank_texture
Definition: vulkan_common.h:382
GLuint index
Definition: glext.h:6671
void vulkan_draw_triangles(vk_t *vk, const struct vk_draw_triangles *call)
Definition: vulkan_common.c:1002
VkImageView view
Definition: vulkan_common.h:210
struct vk_color color
Definition: vulkan_common.h:185
struct vulkan_emulated_mailbox mailbox
Definition: vulkan_common.h:163
float tex_y
Definition: vulkan_common.h:184
uint32_t num_swapchain_images
Definition: vulkan_common.h:106
bool full_screen
Definition: vulkan_common.h:363
Definition: vulkan_core.h:1898
bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:119
VkPipeline pipeline
Definition: vulkan_common.h:315
struct vk_vertex * vertex
Definition: vulkan_common.h:366
Definition: video_driver.h:686
float tex_x
Definition: vulkan_common.h:184
math_matrix_4x4 mvp_no_rot
Definition: vulkan_common.h:339
VkFlags VkPipelineStageFlags
Definition: vulkan_core.h:1360
VkCommandBuffer cmd
Definition: vulkan_common.h:296
size_t size
Definition: vulkan_common.h:205
VkRect2D scissor
Definition: vulkan_common.h:427
struct vk::@215 display
GLuint color
Definition: glext.h:6883
bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, unsigned width, unsigned height, unsigned swap_interval)
Definition: vulkan_common.c:2781
void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk, bool destroy_surface)
Definition: vulkan_common.c:2569
VkViewport vk_vp
Definition: vulkan_common.h:340
Definition: vulkan_common.h:229
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glext.h:6293
const GLuint * textures
Definition: glext.h:9001
bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, enum vulkan_wsi_type type)
Definition: vulkan_common.c:1854
void vulkan_destroy_buffer(VkDevice device, struct vk_buffer *buffer)
Definition: vulkan_common.c:1237
VkSurfaceKHR vk_surface
Definition: vulkan_common.h:160
GLint GLint GLsizei width
Definition: glext.h:6293
Definition: vulkan_common.h:188
bool emulate_mailbox
Definition: vulkan_common.h:157
#define VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS
Definition: vulkan_common.h:23
struct gfx_ctx_vulkan_data gfx_ctx_vulkan_data_t
struct vk_descriptor_manager descriptor_manager
Definition: vulkan_common.h:293
uint32_t graphics_queue_index
Definition: vulkan_common.h:105
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)
Definition: vulkan_common.c:1144
uint32_t current_swapchain_index
Definition: vulkan_common.h:107
struct vk_buffer_node * head
Definition: vulkan_common.h:241
void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd, struct vk_texture *dynamic, struct vk_texture *staging)
Definition: vulkan_common.c:339
const struct vk_buffer_range * vbo
Definition: vulkan_common.h:313
Definition: vulkan_common.h:87
struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:344
Definition: metal_common.m:516
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition: glsym_gl.h:634
VkFlags VkAccessFlags
Definition: vulkan_core.h:1561
Definition: vulkan_common.h:286
VkSampler linear
Definition: vulkan_common.h:398
VkDeviceMemory memory
Definition: vulkan_common.h:211
Definition: vulkan_common.h:153
VkRenderPass render_pass
Definition: vulkan_common.h:341
unsigned swapchain_height
Definition: vulkan_common.h:102
unsigned capacity_cmd
Definition: vulkan_common.h:409
VkDeviceSize offset
Definition: vulkan_common.h:239
VkResult vulkan_emulated_mailbox_acquire_next_image_blocking(struct vulkan_emulated_mailbox *mailbox, unsigned *index)
Definition: vulkan_common.c:171
unsigned index
Definition: vulkan_common.h:139
VkDeviceSize size
Definition: vulkan_common.h:225
Definition: vulkan_common.h:245
VkPipeline alpha_blend
Definition: vulkan_common.h:371
bool swapchain_is_srgb
Definition: vulkan_common.h:97
unsigned count
Definition: vulkan_common.h:364
VkSampler sampler
Definition: vulkan_common.h:316
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)
Definition: vulkan_common.c:283
Definition: vulkan_common.h:221
struct vk_descriptor_pool * next
Definition: vulkan_common.h:272
VkFormat swapchain_format
Definition: vulkan_common.h:121
void * ctx_data
Definition: vulkan_common.h:335
unsigned height
Definition: vulkan_common.h:172
Definition: video4linux2.c:51
Definition: vulkan_common.h:181
struct vulkan_context vulkan_context_t
uint32_t vulkan_find_memory_type(const VkPhysicalDeviceMemoryProperties *mem_props, uint32_t device_reqs, uint32_t host_reqs)
Definition: vulkan_common.c:267
vulkan_context_t context
Definition: vulkan_common.h:159
uint8_t * data
Definition: vulkan_common.h:247
void vulkan_sync_texture_to_cpu(vk_t *vk, const struct vk_texture *tex)
Definition: vulkan_common.c:442
Definition: vulkan_core.h:483
vulkan_wsi_type
Definition: vulkan_common.h:79
bool vsync
Definition: vulkan_common.h:321
struct nk_device device
Definition: nk_common.c:44
uint64_t VkDeviceSize
Definition: vulkan_core.h:70
unsigned __int64 uint64_t
Definition: stdint.h:136
unsigned char uint8_t
Definition: stdint.h:124
retro_vulkan_destroy_device_t destroy_device
Definition: vulkan_common.h:124
unsigned int uint32_t
Definition: stdint.h:126
any call(F fn, Args &&... args)
Definition: peglib.h:337
VkCommandPool staging_pool
Definition: vulkan_common.h:350
Definition: vulkan_common.h:308
void vulkan_buffer_chain_free(VkDevice device, struct vk_buffer_chain *chain)
Definition: vulkan_common.c:1453
struct vk::@212 readback
Definition: vulkan_common.h:275
unsigned last_width
Definition: vulkan_common.h:410
void vulkan_emulated_mailbox_deinit(struct vulkan_emulated_mailbox *mailbox)
Definition: vulkan_common.c:121
VkSemaphore signal_semaphore
Definition: vulkan_common.h:419
GLint GLint GLsizei GLsizei height
Definition: glext.h:6293
void RARCH_ERR(const char *fmt,...)
Definition: verbosity.c:313
struct vk_texture * texture
Definition: vulkan_common.h:302
struct vk_texture textures_optimal[VULKAN_MAX_SWAPCHAIN_IMAGES]
Definition: vulkan_common.h:392
Definition: vulkan_common.h:235
unsigned swapchain_width
Definition: vulkan_common.h:101
VkDescriptorPool pool
Definition: vulkan_common.h:270