From 1ac758a2ef98a137eec874fd47c8454c7043a72e Mon Sep 17 00:00:00 2001 From: jpark37 Date: Thu, 2 Jun 2022 21:58:42 -0700 Subject: [PATCH] libobs: Ensure active copy surfaces are active Stale surfaces can cause improper downloads from GPU, and lead to video corruption in certain cases. --- libobs/obs-video.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libobs/obs-video.c b/libobs/obs-video.c index a2dc38a6f..bb3b160e6 100644 --- a/libobs/obs-video.c +++ b/libobs/obs-video.c @@ -392,22 +392,25 @@ stage_output_texture(struct obs_core_video *video, int cur_texture, if (!video->gpu_conversion) { gs_stagesurf_t *copy = copy_surfaces[0]; - if (copy) { + if (copy) gs_stage_texture(copy, video->output_texture); - video->active_copy_surfaces[cur_texture][0] = copy; - } + video->active_copy_surfaces[cur_texture][0] = copy; + + for (size_t i = 1; i < NUM_CHANNELS; ++i) + video->active_copy_surfaces[cur_texture][i] = NULL; video->textures_copied[cur_texture] = true; } else if (video->texture_converted) { for (size_t i = 0; i < channel_count; i++) { gs_stagesurf_t *copy = copy_surfaces[i]; - if (copy) { + if (copy) gs_stage_texture(copy, convert_textures[i]); - video->active_copy_surfaces[cur_texture][i] = - copy; - } + video->active_copy_surfaces[cur_texture][i] = copy; } + for (size_t i = channel_count; i < NUM_CHANNELS; ++i) + video->active_copy_surfaces[cur_texture][i] = NULL; + video->textures_copied[cur_texture] = true; }