From 537412b959ba7cb551ca6b1c1e33a90f181471a6 Mon Sep 17 00:00:00 2001 From: Seth Date: Tue, 26 Feb 2019 13:21:31 -0600 Subject: [PATCH 1/2] trying to remove graphical anomalies, alternative deadlock fix branch --- BasiliskII/src/SDL/video_sdl2.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index c99e3248..82888389 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -875,23 +875,26 @@ static int present_sdl_video() SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 0); // Use black SDL_RenderClear(sdl_renderer); // Clear the display + LOCK_PALETTE; + SDL_LockMutex(sdl_update_video_mutex); // Convert from the guest OS' pixel format, to the host OS' texture, if necessary. if (host_surface != guest_surface && host_surface != NULL && guest_surface != NULL) { SDL_Rect destRect = sdl_update_video_rect; - LOCK_PALETTE; - SDL_LockMutex(sdl_update_video_mutex); int result = SDL_BlitSurface(guest_surface, &sdl_update_video_rect, host_surface, &destRect); - SDL_UnlockMutex(sdl_update_video_mutex); - UNLOCK_PALETTE; - if (result != 0) return -1; + if (result != 0) { + SDL_UnlockMutex(sdl_update_video_mutex); + UNLOCK_PALETTE; + return -1; + } } + UNLOCK_PALETTE; // We're about to work with sdl_update_video_rect, so stop other threads from // modifying it! - SDL_LockMutex(sdl_update_video_mutex); +// SDL_LockMutex(sdl_update_video_mutex); // Update the host OS' texture void * srcPixels = (void *)((uint8_t *)host_surface->pixels + From 1889560d1f13cdf8216f07dfa8404f3a3f998b4e Mon Sep 17 00:00:00 2001 From: Seth Date: Tue, 26 Feb 2019 21:02:57 -0600 Subject: [PATCH 2/2] deadlock and video fix comments tidied --- BasiliskII/src/SDL/video_sdl2.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 82888389..b6237489 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -875,6 +875,8 @@ static int present_sdl_video() SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 0); // Use black SDL_RenderClear(sdl_renderer); // Clear the display + // We're about to work with sdl_update_video_rect, so stop other threads from + // modifying it! LOCK_PALETTE; SDL_LockMutex(sdl_update_video_mutex); // Convert from the guest OS' pixel format, to the host OS' texture, if necessary. @@ -890,11 +892,7 @@ static int present_sdl_video() return -1; } } - UNLOCK_PALETTE; - - // We're about to work with sdl_update_video_rect, so stop other threads from - // modifying it! -// SDL_LockMutex(sdl_update_video_mutex); + UNLOCK_PALETTE; // passed potential deadlock, can unlock palette // Update the host OS' texture void * srcPixels = (void *)((uint8_t *)host_surface->pixels +