mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
Prepare FFlatVertexBuffer for removal
This commit is contained in:
parent
eb3878ad78
commit
8c4ddea735
13 changed files with 102 additions and 73 deletions
|
@ -128,10 +128,3 @@ void FFlatVertexBuffer::Copy(int start, int count)
|
||||||
|
|
||||||
mVertexBuffer = old;
|
mVertexBuffer = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
std::pair<FFlatVertex*, unsigned int> FRenderState::AllocVertices(unsigned int count)
|
|
||||||
{
|
|
||||||
return screen->mVertexData->AllocVertices(count);
|
|
||||||
}
|
|
||||||
|
|
|
@ -22,6 +22,12 @@ MeshBuilder::MeshBuilder()
|
||||||
mVertices = screen->mVertexData->vbo_shadowdata;
|
mVertices = screen->mVertexData->vbo_shadowdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeshBuilder::SetShadowData(const TArray<FFlatVertex>& vertices, const TArray<uint32_t>& indexes)
|
||||||
|
{
|
||||||
|
mVertices = vertices;
|
||||||
|
mIndexes = indexes;
|
||||||
|
}
|
||||||
|
|
||||||
void MeshBuilder::Draw(int dt, int index, int count, bool apply)
|
void MeshBuilder::Draw(int dt, int index, int count, bool apply)
|
||||||
{
|
{
|
||||||
if (apply)
|
if (apply)
|
||||||
|
|
|
@ -69,6 +69,8 @@ public:
|
||||||
|
|
||||||
// Vertices
|
// Vertices
|
||||||
std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count) override;
|
std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count) override;
|
||||||
|
void SetShadowData(const TArray<FFlatVertex>& vertices, const TArray<uint32_t>& indexes) override;
|
||||||
|
void UpdateShadowData(unsigned int index, const FFlatVertex* vertices, unsigned int count) { }
|
||||||
|
|
||||||
// Buffers
|
// Buffers
|
||||||
int SetViewpoint(const HWViewpointUniforms& vp) override { return 0; }
|
int SetViewpoint(const HWViewpointUniforms& vp) override { return 0; }
|
||||||
|
@ -115,6 +117,7 @@ private:
|
||||||
DrawLists* mDrawLists = nullptr;
|
DrawLists* mDrawLists = nullptr;
|
||||||
|
|
||||||
TArray<FFlatVertex> mVertices;
|
TArray<FFlatVertex> mVertices;
|
||||||
|
TArray<uint32_t> mIndexes;
|
||||||
int mDepthFunc = 0;
|
int mDepthFunc = 0;
|
||||||
|
|
||||||
VSMatrix mTextureMatrix = VSMatrix::identity();
|
VSMatrix mTextureMatrix = VSMatrix::identity();
|
||||||
|
|
|
@ -734,7 +734,9 @@ public:
|
||||||
// API-dependent render interface
|
// API-dependent render interface
|
||||||
|
|
||||||
// Vertices
|
// Vertices
|
||||||
virtual std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count);
|
virtual std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count) = 0;
|
||||||
|
virtual void SetShadowData(const TArray<FFlatVertex>& vertices, const TArray<uint32_t>& indexes) = 0;
|
||||||
|
virtual void UpdateShadowData(unsigned int index, const FFlatVertex* vertices, unsigned int count) = 0;
|
||||||
|
|
||||||
// Buffers
|
// Buffers
|
||||||
virtual int SetViewpoint(const HWViewpointUniforms& vp) = 0;
|
virtual int SetViewpoint(const HWViewpointUniforms& vp) = 0;
|
||||||
|
|
|
@ -620,6 +620,30 @@ int VkRenderState::UploadBones(const TArray<VSMatrix>& bones)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<FFlatVertex*, unsigned int> VkRenderState::AllocVertices(unsigned int count)
|
||||||
|
{
|
||||||
|
return fb->mVertexData->AllocVertices(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VkRenderState::SetShadowData(const TArray<FFlatVertex>& vertices, const TArray<uint32_t>& indexes)
|
||||||
|
{
|
||||||
|
FFlatVertexBuffer* fvb = fb->mVertexData;
|
||||||
|
fvb->vbo_shadowdata = vertices;
|
||||||
|
fvb->ibo_data = indexes;
|
||||||
|
fvb->mCurIndex = fvb->vbo_shadowdata.Size();
|
||||||
|
fvb->mIndex = fvb->vbo_shadowdata.Size();
|
||||||
|
fvb->Copy(0, fvb->mIndex);
|
||||||
|
fvb->mIndexBuffer->SetData(fvb->ibo_data.Size() * sizeof(uint32_t), &fvb->ibo_data[0], BufferUsageType::Static);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VkRenderState::UpdateShadowData(unsigned int index, const FFlatVertex* vertices, unsigned int count)
|
||||||
|
{
|
||||||
|
FFlatVertexBuffer* fvb = fb->mVertexData;
|
||||||
|
FFlatVertex* mapvt = fvb->GetBuffer(index);
|
||||||
|
memcpy(mapvt, vertices, count * sizeof(FFlatVertex));
|
||||||
|
fvb->mVertexBuffer->Upload(index * sizeof(FFlatVertex), count * sizeof(FFlatVertex));
|
||||||
|
}
|
||||||
|
|
||||||
void VkRenderState::BeginFrame()
|
void VkRenderState::BeginFrame()
|
||||||
{
|
{
|
||||||
mMaterial.Reset();
|
mMaterial.Reset();
|
||||||
|
|
|
@ -55,6 +55,11 @@ public:
|
||||||
int UploadLights(const FDynLightData& lightdata) override;
|
int UploadLights(const FDynLightData& lightdata) override;
|
||||||
int UploadBones(const TArray<VSMatrix>& bones) override;
|
int UploadBones(const TArray<VSMatrix>& bones) override;
|
||||||
|
|
||||||
|
// Vertices
|
||||||
|
std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count) override;
|
||||||
|
void SetShadowData(const TArray<FFlatVertex>& vertices, const TArray<uint32_t>& indexes) override;
|
||||||
|
void UpdateShadowData(unsigned int index, const FFlatVertex* vertices, unsigned int count) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Apply(int dt);
|
void Apply(int dt);
|
||||||
void ApplyRenderPass(int dt);
|
void ApplyRenderPass(int dt);
|
||||||
|
|
|
@ -706,7 +706,7 @@ struct sector_t
|
||||||
|
|
||||||
int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering. This is only needed for updating plane heights.
|
int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering. This is only needed for updating plane heights.
|
||||||
int iboindex[4]; // IBO indices of the 4 planes this sector uses during rendering
|
int iboindex[4]; // IBO indices of the 4 planes this sector uses during rendering
|
||||||
double vboheight[HW_MAX_PIPELINE_BUFFERS][2]; // Last calculated height for the 2 planes of this actual sector
|
double vboheight[2]; // Last calculated height for the 2 planes of this actual sector
|
||||||
int vbocount[2]; // Total count of vertices belonging to this sector's planes. This is used when a sector height changes and also contains all attached planes.
|
int vbocount[2]; // Total count of vertices belonging to this sector's planes. This is used when a sector height changes and also contains all attached planes.
|
||||||
int ibocount; // number of indices per plane (identical for all planes.) If this is -1 the index buffer is not in use.
|
int ibocount; // number of indices per plane (identical for all planes.) If this is -1 the index buffer is not in use.
|
||||||
|
|
||||||
|
|
|
@ -3243,7 +3243,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
|
||||||
|
|
||||||
InitRenderInfo(); // create hardware independent renderer resources for the level. This must be done BEFORE the PolyObj Spawn!!!
|
InitRenderInfo(); // create hardware independent renderer resources for the level. This must be done BEFORE the PolyObj Spawn!!!
|
||||||
Level->ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data.
|
Level->ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data.
|
||||||
CreateVBO(screen->mVertexData, Level->sectors);
|
CreateVBO(*screen->RenderState(), Level->sectors);
|
||||||
meshcache.Clear();
|
meshcache.Clear();
|
||||||
|
|
||||||
screen->InitLightmap(Level->LMTextureSize, Level->LMTextureCount, Level->LMTextureData);
|
screen->InitLightmap(Level->LMTextureSize, Level->LMTextureCount, Level->LMTextureData);
|
||||||
|
|
|
@ -24,10 +24,14 @@
|
||||||
|
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
#include "hw_vertexbuilder.h"
|
#include "hw_vertexbuilder.h"
|
||||||
|
#include "hw_renderstate.h"
|
||||||
#include "flatvertices.h"
|
#include "flatvertices.h"
|
||||||
#include "earcut.hpp"
|
#include "earcut.hpp"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
|
|
||||||
|
TArray<FFlatVertex> sector_vertices;
|
||||||
|
TArray<uint32_t> sector_indexes;
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// Creates vertex meshes for sector planes
|
// Creates vertex meshes for sector planes
|
||||||
|
@ -210,12 +214,12 @@ static void SetFlatVertex(FFlatVertex& ffv, vertex_t* vt, const secplane_t& plan
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static int CreateIndexedSectorVerticesLM(FFlatVertexBuffer* fvb, sector_t* sec, const secplane_t& plane, int floor, int h, int lightmapIndex)
|
static int CreateIndexedSectorVerticesLM(FRenderState& renderstate, sector_t* sec, const secplane_t& plane, int floor, int h, int lightmapIndex)
|
||||||
{
|
{
|
||||||
int i, pos;
|
int i, pos;
|
||||||
float diff;
|
float diff;
|
||||||
|
|
||||||
auto& ibo_data = fvb->ibo_data;
|
auto& ibo_data = sector_indexes;
|
||||||
|
|
||||||
int rt = ibo_data.Size();
|
int rt = ibo_data.Size();
|
||||||
if (sec->transdoor && floor) diff = -1.f;
|
if (sec->transdoor && floor) diff = -1.f;
|
||||||
|
@ -227,7 +231,7 @@ static int CreateIndexedSectorVerticesLM(FFlatVertexBuffer* fvb, sector_t* sec,
|
||||||
pos += sec->subsectors[i]->numlines;
|
pos += sec->subsectors[i]->numlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& vbo_shadowdata = fvb->vbo_shadowdata;
|
auto& vbo_shadowdata = sector_vertices;
|
||||||
int vi = vbo_shadowdata.Reserve(pos);
|
int vi = vbo_shadowdata.Reserve(pos);
|
||||||
int idx = ibo_data.Reserve((pos - 2 * sec->subsectorcount) * 3);
|
int idx = ibo_data.Reserve((pos - 2 * sec->subsectorcount) * 3);
|
||||||
|
|
||||||
|
@ -276,12 +280,12 @@ static int CreateIndexedSectorVerticesLM(FFlatVertexBuffer* fvb, sector_t* sec,
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CreateIndexedSectorVertices(FFlatVertexBuffer* fvb, sector_t* sec, const secplane_t& plane, int floor, VertexContainer& verts, int h, int lightmapIndex)
|
static int CreateIndexedSectorVertices(FRenderState& renderstate, sector_t* sec, const secplane_t& plane, int floor, VertexContainer& verts, int h, int lightmapIndex)
|
||||||
{
|
{
|
||||||
if (sec->HasLightmaps && lightmapIndex != -1)
|
if (sec->HasLightmaps && lightmapIndex != -1)
|
||||||
return CreateIndexedSectorVerticesLM(fvb, sec, plane, floor, h, lightmapIndex);
|
return CreateIndexedSectorVerticesLM(renderstate, sec, plane, floor, h, lightmapIndex);
|
||||||
|
|
||||||
auto& vbo_shadowdata = fvb->vbo_shadowdata;
|
auto& vbo_shadowdata = sector_vertices;
|
||||||
unsigned vi = vbo_shadowdata.Reserve(verts.vertices.Size());
|
unsigned vi = vbo_shadowdata.Reserve(verts.vertices.Size());
|
||||||
float diff;
|
float diff;
|
||||||
|
|
||||||
|
@ -294,7 +298,7 @@ static int CreateIndexedSectorVertices(FFlatVertexBuffer* fvb, sector_t* sec, co
|
||||||
vbo_shadowdata[vi + i].z += diff;
|
vbo_shadowdata[vi + i].z += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& ibo_data = fvb->ibo_data;
|
auto& ibo_data = sector_indexes;
|
||||||
unsigned rt = ibo_data.Reserve(verts.indices.Size());
|
unsigned rt = ibo_data.Reserve(verts.indices.Size());
|
||||||
for (unsigned i = 0; i < verts.indices.Size(); i++)
|
for (unsigned i = 0; i < verts.indices.Size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -309,22 +313,21 @@ static int CreateIndexedSectorVertices(FFlatVertexBuffer* fvb, sector_t* sec, co
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static int CreateIndexedVertices(FFlatVertexBuffer* fvb, int h, sector_t* sec, const secplane_t& plane, int floor, VertexContainers& verts)
|
static int CreateIndexedVertices(FRenderState& renderstate, int h, sector_t* sec, const secplane_t& plane, int floor, VertexContainers& verts)
|
||||||
{
|
{
|
||||||
auto& vbo_shadowdata = fvb->vbo_shadowdata;
|
auto& vbo_shadowdata = sector_vertices;
|
||||||
sec->vboindex[h] = vbo_shadowdata.Size();
|
sec->vboindex[h] = vbo_shadowdata.Size();
|
||||||
// First calculate the vertices for the sector itself
|
// First calculate the vertices for the sector itself
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
sec->vboheight[h] = sec->GetPlaneTexZ(h);
|
||||||
sec->vboheight[n][h] = sec->GetPlaneTexZ(h);
|
|
||||||
sec->ibocount = verts[sec->Index()].indices.Size();
|
sec->ibocount = verts[sec->Index()].indices.Size();
|
||||||
sec->iboindex[h] = CreateIndexedSectorVertices(fvb, sec, plane, floor, verts[sec->Index()], h, 0);
|
sec->iboindex[h] = CreateIndexedSectorVertices(renderstate, sec, plane, floor, verts[sec->Index()], h, 0);
|
||||||
|
|
||||||
// Next are all sectors using this one as heightsec
|
// Next are all sectors using this one as heightsec
|
||||||
TArray<sector_t*>& fakes = sec->e->FakeFloor.Sectors;
|
TArray<sector_t*>& fakes = sec->e->FakeFloor.Sectors;
|
||||||
for (unsigned g = 0; g < fakes.Size(); g++)
|
for (unsigned g = 0; g < fakes.Size(); g++)
|
||||||
{
|
{
|
||||||
sector_t* fsec = fakes[g];
|
sector_t* fsec = fakes[g];
|
||||||
fsec->iboindex[2 + h] = CreateIndexedSectorVertices(fvb, fsec, plane, false, verts[fsec->Index()], h, -1);
|
fsec->iboindex[2 + h] = CreateIndexedSectorVertices(renderstate, fsec, plane, false, verts[fsec->Index()], h, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and finally all attached 3D floors
|
// and finally all attached 3D floors
|
||||||
|
@ -342,7 +345,7 @@ static int CreateIndexedVertices(FFlatVertexBuffer* fvb, int h, sector_t* sec, c
|
||||||
|
|
||||||
if (dotop || dobottom)
|
if (dotop || dobottom)
|
||||||
{
|
{
|
||||||
auto ndx = CreateIndexedSectorVertices(fvb, fsec, plane, false, verts[fsec->Index()], h, ffloorIndex + 1);
|
auto ndx = CreateIndexedSectorVertices(renderstate, fsec, plane, false, verts[fsec->Index()], h, ffloorIndex + 1);
|
||||||
if (dotop) ffloor->top.vindex = ndx;
|
if (dotop) ffloor->top.vindex = ndx;
|
||||||
if (dobottom) ffloor->bottom.vindex = ndx;
|
if (dobottom) ffloor->bottom.vindex = ndx;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +362,7 @@ static int CreateIndexedVertices(FFlatVertexBuffer* fvb, int h, sector_t* sec, c
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void CreateIndexedFlatVertices(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors)
|
static void CreateIndexedFlatVertices(FRenderState& renderstate, TArray<sector_t>& sectors)
|
||||||
{
|
{
|
||||||
auto verts = BuildVertices(sectors);
|
auto verts = BuildVertices(sectors);
|
||||||
|
|
||||||
|
@ -388,7 +391,7 @@ static void CreateIndexedFlatVertices(FFlatVertexBuffer* fvb, TArray<sector_t>&
|
||||||
{
|
{
|
||||||
for (auto& sec : sectors)
|
for (auto& sec : sectors)
|
||||||
{
|
{
|
||||||
CreateIndexedVertices(fvb, h, &sec, sec.GetSecPlane(h), h == sector_t::floor, verts);
|
CreateIndexedVertices(renderstate, h, &sec, sec.GetSecPlane(h), h == sector_t::floor, verts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,21 +419,19 @@ static void CreateIndexedFlatVertices(FFlatVertexBuffer* fvb, TArray<sector_t>&
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void UpdatePlaneVertices(FFlatVertexBuffer *fvb, sector_t* sec, int plane)
|
static void UpdatePlaneVertices(FRenderState& renderstate, sector_t* sec, int plane)
|
||||||
{
|
{
|
||||||
int startvt = sec->vboindex[plane];
|
int startvt = sec->vboindex[plane];
|
||||||
int countvt = sec->vbocount[plane];
|
int countvt = sec->vbocount[plane];
|
||||||
secplane_t& splane = sec->GetSecPlane(plane);
|
secplane_t& splane = sec->GetSecPlane(plane);
|
||||||
FFlatVertex* vt = &fvb->vbo_shadowdata[startvt];
|
FFlatVertex* vt = §or_vertices[startvt];
|
||||||
FFlatVertex* mapvt = fvb->GetBuffer(startvt);
|
for (int i = 0; i < countvt; i++, vt++)
|
||||||
for (int i = 0; i < countvt; i++, vt++, mapvt++)
|
|
||||||
{
|
{
|
||||||
vt->z = (float)splane.ZatPoint(vt->x, vt->y);
|
vt->z = (float)splane.ZatPoint(vt->x, vt->y);
|
||||||
if (plane == sector_t::floor && sec->transdoor) vt->z -= 1;
|
if (plane == sector_t::floor && sec->transdoor) vt->z -= 1;
|
||||||
mapvt->z = vt->z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fvb->mVertexBuffer->Upload(startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex));
|
renderstate.UpdateShadowData(startvt, §or_vertices[startvt], countvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -439,10 +440,10 @@ static void UpdatePlaneVertices(FFlatVertexBuffer *fvb, sector_t* sec, int plane
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void CreateVertices(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors)
|
static void CreateVertices(FRenderState& renderstate, TArray<sector_t>& sectors)
|
||||||
{
|
{
|
||||||
fvb->vbo_shadowdata.Clear();
|
sector_vertices.Clear();
|
||||||
CreateIndexedFlatVertices(fvb, sectors);
|
CreateIndexedFlatVertices(renderstate, sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -451,17 +452,17 @@ static void CreateVertices(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void CheckPlanes(FFlatVertexBuffer* fvb, sector_t* sector)
|
static void CheckPlanes(FRenderState& renderstate, sector_t* sector)
|
||||||
{
|
{
|
||||||
if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[screen->mVertexData->GetPipelinePos()][sector_t::ceiling])
|
if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling])
|
||||||
{
|
{
|
||||||
UpdatePlaneVertices(fvb, sector, sector_t::ceiling);
|
UpdatePlaneVertices(renderstate, sector, sector_t::ceiling);
|
||||||
sector->vboheight[screen->mVertexData->GetPipelinePos()][sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling);
|
sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling);
|
||||||
}
|
}
|
||||||
if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[screen->mVertexData->GetPipelinePos()][sector_t::floor])
|
if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor])
|
||||||
{
|
{
|
||||||
UpdatePlaneVertices(fvb, sector, sector_t::floor);
|
UpdatePlaneVertices(renderstate, sector, sector_t::floor);
|
||||||
sector->vboheight[screen->mVertexData->GetPipelinePos()][sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor);
|
sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,13 +473,13 @@ static void CheckPlanes(FFlatVertexBuffer* fvb, sector_t* sector)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void CheckUpdate(FFlatVertexBuffer* fvb, sector_t* sector)
|
void CheckUpdate(FRenderState& renderstate, sector_t* sector)
|
||||||
{
|
{
|
||||||
CheckPlanes(fvb, sector);
|
CheckPlanes(renderstate, sector);
|
||||||
sector_t* hs = sector->GetHeightSec();
|
sector_t* hs = sector->GetHeightSec();
|
||||||
if (hs != NULL) CheckPlanes(fvb, hs);
|
if (hs != NULL) CheckPlanes(renderstate, hs);
|
||||||
for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++)
|
for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++)
|
||||||
CheckPlanes(fvb, sector->e->XFloor.ffloors[i]->model);
|
CheckPlanes(renderstate, sector->e->XFloor.ffloors[i]->model);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -487,11 +488,9 @@ void CheckUpdate(FFlatVertexBuffer* fvb, sector_t* sector)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void CreateVBO(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors)
|
void CreateVBO(FRenderState& renderstate, TArray<sector_t>& sectors)
|
||||||
{
|
{
|
||||||
fvb->vbo_shadowdata.Clear();
|
sector_vertices.Clear();
|
||||||
CreateVertices(fvb, sectors);
|
CreateVertices(renderstate, sectors);
|
||||||
fvb->mCurIndex = fvb->mIndex = fvb->vbo_shadowdata.Size();
|
renderstate.SetShadowData(sector_vertices, sector_indexes);
|
||||||
fvb->Copy(0, fvb->mIndex);
|
|
||||||
fvb->mIndexBuffer->SetData(fvb->ibo_data.Size() * sizeof(uint32_t), &fvb->ibo_data[0], BufferUsageType::Static);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
|
|
||||||
struct vertex_t;
|
struct vertex_t;
|
||||||
|
struct FFlatVertex;
|
||||||
|
|
||||||
struct FQualifiedVertex
|
struct FQualifiedVertex
|
||||||
{
|
{
|
||||||
|
@ -67,7 +69,9 @@ using VertexContainers = TArray<VertexContainer>;
|
||||||
|
|
||||||
VertexContainers BuildVertices(TArray<sector_t> §ors);
|
VertexContainers BuildVertices(TArray<sector_t> §ors);
|
||||||
|
|
||||||
class FFlatVertexBuffer;
|
class FRenderState;
|
||||||
void CheckUpdate(FFlatVertexBuffer* fvb, sector_t* sector);
|
void CheckUpdate(FRenderState& renderstate, sector_t* sector);
|
||||||
void CreateVBO(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors);
|
void CreateVBO(FRenderState& renderstate, TArray<sector_t>& sectors);
|
||||||
|
|
||||||
|
extern TArray<FFlatVertex> sector_vertices;
|
||||||
|
extern TArray<uint32_t> sector_indexes;
|
||||||
|
|
|
@ -664,7 +664,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
||||||
|
|
||||||
if (sector->validcount != validcount)
|
if (sector->validcount != validcount)
|
||||||
{
|
{
|
||||||
CheckUpdate(screen->mVertexData, sector);
|
CheckUpdate(state, sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [RH] Add particles
|
// [RH] Add particles
|
||||||
|
|
|
@ -266,8 +266,7 @@ sector_t * hw_FakeFlat(sector_t * sec, area_t in_area, bool back, sector_t *loca
|
||||||
dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
|
dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
|
||||||
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
|
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
|
||||||
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakefloor];
|
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakefloor];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor];
|
||||||
dest->vboheight[n][sector_t::floor] = s->vboheight[n][sector_t::floor];
|
|
||||||
}
|
}
|
||||||
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
|
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
|
||||||
{
|
{
|
||||||
|
@ -293,8 +292,7 @@ sector_t * hw_FakeFlat(sector_t * sec, area_t in_area, bool back, sector_t *loca
|
||||||
dest->floorplane = s->floorplane;
|
dest->floorplane = s->floorplane;
|
||||||
|
|
||||||
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakefloor];
|
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakefloor];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor];
|
||||||
dest->vboheight[n][sector_t::floor] = s->vboheight[n][sector_t::floor];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(s->MoreFlags&SECMF_FAKEFLOORONLY))
|
if (!(s->MoreFlags&SECMF_FAKEFLOORONLY))
|
||||||
|
@ -306,8 +304,7 @@ sector_t * hw_FakeFlat(sector_t * sec, area_t in_area, bool back, sector_t *loca
|
||||||
dest->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false);
|
dest->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false);
|
||||||
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
|
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
|
||||||
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakeceiling];
|
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakeceiling];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
|
||||||
dest->vboheight[n][sector_t::ceiling] = s->vboheight[n][sector_t::ceiling];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -315,8 +312,7 @@ sector_t * hw_FakeFlat(sector_t * sec, area_t in_area, bool back, sector_t *loca
|
||||||
dest->ceilingplane = s->ceilingplane;
|
dest->ceilingplane = s->ceilingplane;
|
||||||
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
|
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
|
||||||
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakeceiling];
|
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakeceiling];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
|
||||||
dest->vboheight[n][sector_t::ceiling] = s->vboheight[n][sector_t::ceiling];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +326,10 @@ sector_t * hw_FakeFlat(sector_t * sec, area_t in_area, bool back, sector_t *loca
|
||||||
dest->ceilingplane.FlipVert();
|
dest->ceilingplane.FlipVert();
|
||||||
|
|
||||||
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::floor];
|
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::floor];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::floor] = sec->vboheight[sector_t::floor];
|
||||||
dest->vboheight[n][sector_t::floor] = sec->vboheight[n][sector_t::floor];
|
|
||||||
|
|
||||||
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakefloor];
|
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakefloor];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor];
|
||||||
dest->vboheight[n][sector_t::ceiling] = s->vboheight[n][sector_t::floor];
|
|
||||||
|
|
||||||
dest->ClearPortal(sector_t::ceiling);
|
dest->ClearPortal(sector_t::ceiling);
|
||||||
|
|
||||||
|
@ -385,12 +379,10 @@ sector_t * hw_FakeFlat(sector_t * sec, area_t in_area, bool back, sector_t *loca
|
||||||
dest->floorplane.FlipVert();
|
dest->floorplane.FlipVert();
|
||||||
|
|
||||||
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakeceiling];
|
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakeceiling];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::floor] = sec->vboheight[sector_t::ceiling];
|
||||||
dest->vboheight[n][sector_t::floor] = sec->vboheight[n][sector_t::ceiling];
|
|
||||||
|
|
||||||
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::ceiling];
|
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::ceiling];
|
||||||
for (int n = 0; n < screen->mPipelineNbr; n++)
|
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
|
||||||
dest->vboheight[n][sector_t::ceiling] = s->vboheight[n][sector_t::ceiling];
|
|
||||||
|
|
||||||
dest->ClearPortal(sector_t::floor);
|
dest->ClearPortal(sector_t::floor);
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ void HWMeshCache::Update(FRenderViewpoint& vp)
|
||||||
di->MeshBuilding = true;
|
di->MeshBuilding = true;
|
||||||
|
|
||||||
MeshBuilder state;
|
MeshBuilder state;
|
||||||
|
state.SetShadowData(sector_vertices, sector_indexes);
|
||||||
|
|
||||||
// Add to the draw lists
|
// Add to the draw lists
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ void HWMeshCache::Update(FRenderViewpoint& vp)
|
||||||
{
|
{
|
||||||
auto sector = &level->sectors[i];
|
auto sector = &level->sectors[i];
|
||||||
|
|
||||||
CheckUpdate(screen->mVertexData, sector);
|
// CheckUpdate(state, sector);
|
||||||
std::unordered_set<FSection*> seenSections;
|
std::unordered_set<FSection*> seenSections;
|
||||||
for (int i = 0, count = sector->subsectorcount; i < count; i++)
|
for (int i = 0, count = sector->subsectorcount; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue