diff --git a/src/common/textures/gametexture.h b/src/common/textures/gametexture.h index e6b3461cf06..c624fa9f52a 100644 --- a/src/common/textures/gametexture.h +++ b/src/common/textures/gametexture.h @@ -241,10 +241,6 @@ class FGameTexture DisplayHeight = h; ScaleX = TexelWidth / w; ScaleY = TexelHeight / h; - if (shouldUpscaleFlag < 2) - { - shouldUpscaleFlag = ScaleX < 2 && ScaleY < 2; - } // compensate for roundoff errors if (int(ScaleX * w) != TexelWidth) ScaleX += (1 / 65536.); @@ -271,10 +267,6 @@ class FGameTexture { ScaleX = x; ScaleY = y; - if (shouldUpscaleFlag < 2) - { - shouldUpscaleFlag = ScaleX < 2 && ScaleY < 2; - } DisplayWidth = TexelWidth / x; DisplayHeight = TexelHeight / y; } @@ -374,7 +366,7 @@ enum EUpscaleFlags extern int upscalemask; void UpdateUpscaleMask(); -int calcShouldUpscale(FGameTexture* tex); +void calcShouldUpscale(FGameTexture* tex); inline int shouldUpscale(FGameTexture* tex, EUpscaleFlags UseType) { // This only checks the global scale mask and the texture's validation for upscaling. Everything else has been done up front elsewhere. diff --git a/src/common/textures/hires/hqresize.cpp b/src/common/textures/hires/hqresize.cpp index fe5beda4e3d..e8b457ee1e7 100644 --- a/src/common/textures/hires/hqresize.cpp +++ b/src/common/textures/hires/hqresize.cpp @@ -502,20 +502,21 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA // //=========================================================================== -int calcShouldUpscale(FGameTexture *tex) +void calcShouldUpscale(FGameTexture *tex) { + tex->SetUpscaleFlag(0); // [BB] Don't resample if width * height of the input texture is bigger than gl_texture_hqresize_maxinputsize squared. const int maxInputSize = gl_texture_hqresize_maxinputsize; if (tex->GetTexelWidth() * tex->GetTexelHeight() > maxInputSize * maxInputSize) - return 0; + return; // [BB] Don't try to upsample textures based off FCanvasTexture. (This should never get here in the first place!) if (tex->isHardwareCanvas()) - return 0; + return; // already scaled? if (tex->GetScaleX() >= 2.f || tex->GetScaleY() > 2.f) - return 0; + return; - return CTF_Upscale; + tex->SetUpscaleFlag(1); } \ No newline at end of file diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 848f18bc20a..73918db92d5 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -106,7 +106,7 @@ void FTextureManager::DeleteAll() // This must not, under any circumstances, delete the wipe textures, because // all CCMDs triggering a flush can be executed while a wipe is in progress // -// This now also deletes the software textures because having the software +// This now also deletes the software textures because the software // renderer can also use the texture scalers and that is the // main reason to call this outside of the destruction code. // @@ -120,8 +120,8 @@ void FTextureManager::FlushAll() { Textures[i].Texture->CleanHardwareData(); delete Textures[i].Texture->GetSoftwareTexture(); - Textures[i].Texture->SetSoftwareTexture(nullptr); calcShouldUpscale(Textures[i].Texture); + Textures[i].Texture->SetSoftwareTexture(nullptr); } } } diff --git a/src/rendering/swrenderer/r_swrenderer.cpp b/src/rendering/swrenderer/r_swrenderer.cpp index 5eece9b3fab..1b3d30a0e94 100644 --- a/src/rendering/swrenderer/r_swrenderer.cpp +++ b/src/rendering/swrenderer/r_swrenderer.cpp @@ -241,6 +241,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *camtex, AActor *viewp cameraViewwindow = r_viewwindow; auto tex = GetSWCamTex(camtex); + if (!tex) return; DCanvas *Canvas = renderTarget->IsBgra() ? tex->GetCanvasBgra() : tex->GetCanvas(); diff --git a/src/rendering/swrenderer/textures/r_swtexture.cpp b/src/rendering/swrenderer/textures/r_swtexture.cpp index 5b35a951667..a22daeeac03 100644 --- a/src/rendering/swrenderer/textures/r_swtexture.cpp +++ b/src/rendering/swrenderer/textures/r_swtexture.cpp @@ -68,11 +68,10 @@ FSoftwareTexture::FSoftwareTexture(FGameTexture *tex) mSource = tex->GetTexture(); mBufferFlags = CTF_ProcessData; - auto f = mBufferFlags; - if (shouldUpscale(tex, scaleFlagFromUseType(tex->GetUseType()))) f |= CTF_Upscale; + if (shouldUpscale(tex, scaleFlagFromUseType(tex->GetUseType()))) mBufferFlags |= CTF_Upscale; // calculate the real size after running the scaler. - auto info = mSource->CreateTexBuffer(0, CTF_CheckOnly| f); + auto info = mSource->CreateTexBuffer(0, CTF_CheckOnly| mBufferFlags); mPhysicalWidth = info.mWidth; mPhysicalHeight = info.mHeight; mPhysicalScale = tex->GetTexelWidth() > 0 ? mPhysicalWidth / tex->GetTexelWidth() : mPhysicalWidth; @@ -130,7 +129,7 @@ const uint8_t *FSoftwareTexture::GetPixels(int style) } else { - auto f = mBufferFlags | CTF_Upscale; + auto f = mBufferFlags; auto tempbuffer = mSource->CreateTexBuffer(0, f); Pixels.Resize(GetPhysicalWidth()*GetPhysicalHeight()); PalEntry *pe = (PalEntry*)tempbuffer.mBuffer; @@ -176,7 +175,7 @@ const uint32_t *FSoftwareTexture::GetPixelsBgra() } else { - auto tempbuffer = mSource->CreateTexBuffer(0, mBufferFlags | CTF_Upscale); + auto tempbuffer = mSource->CreateTexBuffer(0, mBufferFlags); CreatePixelsBgraWithMipmaps(); PalEntry *pe = (PalEntry*)tempbuffer.mBuffer; for (int y = 0; y < GetPhysicalHeight(); y++)