Fix warp texture crash in software renderer true color mode

This commit is contained in:
Magnus Norddahl 2017-03-13 18:02:44 +01:00
parent a408ea312f
commit 22d3599ea1
2 changed files with 6 additions and 2 deletions

View file

@ -570,6 +570,7 @@ public:
FTexture *GetRedirect(bool wantwarped); FTexture *GetRedirect(bool wantwarped);
uint32_t GenTime; uint32_t GenTime;
uint32_t GenTimeBgra;
float Speed; float Speed;
int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd]
protected: protected:

View file

@ -43,7 +43,7 @@
FWarpTexture::FWarpTexture (FTexture *source, int warptype) 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); CopyInfo(source);
if (warptype == 2) SetupMultipliers(256, 128); if (warptype == 2) SetupMultipliers(256, 128);
@ -98,8 +98,10 @@ const uint32_t *FWarpTexture::GetPixelsBgra()
{ {
uint32_t time = r_viewpoint.FrameTime; uint32_t time = r_viewpoint.FrameTime;
if (Pixels == NULL || time != GenTime) if (Pixels == NULL || time != GenTime)
{
MakeTexture(time); MakeTexture(time);
if (PixelsBgra.empty() || time != GenTimeBgra)
{
CreatePixelsBgraWithMipmaps(); CreatePixelsBgraWithMipmaps();
for (int i = 0; i < Width * Height; i++) for (int i = 0; i < Width * Height; i++)
{ {
@ -109,6 +111,7 @@ const uint32_t *FWarpTexture::GetPixelsBgra()
PixelsBgra[i] = 0; PixelsBgra[i] = 0;
} }
GenerateBgraMipmapsFast(); GenerateBgraMipmapsFast();
GenTimeBgra = time;
} }
return PixelsBgra.data(); return PixelsBgra.data();
} }