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->Bind(NOQUEUE);
|
||||||
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
||||||
GLRenderer->mShadowMapShader->Uniforms.Set();
|
GLRenderer->mShadowMapShader->Uniforms.Set();
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList);
|
mLightList->BindBase();
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, mNodesBuffer);
|
mNodesBuffer->BindBase();
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, mLinesBuffer);
|
mLinesBuffer->BindBase();
|
||||||
|
|
||||||
glViewport(0, 0, gl_shadowmap_quality, 1024);
|
glViewport(0, 0, gl_shadowmap_quality, 1024);
|
||||||
GLRenderer->RenderScreenQuad();
|
GLRenderer->RenderScreenQuad();
|
||||||
|
@ -64,10 +64,6 @@ void FShadowMap::Update()
|
||||||
const auto &viewport = screen->mScreenViewport;
|
const auto &viewport = screen->mScreenViewport;
|
||||||
glViewport(viewport.left, viewport.top, viewport.width, viewport.height);
|
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);
|
GLRenderer->mBuffers->BindShadowMapTexture(16);
|
||||||
|
|
||||||
FGLDebug::PopGroup();
|
FGLDebug::PopGroup();
|
||||||
|
@ -75,56 +71,34 @@ void FShadowMap::Update()
|
||||||
UpdateCycles.Unclock();
|
UpdateCycles.Unclock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FShadowMap::UploadLights()
|
void FShadowMap::UploadLights()
|
||||||
{
|
{
|
||||||
CollectLights();
|
CollectLights();
|
||||||
|
|
||||||
if (mLightList == 0)
|
if (mLightList == nullptr)
|
||||||
glGenBuffers(1, (GLuint*)&mLightList);
|
mLightList = screen->CreateDataBuffer(4, true);
|
||||||
|
|
||||||
int oldBinding = 0;
|
mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FShadowMap::UploadAABBTree()
|
void FShadowMap::UploadAABBTree()
|
||||||
{
|
{
|
||||||
if (!ValidateAABBTree())
|
if (!ValidateAABBTree())
|
||||||
{
|
{
|
||||||
int oldBinding = 0;
|
mNodesBuffer = screen->CreateDataBuffer(2, true);
|
||||||
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &oldBinding);
|
mNodesBuffer->SetData(sizeof(hwrenderer::AABBTreeNode) * mAABBTree->nodes.Size(), &mAABBTree->nodes[0]);
|
||||||
|
|
||||||
glGenBuffers(1, (GLuint*)&mNodesBuffer);
|
mLinesBuffer = screen->CreateDataBuffer(3, true);
|
||||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, mNodesBuffer);
|
mLinesBuffer->SetData(sizeof(hwrenderer::AABBTreeLine) * mAABBTree->lines.Size(), &mAABBTree->lines[0]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FShadowMap::Clear()
|
void FShadowMap::Clear()
|
||||||
{
|
{
|
||||||
if (mLightList != 0)
|
if (mLightList) delete mLightList;
|
||||||
{
|
if (mNodesBuffer) delete mNodesBuffer;
|
||||||
glDeleteBuffers(1, (GLuint*)&mLightList);
|
if (mLinesBuffer) delete mLinesBuffer;
|
||||||
mLightList = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mNodesBuffer != 0)
|
|
||||||
{
|
|
||||||
glDeleteBuffers(1, (GLuint*)&mNodesBuffer);
|
|
||||||
mNodesBuffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mLinesBuffer != 0)
|
|
||||||
{
|
|
||||||
glDeleteBuffers(1, (GLuint*)&mLinesBuffer);
|
|
||||||
mLinesBuffer = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "hwrenderer/dynlights/hw_shadowmap.h"
|
#include "hwrenderer/dynlights/hw_shadowmap.h"
|
||||||
|
|
||||||
|
class IDataBuffer;
|
||||||
|
|
||||||
class FShadowMap : public IShadowMap
|
class FShadowMap : public IShadowMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -22,9 +24,9 @@ private:
|
||||||
void UploadLights();
|
void UploadLights();
|
||||||
|
|
||||||
// OpenGL storage buffer with the list of lights in the shadow map texture
|
// 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
|
// OpenGL storage buffers for the AABB tree
|
||||||
int mNodesBuffer = 0;
|
IDataBuffer *mNodesBuffer = nullptr;
|
||||||
int mLinesBuffer = 0;
|
IDataBuffer *mLinesBuffer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue