- removed FMaterial references from other high level renderer data like HWFlat and HWSprite.

This commit is contained in:
Christoph Oelckers 2020-04-15 00:29:23 +02:00
parent 1146cf9e08
commit cca3f878f5
11 changed files with 68 additions and 61 deletions

View file

@ -649,6 +649,8 @@ public:
bool isMiscPatch() const { return wrapped.GetUseType() == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not.
bool isMultiPatch() const { return wrapped.bMultiPatch; }
bool isFullbrightDisabled() const { return wrapped.isFullbrightDisabled(); }
bool isFullbright() const { return wrapped.isFullbright(); }
bool expandSprites() const { return wrapped.bExpandSprite; }
bool useWorldPanning() const { return wrapped.UseWorldPanning(); }
bool allowNoDecals() const { return wrapped.allowNoDecals(); }
void SetTranslucent(bool on) { wrapped.bTranslucent = on; }
@ -710,7 +712,7 @@ public:
void SetSize(int x, int y) { wrapped.SetSize(x, y); }
void SetSpriteRect() { wrapped.SetSpriteRect(); }
const SpritePositioningInfo& GetSpritePositioning() { if (wrapped.mTrimResult == -1) wrapped.SetupSpriteData(); return wrapped.spi; }
const SpritePositioningInfo& GetSpritePositioning(int which) { /* todo: keep two sets of positioning infd*/ if (wrapped.mTrimResult == -1) wrapped.SetupSpriteData(); return wrapped.spi; }
int GetAreas(FloatRect** pAreas) const { return wrapped.GetAreas(pAreas); }
bool GetTranslucency()

View file

@ -737,7 +737,7 @@ void HWDrawList::SortFlats()
{
HWFlat * w1 = flats[a.index];
HWFlat* w2 = flats[b.index];
return w1->gltexture < w2->gltexture;
return w1->texture < w2->texture;
});
}
}

View file

@ -96,12 +96,12 @@ void HWDrawInfo::AddFlat(HWFlat *flat, bool fog)
{
int list;
if (flat->renderstyle != STYLE_Translucent || flat->alpha < 1.f - FLT_EPSILON || fog || flat->gltexture == nullptr)
if (flat->renderstyle != STYLE_Translucent || flat->alpha < 1.f - FLT_EPSILON || fog || flat->texture == nullptr)
{
// translucent 3D floors go into the regular translucent list, translucent portals go into the translucent border list.
list = (flat->renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER;
}
else if (flat->gltexture->GetTranslucency())
else if (flat->texture->GetTranslucency())
{
if (flat->stack)
{
@ -118,7 +118,7 @@ void HWDrawInfo::AddFlat(HWFlat *flat, bool fog)
}
else //if (flat->hacktype != SSRF_FLOODHACK) // The flood hack may later need different treatment but with the current setup can go into the existing render list.
{
bool masked = flat->gltexture->isMasked() && ((flat->renderflags&SSRF_RENDER3DPLANES) || flat->stack);
bool masked = flat->texture->isMasked() && ((flat->renderflags&SSRF_RENDER3DPLANES) || flat->stack);
list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS;
}
auto newflat = drawlists[list].NewFlat();

View file

@ -295,7 +295,7 @@ class HWFlat
public:
sector_t * sector;
FSection *section;
FMaterial *gltexture;
FGameTexture *texture;
TextureManipulation* TextureFx;
float z; // the z position of the flat (only valid for non-sloped planes)
@ -369,7 +369,7 @@ public:
float trans;
int dynlightindex;
FMaterial *gltexture;
FGameTexture *texture;
AActor * actor;
particle_t * particle;
TArray<lightlist_t> *lightlist;
@ -426,7 +426,7 @@ inline float Dist2(float x1,float y1,float x2,float y2)
return sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FMaterial * gltexture, VSMatrix &mat);
bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * gltexture, VSMatrix &mat);
void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata);
extern const float LARGE_VALUE;

View file

@ -45,6 +45,7 @@
#include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "hw_drawstructs.h"
#include "hw_renderstate.h"
#include "texturemanager.h"
#ifdef _DEBUG
CVAR(Int, gl_breaksec, -1, 0)
@ -56,28 +57,28 @@ CVAR(Int, gl_breaksec, -1, 0)
//
//==========================================================================
bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FMaterial * gltexture, VSMatrix &dest)
bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * gltexture, VSMatrix &dest)
{
// only manipulate the texture matrix if needed.
if (!secplane->Offs.isZero() ||
secplane->Scale.X != 1. || secplane->Scale.Y != 1 ||
secplane->Angle != 0 ||
gltexture->TextureWidth() != 64 ||
gltexture->TextureHeight() != 64)
gltexture->GetDisplayWidth() != 64 ||
gltexture->GetDisplayHeight() != 64)
{
float uoffs = secplane->Offs.X / gltexture->TextureWidth();
float voffs = secplane->Offs.Y / gltexture->TextureHeight();
float uoffs = secplane->Offs.X / gltexture->GetDisplayWidth();
float voffs = secplane->Offs.Y / gltexture->GetDisplayHeight();
float xscale1 = secplane->Scale.X;
float yscale1 = secplane->Scale.Y;
if (gltexture->hasCanvas())
if (gltexture->isHardwareCanvas())
{
yscale1 = 0 - yscale1;
}
float angle = -secplane->Angle;
float xscale2 = 64.f / gltexture->TextureWidth();
float yscale2 = 64.f / gltexture->TextureHeight();
float xscale2 = 64.f / gltexture->GetDisplayWidth();
float yscale2 = 64.f / gltexture->GetDisplayHeight();
dest.loadIdentity();
dest.scale(xscale1, yscale1, 1.0f);
@ -203,7 +204,7 @@ void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
void HWFlat::DrawOtherPlanes(HWDrawInfo *di, FRenderState &state)
{
state.SetMaterial(gltexture, CLAMP_NONE, 0, -1);
state.SetMaterial(texture, false, CLAMP_NONE, 0, -1);
// Draw the subsectors assigned to it due to missing textures
auto pNode = (renderflags&SSRF_RENDERFLOOR) ?
@ -235,7 +236,7 @@ void HWFlat::DrawFloodPlanes(HWDrawInfo *di, FRenderState &state)
// This requires a stencil because the projected plane interferes with
// the depth buffer
state.SetMaterial(gltexture, CLAMP_NONE, 0, -1);
state.SetMaterial(texture, false, CLAMP_NONE, 0, -1);
// Draw the subsectors assigned to it due to missing textures
auto pNode = (renderflags&SSRF_RENDERFLOOR) ?
@ -323,14 +324,14 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
{
if (sector->special != GLSector_Skybox)
{
state.SetMaterial(gltexture, CLAMP_NONE, 0, -1);
state.SetPlaneTextureRotation(&plane, gltexture);
state.SetMaterial(texture, false, CLAMP_NONE, 0, -1);
state.SetPlaneTextureRotation(&plane, texture);
DrawSubsectors(di, state);
state.EnableTextureMatrix(false);
}
else if (!hacktype)
{
state.SetMaterial(gltexture, CLAMP_XY, 0, -1);
state.SetMaterial(texture, false, CLAMP_XY, 0, -1);
state.SetLightIndex(dynlightindex);
state.Draw(DT_TriangleStrip,iboindex, 4);
flatvertices += 4;
@ -340,7 +341,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
else
{
state.SetRenderStyle(renderstyle);
if (!gltexture)
if (!texture || !texture->isValid())
{
state.AlphaFunc(Alpha_GEqual, 0.f);
state.EnableTexture(false);
@ -349,10 +350,10 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
}
else
{
if (!gltexture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
if (!texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
else state.AlphaFunc(Alpha_GEqual, 0.f);
state.SetMaterial(gltexture, CLAMP_NONE, 0, -1);
state.SetPlaneTextureRotation(&plane, gltexture);
state.SetMaterial(texture, false, CLAMP_NONE, 0, -1);
state.SetPlaneTextureRotation(&plane, texture);
DrawSubsectors(di, state);
state.EnableTextureMatrix(false);
}
@ -379,7 +380,7 @@ inline void HWFlat::PutFlat(HWDrawInfo *di, bool fog)
}
else if (!screen->BuffersArePersistent())
{
if (di->Level->HasDynamicLights && gltexture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK|SSRF_FLOODHACK)) )
if (di->Level->HasDynamicLights && texture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK|SSRF_FLOODHACK)) )
{
SetupLights(di, section->lighthead, lightdata, sector->PortalGroup);
}
@ -405,9 +406,9 @@ void HWFlat::Process(HWDrawInfo *di, sector_t * model, int whichplane, bool fog)
if (!fog)
{
gltexture=FMaterial::ValidateTexture(plane.texture, false, true);
if (!gltexture) return;
if (gltexture->isFullbright())
texture = TexMan.GetGameTexture(plane.texture, true);
if (!texture || !texture->isValid()) return;
if (texture->isFullbright())
{
Colormap.MakeWhite();
lightlevel=255;
@ -415,7 +416,7 @@ void HWFlat::Process(HWDrawInfo *di, sector_t * model, int whichplane, bool fog)
}
else
{
gltexture = NULL;
texture = NULL;
lightlevel = abs(lightlevel);
}

View file

@ -36,6 +36,7 @@
#include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/utility/hw_lighting.h"
#include "texturemanager.h"
EXTERN_CVAR(Int, r_mirror_recursions)
EXTERN_CVAR(Bool, gl_portals)
@ -947,12 +948,12 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
{
Clocker c(PortalAll);
FMaterial * gltexture;
HWSectorPlane * sp = &origin->plane;
auto &vp = di->Viewpoint;
gltexture = FMaterial::ValidateTexture(sp->texture, false, true);
if (!gltexture)
auto texture = TexMan.GetGameTexture(sp->texture, true);
if (!texture || !texture->isValid())
{
state.ClearScreen();
return;
@ -960,7 +961,7 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
di->SetCameraPos(vp.Pos);
if (gltexture && gltexture->isFullbright())
if (texture->isFullbright())
{
// glowing textures are always drawn full bright without color
di->SetColor(state, 255, 0, false, origin->colormap, 1.f);
@ -974,10 +975,10 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
}
state.SetMaterial(gltexture, CLAMP_NONE, 0, -1);
state.SetMaterial(texture, false, CLAMP_NONE, 0, -1);
state.SetObjectColor(origin->specialcolor);
state.SetPlaneTextureRotation(sp, gltexture);
state.SetPlaneTextureRotation(sp, texture);
state.AlphaFunc(Alpha_GEqual, 0.f);
state.SetRenderStyle(STYLE_Source);

View file

@ -522,7 +522,7 @@ public:
else mAlphaThreshold = thresh - 0.001f;
}
void SetPlaneTextureRotation(HWSectorPlane *plane, FMaterial *texture)
void SetPlaneTextureRotation(HWSectorPlane *plane, FGameTexture *texture)
{
if (hw_SetPlaneTextureRotation(plane, texture, mTextureMatrix))
{
@ -569,6 +569,12 @@ public:
mTextureModeFlags = mat->GetLayerFlags();
}
void SetMaterial(FGameTexture* tex, bool expandmode, int clampmode, int translation, int overrideshader)
{
expandmode &= tex->expandSprites();
SetMaterial(FMaterial::ValidateTexture(tex->GetTexture(), expandmode), clampmode, translation, overrideshader);
}
void SetClipSplit(float bottom, float top)
{
mClipSplit[0] = bottom;

View file

@ -94,7 +94,7 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
// Optionally use STYLE_ColorBlend in place of STYLE_Add for fullbright items.
if (RenderStyle == LegacyRenderStyles[STYLE_Add] && trans > 1.f - FLT_EPSILON &&
gl_usecolorblending && !di->isFullbrightScene() && actor &&
fullbright && gltexture && !gltexture->GetTranslucency())
fullbright && texture && !texture->GetTranslucency())
{
RenderStyle = LegacyRenderStyles[STYLE_ColorAdd];
}
@ -106,7 +106,7 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
{
state.AlphaFunc(Alpha_GEqual, 0.f);
}
else if (!gltexture || !gltexture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
else if (!texture || !texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
else state.AlphaFunc(Alpha_Greater, 0.f);
if (RenderStyle.BlendOp == STYLEOP_Shadow)
@ -197,7 +197,8 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
state.SetFog(0, 0);
}
if (gltexture) state.SetMaterial(gltexture, CLAMP_XY, translation, OverrideShader);
uint32_t spritetype = (actor->renderflags & RF_SPRITETYPEMASK);
if (texture) state.SetMaterial(texture, spritetype == RF_FACESPRITE, CLAMP_XY, translation, OverrideShader);
else if (!modelframe) state.EnableTexture(false);
//SetColor(lightlevel, rel, Colormap, trans);
@ -818,7 +819,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
int type = thing->renderflags & RF_SPRITETYPEMASK;
auto tex = TexMan.GetGameTexture(patch, false);
if (!tex || !tex->isValid()) return;
auto& spi = tex->GetSpritePositioning();
auto& spi = tex->GetSpritePositioning(type == RF_FACESPRITE);
vt = spi.GetSpriteVT();
vb = spi.GetSpriteVB();
@ -842,8 +843,8 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
ur = spi.GetSpriteUL();
}
gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false);
if (!gltexture)
texture = TexMan.GetGameTexture(patch, false);
if (!texture || !texture->isValid())
return;
if (thing->renderflags & RF_SPRITEFLIP) // [SP] Flip back
@ -904,7 +905,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
x1 = x2 = x;
y1 = y2 = y;
z1 = z2 = z;
gltexture = nullptr;
texture = nullptr;
}
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
@ -916,7 +917,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
// allow disabling of the fullbright flag by a brightmap definition
// (e.g. to do the gun flashes of Doom's zombies correctly.
fullbright = (thing->flags5 & MF5_BRIGHT) ||
((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->Source()->isFullbrightDisabled()));
((thing->renderflags & RF_FULLBRIGHT) && (!texture || !texture->isFullbrightDisabled()));
lightlevel = fullbright ? 255 :
hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
@ -1035,7 +1036,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
RenderStyle.DestAlpha = STYLEALPHA_InvSrc;
}
}
if ((gltexture && gltexture->GetTranslucency()) || (RenderStyle.Flags & STYLEF_RedIsAlpha) || (modelframe && thing->RenderStyle != DefaultRenderStyle()))
if ((texture && texture->GetTranslucency()) || (RenderStyle.Flags & STYLEF_RedIsAlpha) || (modelframe && thing->RenderStyle != DefaultRenderStyle()))
{
if (hw_styleflags == STYLEHW_Solid)
{
@ -1163,7 +1164,7 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
ThingColor.a = 255;
modelframe=nullptr;
gltexture=nullptr;
texture=nullptr;
topclip = LARGE_VALUE;
bottomclip = -LARGE_VALUE;
index = 0;
@ -1191,7 +1192,7 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
ur = 1;
vt = 0;
vb = 1;
gltexture = FMaterial::ValidateTexture(lump, true, false);
texture = TexMan.GetGameTexture(lump, false);
}
}

View file

@ -103,8 +103,8 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state)
state.SetRenderStyle(STYLE_Add);
state.AlphaFunc(Alpha_Greater, 0);
FMaterial * pat = FMaterial::ValidateTexture(TexMan.mirrorTexture, false, false);
state.SetMaterial(pat, CLAMP_NONE, 0, -1);
auto tex = TexMan.GetGameTexture(TexMan.mirrorTexture, false);
state.SetMaterial(tex, false, CLAMP_NONE, 0, -1);
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);
}
auto mat = FMaterial::ValidateTexture(texture->GetTexture(), false, true);
state.SetMaterial(mat, flags & 3, 0, -1);
state.SetMaterial(texture, false, flags & 3, 0, -1);
if (type == RENDERWALL_M2SNF)
{

View file

@ -94,9 +94,9 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state)
}
else
{
float thresh = (huds->tex->GetTranslucency() || huds->OverrideShader != -1) ? 0.f : gl_mask_sprite_threshold;
float thresh = (huds->texture->GetTranslucency() || huds->OverrideShader != -1) ? 0.f : gl_mask_sprite_threshold;
state.AlphaFunc(Alpha_GEqual, thresh);
state.SetMaterial(huds->tex, CLAMP_XY_NOMIP, (huds->weapon->Flags & PSPF_PLAYERTRANSLATED) ? huds->owner->Translation : 0, huds->OverrideShader);
state.SetMaterial(huds->texture, true, CLAMP_XY_NOMIP, (huds->weapon->Flags & PSPF_PLAYERTRANSLATED) ? huds->owner->Translation : 0, huds->OverrideShader);
state.Draw(DT_TriangleStrip, huds->mx, 4);
}
@ -419,7 +419,7 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy,
auto tex = TexMan.GetGameTexture(lump, false);
if (!tex || !tex->isValid()) return false;
auto& spi = tex->GetSpritePositioning();
auto& spi = tex->GetSpritePositioning(1);
float vw = (float)viewwidth;
float vh = (float)viewheight;
@ -473,10 +473,7 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy,
verts.first[2].Set(x2, y1, 0, u2, v1);
verts.first[3].Set(x2, y2, 0, u2, v2);
FMaterial* mat = FMaterial::ValidateTexture(lump, true, false);
if (!mat) return false;
this->tex = mat;
texture = tex;
return true;
}

View file

@ -8,7 +8,7 @@ class AActor;
enum area_t : int;
struct FSpriteModelFrame;
struct HWDrawInfo;
class FMaterial;
class FGameTexture;
struct WeaponPosition
@ -29,7 +29,7 @@ struct HUDSprite
{
AActor *owner;
DPSprite *weapon;
FMaterial *tex;
FGameTexture *texture;
FSpriteModelFrame *mframe;
FColormap cm;