- optimization of texture scaling checks.
The texture dimension checks can be performed up front when the texture is inserted into the texture manager.
This commit is contained in:
parent
09898ef6c3
commit
70ec20c137
33 changed files with 167 additions and 169 deletions
|
|
@ -114,7 +114,7 @@ void FHWModelRenderer::SetInterpolation(double inter)
|
|||
|
||||
void FHWModelRenderer::SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation)
|
||||
{
|
||||
state.SetMaterial(skin, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1);
|
||||
state.SetMaterial(skin, UF_None, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1);
|
||||
state.SetLightIndex(modellightindex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
|
|||
|
||||
state.SetTextureMode(decal->RenderStyle);
|
||||
state.SetRenderStyle(decal->RenderStyle);
|
||||
int flags = shouldUpscale(texture, ETextureType::Sprite) ? CTF_Upscale : 0;
|
||||
state.SetMaterial(texture, flags, CLAMP_XY, decal->Translation, -1);
|
||||
state.SetMaterial(texture, UF_Sprite, 0, CLAMP_XY, decal->Translation, -1);
|
||||
|
||||
|
||||
// If srcalpha is one it looks better with a higher alpha threshold
|
||||
|
|
|
|||
|
|
@ -204,8 +204,7 @@ void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
|
|||
|
||||
void HWFlat::DrawOtherPlanes(HWDrawInfo *di, FRenderState &state)
|
||||
{
|
||||
int flags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
state.SetMaterial(texture, flags, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
|
||||
// Draw the subsectors assigned to it due to missing textures
|
||||
auto pNode = (renderflags&SSRF_RENDERFLOOR) ?
|
||||
|
|
@ -237,8 +236,7 @@ void HWFlat::DrawFloodPlanes(HWDrawInfo *di, FRenderState &state)
|
|||
// This requires a stencil because the projected plane interferes with
|
||||
// the depth buffer
|
||||
|
||||
int flags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
state.SetMaterial(texture, flags, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
|
||||
// Draw the subsectors assigned to it due to missing textures
|
||||
auto pNode = (renderflags&SSRF_RENDERFLOOR) ?
|
||||
|
|
@ -324,17 +322,16 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
}
|
||||
else if (!translucent)
|
||||
{
|
||||
int flags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
if (sector->special != GLSector_Skybox)
|
||||
{
|
||||
state.SetMaterial(texture, flags, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetPlaneTextureRotation(&plane, texture);
|
||||
DrawSubsectors(di, state);
|
||||
state.EnableTextureMatrix(false);
|
||||
}
|
||||
else if (!hacktype)
|
||||
{
|
||||
state.SetMaterial(texture, flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.SetLightIndex(dynlightindex);
|
||||
state.Draw(DT_TriangleStrip,iboindex, 4);
|
||||
flatvertices += 4;
|
||||
|
|
@ -355,8 +352,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
{
|
||||
if (!texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
|
||||
else state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
int flags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
state.SetMaterial(texture, flags, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetPlaneTextureRotation(&plane, texture);
|
||||
DrawSubsectors(di, state);
|
||||
state.EnableTextureMatrix(false);
|
||||
|
|
|
|||
|
|
@ -975,8 +975,7 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
}
|
||||
|
||||
|
||||
int flags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
state.SetMaterial(texture, flags, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetObjectColor(origin->specialcolor);
|
||||
|
||||
state.SetPlaneTextureRotation(sp, texture);
|
||||
|
|
|
|||
|
|
@ -569,8 +569,9 @@ public:
|
|||
mTextureModeFlags = mat->GetLayerFlags();
|
||||
}
|
||||
|
||||
void SetMaterial(FGameTexture* tex, int scaleflags, int clampmode, int translation, int overrideshader)
|
||||
void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader)
|
||||
{
|
||||
if (shouldUpscale(tex, upscalemask)) scaleflags |= CTF_Upscale;
|
||||
if (!tex->expandSprites()) scaleflags &= ~CTF_Expand;
|
||||
SetMaterial(FMaterial::ValidateTexture(tex, scaleflags), clampmode, translation, overrideshader);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,10 +52,9 @@ void HWSkyPortal::RenderRow(HWDrawInfo *di, FRenderState &state, EDrawType prim,
|
|||
|
||||
void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture * tex, float x_offset, float y_offset, bool mirror, int mode)
|
||||
{
|
||||
int flags = shouldUpscale(tex, ETextureType::Wall) ? CTF_Upscale : 0;
|
||||
if (tex)
|
||||
{
|
||||
state.SetMaterial(tex, flags, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(tex, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.EnableModelMatrix(true);
|
||||
state.EnableTextureMatrix(true);
|
||||
|
||||
|
|
@ -107,41 +106,39 @@ void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texn
|
|||
else
|
||||
state.mModelMatrix.rotate(-180.0f+x_offset, di->Level->info->skyrotatevector2.X, di->Level->info->skyrotatevector2.Z, di->Level->info->skyrotatevector2.Y);
|
||||
|
||||
// Only test the first face - the result here must be consistent - either all get scaled or none.
|
||||
int flags = shouldUpscale(tex->GetSkyFace(0), ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
if (tex->GetSkyFace(5))
|
||||
{
|
||||
faces=4;
|
||||
|
||||
// north
|
||||
state.SetMaterial(tex->GetSkyFace(0), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(0), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(0), 4);
|
||||
|
||||
// east
|
||||
state.SetMaterial(tex->GetSkyFace(1), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(1), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(1), 4);
|
||||
|
||||
// south
|
||||
state.SetMaterial(tex->GetSkyFace(2), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(2), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(2), 4);
|
||||
|
||||
// west
|
||||
state.SetMaterial(tex->GetSkyFace(3), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(3), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(3), 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
faces=1;
|
||||
state.SetMaterial(tex->GetSkyFace(0), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(0), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(-1), 10);
|
||||
}
|
||||
|
||||
// top
|
||||
state.SetMaterial(tex->GetSkyFace(faces), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(faces), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(tex->GetSkyFlip() ? 6 : 5), 4);
|
||||
|
||||
// bottom
|
||||
state.SetMaterial(tex->GetSkyFace(faces+1), flags, CLAMP_XY, 0, -1);
|
||||
state.SetMaterial(tex->GetSkyFace(faces+1), UF_Texture, 0, CLAMP_XY, 0, -1);
|
||||
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(4), 4);
|
||||
|
||||
state.EnableModelMatrix(false);
|
||||
|
|
|
|||
|
|
@ -198,9 +198,7 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
}
|
||||
|
||||
uint32_t spritetype = (actor->renderflags & RF_SPRITETYPEMASK);
|
||||
int flags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
if (spritetype == RF_FACESPRITE) flags |= CTF_Expand;
|
||||
if (texture) state.SetMaterial(texture, flags, CLAMP_XY, translation, OverrideShader);
|
||||
if (texture) state.SetMaterial(texture, UF_Sprite, (spritetype == RF_FACESPRITE) ? CTF_Expand : 0, CLAMP_XY, translation, OverrideShader);
|
||||
else if (!modelframe) state.EnableTexture(false);
|
||||
|
||||
//SetColor(lightlevel, rel, Colormap, trans);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state)
|
|||
state.AlphaFunc(Alpha_Greater, 0);
|
||||
|
||||
auto tex = TexMan.GetGameTexture(TexMan.mirrorTexture, false);
|
||||
state.SetMaterial(tex, false, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(tex, UF_None, 0, CLAMP_NONE, 0, -1); // do not upscale the mirror texture.
|
||||
|
||||
flags &= ~HWWall::HWF_GLOW;
|
||||
RenderWall(di, state, HWWall::RWF_BLANK);
|
||||
|
|
@ -156,8 +156,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
|||
state.SetGlowParams(topglowcolor, bottomglowcolor);
|
||||
state.SetGlowPlanes(frontsector->ceilingplane, frontsector->floorplane);
|
||||
}
|
||||
int uflags = shouldUpscale(texture, ETextureType::Flat) ? CTF_Upscale : 0;
|
||||
state.SetMaterial(texture, uflags, flags & 3, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, flags & 3, 0, -1);
|
||||
|
||||
if (type == RENDERWALL_M2SNF)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -96,8 +96,7 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state)
|
|||
{
|
||||
float thresh = (huds->texture->GetTranslucency() || huds->OverrideShader != -1) ? 0.f : gl_mask_sprite_threshold;
|
||||
state.AlphaFunc(Alpha_GEqual, thresh);
|
||||
int flags = shouldUpscale(huds->texture, ETextureType::Flat) ? CTF_Upscale|CTF_Expand : CTF_Expand;
|
||||
state.SetMaterial(huds->texture, flags, CLAMP_XY_NOMIP, (huds->weapon->Flags & PSPF_PLAYERTRANSLATED) ? huds->owner->Translation : 0, huds->OverrideShader);
|
||||
state.SetMaterial(huds->texture, UF_Sprite, CTF_Expand, CLAMP_XY_NOMIP, (huds->weapon->Flags & PSPF_PLAYERTRANSLATED) ? huds->owner->Translation : 0, huds->OverrideShader);
|
||||
state.Draw(DT_TriangleStrip, huds->mx, 4);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
{
|
||||
if (texhitlist[i] & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky))
|
||||
{
|
||||
int flags = shouldUpscale(gtex, ETextureType::Wall) ? CTF_Upscale : 0;
|
||||
int flags = shouldUpscale(gtex, UF_Texture);
|
||||
if (tex->GetImage() && tex->SystemTextures.GetHardwareTexture(0, flags) == nullptr)
|
||||
{
|
||||
FImageSource::RegisterForPrecache(tex->GetImage(), V_IsTrueColor());
|
||||
|
|
|
|||
|
|
@ -164,7 +164,8 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
|||
|
||||
if (cmd.mTexture != nullptr && cmd.mTexture->isValid())
|
||||
{
|
||||
state.SetMaterial(cmd.mTexture, 0, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
|
||||
auto flags = cmd.mTexture->GetUseType() >= ETextureType::Special? UF_None : cmd.mTexture->GetUseType() == ETextureType::FontChar? UF_Font : UF_Texture;
|
||||
state.SetMaterial(cmd.mTexture, flags, 0, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
|
||||
state.EnableTexture(true);
|
||||
|
||||
// Canvas textures are stored upside down
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ SWSceneDrawer::SWSceneDrawer()
|
|||
if (!texid.Exists())
|
||||
{
|
||||
// We need to wrap this in a game texture object to have it managed by the texture manager, even though it will never be used as a material.
|
||||
auto tex = MakeGameTexture(new FImageTexture(new FSWPaletteTexture, "@@palette@@"));
|
||||
auto tex = MakeGameTexture(new FImageTexture(new FSWPaletteTexture, "@@palette@@"), ETextureType::Special);
|
||||
texid = TexMan.AddGameTexture(tex);
|
||||
}
|
||||
PaletteTexture = TexMan.GetGameTexture(texid)->GetTexture();
|
||||
|
|
@ -103,7 +103,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
{
|
||||
// This manually constructs its own material here.
|
||||
fbtex.reset();
|
||||
fbtex.reset(MakeGameTexture(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())));
|
||||
fbtex.reset(MakeGameTexture(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()), ETextureType::SWCanvas));
|
||||
GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
||||
mat->AddTextureLayer(PaletteTexture);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,21 @@
|
|||
#include "texturemanager.h"
|
||||
|
||||
|
||||
inline EUpscaleFlags scaleFlagFromUseType(ETextureType useType)
|
||||
{
|
||||
switch (useType)
|
||||
{
|
||||
case ETextureType::Sprite:
|
||||
case ETextureType::SkinSprite:
|
||||
return UF_Sprite;
|
||||
|
||||
case ETextureType::FontChar:
|
||||
return UF_Font;
|
||||
|
||||
default:
|
||||
return UF_Texture;
|
||||
}
|
||||
}
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -55,7 +69,8 @@ FSoftwareTexture::FSoftwareTexture(FGameTexture *tex)
|
|||
|
||||
mBufferFlags = CTF_ProcessData;
|
||||
auto f = mBufferFlags;
|
||||
if (shouldUpscale(tex, tex->GetUseType())) f |= CTF_Upscale;
|
||||
|
||||
if (shouldUpscale(tex, scaleFlagFromUseType(tex->GetUseType()))) f |= CTF_Upscale;
|
||||
// calculate the real size after running the scaler.
|
||||
auto info = mSource->CreateTexBuffer(0, CTF_CheckOnly| f);
|
||||
mPhysicalWidth = info.mWidth;
|
||||
|
|
@ -116,7 +131,7 @@ const uint8_t *FSoftwareTexture::GetPixels(int style)
|
|||
else
|
||||
{
|
||||
auto f = mBufferFlags;
|
||||
if (shouldUpscale(mTexture, mTexture->GetUseType())) f |= CTF_Upscale;
|
||||
if (shouldUpscale(mTexture, scaleFlagFromUseType(mTexture->GetUseType()))) f |= CTF_Upscale;
|
||||
auto tempbuffer = mSource->CreateTexBuffer(0, mBufferFlags);
|
||||
Pixels.Resize(GetPhysicalWidth()*GetPhysicalHeight());
|
||||
PalEntry *pe = (PalEntry*)tempbuffer.mBuffer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue