Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into archive_split
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Sep 10, 2017
2 parents c4ad6e5 + d80f963 commit 10dcb40
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 79 deletions.
4 changes: 1 addition & 3 deletions src/gl/dynlights/gl_shadowmap.cpp
Expand Up @@ -82,12 +82,10 @@ ADD_STAT(shadowmap)
return out;
}

CUSTOM_CVAR(Int, gl_shadowmap_quality, 128, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Int, gl_shadowmap_quality, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
switch (self)
{
case 32:
case 64:
case 128:
case 256:
case 512:
Expand Down
44 changes: 35 additions & 9 deletions src/polyrenderer/scene/poly_cull.cpp
Expand Up @@ -33,11 +33,32 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const PolyClipPlane &port
ClearSolidSegments();
MarkViewFrustum();

if (level.LevelName != lastLevelName) // Is this the best way to detect a level change?
{
lastLevelName = level.LevelName;
SubsectorDepths.clear();
SubsectorDepths.resize(level.subsectors.Size(), 0xffffffff);
SectorSeen.clear();
SectorSeen.resize(level.sectors.Size());
}
else
{
for (const auto &sub : PvsSectors)
SubsectorDepths[sub->Index()] = 0xffffffff;
SubsectorDepths.resize(level.subsectors.Size(), 0xffffffff);

for (const auto &sector : SeenSectors)
SectorSeen[sector->Index()] = false;
SectorSeen.resize(level.sectors.Size());
}

PvsSectors.clear();
PvsLineStart.clear();
PvsLineVisible.clear();
SeenSectors.clear();
SubsectorDepths.clear();

NextPvsLineStart = 0;
PvsLineStart.clear();
PvsLineVisible.resize(level.segs.Size());

PortalClipPlane = portalClipPlane;

// Cull front to back
Expand Down Expand Up @@ -108,7 +129,7 @@ void PolyCull::CullSubsector(subsector_t *sub)

// Mark that we need to render this
PvsSectors.push_back(sub);
PvsLineStart.push_back((uint32_t)PvsLineVisible.size());
PvsLineStart.push_back(NextPvsLineStart);

DVector3 viewpos = PolyRenderer::Instance()->Viewpoint.Pos;

Expand All @@ -122,15 +143,15 @@ void PolyCull::CullSubsector(subsector_t *sub)
DVector2 pt2 = line->v2->fPos() - viewpos;
if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
{
PvsLineVisible.push_back(false);
PvsLineVisible[NextPvsLineStart++] = false;
continue;
}

// Skip line if entirely behind portal clipping plane
if ((PortalClipPlane.A * line->v1->fX() + PortalClipPlane.B * line->v1->fY() + PortalClipPlane.D <= 0.0) ||
(PortalClipPlane.A * line->v2->fX() + PortalClipPlane.B * line->v2->fY() + PortalClipPlane.D <= 0.0))
{
PvsLineVisible.push_back(false);
PvsLineVisible[NextPvsLineStart++] = false;
continue;
}

Expand All @@ -142,11 +163,16 @@ void PolyCull::CullSubsector(subsector_t *sub)
}

// Mark if this line was visible
PvsLineVisible.push_back(lineVisible);
PvsLineVisible[NextPvsLineStart++] = lineVisible;
}

if (!SectorSeen[sub->sector->Index()])
{
SectorSeen[sub->sector->Index()] = true;
SeenSectors.push_back(sub->sector);
}

SeenSectors.insert(sub->sector);
SubsectorDepths[sub] = subsectorDepth;
SubsectorDepths[sub->Index()] = subsectorDepth;
}

void PolyCull::ClearSolidSegments()
Expand Down
8 changes: 6 additions & 2 deletions src/polyrenderer/scene/poly_cull.h
Expand Up @@ -40,8 +40,9 @@ class PolyCull
double MaxCeilingHeight = 0.0;
double MinFloorHeight = 0.0;

std::set<sector_t *> SeenSectors;
std::unordered_map<subsector_t *, uint32_t> SubsectorDepths;
std::vector<sector_t *> SeenSectors;
std::vector<bool> SectorSeen;
std::vector<uint32_t> SubsectorDepths;

static angle_t PointToPseudoAngle(double x, double y);

Expand Down Expand Up @@ -69,6 +70,8 @@ class PolyCull

void MarkSegmentCulled(angle_t angle1, angle_t angle2);

FString lastLevelName;

std::vector<SolidSegment> SolidSegments;
std::vector<SolidSegment> TempInvertSolidSegments;
const int SolidCullScale = 3000;
Expand All @@ -78,6 +81,7 @@ class PolyCull

std::vector<uint32_t> PvsLineStart;
std::vector<bool> PvsLineVisible;
uint32_t NextPvsLineStart = 0;

static angle_t AngleToPseudo(angle_t ang);
};
10 changes: 4 additions & 6 deletions src/polyrenderer/scene/poly_scene.cpp
Expand Up @@ -213,9 +213,8 @@ void RenderPolyScene::RenderSprite(PolyRenderThread *thread, AActor *thing, doub
if (level.nodes.Size() == 0)
{
subsector_t *sub = &level.subsectors[0];
auto it = Cull.SubsectorDepths.find(sub);
if (it != Cull.SubsectorDepths.end())
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, it->second, sortDistance, 0.0f, 1.0f, StencilValue));
if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, 0.0f, 1.0f, StencilValue));
}
else
{
Expand Down Expand Up @@ -254,9 +253,8 @@ void RenderPolyScene::RenderSprite(PolyRenderThread *thread, AActor *thing, doub

subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);

auto it = Cull.SubsectorDepths.find(sub);
if (it != Cull.SubsectorDepths.end())
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, it->second, sortDistance, (float)t1, (float)t2, StencilValue));
if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, (float)t1, (float)t2, StencilValue));
}

void RenderPolyScene::RenderLine(PolyRenderThread *thread, subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth)
Expand Down
75 changes: 37 additions & 38 deletions src/r_videoscale.cpp
Expand Up @@ -25,63 +25,62 @@
#include "c_dispatch.h"
#include "c_cvars.h"

CUSTOM_CVAR (Int, vid_scalemode, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
#define NUMSCALEMODES 5

namespace
{
struct v_ScaleTable
{
bool isValid;
bool isLinear;
uint32_t(*GetScaledWidth)(uint32_t Width);
uint32_t(*GetScaledHeight)(uint32_t Height);
bool isScaled43;
};
v_ScaleTable vScaleTable[NUMSCALEMODES] =
{
// isValid, isLinear, GetScaledWidth(), GetScaledHeight(), isScaled43
{ true, false, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false }, // 0 - Native
{ true, true, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false }, // 1 - Native (Linear)
{ true, false, [](uint32_t Width)->uint32_t { return 320; }, [](uint32_t Height)->uint32_t { return 200; }, true }, // 2 - 320x200
{ true, false, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true }, // 3 - 640x400
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true }, // 4 - 1280x800
};
}

CUSTOM_CVAR(Float, vid_scalefactor, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self <= 0.0 || self > 2.0)
self = 1.0;
}

CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self < 0 || self > 6)
if (self < 0 || self >= NUMSCALEMODES || vScaleTable[self].isValid == false)
{
self = 0;
}
}

bool ViewportLinearScale()
{
switch(vid_scalemode)
{
default: return false;
case 4:
case 5:
case 6: return true;
}
// vid_scalefactor > 1 == forced linear scale
return (vid_scalefactor > 1.0) ? true : vScaleTable[vid_scalemode].isLinear;
}

int ViewportScaledWidth(int width)
{
switch (vid_scalemode)
{
default:
case 0: return width;
case 1: return 320;
case 2: return 640;
case 3: return (int)roundf(width * 0.5f);
case 4: return (int)roundf(width * 0.75f);
case 5: return width * 2;
case 6: return 1280;
}
return vScaleTable[vid_scalemode].GetScaledWidth((int)((float)width * vid_scalefactor));
}

int ViewportScaledHeight(int height)
{
switch (vid_scalemode)
{
default:
case 0: return height;
case 1: return 200;
case 2: return 400;
case 3: return (int)roundf(height * 0.5f);
case 4: return (int)roundf(height * 0.75f);
case 5: return height * 2;
case 6: return 800;
}
return vScaleTable[vid_scalemode].GetScaledHeight((int)((float)height * vid_scalefactor));
}

bool ViewportIsScaled43()
{
switch (vid_scalemode)
{
default: return false;
case 1:
case 2:
case 6: return true;
}
return vScaleTable[vid_scalemode].isScaled43;
}


18 changes: 11 additions & 7 deletions wadsrc/static/language.enu
Expand Up @@ -2193,6 +2193,7 @@ VIDMNU_ASPECTRATIO = "Aspect ratio";
VIDMNU_FORCEASPECT = "Force aspect ratio";
VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio";
VIDMNU_SCALEMODE = "Resolution scale";
VIDMNU_SCALEFACTOR = "Scale Factor";
VIDMNU_ENTERTEXT = "Press ENTER to set mode";
VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds";
VIDMNU_TESTTEXT2 = "Please wait 5 seconds...";
Expand Down Expand Up @@ -2378,6 +2379,8 @@ OPTVAL_VTFZDOOM = "ZDoom (Forced)";
OPTVAL_VTFVANILLA = "Vanilla (Forced)";
OPTVAL_VTAZDOOM = "Auto (ZDoom Preferred)";
OPTVAL_VTAVANILLA = "Auto (Vanilla Preferred)";
OPTVAL_SCALENEAREST = "Scaled (Nearest)";
OPTVAL_SCALELINEAR = "Scaled (Linear)";

// Colors
C_BRICK = "\cabrick";
Expand Down Expand Up @@ -2685,13 +2688,14 @@ GLTEXMNU_TRIMSPREDGE = "Trim sprite edges";
GLTEXMNU_SORTDRAWLIST = "Sort draw lists by texture";

// Dynamic Light Options
GLLIGHTMNU_TITLE = "DYNAMIC LIGHTS";
GLLIGHTMNU_LIGHTSENABLED = "Dynamic Lights (OpenGL)";
GLLIGHTMNU_LIGHTDEFS = "Enable light definitions";
GLLIGHTMNU_CLIPLIGHTS = "Clip lights";
GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites";
GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles";
GLLIGHTMNU_LIGHTSHADOWMAP = "Light shadowmaps";
GLLIGHTMNU_TITLE = "DYNAMIC LIGHTS";
GLLIGHTMNU_LIGHTSENABLED = "Dynamic Lights (OpenGL)";
GLLIGHTMNU_LIGHTDEFS = "Enable light definitions";
GLLIGHTMNU_CLIPLIGHTS = "Clip lights";
GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites";
GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles";
GLLIGHTMNU_LIGHTSHADOWMAP = "Light shadowmaps";
GLLIGHTMNU_LIGHTSHADOWMAPQUALITY = "Shadowmap quality";

// OpenGL Preferences
GLPREFMNU_TITLE = "OPENGL PREFERENCES";
Expand Down
36 changes: 22 additions & 14 deletions wadsrc/static/menudef.txt
Expand Up @@ -1858,13 +1858,11 @@ OptionValue RatiosTFT
}
OptionValue ScaleModes
{
0, "$OPTVAL_OFF"
1, "320x200"
2, "640x400"
3, "0.5x"
4, "0.75x"
5, "2x SSAA"
6, "1280x800"
0, "$OPTVAL_SCALENEAREST"
1, "$OPTVAL_SCALELINEAR"
2, "320x200"
3, "640x400"
4, "1280x800"
}

OptionMenu VideoModeMenu protected
Expand All @@ -1880,6 +1878,7 @@ OptionMenu VideoModeMenu protected
Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios"
Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo"
Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes"
Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2
StaticText " "
ScreenResolution "res_0"
ScreenResolution "res_1"
Expand Down Expand Up @@ -2128,6 +2127,14 @@ OptionValue VRMode
7, "$OPTVAL_QUADBUFFERED"
}

OptionValue ShadowMapQuality
{
128, "128"
256, "256"
512, "512"
1024, "1024"
}

OptionMenu "GLTextureGLOptions" protected
{
Title "$GLTEXMNU_TITLE"
Expand All @@ -2148,13 +2155,14 @@ OptionMenu "GLTextureGLOptions" protected
OptionMenu "GLLightOptions" protected
{
Title "$GLLIGHTMNU_TITLE"
Option "$TCMNU_DYNLIGHTS", "r_dynlights", "OnOff"
Option "$GLLIGHTMNU_LIGHTSENABLED", gl_lights, "OnOff"
Option "$GLLIGHTMNU_LIGHTDEFS", gl_attachedlights, "YesNo"
Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo"
Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo"
Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo"
Option "$GLLIGHTMNU_LIGHTSHADOWMAP", gl_light_shadowmap, "YesNo"
Option "$TCMNU_DYNLIGHTS", "r_dynlights", "OnOff"
Option "$GLLIGHTMNU_LIGHTSENABLED", gl_lights, "OnOff"
Option "$GLLIGHTMNU_LIGHTDEFS", gl_attachedlights, "YesNo"
Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo"
Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo"
Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo"
Option "$GLLIGHTMNU_LIGHTSHADOWMAP", gl_light_shadowmap, "YesNo"
Option "$GLLIGHTMNU_LIGHTSHADOWMAPQUALITY", gl_shadowmap_quality, "ShadowMapQuality"
}

OptionMenu "OpenGLOptions" protected
Expand Down

0 comments on commit 10dcb40

Please sign in to comment.