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
{
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;
unsigned swapchain_width;
unsigned swapchain_height;
unsigned swap_interval;
slock_t *queue_lock;
retro_vulkan_destroy_device_t destroy_device; /* ptr alignment */
uint32_t graphics_queue_index;
uint32_t num_swapchain_images;
uint32_t current_swapchain_index;
uint32_t current_frame_index;
unsigned swapchain_width;
unsigned swapchain_height;
unsigned swap_interval;
unsigned num_recycled_acquire_semaphores;
VkInstance instance;
VkPhysicalDevice gpu;
VkDevice device;
@ -117,41 +115,54 @@ typedef struct vulkan_context
VkImage swapchain_images[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;
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkSemaphore swapchain_acquire_semaphore;
unsigned num_recycled_acquire_semaphores;
VkSemaphore swapchain_recycled_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
VkDebugReportCallbackEXT debug_callback;
#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;
struct vulkan_emulated_mailbox
{
sthread_t *thread;
VkDevice device;
VkSwapchainKHR swapchain;
slock_t *lock;
scond_t *cond;
VkDevice device; /* ptr alignment */
VkSwapchainKHR swapchain; /* ptr alignment */
unsigned index;
VkResult result; /* enum alignment */
bool acquired;
bool request_acquire;
bool dead;
bool has_pending_request;
VkResult result;
};
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 created_new_swapchain;
bool emulate_mailbox;
@ -160,16 +171,6 @@ typedef struct gfx_ctx_vulkan_data
* semaphores instead of fences for vkAcquireNextImageKHR.
* Helps workaround certain performance issues on some drivers. */
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;
struct vulkan_display_surface_info
@ -193,43 +194,41 @@ struct vk_vertex
struct vk_image
{
VkImage image;
VkImageView view;
VkFramebuffer framebuffer;
VkImage image; /* ptr alignment */
VkImageView view; /* ptr alignment */
VkFramebuffer framebuffer; /* ptr alignment */
};
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;
bool default_smooth;
bool need_manual_cache_management;
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
{
VkBuffer buffer;
VkDeviceMemory memory;
VkDeviceSize size;
VkDeviceSize size; /* uint64_t alignment */
void *mapped;
VkBuffer buffer; /* ptr alignment */
VkDeviceMemory memory; /* ptr alignment */
};
struct vk_buffer_node
@ -240,19 +239,19 @@ struct vk_buffer_node
struct vk_buffer_chain
{
VkDeviceSize block_size;
VkDeviceSize alignment;
VkDeviceSize offset;
VkBufferUsageFlags usage;
VkDeviceSize block_size; /* uint64_t alignment */
VkDeviceSize alignment; /* uint64_t alignment */
VkDeviceSize offset; /* uint64_t alignment */
struct vk_buffer_node *head;
struct vk_buffer_node *current;
VkBufferUsageFlags usage; /* uint32_t alignment */
};
struct vk_buffer_range
{
VkDeviceSize offset; /* uint64_t alignment */
uint8_t *data;
VkBuffer buffer;
VkDeviceSize offset;
VkBuffer buffer; /* ptr alignment */
};
struct vk_buffer_chain vulkan_buffer_chain_init(
@ -270,19 +269,18 @@ void vulkan_buffer_chain_free(
struct vk_descriptor_pool
{
VkDescriptorPool pool;
VkDescriptorSet sets[VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS];
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_pool *head;
struct vk_descriptor_pool *current;
VkDescriptorSetLayout set_layout; /* ptr alignment */
VkDescriptorPoolSize sizes[VULKAN_MAX_DESCRIPTOR_POOL_SIZES]; /* uint32_t alignment */
unsigned count;
VkDescriptorPoolSize sizes[VULKAN_MAX_DESCRIPTOR_POOL_SIZES];
VkDescriptorSetLayout set_layout;
unsigned num_sizes;
};
@ -294,37 +292,38 @@ struct vk_per_frame
struct vk_buffer_chain ubo;
struct vk_descriptor_manager descriptor_manager;
VkCommandPool cmd_pool;
VkCommandBuffer cmd;
VkCommandPool cmd_pool; /* ptr alignment */
VkCommandBuffer cmd; /* ptr alignment */
};
struct vk_draw_quad
{
VkPipeline pipeline;
struct vk_texture *texture;
VkSampler sampler;
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
{
unsigned vertices;
size_t uniform_size;
const void *uniform;
const struct vk_buffer_range *vbo;
struct vk_texture *texture;
VkPipeline pipeline;
VkSampler sampler;
VkPipeline pipeline; /* ptr alignment */
VkSampler sampler; /* ptr alignment */
size_t uniform_size;
unsigned vertices;
};
typedef struct vk
{
bool vsync;
bool keep_aspect;
bool fullscreen;
bool quitting;
bool should_resize;
void *filter_chain;
vulkan_context_t *context;
void *ctx_data;
const gfx_ctx_driver_t *ctx_driver;
struct vk_per_frame *chain;
struct vk_image *backbuffer;
unsigned video_width;
unsigned video_height;
@ -335,18 +334,13 @@ typedef struct vk
unsigned num_swapchain_images;
unsigned last_valid_index;
vulkan_context_t *context;
video_info_t video;
void *ctx_data;
const gfx_ctx_driver_t *ctx_driver;
VkFormat tex_fmt;
math_matrix_4x4 mvp, mvp_no_rot;
VkViewport vk_vp;
VkRenderPass render_pass;
struct video_viewport vp;
struct vk_per_frame *chain;
struct vk_image *backbuffer;
struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES];
struct vk_image backbuffers[VULKAN_MAX_SWAPCHAIN_IMAGES];
struct vk_texture default_texture;
@ -358,20 +352,20 @@ typedef struct vk
struct
{
bool pending;
bool streamed;
struct scaler_ctx scaler_bgr;
struct scaler_ctx scaler_rgb;
struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool pending;
bool streamed;
} readback;
struct
{
bool enable;
bool full_screen;
unsigned count;
struct vk_texture *images;
struct vk_vertex *vertex;
unsigned count;
bool enable;
bool full_screen;
} overlay;
struct
@ -385,20 +379,20 @@ typedef struct vk
struct
{
bool blend;
VkPipeline pipelines[7 * 2];
struct vk_texture blank_texture;
bool blend;
} display;
struct
{
bool enable;
bool full_screen;
unsigned last_index;
float alpha;
struct vk_texture textures[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 enable;
bool full_screen;
} menu;
struct
@ -411,8 +405,13 @@ typedef struct vk
struct
{
bool enable;
bool valid_semaphore;
const struct retro_vulkan_image *image;
VkPipelineStageFlags *wait_dst_stages;
VkCommandBuffer *cmd;
VkSemaphore *semaphores;
VkSemaphore signal_semaphore; /* ptr alignment */
struct retro_hw_render_interface_vulkan iface;
unsigned capacity_cmd;
unsigned last_width;
@ -421,26 +420,27 @@ typedef struct vk
uint32_t num_cmd;
uint32_t src_queue_family;
struct retro_hw_render_interface_vulkan iface;
const struct retro_vulkan_image *image;
VkSemaphore *semaphores;
VkSemaphore signal_semaphore;
VkPipelineStageFlags *wait_dst_stages;
VkCommandBuffer *cmd;
bool enable;
bool valid_semaphore;
} hw;
struct
{
uint64_t dirty;
VkRect2D scissor;
bool use_scissor;
VkPipeline pipeline;
VkImageView view;
VkSampler sampler;
VkPipeline pipeline; /* ptr alignment */
VkImageView view; /* ptr alignment */
VkSampler sampler; /* ptr alignment */
math_matrix_4x4 mvp;
VkRect2D scissor; /* int32_t alignment */
bool use_scissor;
} tracker;
void *filter_chain;
bool vsync;
bool keep_aspect;
bool fullscreen;
bool quitting;
bool should_resize;
} vk_t;
#define VK_BUFFER_CHAIN_DISCARD(chain) \

View File

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