- moved the decision whether to upscale textures up one level in the function chain. Still not the perfect place, this should be decided before creating the texture, not in the middle of the process.

- disabled the selective texture cleaning in the precacher. The logic here turned out to be a serious blocker and needs to be rethought.
This commit is contained in:
Christoph Oelckers 2020-04-16 21:36:14 +02:00
parent a81bb2a136
commit 0b990f0dcb
8 changed files with 32 additions and 32 deletions

View file

@ -50,7 +50,7 @@ void AnimTexture::SetFrame(const uint8_t *palette, const void *data_)
{ {
memcpy(Palette, palette, 768); memcpy(Palette, palette, 768);
memcpy(Image.Data(), data_, Width * Height); memcpy(Image.Data(), data_, Width * Height);
CleanHardwareTextures(true, true); CleanHardwareTextures(true);
} }
//=========================================================================== //===========================================================================

View file

@ -425,22 +425,6 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA
if (Scale.X >= 2 && Scale.Y >= 2) if (Scale.X >= 2 && Scale.Y >= 2)
return; 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 type = gl_texture_hqresizemode;
int mult = gl_texture_hqresizemult; int mult = gl_texture_hqresizemult;
#ifdef HAVE_MMX #ifdef HAVE_MMX

View file

@ -49,6 +49,8 @@
#include "texturemanager.h" #include "texturemanager.h"
#include "c_cvars.h" #include "c_cvars.h"
EXTERN_CVAR(Int, gl_texture_hqresize_targets)
// Wrappers to keep the definitions of these classes out of here. // Wrappers to keep the definitions of these classes out of here.
void DeleteMaterial(FMaterial* mat); void DeleteMaterial(FMaterial* mat);
IHardwareTexture* CreateHardwareTexture(); IHardwareTexture* CreateHardwareTexture();
@ -686,10 +688,27 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
result.mWidth = W; result.mWidth = W;
result.mHeight = H; 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.) // 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) 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); 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);
} }
//=========================================================================== //===========================================================================

View file

@ -103,7 +103,7 @@ void FTextureManager::DeleteAll()
//========================================================================== //==========================================================================
// //
// Flushes all hardware dependent data. // 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 // 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 having the software
@ -118,7 +118,7 @@ void FTextureManager::FlushAll()
{ {
for (int j = 0; j < 2; j++) 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; delete Textures[i].Texture->GetTexture()->SoftwareTexture;
Textures[i].Texture->GetTexture()->SoftwareTexture = nullptr; Textures[i].Texture->GetTexture()->SoftwareTexture = nullptr;
} }

View file

@ -264,7 +264,7 @@ public:
virtual FImageSource *GetImage() const { return nullptr; } virtual FImageSource *GetImage() const { return nullptr; }
void AddAutoMaterials(); void AddAutoMaterials();
void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly); 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. // 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); } int GetDisplayWidth() { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); }

View file

@ -373,8 +373,8 @@ bool Wiper_Burn::Run(int ticks)
done = (Density < 0); done = (Density < 0);
} }
BurnTexture->CleanHardwareTextures(true, true); BurnTexture->CleanHardwareTextures(true);
endScreen->GetTexture()->CleanHardwareTextures(false, false); endScreen->GetTexture()->CleanHardwareTextures(false); // this only cleans the descriptor sets for the Vulkan backend. Needs to be done better.
const uint8_t *src = BurnArray; const uint8_t *src = BurnArray;
uint32_t *dest = (uint32_t *)BurnTexture->GetBuffer(); uint32_t *dest = (uint32_t *)BurnTexture->GetBuffer();

View file

@ -227,13 +227,10 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
auto tex = TexMan.GameByIndex(i); auto tex = TexMan.GameByIndex(i);
if (tex != nullptr && tex->GetUseType() != ETextureType::FontChar) 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); tex->GetTexture()->CleanHardwareTextures(true);
}
if (usedSprites.CheckKey(tex->GetTexture()) == nullptr)
{
tex->GetTexture()->CleanHardwareTextures(false, true);
} }
} }
} }