mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- fixed code that deternines when to upscale a texture.
This was very much non-functional.
This commit is contained in:
parent
2d13dcfc81
commit
60a20af8ff
5 changed files with 14 additions and 21 deletions
|
@ -241,10 +241,6 @@ public:
|
|||
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 @@ public:
|
|||
{
|
||||
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.
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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++)
|
||||
|
|
Loading…
Reference in a new issue