Merge pull request #12380 from stenzek/vulkan-software-fb

(video/vulkan) Avoid caching stale mapped GPU texture as frame data
This commit is contained in:
Autechre 2021-05-18 18:01:47 +02:00 committed by GitHub
commit a04fe66032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -57,6 +57,8 @@
static void vulkan_set_viewport(void *data, unsigned viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate);
static bool vulkan_is_mapped_swapchain_texture_ptr(const vk_t* vk,
const void* ptr);
#ifdef HAVE_OVERLAY
static void vulkan_overlay_free(vk_t *vk);
@ -682,6 +684,12 @@ static void vulkan_deinit_textures(vk_t *vk)
{
unsigned i;
/* Avoid memcpying from a destroyed/unmapped texture later on. */
const void* cached_frame;
video_driver_cached_frame_get(&cached_frame, NULL, NULL, NULL);
if (vulkan_is_mapped_swapchain_texture_ptr(vk, cached_frame))
video_driver_set_cached_frame_ptr(NULL);
vulkan_deinit_samplers(vk);
for (i = 0; i < vk->num_swapchain_images; i++)
@ -2389,6 +2397,18 @@ static bool vulkan_get_current_sw_framebuffer(void *data,
return true;
}
static bool vulkan_is_mapped_swapchain_texture_ptr(const vk_t* vk,
const void* ptr)
{
for (unsigned i = 0; i < vk->num_swapchain_images; i++)
{
if (ptr == vk->swapchain[i].texture.mapped)
return true;
}
return false;
}
static bool vulkan_get_hw_render_interface(void *data,
const struct retro_hw_render_interface **iface)
{

View File

@ -30897,8 +30897,7 @@ static void video_driver_lock_new(struct rarch_state *p_rarch)
void video_driver_set_cached_frame_ptr(const void *data)
{
struct rarch_state *p_rarch = &rarch_st;
if (data)
p_rarch->frame_cache_data = data;
p_rarch->frame_cache_data = data;
}
void video_driver_set_stub_frame(void)