mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +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();
|
UpdateCycles.Clock();
|
||||||
|
|
||||||
UploadAABBTree();
|
PerformUpdate();
|
||||||
UploadLights();
|
|
||||||
|
|
||||||
FGLDebug::PushGroup("ShadowMap");
|
FGLDebug::PushGroup("ShadowMap");
|
||||||
FGLPostProcessState savedState;
|
FGLPostProcessState savedState;
|
||||||
|
@ -54,9 +53,6 @@ void FShadowMap::Update()
|
||||||
GLRenderer->mShadowMapShader->Bind(NOQUEUE);
|
GLRenderer->mShadowMapShader->Bind(NOQUEUE);
|
||||||
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
||||||
GLRenderer->mShadowMapShader->Uniforms.Set();
|
GLRenderer->mShadowMapShader->Uniforms.Set();
|
||||||
mLightList->BindBase();
|
|
||||||
mNodesBuffer->BindBase();
|
|
||||||
mLinesBuffer->BindBase();
|
|
||||||
|
|
||||||
glViewport(0, 0, gl_shadowmap_quality, 1024);
|
glViewport(0, 0, gl_shadowmap_quality, 1024);
|
||||||
GLRenderer->RenderScreenQuad();
|
GLRenderer->RenderScreenQuad();
|
||||||
|
@ -71,34 +67,3 @@ void FShadowMap::Update()
|
||||||
UpdateCycles.Unclock();
|
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
|
class FShadowMap : public IShadowMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~FShadowMap() { Clear(); }
|
|
||||||
|
|
||||||
// Release resources
|
|
||||||
void Clear() override;
|
|
||||||
|
|
||||||
// Update shadow map texture
|
// Update shadow map texture
|
||||||
void Update() override;
|
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/dynlights/hw_shadowmap.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||||
|
#include "hwrenderer/data/buffers.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
|
||||||
|
@ -160,3 +161,43 @@ bool IShadowMap::ValidateAABBTree()
|
||||||
mAABBTree.reset(new hwrenderer::LevelAABBTree());
|
mAABBTree.reset(new hwrenderer::LevelAABBTree());
|
||||||
return false;
|
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;
|
class ADynamicLight;
|
||||||
struct level_info_t;
|
struct level_info_t;
|
||||||
|
class IDataBuffer;
|
||||||
|
|
||||||
class IShadowMap
|
class IShadowMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IShadowMap() { }
|
IShadowMap() { }
|
||||||
virtual ~IShadowMap() { }
|
virtual ~IShadowMap();
|
||||||
|
|
||||||
// Release resources
|
|
||||||
virtual void Clear() = 0;
|
|
||||||
|
|
||||||
// Update shadow map texture
|
// Update shadow map texture
|
||||||
virtual void Update() = 0;
|
virtual void Update() = 0;
|
||||||
|
@ -33,6 +31,13 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void CollectLights();
|
void CollectLights();
|
||||||
bool ValidateAABBTree();
|
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
|
// Working buffer for creating the list of lights. Stored here to avoid allocating memory each frame
|
||||||
TArray<float> mLights;
|
TArray<float> mLights;
|
||||||
|
@ -47,4 +52,12 @@ protected:
|
||||||
|
|
||||||
IShadowMap(const IShadowMap &) = delete;
|
IShadowMap(const IShadowMap &) = delete;
|
||||||
IShadowMap &operator=(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