- make the vertex buffer accessible from the hwrenderer code.

This commit is contained in:
Christoph Oelckers 2018-05-22 18:48:10 +02:00
parent 226e8f84da
commit 2514753afb
10 changed files with 29 additions and 32 deletions

View file

@ -157,6 +157,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
mIndex = mCurIndex = 0;
mNumReserved = NUM_RESERVED;
mMap = map;
Map();
memcpy(map, &vbo_shadowdata[0], mNumReserved * sizeof(FFlatVertex));
Unmap();
@ -215,7 +216,7 @@ void FFlatVertexBuffer::Map()
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl_RenderState.ResetVertexBuffer();
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
mMap = map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
}
}
@ -227,7 +228,7 @@ void FFlatVertexBuffer::Unmap()
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl_RenderState.ResetVertexBuffer();
glUnmapBuffer(GL_ARRAY_BUFFER);
map = nullptr;
mMap = map = nullptr;
}
}

View file

@ -177,16 +177,6 @@ public:
#endif
void CheckPlanes(sector_t *sector)
{
FFlatVertexGenerator::CheckPlanes(sector, map);
}
void CheckUpdate(sector_t *sector)
{
FFlatVertexGenerator::CheckUpdate(sector, map);
}
void Reset()
{
mCurIndex = mIndex;

View file

@ -37,6 +37,7 @@
#include "hwrenderer/scene/hw_drawinfo.h"
#include "hwrenderer/scene/hw_portal.h"
#include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/data/flatvertices.h"
EXTERN_CVAR(Bool, gl_render_segs)
@ -452,7 +453,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub)
if (sector->validcount != validcount)
{
GLRenderer->mVBO->CheckUpdate(sector);
mVBO->CheckUpdate(sector);
}
// [RH] Add particles

View file

@ -199,6 +199,7 @@ FDrawInfo *FDrawInfo::StartDrawInfo(GLSceneDrawer *drawer)
{
FDrawInfo *di=di_list.GetNew();
di->mDrawer = drawer;
di->mVBO = GLRenderer->mVBO;
di->mClipper = &staticClipper;
staticClipper.Clear();
di->FixedColormap = drawer->FixedColormap;

View file

@ -425,11 +425,11 @@ void GLPortal::End(bool usestencil)
//-----------------------------------------------------------------------------
void GLPortal::StartFrame()
{
GLPortal * p=NULL;
GLPortal * p = nullptr;
portals.Push(p);
if (renderdepth==0)
if (renderdepth == 0)
{
inskybox=false;
inskybox = false;
screen->instack[sector_t::floor] = screen->instack[sector_t::ceiling] = 0;
}
renderdepth++;

View file

@ -557,6 +557,7 @@ void GLSceneDrawer::ProcessScene(FDrawInfo *di, bool toscreen)
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
di->CurrentMapSections.Set(mapsection);
GLRenderer->mCurrentPortal = nullptr;
DrawScene(di, toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
}

View file

@ -233,13 +233,13 @@ void FFlatVertexGenerator::CreateFlatVertices()
//
//==========================================================================
void FFlatVertexGenerator::UpdatePlaneVertices(sector_t *sec, int plane, FFlatVertex *map)
void FFlatVertexGenerator::UpdatePlaneVertices(sector_t *sec, int plane)
{
int startvt = sec->vboindex[plane];
int countvt = sec->vbocount[plane];
secplane_t &splane = sec->GetSecPlane(plane);
FFlatVertex *vt = &vbo_shadowdata[startvt];
FFlatVertex *mapvt = &map[startvt];
FFlatVertex *mapvt = &mMap[startvt];
for(int i=0; i<countvt; i++, vt++, mapvt++)
{
vt->z = (float)splane.ZatPoint(vt->x, vt->y);
@ -266,16 +266,16 @@ void FFlatVertexGenerator::CreateVertices()
//
//==========================================================================
void FFlatVertexGenerator::CheckPlanes(sector_t *sector, FFlatVertex *map)
void FFlatVertexGenerator::CheckPlanes(sector_t *sector)
{
if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling])
{
UpdatePlaneVertices(sector, sector_t::ceiling, map);
UpdatePlaneVertices(sector, sector_t::ceiling);
sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling);
}
if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor])
{
UpdatePlaneVertices(sector, sector_t::floor, map);
UpdatePlaneVertices(sector, sector_t::floor);
sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor);
}
}
@ -287,11 +287,11 @@ void FFlatVertexGenerator::CheckPlanes(sector_t *sector, FFlatVertex *map)
//
//==========================================================================
void FFlatVertexGenerator::CheckUpdate(sector_t *sector, FFlatVertex *map)
void FFlatVertexGenerator::CheckUpdate(sector_t *sector)
{
CheckPlanes(sector, map);
CheckPlanes(sector);
sector_t *hs = sector->GetHeightSec();
if (hs != NULL) CheckPlanes(hs, map);
if (hs != NULL) CheckPlanes(hs);
for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++)
CheckPlanes(sector->e->XFloor.ffloors[i]->model, map);
CheckPlanes(sector->e->XFloor.ffloors[i]->model);
}

View file

@ -45,10 +45,9 @@ class FFlatVertexGenerator
{
protected:
TArray<FFlatVertex> vbo_shadowdata;
FFlatVertex *mMap;
void CheckPlanes(sector_t *sector);
public:
enum
{
@ -70,12 +69,12 @@ private:
int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor);
int CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor);
void CreateFlatVertices();
void UpdatePlaneVertices(sector_t *sec, int plane, FFlatVertex *map);
void UpdatePlaneVertices(sector_t *sec, int plane);
protected:
void CreateVertices();
void CheckPlanes(sector_t *sector, FFlatVertex *map);
void CheckUpdate(sector_t *sector, FFlatVertex *map);
void CheckPlanes(sector_t *sector);
public:
void CheckUpdate(sector_t *sector);
};
#endif

View file

@ -3,6 +3,7 @@
#include <atomic>
#include "r_defs.h"
struct FSectorPortalGroup;
struct FLinePortalSpan;
struct FFlatVertex;
@ -16,6 +17,7 @@ struct FDynLightData;
struct HUDSprite;
class Clipper;
class IPortal;
class FFlatVertexGenerator;
//==========================================================================
//
@ -107,9 +109,11 @@ struct HWDrawInfo
TArray<uint8_t> ss_renderflags;
TArray<uint8_t> no_renderflags;
// This is needed by the BSP traverser.
BitArray CurrentMapSections; // this cannot be a single number, because a group of portals with the same displacement may link different sections.
area_t in_area;
fixed_t viewx, viewy; // since the nodes are still fixed point, keeping the view position also fixed point for node traversal is faster.
FFlatVertexGenerator *mVBO; // this class needs access because the sector vertex updating is part of BSP traversal.
private:

View file

@ -36,7 +36,7 @@ struct GLHorizonInfo
class IPortal
{
public:
virtual ~IPortal();
virtual ~IPortal() {}
virtual int ClipSeg(seg_t *seg) { return PClip_Inside; }
virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; }
virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; }