diff --git a/src/common/textures/animtexture.cpp b/src/common/textures/animtexture.cpp index b09c5cd18..7ec249025 100644 --- a/src/common/textures/animtexture.cpp +++ b/src/common/textures/animtexture.cpp @@ -50,7 +50,7 @@ void AnimTexture::SetFrame(const uint8_t *palette, const void *data_) { memcpy(Palette, palette, 768); memcpy(Image.Data(), data_, Width * Height); - CleanHardwareTextures(true, true); + CleanHardwareTextures(true); } //=========================================================================== diff --git a/src/common/textures/hires/hqresize.cpp b/src/common/textures/hires/hqresize.cpp index e04be8262..9a4fd8b45 100644 --- a/src/common/textures/hires/hqresize.cpp +++ b/src/common/textures/hires/hqresize.cpp @@ -425,22 +425,6 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA if (Scale.X >= 2 && Scale.Y >= 2) return; - switch (UseType) - { - case ETextureType::Sprite: - case ETextureType::SkinSprite: - if (!(gl_texture_hqresize_targets & 2)) return; - break; - - case ETextureType::FontChar: - if (!(gl_texture_hqresize_targets & 4)) return; - break; - - default: - if (!(gl_texture_hqresize_targets & 1)) return; - break; - } - int type = gl_texture_hqresizemode; int mult = gl_texture_hqresizemult; #ifdef HAVE_MMX diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index 9e7ad3aae..d51d06043 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -49,6 +49,8 @@ #include "texturemanager.h" #include "c_cvars.h" +EXTERN_CVAR(Int, gl_texture_hqresize_targets) + // Wrappers to keep the definitions of these classes out of here. void DeleteMaterial(FMaterial* mat); IHardwareTexture* CreateHardwareTexture(); @@ -686,10 +688,27 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags) result.mWidth = W; result.mHeight = H; + bool upscale = true; + switch (UseType) + { + case ETextureType::Sprite: + case ETextureType::SkinSprite: + if (!(gl_texture_hqresize_targets & 2)) upscale = false; + break; + + case ETextureType::FontChar: + if (!(gl_texture_hqresize_targets & 4)) upscale = false; + break; + + default: + if (!(gl_texture_hqresize_targets & 1)) upscale = false; + break; + } + // Only do postprocessing for image-backed textures. (i.e. not for the burn texture which can also pass through here.) if (GetImage() && flags & CTF_ProcessData) { - CreateUpsampledTextureBuffer(result, !!isTransparent, checkonly); + if (upscale) CreateUpsampledTextureBuffer(result, !!isTransparent, checkonly); if (!checkonly) ProcessData(result.mBuffer, result.mWidth, result.mHeight, false); } @@ -717,9 +736,9 @@ bool FTexture::DetermineTranslucency() } -void FTexture::CleanHardwareTextures(bool cleannormal, bool cleanexpanded) +void FTexture::CleanHardwareTextures(bool reallyclean) { - SystemTextures.Clean(cleannormal, cleanexpanded); + SystemTextures.Clean(reallyclean, reallyclean); } //=========================================================================== diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index ca370dda6..b29f00e32 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -103,7 +103,7 @@ void FTextureManager::DeleteAll() //========================================================================== // // Flushes all hardware dependent data. -// Thia must not, under any circumstances, delete the wipe textures, because +// 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 @@ -118,7 +118,7 @@ void FTextureManager::FlushAll() { for (int j = 0; j < 2; j++) { - Textures[i].Texture->GetTexture()->CleanHardwareTextures(true, true); + Textures[i].Texture->GetTexture()->CleanHardwareTextures(true); delete Textures[i].Texture->GetTexture()->SoftwareTexture; Textures[i].Texture->GetTexture()->SoftwareTexture = nullptr; } diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index 1b5bac410..a826c06eb 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -264,7 +264,7 @@ public: virtual FImageSource *GetImage() const { return nullptr; } void AddAutoMaterials(); void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly); - void CleanHardwareTextures(bool cleannormal, bool cleanextended); + void CleanHardwareTextures(bool reallyclean); // These are mainly meant for 2D code which only needs logical information about the texture to position it properly. int GetDisplayWidth() { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); } diff --git a/src/rendering/2d/f_wipe.cpp b/src/rendering/2d/f_wipe.cpp index 80e425718..4797ab82c 100644 --- a/src/rendering/2d/f_wipe.cpp +++ b/src/rendering/2d/f_wipe.cpp @@ -373,8 +373,8 @@ bool Wiper_Burn::Run(int ticks) done = (Density < 0); } - BurnTexture->CleanHardwareTextures(true, true); - endScreen->GetTexture()->CleanHardwareTextures(false, false); + BurnTexture->CleanHardwareTextures(true); + endScreen->GetTexture()->CleanHardwareTextures(false); // this only cleans the descriptor sets for the Vulkan backend. Needs to be done better. const uint8_t *src = BurnArray; uint32_t *dest = (uint32_t *)BurnTexture->GetBuffer(); diff --git a/src/rendering/hwrenderer/textures/hw_precache.cpp b/src/rendering/hwrenderer/textures/hw_precache.cpp index fa695f925..5c599c491 100644 --- a/src/rendering/hwrenderer/textures/hw_precache.cpp +++ b/src/rendering/hwrenderer/textures/hw_precache.cpp @@ -227,13 +227,10 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl auto tex = TexMan.GameByIndex(i); if (tex != nullptr && tex->GetUseType() != ETextureType::FontChar) { - if (usedTextures.CheckKey(tex->GetTexture()) == nullptr) + // For now, only delete what's in neither list. The logic being used here does not really work that well for selective deletion. + if (usedTextures.CheckKey(tex->GetTexture()) == nullptr && usedSprites.CheckKey(tex->GetTexture()) == nullptr) { - tex->GetTexture()->CleanHardwareTextures(true, false); - } - if (usedSprites.CheckKey(tex->GetTexture()) == nullptr) - { - tex->GetTexture()->CleanHardwareTextures(false, true); + tex->GetTexture()->CleanHardwareTextures(true); } } } diff --git a/src/rendering/swrenderer/textures/r_swtexture.cpp b/src/rendering/swrenderer/textures/r_swtexture.cpp index 4f3a94bc9..6b9fcd7f3 100644 --- a/src/rendering/swrenderer/textures/r_swtexture.cpp +++ b/src/rendering/swrenderer/textures/r_swtexture.cpp @@ -57,7 +57,7 @@ FSoftwareTexture::FSoftwareTexture(FGameTexture *tex) // calculate the real size after running the scaler. auto info = mSource->CreateTexBuffer(0, CTF_CheckOnly| mBufferFlags); mPhysicalWidth = info.mWidth; - mPhysicalHeight = info.mHeight; + mPhysicalHeight = info.mHeight; mPhysicalScale = tex->GetTexelWidth() > 0 ? mPhysicalWidth / tex->GetTexelWidth() : mPhysicalWidth; Scale.X = (double)tex->GetTexelWidth() / tex->GetDisplayWidth(); Scale.Y = (double)tex->GetTexelHeight() / tex->GetDisplayHeight();