- hw_sprites extracted

- moved the variables for OpenGL's special textures to the texture manager because it is far better suited as a container than the GLRenderer.
This commit is contained in:
Christoph Oelckers 2018-04-29 00:09:44 +02:00
parent d1720ad790
commit 64b108ff44
23 changed files with 1196 additions and 1124 deletions

View file

@ -834,6 +834,7 @@ set( FASTMATH_SOURCES
hwrenderer/scene/hw_flats.cpp
hwrenderer/scene/hw_renderhacks.cpp
hwrenderer/scene/hw_sky.cpp
hwrenderer/scene/hw_sprites.cpp
hwrenderer/scene/hw_walls.cpp
hwrenderer/scene/hw_walls_vertex.cpp
r_data/models/models.cpp

View file

@ -283,6 +283,17 @@ enum ESSType
const double M_PI = 3.14159265358979323846; // matches value in gcc v2 math.h
inline float DEG2RAD(float deg)
{
return deg * float(M_PI / 180.0);
}
inline float RAD2DEG(float deg)
{
return deg * float(180. / M_PI);
}
template <typename T, size_t N>
char ( &_ArraySizeHelper( T (&array)[N] ))[N];

View file

@ -483,8 +483,8 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, FVector3 & nearP
bool gl_SetupLightTexture()
{
if (!GLRenderer->glLight.isValid()) return false;
FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->glLight, false, false);
if (!TexMan.glLight.isValid()) return false;
FMaterial * pat = FMaterial::ValidateTexture(TexMan.glLight, false, false);
gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false);
return true;
}

View file

@ -95,7 +95,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
mViewVector = FVector2(0,0);
mVBO = nullptr;
mSkyVBO = nullptr;
gl_spriteindex = 0;
mShaderManager = nullptr;
mLights = nullptr;
mTonemapPalette = nullptr;
@ -158,8 +157,6 @@ void FGLRenderer::Initialize(int width, int height)
legacyShaders = new LegacyShaderContainer;
}
GetSpecialTextures();
// needed for the core profile, because someone decided it was a good idea to remove the default VAO.
if (!gl.legacyMode)
{
@ -230,16 +227,6 @@ FGLRenderer::~FGLRenderer()
delete mFXAALumaShader;
}
void FGLRenderer::GetSpecialTextures()
{
if (gl.legacyMode) glLight = TexMan.CheckForTexture("glstuff/gllight.png", ETextureType::MiscPatch);
glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", ETextureType::MiscPatch);
glPart = TexMan.CheckForTexture("glstuff/glpart.png", ETextureType::MiscPatch);
mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", ETextureType::MiscPatch);
}
//==========================================================================
//
// Calculates the viewport values needed for 2D and 3D operations

View file

@ -51,16 +51,6 @@ class FCustomPostProcessShaders;
class GLSceneDrawer;
class SWSceneDrawer;
inline float DEG2RAD(float deg)
{
return deg * float(M_PI / 180.0);
}
inline float RAD2DEG(float deg)
{
return deg * float(180. / M_PI);
}
struct GL_IRECT
{
int left,top;
@ -119,7 +109,6 @@ public:
AActor *mViewActor;
FShaderManager *mShaderManager;
FSamplerManager *mSamplerManager;
int gl_spriteindex;
unsigned int mFBID;
unsigned int mVAOID;
int mOldFBID;
@ -150,11 +139,6 @@ public:
FShadowMap mShadowMap;
FTextureID glLight;
FTextureID glPart2;
FTextureID glPart;
FTextureID mirrorTexture;
FRotator mAngles;
FVector2 mViewVector;
@ -204,7 +188,6 @@ public:
void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma);
void DrawPresentTexture(const GL_IRECT &box, bool applyGamma);
void Flush();
void GetSpecialTextures();
void Draw2D(F2DDrawer *data);
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);

View file

@ -85,7 +85,7 @@ void GLSceneDrawer::AddLine (seg_t *seg, bool portalclip)
if (portalclip)
{
int clipres = GLRenderer->mClipPortal->ClipSeg(seg);
if (clipres == GLPortal::PClip_InFront) return;
if (clipres == PClip_InFront) return;
}
angle_t startAngle = clipper.GetClipAngle(seg->v2);
@ -436,7 +436,7 @@ void GLSceneDrawer::DoSubsector(subsector_t * sub)
if (GLRenderer->mClipPortal)
{
int clipres = GLRenderer->mClipPortal->ClipSubsector(sub);
if (clipres == GLPortal::PClip_InFront)
if (clipres == PClip_InFront)
{
line_t *line = GLRenderer->mClipPortal->ClipLine();
// The subsector is out of range, but we still have to check lines that lie directly on the boundary and may expose their upper or lower parts.
@ -458,6 +458,12 @@ void GLSceneDrawer::DoSubsector(subsector_t * sub)
for (i = ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Particles[i].snext)
{
if (GLRenderer->mClipPortal)
{
int clipres = GLRenderer->mClipPortal->ClipPoint(Particles[i].Pos);
if (clipres == PClip_InFront) continue;
}
GLSprite sprite;
sprite.ProcessParticle(gl_drawinfo, &Particles[i], fakesector);
}

View file

@ -32,6 +32,7 @@
#include "r_utility.h"
#include "doomstat.h"
#include "g_levellocals.h"
#include "hwrenderer/scene/hw_drawstructs.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h"
@ -1306,6 +1307,12 @@ void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *su
portal->GetRenderState()->AddSubsector(sub);
}
int FDrawInfo::ClipPoint(const DVector3 &pos)
{
return GLRenderer->mClipPortal->ClipPoint(pos);
}
std::pair<FFlatVertex *, unsigned int> FDrawInfo::AllocVertices(unsigned int count)
{
unsigned int index = -1;

View file

@ -4,6 +4,8 @@
#include "gl/scene/gl_wall.h"
#include "hwrenderer/scene/hw_drawinfo.h"
class GLSceneDrawer;
enum GLDrawItemType
{
GLDIT_WALL,
@ -226,6 +228,7 @@ struct FDrawInfo : public HWDrawInfo
// These two may be moved to the API independent part of the renderer later.
void ProcessLowerMinisegs(TArray<seg_t *> &lowersegs) override;
void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) override;
int ClipPoint(const DVector3 &pos) override;
static void StartDrawInfo(GLSceneDrawer *drawer);
static void EndDrawInfo();

View file

@ -106,13 +106,6 @@ protected:
public:
enum
{
PClip_InFront,
PClip_Inside,
PClip_Behind,
};
void RenderPortal(bool usestencil, bool doquery)
{
// Start may perform an occlusion query. If that returns 0 there

View file

@ -247,11 +247,16 @@ void GLSceneDrawer::CreateScene()
// clip the scene and fill the drawlists
for(auto p : level.portalGroups) p->glportal = nullptr;
GLRenderer->gl_spriteindex=0;
Bsp.Clock();
GLRenderer->mVBO->Map();
SetView();
validcount++; // used for processing sidedefs only once by the renderer.
gl_drawinfo->clipPortal = !!GLRenderer->mClipPortal;
gl_drawinfo->mAngles = GLRenderer->mAngles;
gl_drawinfo->mViewVector = GLRenderer->mViewVector;
gl_drawinfo->mViewActor = GLRenderer->mViewActor;
RenderBSPNode (level.HeadNode());
if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached();
Bsp.Unclock();

File diff suppressed because it is too large Load diff

View file

@ -15,95 +15,7 @@
#pragma warning(disable:4244)
#endif
struct GLHorizonInfo;
struct F3DFloor;
struct model_t;
struct FSpriteModelFrame;
struct particle_t;
class ADynamicLight;
class FMaterial;
struct GLDrawList;
struct GLSkyInfo;
struct FTexCoordInfo;
struct FSectorPortalGroup;
struct FFlatVertex;
struct FLinePortalSpan;
class GLSceneDrawer;
struct FDynLightData;
enum area_t : int;
struct FDrawInfo;
struct HWDrawInfo;
//==========================================================================
//
// One sprite in the draw list
//
//==========================================================================
class GLSprite
{
public:
friend struct GLDrawList;
friend void Mod_RenderModel(GLSprite * spr, model_t * mdl, int framenumber);
int lightlevel;
uint8_t foglevel;
uint8_t hw_styleflags;
bool fullbright;
PalEntry ThingColor; // thing's own color
FColormap Colormap;
FSpriteModelFrame * modelframe;
FRenderStyle RenderStyle;
int OverrideShader;
int translation;
int index;
int depth;
float topclip;
float bottomclip;
float x,y,z; // needed for sorting!
float ul,ur;
float vt,vb;
float x1,y1,z1;
float x2,y2,z2;
FMaterial *gltexture;
float trans;
AActor * actor;
particle_t * particle;
TArray<lightlist_t> *lightlist;
DRotator Angles;
int dynlightindex;
void SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight);
bool CalculateVertices(FVector3 *v);
public:
GLSprite() {}
void PutSprite(HWDrawInfo *di, bool translucent);
void Process(HWDrawInfo *di, AActor* thing,sector_t * sector, area_t in_area, int thruportal = false);
void ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *sector);//, int shade, int fakeside)
GLSprite(const GLSprite &other)
{
memcpy(this, &other, sizeof(GLSprite));
}
GLSprite & operator=(const GLSprite &other)
{
memcpy(this, &other, sizeof(GLSprite));
return *this;
}
};
// Light + color

View file

@ -101,7 +101,7 @@ void FDrawInfo::RenderFogBoundary(GLWall *wall)
//==========================================================================
void FDrawInfo::RenderMirrorSurface(GLWall *wall)
{
if (!GLRenderer->mirrorTexture.isValid()) return;
if (!TexMan.mirrorTexture.isValid()) return;
if (!gl.legacyMode)
{
@ -124,7 +124,7 @@ void FDrawInfo::RenderMirrorSurface(GLWall *wall)
gl_RenderState.AlphaFunc(GL_GREATER,0);
glDepthFunc(GL_LEQUAL);
FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrorTexture, false, false);
FMaterial * pat=FMaterial::ValidateTexture(TexMan.mirrorTexture, false, false);
gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false);
wall->flags &= ~GLWall::GLWF_GLOW;

View file

@ -574,7 +574,6 @@ void OpenGLFrameBuffer::GameRestart()
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
UpdatePalette ();
ScreenshotBuffer = NULL;
GLRenderer->GetSpecialTextures();
}

View file

@ -1,5 +1,6 @@
#pragma once
#include <atomic>
#include "r_defs.h"
struct FSectorPortalGroup;
@ -34,6 +35,13 @@ enum SectorRenderFlags
SSRF_SEEN = 16,
};
enum EPortalClip
{
PClip_InFront,
PClip_Inside,
PClip_Behind,
};
struct HWDrawInfo
{
@ -65,6 +73,11 @@ struct HWDrawInfo
};
int FixedColormap;
std::atomic<int> spriteindex;
bool clipPortal;
FRotator mAngles;
FVector2 mViewVector;
AActor *mViewActor;
TArray<MissingTextureInfo> MissingUpperTextures;
TArray<MissingTextureInfo> MissingLowerTextures;
@ -138,6 +151,8 @@ public:
virtual GLDecal *AddDecal(bool onmirror) = 0;
virtual std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count) = 0;
virtual int ClipPoint(const DVector3 &pos) = 0;
};

View file

@ -23,6 +23,9 @@ struct FFlatVertex;
struct FLinePortalSpan;
struct FDynLightData;
class VSMatrix;
struct FSpriteModelFrame;
struct particle_t;
enum area_t : int;
enum HWRenderStyle
{
@ -330,8 +333,73 @@ public:
};
//==========================================================================
//
// One sprite in the draw list
//
//==========================================================================
class GLSprite
{
public:
int lightlevel;
uint8_t foglevel;
uint8_t hw_styleflags;
bool fullbright;
PalEntry ThingColor; // thing's own color
FColormap Colormap;
FSpriteModelFrame * modelframe;
FRenderStyle RenderStyle;
int OverrideShader;
int translation;
int index;
int depth;
float topclip;
float bottomclip;
float x,y,z; // needed for sorting!
float ul,ur;
float vt,vb;
float x1,y1,z1;
float x2,y2,z2;
FMaterial *gltexture;
float trans;
AActor * actor;
particle_t * particle;
TArray<lightlist_t> *lightlist;
DRotator Angles;
int dynlightindex;
void SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight);
bool CalculateVertices(HWDrawInfo *di, FVector3 *v);
public:
GLSprite() {}
void PutSprite(HWDrawInfo *di, bool translucent);
void Process(HWDrawInfo *di, AActor* thing,sector_t * sector, area_t in_area, int thruportal = false);
void ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *sector);//, int shade, int fakeside)
GLSprite(const GLSprite &other)
{
memcpy(this, &other, sizeof(GLSprite));
}
GLSprite & operator=(const GLSprite &other)
{
memcpy(this, &other, sizeof(GLSprite));
return *this;
}
};
@ -364,3 +432,4 @@ inline float Dist2(float x1,float y1,float x2,float y2)
}
bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture, VSMatrix &mat);
extern const float LARGE_VALUE;

View file

@ -70,6 +70,7 @@ void HWDrawInfo::ClearBuffers()
CeilingStacks.Clear();
FloorStacks.Clear();
HandledSubsectors.Clear();
spriteindex = 0;
}
//==========================================================================

File diff suppressed because it is too large Load diff

View file

@ -109,3 +109,25 @@ CVAR(Bool, gl_precache, false, CVAR_ARCHIVE)
CVAR(Bool, gl_trimsprites, true, CVAR_ARCHIVE);
//==========================================================================
//
// Sprite CVARs
//
//==========================================================================
CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
CVAR(Int, gl_spriteclip, 1, CVAR_ARCHIVE)
CVAR(Float, gl_sclipthreshold, 10.0, CVAR_ARCHIVE)
CVAR(Float, gl_sclipfactor, 1.8f, CVAR_ARCHIVE)
CVAR(Int, gl_particles_style, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // 0 = square, 1 = round, 2 = smooth
CVAR(Int, gl_billboard_mode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, gl_billboard_faces_camera, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, gl_billboard_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, gl_enhanced_nv_stealth, 3, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE)
{
if (self < 0 || self > 8) self = 0;
}

View file

@ -57,3 +57,16 @@ EXTERN_CVAR(Float, gl_ssao_blur_amount)
EXTERN_CVAR(Int, gl_debug_level)
EXTERN_CVAR(Bool, gl_debug_breakpoint)
EXTERN_CVAR(Bool, gl_usecolorblending)
EXTERN_CVAR(Bool, gl_spritebrightfog)
EXTERN_CVAR(Bool, gl_sprite_blend)
EXTERN_CVAR(Int, gl_spriteclip)
EXTERN_CVAR(Float, gl_sclipthreshold)
EXTERN_CVAR(Float, gl_sclipfactor)
EXTERN_CVAR(Int, gl_particles_style)
EXTERN_CVAR(Int, gl_billboard_mode)
EXTERN_CVAR(Bool, gl_billboard_faces_camera)
EXTERN_CVAR(Bool, gl_billboard_particles)
EXTERN_CVAR(Int, gl_enhanced_nv_stealth)
EXTERN_CVAR(Int, gl_fuzztype)

View file

@ -20,6 +20,7 @@ struct FRenderViewpoint
DVector3 Pos; // Camera position
DVector3 ActorPos; // Camera actor's position
DRotator Angles; // Camera angles
DVector3 Path[2]; // View path for portal calculations
double Cos; // cos(Angles.Yaw)
double Sin; // sin(Angles.Yaw)

View file

@ -1054,6 +1054,12 @@ void FTextureManager::Init()
{
tex.Texture->AddAutoMaterials();
}
glLight = TexMan.CheckForTexture("glstuff/gllight.png", ETextureType::MiscPatch);
glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", ETextureType::MiscPatch);
glPart = TexMan.CheckForTexture("glstuff/glpart.png", ETextureType::MiscPatch);
mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", ETextureType::MiscPatch);
}
//==========================================================================

View file

@ -682,6 +682,12 @@ public:
{
SINMASK = 2047
};
FTextureID glLight;
FTextureID glPart2;
FTextureID glPart;
FTextureID mirrorTexture;
};
// base class for everything that can be used as a world texture.