From dbb1492bf97d3f6fd87312c8895b168c3ffb6069 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 24 Apr 2018 11:52:15 +0200 Subject: [PATCH] Fully separated HWDrawInfo from GL dependencies. This also required temoporarily moving one small function because in the current state this cannot be done in the API independent part. --- src/gl/renderer/gl_renderer.h | 11 --- src/gl/scene/gl_drawinfo.cpp | 7 ++ src/gl/scene/gl_drawinfo.h | 108 ++-------------------------- src/gl/scene/gl_renderhacks.cpp | 13 ++-- src/gl/scene/hw_drawinfo.h | 121 ++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 122 deletions(-) create mode 100644 src/gl/scene/hw_drawinfo.h diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index c65314a618..4ce050d05e 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -57,17 +57,6 @@ inline float RAD2DEG(float deg) return deg * float(180. / M_PI); } -enum SectorRenderFlags -{ - // This is used to avoid creating too many drawinfos - SSRF_RENDERFLOOR = 1, - SSRF_RENDERCEILING = 2, - SSRF_RENDER3DPLANES = 4, - SSRF_RENDERALL = 7, - SSRF_PROCESSED = 8, - SSRF_SEEN = 16, -}; - struct GL_IRECT { int left,top; diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 9ea7aae9a2..2385730e81 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1319,3 +1319,10 @@ void FDrawInfo::ProcessLowerMinisegs(TArray &lowersegs) rendered_lines++; } } + +// Same here for the dependency on the portal. +void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) +{ + portal->GetRenderState()->AddSubsector(sub); +} + diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index fbb2f796f8..5643fc90ce 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -2,6 +2,7 @@ #define __GL_DRAWINFO_H #include "gl/scene/gl_wall.h" +#include "hw_drawinfo.h" enum GLDrawItemType { @@ -163,108 +164,6 @@ public: } ; -//========================================================================== -// -// these are used to link faked planes due to missing textures to a sector -// -//========================================================================== -struct gl_subsectorrendernode -{ - gl_subsectorrendernode * next; - subsector_t * sub; -}; - -enum area_t : int -{ - area_normal, - area_below, - area_above, - area_default -}; - -struct HWDrawInfo -{ - virtual ~HWDrawInfo() {} - - struct wallseg - { - float x1, y1, z1, x2, y2, z2; - }; - - struct MissingTextureInfo - { - seg_t * seg; - subsector_t * sub; - float Planez; - float Planezfront; - }; - - struct MissingSegInfo - { - seg_t * seg; - int MTI_Index; // tells us which MissingTextureInfo represents this seg. - }; - - struct SubsectorHackInfo - { - subsector_t * sub; - uint8_t flags; - }; - - TArray MissingUpperTextures; - TArray MissingLowerTextures; - - TArray MissingUpperSegs; - TArray MissingLowerSegs; - - TArray SubsectorHacks; - - TArray otherfloorplanes; - TArray otherceilingplanes; - - TArray CeilingStacks; - TArray FloorStacks; - - TArray HandledSubsectors; - - TArray sectorrenderflags; - TArray ss_renderflags; - TArray no_renderflags; - - - void ClearBuffers(); - - bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area); - bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area); - bool DoFakeBridge(subsector_t * subsec, float planez, area_t in_area); - bool DoFakeCeilingBridge(subsector_t * subsec, float planez, area_t in_area); - - bool CheckAnchorFloor(subsector_t * sub); - bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); - bool CheckAnchorCeiling(subsector_t * sub); - bool CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor); - void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor, area_t in_area); - void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor, area_t in_area); - - void AddUpperMissingTexture(side_t * side, subsector_t *sub, float backheight); - void AddLowerMissingTexture(side_t * side, subsector_t *sub, float backheight); - void HandleMissingTextures(area_t in_area); - void DrawUnhandledMissingTextures(); - void AddHackedSubsector(subsector_t * sub); - void HandleHackedSubsectors(); - void AddFloorStack(sector_t * sec); - void AddCeilingStack(sector_t * sec); - void ProcessSectorStacks(area_t in_area); - - void AddOtherFloorPlane(int sector, gl_subsectorrendernode * node); - void AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node); - - virtual void FloodUpperGap(seg_t * seg) = 0; - virtual void FloodLowerGap(seg_t * seg) = 0; - virtual void ProcessLowerMinisegs(TArray &lowersegs) = 0; - -}; - struct FDrawInfo : public HWDrawInfo { @@ -288,8 +187,11 @@ struct FDrawInfo : public HWDrawInfo void DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling); void FloodUpperGap(seg_t * seg) override; void FloodLowerGap(seg_t * seg) override; - void ProcessLowerMinisegs(TArray &lowersegs) override; + // These two may be moved to the API independent part of the renderer later. + void ProcessLowerMinisegs(TArray &lowersegs) override; + void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) override; + static void StartDrawInfo(GLSceneDrawer *drawer); static void EndDrawInfo(); diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 9c1b1eb17b..ad35195cda 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -27,17 +27,15 @@ #include "a_sharedglobal.h" #include "r_utility.h" -#include "r_defs.h" #include "r_sky.h" #include "g_level.h" #include "g_levellocals.h" -#include "gl/renderer/gl_renderer.h" -#include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_portal.h" -#include "gl/scene/gl_scenedrawer.h" +#include "hw_drawinfo.h" #include "gl/utility/gl_clock.h" +sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); + // This is for debugging maps. @@ -1147,7 +1145,7 @@ void HWDrawInfo::ProcessSectorStacks(area_t in_area) BuildPortalCoverage(&sub->portalcoverage[sector_t::ceiling], sub, portal->mDisplacement); } - portal->GetRenderState()->AddSubsector(sub); + AddSubsectorToPortal(portal, sub); if (sec->GetAlpha(sector_t::ceiling) != 0 && sec->GetTexture(sector_t::ceiling) != skyflatnum) { @@ -1192,8 +1190,7 @@ void HWDrawInfo::ProcessSectorStacks(area_t in_area) BuildPortalCoverage(&sub->portalcoverage[sector_t::floor], sub, portal->mDisplacement); } - GLSectorStackPortal *glportal = portal->GetRenderState(); - glportal->AddSubsector(sub); + AddSubsectorToPortal(portal, sub); if (sec->GetAlpha(sector_t::floor) != 0 && sec->GetTexture(sector_t::floor) != skyflatnum) { diff --git a/src/gl/scene/hw_drawinfo.h b/src/gl/scene/hw_drawinfo.h new file mode 100644 index 0000000000..2bf3c06394 --- /dev/null +++ b/src/gl/scene/hw_drawinfo.h @@ -0,0 +1,121 @@ +#pragma once + +#include "r_defs.h" + +struct FSectorPortalGroup; + +//========================================================================== +// +// these are used to link faked planes due to missing textures to a sector +// +//========================================================================== +struct gl_subsectorrendernode +{ + gl_subsectorrendernode * next; + subsector_t * sub; +}; + +enum area_t : int +{ + area_normal, + area_below, + area_above, + area_default +}; + +enum SectorRenderFlags +{ + // This is used to merge several subsectors into a single draw item + SSRF_RENDERFLOOR = 1, + SSRF_RENDERCEILING = 2, + SSRF_RENDER3DPLANES = 4, + SSRF_RENDERALL = 7, + SSRF_PROCESSED = 8, + SSRF_SEEN = 16, +}; + + +struct HWDrawInfo +{ + virtual ~HWDrawInfo() {} + + struct wallseg + { + float x1, y1, z1, x2, y2, z2; + }; + + struct MissingTextureInfo + { + seg_t * seg; + subsector_t * sub; + float Planez; + float Planezfront; + }; + + struct MissingSegInfo + { + seg_t * seg; + int MTI_Index; // tells us which MissingTextureInfo represents this seg. + }; + + struct SubsectorHackInfo + { + subsector_t * sub; + uint8_t flags; + }; + + TArray MissingUpperTextures; + TArray MissingLowerTextures; + + TArray MissingUpperSegs; + TArray MissingLowerSegs; + + TArray SubsectorHacks; + + TArray otherfloorplanes; + TArray otherceilingplanes; + + TArray CeilingStacks; + TArray FloorStacks; + + TArray HandledSubsectors; + + TArray sectorrenderflags; + TArray ss_renderflags; + TArray no_renderflags; + + + void ClearBuffers(); + + bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area); + bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area); + bool DoFakeBridge(subsector_t * subsec, float planez, area_t in_area); + bool DoFakeCeilingBridge(subsector_t * subsec, float planez, area_t in_area); + + bool CheckAnchorFloor(subsector_t * sub); + bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); + bool CheckAnchorCeiling(subsector_t * sub); + bool CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor); + void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor, area_t in_area); + void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor, area_t in_area); + + void AddUpperMissingTexture(side_t * side, subsector_t *sub, float backheight); + void AddLowerMissingTexture(side_t * side, subsector_t *sub, float backheight); + void HandleMissingTextures(area_t in_area); + void DrawUnhandledMissingTextures(); + void AddHackedSubsector(subsector_t * sub); + void HandleHackedSubsectors(); + void AddFloorStack(sector_t * sec); + void AddCeilingStack(sector_t * sec); + void ProcessSectorStacks(area_t in_area); + + void AddOtherFloorPlane(int sector, gl_subsectorrendernode * node); + void AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node); + + virtual void FloodUpperGap(seg_t * seg) = 0; + virtual void FloodLowerGap(seg_t * seg) = 0; + virtual void ProcessLowerMinisegs(TArray &lowersegs) = 0; + virtual void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) = 0; + +}; +