mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
Go through more function pointers
This commit is contained in:
parent
dfde6f833a
commit
0e91bb6852
@ -96,10 +96,11 @@ uint32_t vulkan_find_memory_type_fallback(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vulkan_map_persistent_texture(
|
void vulkan_map_persistent_texture(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
struct vk_texture *texture)
|
struct vk_texture *texture)
|
||||||
{
|
{
|
||||||
vkMapMemory(device, texture->memory, texture->offset,
|
VKFUNC(vkMapMemory)(device, texture->memory, texture->offset,
|
||||||
texture->size, 0, &texture->mapped);
|
texture->size, 0, &texture->mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,8 +356,9 @@ struct vk_texture vulkan_create_texture(vk_t *vk,
|
|||||||
tex.memory_type = old->memory_type;
|
tex.memory_type = old->memory_type;
|
||||||
|
|
||||||
if (old->mapped)
|
if (old->mapped)
|
||||||
vkUnmapMemory(device, old->memory);
|
VKFUNC(vkUnmapMemory)(device, old->memory);
|
||||||
old->memory = VK_NULL_HANDLE;
|
|
||||||
|
old->memory = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -419,7 +421,7 @@ struct vk_texture vulkan_create_texture(vk_t *vk,
|
|||||||
for (y = 0; y < tex.height; y++, dst += tex.stride, src += stride)
|
for (y = 0; y < tex.height; y++, dst += tex.stride, src += stride)
|
||||||
memcpy(dst, src, width * bpp);
|
memcpy(dst, src, width * bpp);
|
||||||
|
|
||||||
vkUnmapMemory(device, tex.memory);
|
VKFUNC(vkUnmapMemory)(device, tex.memory);
|
||||||
}
|
}
|
||||||
else if (initial && type == VULKAN_TEXTURE_STATIC)
|
else if (initial && type == VULKAN_TEXTURE_STATIC)
|
||||||
{
|
{
|
||||||
@ -485,16 +487,20 @@ struct vk_texture vulkan_create_texture(vk_t *vk,
|
|||||||
slock_unlock(vk->context->queue_lock);
|
slock_unlock(vk->context->queue_lock);
|
||||||
|
|
||||||
vkFreeCommandBuffers(vk->context->device, vk->staging_pool, 1, &staging);
|
vkFreeCommandBuffers(vk->context->device, vk->staging_pool, 1, &staging);
|
||||||
vulkan_destroy_texture(vk->context->device, &tmp);
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &tmp);
|
||||||
tex.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
tex.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
}
|
}
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vulkan_destroy_texture(VkDevice device, struct vk_texture *tex)
|
void vulkan_destroy_texture(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
|
struct vk_texture *tex)
|
||||||
{
|
{
|
||||||
if (tex->mapped)
|
if (tex->mapped)
|
||||||
vkUnmapMemory(device, tex->memory);
|
VKFUNC(vkUnmapMemory)(device, tex->memory);
|
||||||
vkFreeMemory(device, tex->memory, NULL);
|
vkFreeMemory(device, tex->memory, NULL);
|
||||||
vkDestroyImageView(device, tex->view, NULL);
|
vkDestroyImageView(device, tex->view, NULL);
|
||||||
vkDestroyImage(device, tex->image, NULL);
|
vkDestroyImage(device, tex->image, NULL);
|
||||||
@ -788,9 +794,12 @@ struct vk_buffer vulkan_create_buffer(const struct vulkan_context *context,
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vulkan_destroy_buffer(VkDevice device, struct vk_buffer *buffer)
|
void vulkan_destroy_buffer(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
|
struct vk_buffer *buffer)
|
||||||
{
|
{
|
||||||
vkUnmapMemory(device, buffer->memory);
|
VKFUNC(vkUnmapMemory)(device, buffer->memory);
|
||||||
vkFreeMemory(device, buffer->memory, NULL);
|
vkFreeMemory(device, buffer->memory, NULL);
|
||||||
vkDestroyBuffer(device, buffer->buffer, NULL);
|
vkDestroyBuffer(device, buffer->buffer, NULL);
|
||||||
memset(buffer, 0, sizeof(*buffer));
|
memset(buffer, 0, sizeof(*buffer));
|
||||||
@ -992,13 +1001,16 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vulkan_buffer_chain_free(VkDevice device, struct vk_buffer_chain *chain)
|
void vulkan_buffer_chain_free(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
|
struct vk_buffer_chain *chain)
|
||||||
{
|
{
|
||||||
struct vk_buffer_node *node = chain->head;
|
struct vk_buffer_node *node = chain->head;
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
struct vk_buffer_node *next = node->next;
|
struct vk_buffer_node *next = node->next;
|
||||||
vulkan_destroy_buffer(device, &node->buffer);
|
vulkan_destroy_buffer(vkcfp, device, &node->buffer);
|
||||||
|
|
||||||
free(node);
|
free(node);
|
||||||
node = next;
|
node = next;
|
||||||
@ -1126,6 +1138,10 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
|
|||||||
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, CmdBindDescriptorSets);
|
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, CmdBindDescriptorSets);
|
||||||
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, UpdateDescriptorSets);
|
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, UpdateDescriptorSets);
|
||||||
|
|
||||||
|
/* Memory allocation */
|
||||||
|
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, MapMemory);
|
||||||
|
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, UnmapMemory);
|
||||||
|
|
||||||
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, CmdSetScissor);
|
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, CmdSetScissor);
|
||||||
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, CmdSetViewport);
|
VK_GET_INSTANCE_PROC_ADDR(vk, vk->context.instance, CmdSetViewport);
|
||||||
|
|
||||||
|
@ -165,7 +165,13 @@ typedef struct vulkan_context
|
|||||||
PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
|
PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
|
||||||
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
|
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
|
||||||
|
|
||||||
|
/* Framebuffers */
|
||||||
PFN_vkCreateFramebuffer vkCreateFramebuffer;
|
PFN_vkCreateFramebuffer vkCreateFramebuffer;
|
||||||
|
|
||||||
|
/* Memory allocation */
|
||||||
|
PFN_vkMapMemory vkMapMemory;
|
||||||
|
PFN_vkUnmapMemory vkUnmapMemory;
|
||||||
|
|
||||||
PFN_vkCreateCommandPool vkCreateCommandPool;
|
PFN_vkCreateCommandPool vkCreateCommandPool;
|
||||||
|
|
||||||
PFN_vkCreateInstance vkCreateInstance;
|
PFN_vkCreateInstance vkCreateInstance;
|
||||||
@ -331,7 +337,9 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context,
|
|||||||
struct vk_buffer_chain *chain, size_t size,
|
struct vk_buffer_chain *chain, size_t size,
|
||||||
struct vk_buffer_range *range);
|
struct vk_buffer_range *range);
|
||||||
|
|
||||||
void vulkan_buffer_chain_free(VkDevice device,
|
void vulkan_buffer_chain_free(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
struct vk_buffer_chain *chain);
|
struct vk_buffer_chain *chain);
|
||||||
|
|
||||||
|
|
||||||
@ -520,8 +528,15 @@ struct vk_texture vulkan_create_texture(vk_t *vk,
|
|||||||
|
|
||||||
void vulkan_transition_texture(vk_t *vk, struct vk_texture *texture);
|
void vulkan_transition_texture(vk_t *vk, struct vk_texture *texture);
|
||||||
|
|
||||||
void vulkan_map_persistent_texture(VkDevice device, struct vk_texture *tex);
|
void vulkan_map_persistent_texture(
|
||||||
void vulkan_destroy_texture(VkDevice device, struct vk_texture *tex);
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
|
struct vk_texture *texture);
|
||||||
|
|
||||||
|
void vulkan_destroy_texture(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
|
struct vk_texture *tex);
|
||||||
|
|
||||||
void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd,
|
void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd,
|
||||||
struct vk_texture *dynamic,
|
struct vk_texture *dynamic,
|
||||||
@ -588,7 +603,11 @@ static INLINE void vulkan_write_quad_vbo(struct vk_vertex *pv,
|
|||||||
|
|
||||||
struct vk_buffer vulkan_create_buffer(const struct vulkan_context *context,
|
struct vk_buffer vulkan_create_buffer(const struct vulkan_context *context,
|
||||||
size_t size, VkBufferUsageFlags usage);
|
size_t size, VkBufferUsageFlags usage);
|
||||||
void vulkan_destroy_buffer(VkDevice device, struct vk_buffer *buffer);
|
|
||||||
|
void vulkan_destroy_buffer(
|
||||||
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
VkDevice device,
|
||||||
|
struct vk_buffer *buffer);
|
||||||
|
|
||||||
VkDescriptorSet vulkan_descriptor_manager_alloc(
|
VkDescriptorSet vulkan_descriptor_manager_alloc(
|
||||||
struct vulkan_context_fp *vkcfp,
|
struct vulkan_context_fp *vkcfp,
|
||||||
|
@ -441,8 +441,10 @@ static void vulkan_deinit_buffers(vk_t *vk)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < vk->num_swapchain_images; i++)
|
for (i = 0; i < vk->num_swapchain_images; i++)
|
||||||
{
|
{
|
||||||
vulkan_buffer_chain_free(vk->context->device, &vk->swapchain[i].vbo);
|
vulkan_buffer_chain_free(&vk->context->fp,
|
||||||
vulkan_buffer_chain_free(vk->context->device, &vk->swapchain[i].ubo);
|
vk->context->device, &vk->swapchain[i].vbo);
|
||||||
|
vulkan_buffer_chain_free(&vk->context->fp,
|
||||||
|
vk->context->device, &vk->swapchain[i].ubo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +488,9 @@ static void vulkan_init_textures(vk_t *vk)
|
|||||||
vk->swapchain[i].texture = vulkan_create_texture(vk, NULL,
|
vk->swapchain[i].texture = vulkan_create_texture(vk, NULL,
|
||||||
vk->tex_w, vk->tex_h, vk->tex_fmt,
|
vk->tex_w, vk->tex_h, vk->tex_fmt,
|
||||||
NULL, NULL, VULKAN_TEXTURE_STREAMED);
|
NULL, NULL, VULKAN_TEXTURE_STREAMED);
|
||||||
vulkan_map_persistent_texture(vk->context->device,
|
|
||||||
|
vulkan_map_persistent_texture(&vk->context->fp,
|
||||||
|
vk->context->device,
|
||||||
&vk->swapchain[i].texture);
|
&vk->swapchain[i].texture);
|
||||||
|
|
||||||
if (vk->swapchain[i].texture.type == VULKAN_TEXTURE_STAGING)
|
if (vk->swapchain[i].texture.type == VULKAN_TEXTURE_STAGING)
|
||||||
@ -507,9 +511,12 @@ static void vulkan_deinit_textures(vk_t *vk)
|
|||||||
for (i = 0; i < vk->num_swapchain_images; i++)
|
for (i = 0; i < vk->num_swapchain_images; i++)
|
||||||
{
|
{
|
||||||
if (vk->swapchain[i].texture.memory != VK_NULL_HANDLE)
|
if (vk->swapchain[i].texture.memory != VK_NULL_HANDLE)
|
||||||
vulkan_destroy_texture(vk->context->device, &vk->swapchain[i].texture);
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &vk->swapchain[i].texture);
|
||||||
|
|
||||||
if (vk->swapchain[i].texture_optimal.memory != VK_NULL_HANDLE)
|
if (vk->swapchain[i].texture_optimal.memory != VK_NULL_HANDLE)
|
||||||
vulkan_destroy_texture(vk->context->device, &vk->swapchain[i].texture_optimal);
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &vk->swapchain[i].texture_optimal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,15 +694,18 @@ static void vulkan_deinit_static_resources(vk_t *vk)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
vkDestroyPipelineCache(vk->context->device,
|
vkDestroyPipelineCache(vk->context->device,
|
||||||
vk->pipelines.cache, NULL);
|
vk->pipelines.cache, NULL);
|
||||||
vulkan_destroy_texture(vk->context->device,
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device,
|
||||||
&vk->display.blank_texture);
|
&vk->display.blank_texture);
|
||||||
|
|
||||||
vkDestroyCommandPool(vk->context->device, vk->staging_pool, NULL);
|
vkDestroyCommandPool(vk->context->device, vk->staging_pool, NULL);
|
||||||
free(vk->hw.cmd);
|
free(vk->hw.cmd);
|
||||||
free(vk->hw.wait_dst_stages);
|
free(vk->hw.wait_dst_stages);
|
||||||
|
|
||||||
for (i = 0; i < VULKAN_MAX_SWAPCHAIN_IMAGES; i++)
|
for (i = 0; i < VULKAN_MAX_SWAPCHAIN_IMAGES; i++)
|
||||||
if (vk->readback.staging[i].memory != VK_NULL_HANDLE)
|
if (vk->readback.staging[i].memory != VK_NULL_HANDLE)
|
||||||
vulkan_destroy_texture(vk->context->device,
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device,
|
||||||
&vk->readback.staging[i]);
|
&vk->readback.staging[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -715,9 +725,11 @@ static void vulkan_deinit_menu(vk_t *vk)
|
|||||||
for (i = 0; i < VULKAN_MAX_SWAPCHAIN_IMAGES; i++)
|
for (i = 0; i < VULKAN_MAX_SWAPCHAIN_IMAGES; i++)
|
||||||
{
|
{
|
||||||
if (vk->menu.textures[i].memory)
|
if (vk->menu.textures[i].memory)
|
||||||
vulkan_destroy_texture(vk->context->device, &vk->menu.textures[i]);
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &vk->menu.textures[i]);
|
||||||
if (vk->menu.textures_optimal[i].memory)
|
if (vk->menu.textures_optimal[i].memory)
|
||||||
vulkan_destroy_texture(vk->context->device, &vk->menu.textures_optimal[i]);
|
vulkan_destroy_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &vk->menu.textures_optimal[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1398,12 +1410,17 @@ static bool vulkan_frame(void *data, const void *frame,
|
|||||||
{
|
{
|
||||||
chain->texture = vulkan_create_texture(vk, &chain->texture,
|
chain->texture = vulkan_create_texture(vk, &chain->texture,
|
||||||
frame_width, frame_height, chain->texture.format, NULL, NULL,
|
frame_width, frame_height, chain->texture.format, NULL, NULL,
|
||||||
chain->texture_optimal.memory ? VULKAN_TEXTURE_STAGING : VULKAN_TEXTURE_STREAMED);
|
chain->texture_optimal.memory
|
||||||
vulkan_map_persistent_texture(vk->context->device, &chain->texture);
|
? VULKAN_TEXTURE_STAGING : VULKAN_TEXTURE_STREAMED);
|
||||||
|
|
||||||
|
vulkan_map_persistent_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &chain->texture);
|
||||||
|
|
||||||
if (chain->texture.type == VULKAN_TEXTURE_STAGING)
|
if (chain->texture.type == VULKAN_TEXTURE_STAGING)
|
||||||
{
|
{
|
||||||
chain->texture_optimal = vulkan_create_texture(vk, &chain->texture_optimal,
|
chain->texture_optimal = vulkan_create_texture(
|
||||||
|
vk,
|
||||||
|
&chain->texture_optimal,
|
||||||
frame_width, frame_height, chain->texture_optimal.format,
|
frame_width, frame_height, chain->texture_optimal.format,
|
||||||
NULL, NULL, VULKAN_TEXTURE_DYNAMIC);
|
NULL, NULL, VULKAN_TEXTURE_DYNAMIC);
|
||||||
}
|
}
|
||||||
@ -1740,7 +1757,8 @@ static bool vulkan_get_current_sw_framebuffer(void *data,
|
|||||||
chain->texture = vulkan_create_texture(vk, &chain->texture,
|
chain->texture = vulkan_create_texture(vk, &chain->texture,
|
||||||
framebuffer->width, framebuffer->height, chain->texture.format,
|
framebuffer->width, framebuffer->height, chain->texture.format,
|
||||||
NULL, NULL, VULKAN_TEXTURE_STREAMED);
|
NULL, NULL, VULKAN_TEXTURE_STREAMED);
|
||||||
vulkan_map_persistent_texture(vk->context->device, &chain->texture);
|
vulkan_map_persistent_texture(&vk->context->fp,
|
||||||
|
vk->context->device, &chain->texture);
|
||||||
|
|
||||||
if (chain->texture.type == VULKAN_TEXTURE_STAGING)
|
if (chain->texture.type == VULKAN_TEXTURE_STAGING)
|
||||||
{
|
{
|
||||||
@ -1881,7 +1899,9 @@ static void vulkan_unload_texture(void *data, uintptr_t handle)
|
|||||||
/* TODO: We really want to defer this deletion instead,
|
/* TODO: We really want to defer this deletion instead,
|
||||||
* but this will do for now. */
|
* but this will do for now. */
|
||||||
VKFUNC(vkQueueWaitIdle)(vk->context->queue);
|
VKFUNC(vkQueueWaitIdle)(vk->context->queue);
|
||||||
vulkan_destroy_texture(vk->context->device, texture);
|
vulkan_destroy_texture(
|
||||||
|
&vk->context->fp,
|
||||||
|
vk->context->device, texture);
|
||||||
free(texture);
|
free(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1982,7 +2002,9 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer)
|
|||||||
VKFUNC(vkQueueWaitIdle)(vk->context->queue);
|
VKFUNC(vkQueueWaitIdle)(vk->context->queue);
|
||||||
|
|
||||||
if (!staging->mapped)
|
if (!staging->mapped)
|
||||||
vulkan_map_persistent_texture(vk->context->device, staging);
|
vulkan_map_persistent_texture(
|
||||||
|
&vk->context->fp,
|
||||||
|
vk->context->device, staging);
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned x, y;
|
unsigned x, y;
|
||||||
@ -2001,7 +2023,9 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vulkan_destroy_texture(vk->context->device, staging);
|
vulkan_destroy_texture(
|
||||||
|
&vk->context->fp,
|
||||||
|
vk->context->device, staging);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2036,7 +2060,9 @@ static void vulkan_overlay_free(vk_t *vk)
|
|||||||
free(vk->overlay.vertex);
|
free(vk->overlay.vertex);
|
||||||
for (i = 0; i < vk->overlay.count; i++)
|
for (i = 0; i < vk->overlay.count; i++)
|
||||||
if (vk->overlay.images[i].memory != VK_NULL_HANDLE)
|
if (vk->overlay.images[i].memory != VK_NULL_HANDLE)
|
||||||
vulkan_destroy_texture(vk->context->device,
|
vulkan_destroy_texture(
|
||||||
|
&vk->context->fp,
|
||||||
|
vk->context->device,
|
||||||
&vk->overlay.images[i]);
|
&vk->overlay.images[i]);
|
||||||
|
|
||||||
memset(&vk->overlay, 0, sizeof(vk->overlay));
|
memset(&vk->overlay, 0, sizeof(vk->overlay));
|
||||||
|
@ -79,7 +79,8 @@ static void vulkan_raster_font_free_font(void *data)
|
|||||||
font->font_driver->free(font->font_data);
|
font->font_driver->free(font->font_data);
|
||||||
|
|
||||||
VKFUNC(vkQueueWaitIdle)(font->vk->context->queue);
|
VKFUNC(vkQueueWaitIdle)(font->vk->context->queue);
|
||||||
vulkan_destroy_texture(font->vk->context->device, &font->texture);
|
vulkan_destroy_texture(vkcfp,
|
||||||
|
font->vk->context->device, &font->texture);
|
||||||
|
|
||||||
free(font);
|
free(font);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user