Reorder structs/alignment

This commit is contained in:
twinaphex 2020-08-14 21:45:41 +02:00
parent 4c0d9bc68d
commit bfc8a7beca
2 changed files with 111 additions and 111 deletions

View File

@ -92,21 +92,19 @@ enum vulkan_wsi_type
typedef struct vulkan_context typedef struct vulkan_context
{ {
bool invalid_swapchain; slock_t *queue_lock;
/* Used by screenshot to get blits with correct colorspace. */ retro_vulkan_destroy_device_t destroy_device; /* ptr alignment */
bool swapchain_is_srgb;
bool swap_interval_emulation_lock;
bool has_acquired_swapchain;
unsigned swapchain_width;
unsigned swapchain_height;
unsigned swap_interval;
uint32_t graphics_queue_index; uint32_t graphics_queue_index;
uint32_t num_swapchain_images; uint32_t num_swapchain_images;
uint32_t current_swapchain_index; uint32_t current_swapchain_index;
uint32_t current_frame_index; uint32_t current_frame_index;
unsigned swapchain_width;
unsigned swapchain_height;
unsigned swap_interval;
unsigned num_recycled_acquire_semaphores;
VkInstance instance; VkInstance instance;
VkPhysicalDevice gpu; VkPhysicalDevice gpu;
VkDevice device; VkDevice device;
@ -117,41 +115,54 @@ typedef struct vulkan_context
VkImage swapchain_images[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkImage swapchain_images[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkFence swapchain_fences[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkFence swapchain_fences[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkFormat swapchain_format; VkFormat swapchain_format;
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkSemaphore swapchain_acquire_semaphore; VkSemaphore swapchain_acquire_semaphore;
unsigned num_recycled_acquire_semaphores;
VkSemaphore swapchain_recycled_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkSemaphore swapchain_recycled_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkSemaphore swapchain_wait_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkSemaphore swapchain_wait_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
slock_t *queue_lock;
retro_vulkan_destroy_device_t destroy_device;
#ifdef VULKAN_DEBUG #ifdef VULKAN_DEBUG
VkDebugReportCallbackEXT debug_callback; VkDebugReportCallbackEXT debug_callback;
#endif #endif
bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool invalid_swapchain;
/* Used by screenshot to get blits with correct colorspace. */
bool swapchain_is_srgb;
bool swap_interval_emulation_lock;
bool has_acquired_swapchain;
} vulkan_context_t; } vulkan_context_t;
struct vulkan_emulated_mailbox struct vulkan_emulated_mailbox
{ {
sthread_t *thread; sthread_t *thread;
VkDevice device;
VkSwapchainKHR swapchain;
slock_t *lock; slock_t *lock;
scond_t *cond; scond_t *cond;
VkDevice device; /* ptr alignment */
VkSwapchainKHR swapchain; /* ptr alignment */
unsigned index; unsigned index;
VkResult result; /* enum alignment */
bool acquired; bool acquired;
bool request_acquire; bool request_acquire;
bool dead; bool dead;
bool has_pending_request; bool has_pending_request;
VkResult result;
}; };
typedef struct gfx_ctx_vulkan_data typedef struct gfx_ctx_vulkan_data
{ {
struct string_list *gpu_list;
vulkan_context_t context;
VkSurfaceKHR vk_surface; /* ptr alignment */
VkSwapchainKHR swapchain; /* ptr alignment */
struct vulkan_emulated_mailbox mailbox;
/* Used to check if we need to use mailbox emulation or not.
* Only relevant on Windows for now. */
bool fullscreen;
bool need_new_swapchain; bool need_new_swapchain;
bool created_new_swapchain; bool created_new_swapchain;
bool emulate_mailbox; bool emulate_mailbox;
@ -160,16 +171,6 @@ typedef struct gfx_ctx_vulkan_data
* semaphores instead of fences for vkAcquireNextImageKHR. * semaphores instead of fences for vkAcquireNextImageKHR.
* Helps workaround certain performance issues on some drivers. */ * Helps workaround certain performance issues on some drivers. */
bool use_wsi_semaphore; bool use_wsi_semaphore;
vulkan_context_t context;
VkSurfaceKHR vk_surface;
VkSwapchainKHR swapchain;
struct vulkan_emulated_mailbox mailbox;
/* Used to check if we need to use mailbox emulation or not.
* Only relevant on Windows for now. */
bool fullscreen;
struct string_list *gpu_list;
} gfx_ctx_vulkan_data_t; } gfx_ctx_vulkan_data_t;
struct vulkan_display_surface_info struct vulkan_display_surface_info
@ -193,43 +194,41 @@ struct vk_vertex
struct vk_image struct vk_image
{ {
VkImage image; VkImage image; /* ptr alignment */
VkImageView view; VkImageView view; /* ptr alignment */
VkFramebuffer framebuffer; VkFramebuffer framebuffer; /* ptr alignment */
}; };
struct vk_texture struct vk_texture
{ {
VkDeviceSize memory_size; /* uint64_t alignment */
void *mapped;
VkImage image; /* ptr alignment */
VkImageView view; /* ptr alignment */
VkBuffer buffer; /* ptr alignment */
VkDeviceMemory memory; /* ptr alignment */
size_t offset;
size_t stride;
size_t size;
uint32_t memory_type;
unsigned width, height;
VkImageLayout layout; /* enum alignment */
VkFormat format; /* enum alignment */
enum vk_texture_type type; enum vk_texture_type type;
bool default_smooth; bool default_smooth;
bool need_manual_cache_management; bool need_manual_cache_management;
bool mipmap; bool mipmap;
uint32_t memory_type;
unsigned width, height;
size_t offset;
size_t stride;
size_t size;
void *mapped;
VkImage image;
VkImageView view;
VkDeviceMemory memory;
VkBuffer buffer;
VkFormat format;
VkDeviceSize memory_size;
VkImageLayout layout;
}; };
struct vk_buffer struct vk_buffer
{ {
VkBuffer buffer; VkDeviceSize size; /* uint64_t alignment */
VkDeviceMemory memory;
VkDeviceSize size;
void *mapped; void *mapped;
VkBuffer buffer; /* ptr alignment */
VkDeviceMemory memory; /* ptr alignment */
}; };
struct vk_buffer_node struct vk_buffer_node
@ -240,19 +239,19 @@ struct vk_buffer_node
struct vk_buffer_chain struct vk_buffer_chain
{ {
VkDeviceSize block_size; VkDeviceSize block_size; /* uint64_t alignment */
VkDeviceSize alignment; VkDeviceSize alignment; /* uint64_t alignment */
VkDeviceSize offset; VkDeviceSize offset; /* uint64_t alignment */
VkBufferUsageFlags usage;
struct vk_buffer_node *head; struct vk_buffer_node *head;
struct vk_buffer_node *current; struct vk_buffer_node *current;
VkBufferUsageFlags usage; /* uint32_t alignment */
}; };
struct vk_buffer_range struct vk_buffer_range
{ {
VkDeviceSize offset; /* uint64_t alignment */
uint8_t *data; uint8_t *data;
VkBuffer buffer; VkBuffer buffer; /* ptr alignment */
VkDeviceSize offset;
}; };
struct vk_buffer_chain vulkan_buffer_chain_init( struct vk_buffer_chain vulkan_buffer_chain_init(
@ -270,19 +269,18 @@ void vulkan_buffer_chain_free(
struct vk_descriptor_pool struct vk_descriptor_pool
{ {
VkDescriptorPool pool;
VkDescriptorSet sets[VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS];
struct vk_descriptor_pool *next; struct vk_descriptor_pool *next;
VkDescriptorPool pool; /* ptr alignment */
VkDescriptorSet sets[VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS]; /* ptr alignment */
}; };
struct vk_descriptor_manager struct vk_descriptor_manager
{ {
struct vk_descriptor_pool *head; struct vk_descriptor_pool *head;
struct vk_descriptor_pool *current; struct vk_descriptor_pool *current;
VkDescriptorSetLayout set_layout; /* ptr alignment */
VkDescriptorPoolSize sizes[VULKAN_MAX_DESCRIPTOR_POOL_SIZES]; /* uint32_t alignment */
unsigned count; unsigned count;
VkDescriptorPoolSize sizes[VULKAN_MAX_DESCRIPTOR_POOL_SIZES];
VkDescriptorSetLayout set_layout;
unsigned num_sizes; unsigned num_sizes;
}; };
@ -294,37 +292,38 @@ struct vk_per_frame
struct vk_buffer_chain ubo; struct vk_buffer_chain ubo;
struct vk_descriptor_manager descriptor_manager; struct vk_descriptor_manager descriptor_manager;
VkCommandPool cmd_pool; VkCommandPool cmd_pool; /* ptr alignment */
VkCommandBuffer cmd; VkCommandBuffer cmd; /* ptr alignment */
}; };
struct vk_draw_quad struct vk_draw_quad
{ {
VkPipeline pipeline;
struct vk_texture *texture; struct vk_texture *texture;
VkSampler sampler;
const math_matrix_4x4 *mvp; const math_matrix_4x4 *mvp;
struct vk_color color; VkPipeline pipeline; /* ptr alignment */
VkSampler sampler; /* ptr alignment */
struct vk_color color; /* float alignment */
}; };
struct vk_draw_triangles struct vk_draw_triangles
{ {
unsigned vertices;
size_t uniform_size;
const void *uniform; const void *uniform;
const struct vk_buffer_range *vbo; const struct vk_buffer_range *vbo;
struct vk_texture *texture; struct vk_texture *texture;
VkPipeline pipeline; VkPipeline pipeline; /* ptr alignment */
VkSampler sampler; VkSampler sampler; /* ptr alignment */
size_t uniform_size;
unsigned vertices;
}; };
typedef struct vk typedef struct vk
{ {
bool vsync; void *filter_chain;
bool keep_aspect; vulkan_context_t *context;
bool fullscreen; void *ctx_data;
bool quitting; const gfx_ctx_driver_t *ctx_driver;
bool should_resize; struct vk_per_frame *chain;
struct vk_image *backbuffer;
unsigned video_width; unsigned video_width;
unsigned video_height; unsigned video_height;
@ -335,18 +334,13 @@ typedef struct vk
unsigned num_swapchain_images; unsigned num_swapchain_images;
unsigned last_valid_index; unsigned last_valid_index;
vulkan_context_t *context;
video_info_t video; video_info_t video;
void *ctx_data;
const gfx_ctx_driver_t *ctx_driver;
VkFormat tex_fmt; VkFormat tex_fmt;
math_matrix_4x4 mvp, mvp_no_rot; math_matrix_4x4 mvp, mvp_no_rot;
VkViewport vk_vp; VkViewport vk_vp;
VkRenderPass render_pass; VkRenderPass render_pass;
struct video_viewport vp; struct video_viewport vp;
struct vk_per_frame *chain;
struct vk_image *backbuffer;
struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES]; struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES];
struct vk_image backbuffers[VULKAN_MAX_SWAPCHAIN_IMAGES]; struct vk_image backbuffers[VULKAN_MAX_SWAPCHAIN_IMAGES];
struct vk_texture default_texture; struct vk_texture default_texture;
@ -358,20 +352,20 @@ typedef struct vk
struct struct
{ {
bool pending;
bool streamed;
struct scaler_ctx scaler_bgr; struct scaler_ctx scaler_bgr;
struct scaler_ctx scaler_rgb; struct scaler_ctx scaler_rgb;
struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES]; struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool pending;
bool streamed;
} readback; } readback;
struct struct
{ {
bool enable;
bool full_screen;
unsigned count;
struct vk_texture *images; struct vk_texture *images;
struct vk_vertex *vertex; struct vk_vertex *vertex;
unsigned count;
bool enable;
bool full_screen;
} overlay; } overlay;
struct struct
@ -385,20 +379,20 @@ typedef struct vk
struct struct
{ {
bool blend;
VkPipeline pipelines[7 * 2]; VkPipeline pipelines[7 * 2];
struct vk_texture blank_texture; struct vk_texture blank_texture;
bool blend;
} display; } display;
struct struct
{ {
bool enable;
bool full_screen;
unsigned last_index;
float alpha;
struct vk_texture textures[VULKAN_MAX_SWAPCHAIN_IMAGES]; struct vk_texture textures[VULKAN_MAX_SWAPCHAIN_IMAGES];
struct vk_texture textures_optimal[VULKAN_MAX_SWAPCHAIN_IMAGES]; struct vk_texture textures_optimal[VULKAN_MAX_SWAPCHAIN_IMAGES];
unsigned last_index;
float alpha;
bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES]; bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool enable;
bool full_screen;
} menu; } menu;
struct struct
@ -411,8 +405,13 @@ typedef struct vk
struct struct
{ {
bool enable; const struct retro_vulkan_image *image;
bool valid_semaphore; VkPipelineStageFlags *wait_dst_stages;
VkCommandBuffer *cmd;
VkSemaphore *semaphores;
VkSemaphore signal_semaphore; /* ptr alignment */
struct retro_hw_render_interface_vulkan iface;
unsigned capacity_cmd; unsigned capacity_cmd;
unsigned last_width; unsigned last_width;
@ -421,26 +420,27 @@ typedef struct vk
uint32_t num_cmd; uint32_t num_cmd;
uint32_t src_queue_family; uint32_t src_queue_family;
struct retro_hw_render_interface_vulkan iface; bool enable;
const struct retro_vulkan_image *image; bool valid_semaphore;
VkSemaphore *semaphores;
VkSemaphore signal_semaphore;
VkPipelineStageFlags *wait_dst_stages;
VkCommandBuffer *cmd;
} hw; } hw;
struct struct
{ {
uint64_t dirty; uint64_t dirty;
VkRect2D scissor; VkPipeline pipeline; /* ptr alignment */
bool use_scissor; VkImageView view; /* ptr alignment */
VkPipeline pipeline; VkSampler sampler; /* ptr alignment */
VkImageView view;
VkSampler sampler;
math_matrix_4x4 mvp; math_matrix_4x4 mvp;
VkRect2D scissor; /* int32_t alignment */
bool use_scissor;
} tracker; } tracker;
void *filter_chain; bool vsync;
bool keep_aspect;
bool fullscreen;
bool quitting;
bool should_resize;
} vk_t; } vk_t;
#define VK_BUFFER_CHAIN_DISCARD(chain) \ #define VK_BUFFER_CHAIN_DISCARD(chain) \

View File

@ -27,16 +27,16 @@
typedef struct typedef struct
{ {
vk_t *vk; vk_t *vk;
struct vk_texture texture;
struct vk_texture texture_optimal;
const font_renderer_driver_t *font_driver;
void *font_data; void *font_data;
struct font_atlas *atlas; struct font_atlas *atlas;
bool needs_update; const font_renderer_driver_t *font_driver;
struct vk_vertex *pv; struct vk_vertex *pv;
struct vk_texture texture;
struct vk_texture texture_optimal;
struct vk_buffer_range range; struct vk_buffer_range range;
unsigned vertices; unsigned vertices;
bool needs_update;
} vulkan_raster_t; } vulkan_raster_t;
static INLINE void vulkan_raster_font_update_glyph( static INLINE void vulkan_raster_font_update_glyph(