From 22d3599ea1d02a72454e5f5f2634275eab9426c2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Mar 2017 18:02:44 +0100 Subject: [PATCH] Fix warp texture crash in software renderer true color mode --- src/textures/textures.h | 1 + src/textures/warptexture.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/textures/textures.h b/src/textures/textures.h index c5a7a9819c..e647d7dab5 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -570,6 +570,7 @@ public: FTexture *GetRedirect(bool wantwarped); uint32_t GenTime; + uint32_t GenTimeBgra; float Speed; int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] protected: diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index 08ce3103d6..1de8624fea 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -43,7 +43,7 @@ FWarpTexture::FWarpTexture (FTexture *source, int warptype) -: GenTime (0), Speed (1.f), SourcePic (source), Pixels (0), Spans (0) +: GenTime (0), GenTimeBgra(0), Speed (1.f), SourcePic (source), Pixels (0), Spans (0) { CopyInfo(source); if (warptype == 2) SetupMultipliers(256, 128); @@ -98,8 +98,10 @@ const uint32_t *FWarpTexture::GetPixelsBgra() { uint32_t time = r_viewpoint.FrameTime; if (Pixels == NULL || time != GenTime) - { MakeTexture(time); + + if (PixelsBgra.empty() || time != GenTimeBgra) + { CreatePixelsBgraWithMipmaps(); for (int i = 0; i < Width * Height; i++) { @@ -109,6 +111,7 @@ const uint32_t *FWarpTexture::GetPixelsBgra() PixelsBgra[i] = 0; } GenerateBgraMipmapsFast(); + GenTimeBgra = time; } return PixelsBgra.data(); }