Visible surfaces are gathered in processing (gathering) render phase and lightmaps drawn before rendering
This commit is contained in:
parent
139ce34535
commit
d96d1aeffc
4 changed files with 61 additions and 59 deletions
|
|
@ -51,7 +51,6 @@
|
||||||
#include "hwrenderer/scene/hw_drawcontext.h"
|
#include "hwrenderer/scene/hw_drawcontext.h"
|
||||||
#include "hw_vrmodes.h"
|
#include "hw_vrmodes.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Int, lm_background_updates);
|
|
||||||
EXTERN_CVAR(Bool, cl_capfps)
|
EXTERN_CVAR(Bool, cl_capfps)
|
||||||
extern bool NoInterpolateView;
|
extern bool NoInterpolateView;
|
||||||
|
|
||||||
|
|
@ -97,34 +96,6 @@ void CollectLights(FLevelLocals* Level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateLightmaps(DFrameBuffer* screen, FRenderState& RenderState)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Lightmapping stuff
|
|
||||||
auto& list = RenderState.GetVisibleSurfaceList();
|
|
||||||
auto size = RenderState.GetVisibleSurfaceListCount();
|
|
||||||
|
|
||||||
list.Resize(min(list.Size(), unsigned(size)));
|
|
||||||
|
|
||||||
if (size < lm_background_updates)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
for (auto& e : level.levelMesh->Surfaces)
|
|
||||||
{
|
|
||||||
if (e.needsUpdate)
|
|
||||||
{
|
|
||||||
list.Push(index);
|
|
||||||
|
|
||||||
if (list.Size() >= lm_background_updates)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
screen->UpdateLightmaps(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Renders one viewpoint in a scene
|
// Renders one viewpoint in a scene
|
||||||
|
|
@ -152,7 +123,6 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
|
||||||
screen->mShadowMap->SetCollectLights(nullptr);
|
screen->mShadowMap->SetCollectLights(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderState.ClearVisibleSurfaceList();
|
|
||||||
screen->SetLevelMesh(camera->Level->levelMesh);
|
screen->SetLevelMesh(camera->Level->levelMesh);
|
||||||
|
|
||||||
static HWDrawContext mainthread_drawctx;
|
static HWDrawContext mainthread_drawctx;
|
||||||
|
|
@ -226,8 +196,6 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
|
||||||
screen->NextEye(eyeCount);
|
screen->NextEye(eyeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLightmaps(screen, RenderState);
|
|
||||||
|
|
||||||
return mainvp.sector;
|
return mainvp.sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ CVAR(Bool, gl_multithread, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
EXTERN_CVAR(Float, r_actorspriteshadowdist)
|
EXTERN_CVAR(Float, r_actorspriteshadowdist)
|
||||||
EXTERN_CVAR(Bool, gl_meshcache)
|
EXTERN_CVAR(Bool, gl_meshcache)
|
||||||
|
EXTERN_CVAR(Int, lm_background_updates);
|
||||||
|
|
||||||
thread_local bool isWorkerThread;
|
thread_local bool isWorkerThread;
|
||||||
ctpl::thread_pool renderPool(1);
|
ctpl::thread_pool renderPool(1);
|
||||||
|
|
@ -856,8 +857,37 @@ void HWDrawInfo::RenderBSPNode (void *node, FRenderState& state)
|
||||||
DoSubsector ((subsector_t *)((uint8_t *)node - 1), state);
|
DoSubsector ((subsector_t *)((uint8_t *)node - 1), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateLightmaps(DFrameBuffer* screen, FRenderState& RenderState)
|
||||||
|
{
|
||||||
|
// Lightmapping stuff
|
||||||
|
auto& list = RenderState.GetVisibleSurfaceList();
|
||||||
|
auto size = RenderState.GetVisibleSurfaceListCount();
|
||||||
|
|
||||||
|
list.Resize(min(list.Size(), unsigned(size)));
|
||||||
|
|
||||||
|
if (size < lm_background_updates)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
for (auto& e : level.levelMesh->Surfaces)
|
||||||
|
{
|
||||||
|
if (e.needsUpdate)
|
||||||
|
{
|
||||||
|
list.Push(index);
|
||||||
|
|
||||||
|
if (list.Size() >= lm_background_updates)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
screen->UpdateLightmaps(list);
|
||||||
|
}
|
||||||
|
|
||||||
void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state)
|
void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state)
|
||||||
{
|
{
|
||||||
|
state.ClearVisibleSurfaceList();
|
||||||
|
|
||||||
Bsp.Clock();
|
Bsp.Clock();
|
||||||
|
|
||||||
// Give the DrawInfo the viewpoint in fixed point because that's what the nodes are.
|
// Give the DrawInfo the viewpoint in fixed point because that's what the nodes are.
|
||||||
|
|
@ -892,4 +922,6 @@ void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state)
|
||||||
|
|
||||||
if (drawpsprites)
|
if (drawpsprites)
|
||||||
PreparePlayerSprites(Viewpoint.sector, in_area, state);
|
PreparePlayerSprites(Viewpoint.sector, in_area, state);
|
||||||
|
|
||||||
|
UpdateLightmaps(screen, state);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,28 +191,6 @@ void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
|
||||||
SetupLights(di, state, section->lighthead, lightdata, sector->PortalGroup);
|
SetupLights(di, state, section->lighthead, lightdata, sector->PortalGroup);
|
||||||
}
|
}
|
||||||
state.SetLightIndex(dynlightindex);
|
state.SetLightIndex(dynlightindex);
|
||||||
|
|
||||||
const auto* lm = §or->Level->levelMesh->Surfaces[0]; // temporay hack on top of a temporary hack
|
|
||||||
|
|
||||||
for (auto& subsector : section->subsectors)
|
|
||||||
{
|
|
||||||
if (auto lightmap = subsector->lightmap[ceiling ? 1 : 0][0])
|
|
||||||
{
|
|
||||||
state.PushVisibleSurface(lightmap - lm, lightmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto subsectors = sector->Level->levelMesh->XFloorToSurface.CheckKey(sector))
|
|
||||||
{
|
|
||||||
for (auto* surface : *subsectors)
|
|
||||||
{
|
|
||||||
if (surface)
|
|
||||||
{
|
|
||||||
state.PushVisibleSurface(surface - lm, surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state.DrawIndexed(DT_Triangles, iboindex + section->vertexindex, section->vertexcount);
|
state.DrawIndexed(DT_Triangles, iboindex + section->vertexindex, section->vertexcount);
|
||||||
flatvertices += section->vertexcount;
|
flatvertices += section->vertexcount;
|
||||||
flatprimitives++;
|
flatprimitives++;
|
||||||
|
|
@ -523,6 +501,31 @@ void HWFlat::ProcessSector(HWDrawInfo *di, FRenderState& state, sector_t * front
|
||||||
uint8_t &srf = hacktype? sink : di->section_renderflags[di->Level->sections.SectionIndex(section)];
|
uint8_t &srf = hacktype? sink : di->section_renderflags[di->Level->sections.SectionIndex(section)];
|
||||||
const auto &vp = di->Viewpoint;
|
const auto &vp = di->Viewpoint;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lightmaps
|
||||||
|
//
|
||||||
|
|
||||||
|
const auto* lm = §or->Level->levelMesh->Surfaces[0]; // temporay hack on top of a temporary hack
|
||||||
|
|
||||||
|
for (auto& subsector : section->subsectors)
|
||||||
|
{
|
||||||
|
if (auto lightmap = subsector->lightmap[ceiling ? 1 : 0][0])
|
||||||
|
{
|
||||||
|
state.PushVisibleSurface(lightmap - lm, lightmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto subsectors = sector->Level->levelMesh->XFloorToSurface.CheckKey(sector))
|
||||||
|
{
|
||||||
|
for (auto* surface : *subsectors)
|
||||||
|
{
|
||||||
|
if (surface)
|
||||||
|
{
|
||||||
|
state.PushVisibleSurface(surface - lm, surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -347,11 +347,6 @@ void HWWall::DrawWall(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
MakeVertices(di, state, !!(flags & HWWall::HWF_TRANSLUCENT));
|
MakeVertices(di, state, !!(flags & HWWall::HWF_TRANSLUCENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lightmap)
|
|
||||||
{
|
|
||||||
state.PushVisibleSurface(lightmap - &seg->Subsector->sector->Level->levelMesh->Surfaces[0], lightmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
state.SetNormal(glseg.Normal());
|
state.SetNormal(glseg.Normal());
|
||||||
if (!translucent)
|
if (!translucent)
|
||||||
{
|
{
|
||||||
|
|
@ -1270,6 +1265,10 @@ void HWWall::DoTexture(HWDrawInfo *di, FRenderState& state, int _type,seg_t * se
|
||||||
if (seg->sidedef->lightmap && type >= RENDERWALL_TOP && type <= RENDERWALL_BOTTOM)
|
if (seg->sidedef->lightmap && type >= RENDERWALL_TOP && type <= RENDERWALL_BOTTOM)
|
||||||
{
|
{
|
||||||
lightmap = seg->sidedef->lightmap[type - RENDERWALL_TOP];
|
lightmap = seg->sidedef->lightmap[type - RENDERWALL_TOP];
|
||||||
|
if (lightmap)
|
||||||
|
{
|
||||||
|
state.PushVisibleSurface(lightmap - &seg->Subsector->sector->Level->levelMesh->Surfaces[0], lightmap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue