mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- moved most of FShadowMap to IShadowMap, except the main Update function.
This commit is contained in:
parent
cc058f98a5
commit
54f46fdfee
4 changed files with 59 additions and 59 deletions
|
@ -43,8 +43,7 @@ void FShadowMap::Update()
|
|||
|
||||
UpdateCycles.Clock();
|
||||
|
||||
UploadAABBTree();
|
||||
UploadLights();
|
||||
PerformUpdate();
|
||||
|
||||
FGLDebug::PushGroup("ShadowMap");
|
||||
FGLPostProcessState savedState;
|
||||
|
@ -54,9 +53,6 @@ void FShadowMap::Update()
|
|||
GLRenderer->mShadowMapShader->Bind(NOQUEUE);
|
||||
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
||||
GLRenderer->mShadowMapShader->Uniforms.Set();
|
||||
mLightList->BindBase();
|
||||
mNodesBuffer->BindBase();
|
||||
mLinesBuffer->BindBase();
|
||||
|
||||
glViewport(0, 0, gl_shadowmap_quality, 1024);
|
||||
GLRenderer->RenderScreenQuad();
|
||||
|
@ -71,34 +67,3 @@ void FShadowMap::Update()
|
|||
UpdateCycles.Unclock();
|
||||
}
|
||||
|
||||
|
||||
void FShadowMap::UploadLights()
|
||||
{
|
||||
CollectLights();
|
||||
|
||||
if (mLightList == nullptr)
|
||||
mLightList = screen->CreateDataBuffer(4, true);
|
||||
|
||||
mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0]);
|
||||
}
|
||||
|
||||
|
||||
void FShadowMap::UploadAABBTree()
|
||||
{
|
||||
if (!ValidateAABBTree())
|
||||
{
|
||||
mNodesBuffer = screen->CreateDataBuffer(2, true);
|
||||
mNodesBuffer->SetData(sizeof(hwrenderer::AABBTreeNode) * mAABBTree->nodes.Size(), &mAABBTree->nodes[0]);
|
||||
|
||||
mLinesBuffer = screen->CreateDataBuffer(3, true);
|
||||
mLinesBuffer->SetData(sizeof(hwrenderer::AABBTreeLine) * mAABBTree->lines.Size(), &mAABBTree->lines[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void FShadowMap::Clear()
|
||||
{
|
||||
if (mLightList) delete mLightList;
|
||||
if (mNodesBuffer) delete mNodesBuffer;
|
||||
if (mLinesBuffer) delete mLinesBuffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,25 +8,6 @@ class IDataBuffer;
|
|||
class FShadowMap : public IShadowMap
|
||||
{
|
||||
public:
|
||||
~FShadowMap() { Clear(); }
|
||||
|
||||
// Release resources
|
||||
void Clear() override;
|
||||
|
||||
// Update shadow map texture
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
// Upload the AABB-tree to the GPU
|
||||
void UploadAABBTree();
|
||||
|
||||
// Upload light list to the GPU
|
||||
void UploadLights();
|
||||
|
||||
// OpenGL storage buffer with the list of lights in the shadow map texture
|
||||
IDataBuffer *mLightList = nullptr;
|
||||
|
||||
// OpenGL storage buffers for the AABB tree
|
||||
IDataBuffer *mNodesBuffer = nullptr;
|
||||
IDataBuffer *mLinesBuffer = nullptr;
|
||||
};
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "hwrenderer/dynlights/hw_shadowmap.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
#include "stats.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
|
@ -160,3 +161,43 @@ bool IShadowMap::ValidateAABBTree()
|
|||
mAABBTree.reset(new hwrenderer::LevelAABBTree());
|
||||
return false;
|
||||
}
|
||||
|
||||
void IShadowMap::PerformUpdate()
|
||||
{
|
||||
UploadAABBTree();
|
||||
UploadLights();
|
||||
mLightList->BindBase();
|
||||
mNodesBuffer->BindBase();
|
||||
mLinesBuffer->BindBase();
|
||||
}
|
||||
|
||||
void IShadowMap::UploadLights()
|
||||
{
|
||||
CollectLights();
|
||||
|
||||
if (mLightList == nullptr)
|
||||
mLightList = screen->CreateDataBuffer(4, true);
|
||||
|
||||
mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0]);
|
||||
}
|
||||
|
||||
|
||||
void IShadowMap::UploadAABBTree()
|
||||
{
|
||||
if (!ValidateAABBTree())
|
||||
{
|
||||
mNodesBuffer = screen->CreateDataBuffer(2, true);
|
||||
mNodesBuffer->SetData(sizeof(hwrenderer::AABBTreeNode) * mAABBTree->nodes.Size(), &mAABBTree->nodes[0]);
|
||||
|
||||
mLinesBuffer = screen->CreateDataBuffer(3, true);
|
||||
mLinesBuffer->SetData(sizeof(hwrenderer::AABBTreeLine) * mAABBTree->lines.Size(), &mAABBTree->lines[0]);
|
||||
}
|
||||
}
|
||||
|
||||
IShadowMap::~IShadowMap()
|
||||
{
|
||||
if (mLightList) delete mLightList;
|
||||
if (mNodesBuffer) delete mNodesBuffer;
|
||||
if (mLinesBuffer) delete mLinesBuffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,15 +7,13 @@
|
|||
|
||||
class ADynamicLight;
|
||||
struct level_info_t;
|
||||
class IDataBuffer;
|
||||
|
||||
class IShadowMap
|
||||
{
|
||||
public:
|
||||
IShadowMap() { }
|
||||
virtual ~IShadowMap() { }
|
||||
|
||||
// Release resources
|
||||
virtual void Clear() = 0;
|
||||
virtual ~IShadowMap();
|
||||
|
||||
// Update shadow map texture
|
||||
virtual void Update() = 0;
|
||||
|
@ -33,6 +31,13 @@ public:
|
|||
protected:
|
||||
void CollectLights();
|
||||
bool ValidateAABBTree();
|
||||
void PerformUpdate();
|
||||
|
||||
// Upload the AABB-tree to the GPU
|
||||
void UploadAABBTree();
|
||||
|
||||
// Upload light list to the GPU
|
||||
void UploadLights();
|
||||
|
||||
// Working buffer for creating the list of lights. Stored here to avoid allocating memory each frame
|
||||
TArray<float> mLights;
|
||||
|
@ -47,4 +52,12 @@ protected:
|
|||
|
||||
IShadowMap(const IShadowMap &) = delete;
|
||||
IShadowMap &operator=(IShadowMap &) = delete;
|
||||
|
||||
// OpenGL storage buffer with the list of lights in the shadow map texture
|
||||
IDataBuffer *mLightList = nullptr;
|
||||
|
||||
// OpenGL storage buffers for the AABB tree
|
||||
IDataBuffer *mNodesBuffer = nullptr;
|
||||
IDataBuffer *mLinesBuffer = nullptr;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue