Commit 7410f830 authored by Fabian Greffrath's avatar Fabian Greffrath

Apply some patches from the upstream GIT repository that fix a crash when...

Apply some patches from the upstream GIT repository that fix a crash when changing the renderer in-game
parent a6d4f733
From 07e9f3b987cc45c6e5ddd8197309f977d914f6a6 Mon Sep 17 00:00:00 2001
From: Fabian Greffrath <fabian@greffrath.com>
Date: Thu, 20 Dec 2018 11:05:41 +0100
Subject: [PATCH 1/7] video: create new texture before destroying old one
This fixes a racing condition which would leave us with no
intermediate texture available until the new one is created.
---
src/i_video.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -612,6 +612,8 @@ static void CreateUpscaledTexture(boolea
int h_upscale, w_upscale;
static int h_upscale_old, w_upscale_old;
+ SDL_Texture *new_texture, *old_texture;
+
// Get the size of the renderer output. The units this gives us will be
// real world pixels, which are not necessarily equivalent to the screen's
// window size (because of highdpi).
@@ -667,22 +669,25 @@ static void CreateUpscaledTexture(boolea
h_upscale_old = h_upscale;
w_upscale_old = w_upscale;
- if (texture_upscaled)
- {
- SDL_DestroyTexture(texture_upscaled);
- }
-
// Set the scaling quality for rendering the upscaled texture to "linear",
// which looks much softer and smoother than "nearest" but does a better
// job at downscaling from the upscaled texture to screen.
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
- texture_upscaled = SDL_CreateTexture(renderer,
+ new_texture = SDL_CreateTexture(renderer,
pixel_format,
SDL_TEXTUREACCESS_TARGET,
w_upscale*SCREENWIDTH,
h_upscale*SCREENHEIGHT);
+
+ old_texture = texture_upscaled;
+ texture_upscaled = new_texture;
+
+ if (old_texture != NULL)
+ {
+ SDL_DestroyTexture(old_texture);
+ }
}
// [AM] Fractional part of the current tic, in the half-open
From 05c3023d2b891c2d4361822b439c59e5828eee79 Mon Sep 17 00:00:00 2001
From: Fabian Greffrath <fabian@greffrath.com>
Date: Fri, 21 Dec 2018 13:14:56 +0100
Subject: [PATCH 4/7] video: point destroyed textures to NULL
When a renderer gets destroyed, all associated textures get destroyed
as well, so point them to NULL to prevent them being destroyed again.
---
src/i_video.c | 3 +++
1 file changed, 3 insertions(+)
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1320,6 +1320,9 @@ void SetVideoMode(boolean resize_fb) //
if (renderer != NULL)
{
SDL_DestroyRenderer(renderer);
+ // all associated textures get destroyed
+ texture = NULL;
+ texture_upscaled = NULL;
}
renderer = SDL_CreateRenderer(screen, -1, renderer_flags);
0001-video-create-new-texture-before-destroying-old-one.patch
0004-video-point-destroyed-textures-to-NULL.patch
no_server.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment