mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- cache the upscaling check's result in the texture, as this will be queried quite frequently.
This commit is contained in:
parent
8505c7ee7d
commit
09898ef6c3
2 changed files with 25 additions and 2 deletions
|
@ -405,6 +405,7 @@ static void xbrzOldScale(size_t factor, const uint32_t* src, uint32_t* trg, int
|
|||
// the upsampled buffer.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly)
|
||||
{
|
||||
// [BB] Make sure that inWidth and inHeight denote the size of
|
||||
|
@ -482,8 +483,17 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA
|
|||
texbuffer.mContentId = contentId.id;
|
||||
}
|
||||
|
||||
bool shouldUpscale(FGameTexture *tex, ETextureType UseType)
|
||||
//===========================================================================
|
||||
//
|
||||
// This was pulled out of the above function to allow running these
|
||||
// checks before the texture is passed to the render state.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool calcShouldUpscale(FGameTexture *tex, ETextureType UseType)
|
||||
{
|
||||
if (gl_texture_hqresizemode == 0 || gl_texture_hqresizemult == 1) return false;
|
||||
|
||||
// [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)
|
||||
|
|
|
@ -632,10 +632,14 @@ public:
|
|||
class FGameTexture
|
||||
{
|
||||
FTexture *wrapped;
|
||||
int8_t shouldUpscaleFlag = -1;
|
||||
public:
|
||||
FGameTexture(FTexture* wrap) : wrapped(wrap) {}
|
||||
~FGameTexture();
|
||||
|
||||
void SetUpscaleFlag(int what) { shouldUpscaleFlag = what; }
|
||||
int GetUpscaleFlag() { return shouldUpscaleFlag; }
|
||||
|
||||
FTexture* GetTexture() { return wrapped; }
|
||||
int GetSourceLump() const { return wrapped->GetSourceLump(); }
|
||||
void SetBrightmap(FGameTexture* tex) { wrapped->Brightmap = tex->GetTexture(); }
|
||||
|
@ -755,7 +759,16 @@ inline FGameTexture* MakeGameTexture(FTexture* tex)
|
|||
return new FGameTexture(tex);
|
||||
}
|
||||
|
||||
bool shouldUpscale(FGameTexture* tex, ETextureType UseType);
|
||||
bool calcShouldUpscale(FGameTexture* tex, ETextureType UseType);
|
||||
inline bool shouldUpscale(FGameTexture* tex, ETextureType UseType)
|
||||
{
|
||||
auto f = tex->GetUpscaleFlag();
|
||||
// Cache this value in the texture to save time because it is very frequently polled.
|
||||
if (f != -1) return f;
|
||||
auto res = calcShouldUpscale(tex, UseType);
|
||||
tex->SetUpscaleFlag(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue