mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- use IDataBuffer for the shadow map generator's buffers.
This commit is contained in:
parent
926a918e0c
commit
cc058f98a5
2 changed files with 21 additions and 45 deletions
|
@ -54,9 +54,9 @@ void FShadowMap::Update()
|
|||
GLRenderer->mShadowMapShader->Bind(NOQUEUE);
|
||||
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
||||
GLRenderer->mShadowMapShader->Uniforms.Set();
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, mNodesBuffer);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, mLinesBuffer);
|
||||
mLightList->BindBase();
|
||||
mNodesBuffer->BindBase();
|
||||
mLinesBuffer->BindBase();
|
||||
|
||||
glViewport(0, 0, gl_shadowmap_quality, 1024);
|
||||
GLRenderer->RenderScreenQuad();
|
||||
|
@ -64,10 +64,6 @@ void FShadowMap::Update()
|
|||
const auto &viewport = screen->mScreenViewport;
|
||||
glViewport(viewport.left, viewport.top, viewport.width, viewport.height);
|
||||
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, 0);
|
||||
|
||||
GLRenderer->mBuffers->BindShadowMapTexture(16);
|
||||
|
||||
FGLDebug::PopGroup();
|
||||
|
@ -75,56 +71,34 @@ void FShadowMap::Update()
|
|||
UpdateCycles.Unclock();
|
||||
}
|
||||
|
||||
|
||||
void FShadowMap::UploadLights()
|
||||
{
|
||||
CollectLights();
|
||||
|
||||
if (mLightList == 0)
|
||||
glGenBuffers(1, (GLuint*)&mLightList);
|
||||
if (mLightList == nullptr)
|
||||
mLightList = screen->CreateDataBuffer(4, true);
|
||||
|
||||
int oldBinding = 0;
|
||||
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &oldBinding);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, mLightList);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(float) * mLights.Size(), &mLights[0], GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, oldBinding);
|
||||
mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0]);
|
||||
}
|
||||
|
||||
|
||||
void FShadowMap::UploadAABBTree()
|
||||
{
|
||||
if (!ValidateAABBTree())
|
||||
{
|
||||
int oldBinding = 0;
|
||||
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &oldBinding);
|
||||
mNodesBuffer = screen->CreateDataBuffer(2, true);
|
||||
mNodesBuffer->SetData(sizeof(hwrenderer::AABBTreeNode) * mAABBTree->nodes.Size(), &mAABBTree->nodes[0]);
|
||||
|
||||
glGenBuffers(1, (GLuint*)&mNodesBuffer);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, mNodesBuffer);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(hwrenderer::AABBTreeNode) * mAABBTree->nodes.Size(), &mAABBTree->nodes[0], GL_STATIC_DRAW);
|
||||
|
||||
glGenBuffers(1, (GLuint*)&mLinesBuffer);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, mLinesBuffer);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(hwrenderer::AABBTreeLine) * mAABBTree->lines.Size(), &mAABBTree->lines[0], GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, oldBinding);
|
||||
mLinesBuffer = screen->CreateDataBuffer(3, true);
|
||||
mLinesBuffer->SetData(sizeof(hwrenderer::AABBTreeLine) * mAABBTree->lines.Size(), &mAABBTree->lines[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void FShadowMap::Clear()
|
||||
{
|
||||
if (mLightList != 0)
|
||||
{
|
||||
glDeleteBuffers(1, (GLuint*)&mLightList);
|
||||
mLightList = 0;
|
||||
}
|
||||
|
||||
if (mNodesBuffer != 0)
|
||||
{
|
||||
glDeleteBuffers(1, (GLuint*)&mNodesBuffer);
|
||||
mNodesBuffer = 0;
|
||||
}
|
||||
|
||||
if (mLinesBuffer != 0)
|
||||
{
|
||||
glDeleteBuffers(1, (GLuint*)&mLinesBuffer);
|
||||
mLinesBuffer = 0;
|
||||
}
|
||||
if (mLightList) delete mLightList;
|
||||
if (mNodesBuffer) delete mNodesBuffer;
|
||||
if (mLinesBuffer) delete mLinesBuffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "hwrenderer/dynlights/hw_shadowmap.h"
|
||||
|
||||
class IDataBuffer;
|
||||
|
||||
class FShadowMap : public IShadowMap
|
||||
{
|
||||
public:
|
||||
|
@ -22,9 +24,9 @@ private:
|
|||
void UploadLights();
|
||||
|
||||
// OpenGL storage buffer with the list of lights in the shadow map texture
|
||||
int mLightList = 0;
|
||||
IDataBuffer *mLightList = nullptr;
|
||||
|
||||
// OpenGL storage buffers for the AABB tree
|
||||
int mNodesBuffer = 0;
|
||||
int mLinesBuffer = 0;
|
||||
IDataBuffer *mNodesBuffer = nullptr;
|
||||
IDataBuffer *mLinesBuffer = nullptr;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue