From 0ae371f3ce454e712fd8310d75d787737d46bf79 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 Apr 2018 16:32:37 +0200 Subject: [PATCH] - moved gl_use_hires check back into material class and cleaned up the interface a bit. The function is supposed to be a worker, nothing more and its result should only depend on its arguments. --- src/gl/textures/gl_material.cpp | 19 +++++++++---------- src/gl/textures/gl_material.h | 5 +---- src/textures/texture.cpp | 4 +--- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 5e32f855d1..c5d64a4efb 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -50,6 +50,7 @@ EXTERN_CVAR(Bool, gl_render_precise) EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Bool, gl_precache) +EXTERN_CVAR(Bool, gl_texture_usehires) //=========================================================================== // @@ -141,7 +142,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture() // //=========================================================================== -const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck) +const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, int flags) { int usebright = false; @@ -179,11 +180,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { - int flags = CTF_ProcessData; - if (bExpandFlag) flags |= CTF_Expand; - if (hirescheck) flags |= CTF_CheckHires; - - buffer = tex->CreateTexBuffer(translation, w, h, flags); + buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData); if (tex->bWarped && gl.legacyMode && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback. { // need to do software warping @@ -486,8 +483,8 @@ void FMaterial::SetSpriteRect() //=========================================================================== // -// Finds gaps in the texture which can be skipped by the renderer -// This was mainly added to speed up one area in E4M6 of 007LTSD +// Finds empty space around the texture. +// Used for sprites that got placed into a huge empty frame. // //=========================================================================== @@ -607,12 +604,14 @@ void FMaterial::Bind(int clampmode, int translation) int usebright = false; int maxbound = 0; - bool allowhires = tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY && !mExpanded; if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX; else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; - const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL); + // Textures that are already scaled in the texture lump will not get replaced by hires textures. + int flags = mExpanded? CTF_Expand : (gl_texture_usehires && tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY)? CTF_CheckHires : 0; + + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, flags); if (gltexture != NULL) { for(unsigned i=0;i