mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
Cleanups
This commit is contained in:
parent
0488415329
commit
3a92a60a8e
@ -86,24 +86,30 @@ enum vulkan_wsi_type
|
|||||||
|
|
||||||
typedef struct vulkan_context
|
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;
|
||||||
|
|
||||||
|
unsigned swapchain_width;
|
||||||
|
unsigned swapchain_height;
|
||||||
|
unsigned swap_interval;
|
||||||
|
|
||||||
|
uint32_t graphics_queue_index;
|
||||||
|
uint32_t num_swapchain_images;
|
||||||
|
uint32_t current_swapchain_index;
|
||||||
|
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
VkPhysicalDevice gpu;
|
VkPhysicalDevice gpu;
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
VkQueue queue;
|
VkQueue queue;
|
||||||
uint32_t graphics_queue_index;
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties gpu_properties;
|
VkPhysicalDeviceProperties gpu_properties;
|
||||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||||
|
|
||||||
bool invalid_swapchain;
|
|
||||||
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];
|
||||||
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
||||||
uint32_t num_swapchain_images;
|
|
||||||
uint32_t current_swapchain_index;
|
|
||||||
unsigned swapchain_width;
|
|
||||||
unsigned swapchain_height;
|
|
||||||
unsigned swap_interval;
|
|
||||||
VkFormat swapchain_format;
|
VkFormat swapchain_format;
|
||||||
|
|
||||||
slock_t *queue_lock;
|
slock_t *queue_lock;
|
||||||
@ -112,18 +118,14 @@ typedef struct vulkan_context
|
|||||||
#ifdef VULKAN_DEBUG
|
#ifdef VULKAN_DEBUG
|
||||||
VkDebugReportCallbackEXT debug_callback;
|
VkDebugReportCallbackEXT debug_callback;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Used by screenshot to get blits with correct colorspace. */
|
|
||||||
bool swapchain_is_srgb;
|
|
||||||
bool swap_interval_emulation_lock;
|
|
||||||
} vulkan_context_t;
|
} vulkan_context_t;
|
||||||
|
|
||||||
typedef struct gfx_ctx_vulkan_data
|
typedef struct gfx_ctx_vulkan_data
|
||||||
{
|
{
|
||||||
|
bool need_new_swapchain;
|
||||||
vulkan_context_t context;
|
vulkan_context_t context;
|
||||||
VkSurfaceKHR vk_surface;
|
VkSurfaceKHR vk_surface;
|
||||||
VkSwapchainKHR swapchain;
|
VkSwapchainKHR swapchain;
|
||||||
bool need_new_swapchain;
|
|
||||||
} gfx_ctx_vulkan_data_t;
|
} gfx_ctx_vulkan_data_t;
|
||||||
|
|
||||||
struct vulkan_display_surface_info
|
struct vulkan_display_surface_info
|
||||||
@ -153,25 +155,27 @@ struct vk_image
|
|||||||
|
|
||||||
struct vk_texture
|
struct vk_texture
|
||||||
{
|
{
|
||||||
VkImage image;
|
|
||||||
VkImageView view;
|
|
||||||
VkDeviceMemory memory;
|
|
||||||
|
|
||||||
unsigned width, height;
|
|
||||||
VkFormat format;
|
|
||||||
|
|
||||||
void *mapped;
|
|
||||||
size_t offset;
|
|
||||||
size_t stride;
|
|
||||||
size_t size;
|
|
||||||
VkDeviceSize memory_size;
|
|
||||||
uint32_t memory_type;
|
|
||||||
|
|
||||||
VkImageLayout layout;
|
|
||||||
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;
|
||||||
|
|
||||||
|
VkFormat format;
|
||||||
|
|
||||||
|
VkDeviceSize memory_size;
|
||||||
|
|
||||||
|
VkImageLayout layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vk_buffer
|
struct vk_buffer
|
||||||
@ -263,39 +267,39 @@ struct vk_draw_quad
|
|||||||
|
|
||||||
struct vk_draw_triangles
|
struct vk_draw_triangles
|
||||||
{
|
{
|
||||||
VkPipeline pipeline;
|
|
||||||
struct vk_texture *texture;
|
|
||||||
VkSampler sampler;
|
|
||||||
|
|
||||||
const void *uniform;
|
|
||||||
size_t uniform_size;
|
|
||||||
|
|
||||||
const struct vk_buffer_range *vbo;
|
|
||||||
unsigned vertices;
|
unsigned vertices;
|
||||||
|
size_t uniform_size;
|
||||||
|
const void *uniform;
|
||||||
|
const struct vk_buffer_range *vbo;
|
||||||
|
struct vk_texture *texture;
|
||||||
|
VkPipeline pipeline;
|
||||||
|
VkSampler sampler;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct vk
|
typedef struct vk
|
||||||
{
|
{
|
||||||
vulkan_context_t *context;
|
|
||||||
video_info_t video;
|
|
||||||
|
|
||||||
unsigned tex_w, tex_h;
|
|
||||||
VkFormat tex_fmt;
|
|
||||||
bool vsync;
|
bool vsync;
|
||||||
bool keep_aspect;
|
bool keep_aspect;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool quitting;
|
bool quitting;
|
||||||
bool should_resize;
|
bool should_resize;
|
||||||
|
|
||||||
|
unsigned tex_w, tex_h;
|
||||||
unsigned vp_out_width, vp_out_height;
|
unsigned vp_out_width, vp_out_height;
|
||||||
|
|
||||||
unsigned rotation;
|
unsigned rotation;
|
||||||
math_matrix_4x4 mvp, mvp_no_rot;
|
|
||||||
struct video_viewport vp;
|
|
||||||
VkViewport vk_vp;
|
|
||||||
|
|
||||||
VkRenderPass render_pass;
|
|
||||||
struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
|
||||||
unsigned num_swapchain_images;
|
unsigned num_swapchain_images;
|
||||||
|
unsigned last_valid_index;
|
||||||
|
|
||||||
|
vulkan_context_t *context;
|
||||||
|
video_info_t video;
|
||||||
|
|
||||||
|
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_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
||||||
|
|
||||||
/* Currently active command buffer. */
|
/* Currently active command buffer. */
|
||||||
VkCommandBuffer cmd;
|
VkCommandBuffer cmd;
|
||||||
@ -304,19 +308,19 @@ typedef struct vk
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
|
||||||
struct scaler_ctx scaler;
|
|
||||||
bool pending;
|
bool pending;
|
||||||
bool streamed;
|
bool streamed;
|
||||||
|
struct scaler_ctx scaler;
|
||||||
|
struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
||||||
} readback;
|
} readback;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
struct vk_texture *images;
|
|
||||||
struct vk_vertex *vertex;
|
|
||||||
unsigned count;
|
|
||||||
bool enable;
|
bool enable;
|
||||||
bool full_screen;
|
bool full_screen;
|
||||||
|
unsigned count;
|
||||||
|
struct vk_texture *images;
|
||||||
|
struct vk_vertex *vertex;
|
||||||
} overlay;
|
} overlay;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@ -337,14 +341,13 @@ typedef struct vk
|
|||||||
|
|
||||||
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];
|
||||||
bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES];
|
||||||
|
|
||||||
float alpha;
|
|
||||||
unsigned last_index;
|
|
||||||
bool enable;
|
|
||||||
bool full_screen;
|
|
||||||
} menu;
|
} menu;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@ -355,39 +358,33 @@ typedef struct vk
|
|||||||
VkSampler mipmap_linear;
|
VkSampler mipmap_linear;
|
||||||
} samplers;
|
} samplers;
|
||||||
|
|
||||||
unsigned last_valid_index;
|
|
||||||
|
|
||||||
struct vk_per_frame *chain;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
bool enable;
|
||||||
|
bool valid_semaphore;
|
||||||
|
|
||||||
|
unsigned capacity_cmd;
|
||||||
|
unsigned last_width;
|
||||||
|
unsigned last_height;
|
||||||
|
uint32_t num_semaphores;
|
||||||
|
uint32_t num_cmd;
|
||||||
|
uint32_t src_queue_family;
|
||||||
|
|
||||||
struct retro_hw_render_interface_vulkan iface;
|
struct retro_hw_render_interface_vulkan iface;
|
||||||
const struct retro_vulkan_image *image;
|
const struct retro_vulkan_image *image;
|
||||||
const VkSemaphore *semaphores;
|
const VkSemaphore *semaphores;
|
||||||
uint32_t num_semaphores;
|
|
||||||
VkSemaphore signal_semaphore;
|
VkSemaphore signal_semaphore;
|
||||||
|
|
||||||
VkPipelineStageFlags *wait_dst_stages;
|
VkPipelineStageFlags *wait_dst_stages;
|
||||||
|
|
||||||
VkCommandBuffer *cmd;
|
VkCommandBuffer *cmd;
|
||||||
uint32_t num_cmd;
|
|
||||||
unsigned capacity_cmd;
|
|
||||||
|
|
||||||
unsigned last_width;
|
|
||||||
unsigned last_height;
|
|
||||||
uint32_t src_queue_family;
|
|
||||||
|
|
||||||
bool enable;
|
|
||||||
bool valid_semaphore;
|
|
||||||
} hw;
|
} hw;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
uint64_t dirty;
|
||||||
VkPipeline pipeline;
|
VkPipeline pipeline;
|
||||||
VkImageView view;
|
VkImageView view;
|
||||||
VkSampler sampler;
|
VkSampler sampler;
|
||||||
math_matrix_4x4 mvp;
|
math_matrix_4x4 mvp;
|
||||||
uint64_t dirty;
|
|
||||||
} tracker;
|
} tracker;
|
||||||
|
|
||||||
void *filter_chain;
|
void *filter_chain;
|
||||||
|
@ -217,7 +217,8 @@ static void menu_display_vk_draw(void *data)
|
|||||||
for (i = 0; i < draw->coords->vertices; i++, pv++)
|
for (i = 0; i < draw->coords->vertices; i++, pv++)
|
||||||
{
|
{
|
||||||
pv->x = *vertex++;
|
pv->x = *vertex++;
|
||||||
pv->y = 1.0f - (*vertex++); /* Y-flip. Vulkan is top-left clip space */
|
/* Y-flip. Vulkan is top-left clip space */
|
||||||
|
pv->y = 1.0f - (*vertex++);
|
||||||
pv->tex_x = *tex_coord++;
|
pv->tex_x = *tex_coord++;
|
||||||
pv->tex_y = *tex_coord++;
|
pv->tex_y = *tex_coord++;
|
||||||
pv->color.r = *color++;
|
pv->color.r = *color++;
|
||||||
@ -235,16 +236,17 @@ static void menu_display_vk_draw(void *data)
|
|||||||
case VIDEO_SHADER_MENU_4:
|
case VIDEO_SHADER_MENU_4:
|
||||||
case VIDEO_SHADER_MENU_5:
|
case VIDEO_SHADER_MENU_5:
|
||||||
{
|
{
|
||||||
const struct vk_draw_triangles call = {
|
struct vk_draw_triangles call;
|
||||||
vk->display.pipelines[
|
|
||||||
to_menu_pipeline(draw->prim_type, draw->pipeline.id)],
|
call.pipeline = vk->display.pipelines[
|
||||||
NULL,
|
to_menu_pipeline(draw->prim_type, draw->pipeline.id)];
|
||||||
VK_NULL_HANDLE,
|
call.texture = NULL;
|
||||||
draw->pipeline.backend_data,
|
call.sampler = VK_NULL_HANDLE;
|
||||||
draw->pipeline.backend_data_size,
|
call.uniform = draw->pipeline.backend_data;
|
||||||
&range,
|
call.uniform_size = draw->pipeline.backend_data_size;
|
||||||
draw->coords->vertices,
|
call.vbo = ⦥
|
||||||
};
|
call.vertices = draw->coords->vertices;
|
||||||
|
|
||||||
vulkan_draw_triangles(vk, &call);
|
vulkan_draw_triangles(vk, &call);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -261,7 +263,8 @@ static void menu_display_vk_draw(void *data)
|
|||||||
call.texture = texture;
|
call.texture = texture;
|
||||||
call.sampler = texture->mipmap ?
|
call.sampler = texture->mipmap ?
|
||||||
vk->samplers.mipmap_linear :
|
vk->samplers.mipmap_linear :
|
||||||
(texture->default_smooth ? vk->samplers.linear : vk->samplers.nearest);
|
(texture->default_smooth ? vk->samplers.linear
|
||||||
|
: vk->samplers.nearest);
|
||||||
call.uniform = draw->matrix_data
|
call.uniform = draw->matrix_data
|
||||||
? draw->matrix_data : menu_display_vk_get_default_mvp();
|
? draw->matrix_data : menu_display_vk_get_default_mvp();
|
||||||
call.uniform_size = sizeof(math_matrix_4x4);
|
call.uniform_size = sizeof(math_matrix_4x4);
|
||||||
@ -278,7 +281,8 @@ static void menu_display_vk_restore_clear_color(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void menu_display_vk_clear_color(menu_display_ctx_clearcolor_t *clearcolor)
|
static void menu_display_vk_clear_color(
|
||||||
|
menu_display_ctx_clearcolor_t *clearcolor)
|
||||||
{
|
{
|
||||||
VkClearRect rect;
|
VkClearRect rect;
|
||||||
VkClearAttachment attachment;
|
VkClearAttachment attachment;
|
||||||
@ -287,13 +291,14 @@ static void menu_display_vk_clear_color(menu_display_ctx_clearcolor_t *clearcolo
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
memset(&attachment, 0, sizeof(attachment));
|
memset(&attachment, 0, sizeof(attachment));
|
||||||
|
memset(&rect, 0, sizeof(rect));
|
||||||
|
|
||||||
attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
attachment.clearValue.color.float32[0] = clearcolor->r;
|
attachment.clearValue.color.float32[0] = clearcolor->r;
|
||||||
attachment.clearValue.color.float32[1] = clearcolor->g;
|
attachment.clearValue.color.float32[1] = clearcolor->g;
|
||||||
attachment.clearValue.color.float32[2] = clearcolor->b;
|
attachment.clearValue.color.float32[2] = clearcolor->b;
|
||||||
attachment.clearValue.color.float32[3] = clearcolor->a;
|
attachment.clearValue.color.float32[3] = clearcolor->a;
|
||||||
|
|
||||||
memset(&rect, 0, sizeof(rect));
|
|
||||||
rect.rect.extent.width = vk->context->swapchain_width;
|
rect.rect.extent.width = vk->context->swapchain_width;
|
||||||
rect.rect.extent.height = vk->context->swapchain_height;
|
rect.rect.extent.height = vk->context->swapchain_height;
|
||||||
rect.layerCount = 1;
|
rect.layerCount = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user