mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-19 13:33:15 +02:00
Trying SSBO for the object matrices
This commit is contained in:
parent
a7b5ea50d7
commit
554247193c
5 changed files with 14 additions and 10 deletions
|
@ -51,7 +51,7 @@
|
|||
#if (GPU_INPUT_PROFILE == GPU_CORE_43)
|
||||
// Deactivate SSBO for now, we've run into some issues
|
||||
// on GL 4.3 capable GPUs not behaving as expected
|
||||
//#define GPU_SSBO_DRAW_CALL_INFO
|
||||
#define GPU_SSBO_DRAW_CALL_INFO
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<@if GLPROFILE == PC_GL @>
|
||||
<@def GPU_FEATURE_PROFILE GPU_CORE@>
|
||||
<@def VERSION_HEADER #version 410 core@>
|
||||
<@def VERSION_HEADER #version 430 core@>
|
||||
<@elif GLPROFILE == MAC_GL @>
|
||||
<@def GPU_FEATURE_PROFILE GPU_CORE@>
|
||||
<@def VERSION_HEADER #version 410 core@>
|
||||
|
|
|
@ -386,7 +386,8 @@ protected:
|
|||
|
||||
mutable std::map<std::string, GLvoid*> _drawCallInfoOffsets;
|
||||
|
||||
GLuint _objectBuffer { 0 };
|
||||
mutable int batchNum{ 0 };
|
||||
GLuint _objectBuffer[2];
|
||||
GLuint _cameraBuffer { 0 };
|
||||
GLuint _drawCallInfoBuffer { 0 };
|
||||
GLuint _objectBufferTexture { 0 };
|
||||
|
|
|
@ -59,7 +59,7 @@ void GLBackend::do_setDepthRangeTransform(Batch& batch, size_t paramOffset) {
|
|||
}
|
||||
|
||||
void GLBackend::initTransform() {
|
||||
glGenBuffers(1, &_transform._objectBuffer);
|
||||
glGenBuffers(2, _transform._objectBuffer);
|
||||
glGenBuffers(1, &_transform._cameraBuffer);
|
||||
glGenBuffers(1, &_transform._drawCallInfoBuffer);
|
||||
#ifndef GPU_SSBO_DRAW_CALL_INFO
|
||||
|
@ -72,7 +72,8 @@ void GLBackend::initTransform() {
|
|||
}
|
||||
|
||||
void GLBackend::killTransform() {
|
||||
glDeleteBuffers(1, &_transform._objectBuffer);
|
||||
glDeleteBuffers(2, _transform._objectBuffer);
|
||||
// glDeleteBuffers(1, &_transform._objectBuffer);
|
||||
glDeleteBuffers(1, &_transform._cameraBuffer);
|
||||
glDeleteBuffers(1, &_transform._drawCallInfoBuffer);
|
||||
#ifndef GPU_SSBO_DRAW_CALL_INFO
|
||||
|
@ -145,7 +146,9 @@ void GLBackend::TransformStageState::transfer(const Batch& batch) const {
|
|||
memcpy(bufferData.data(), batch._objects.data(), byteSize);
|
||||
|
||||
#ifdef GPU_SSBO_DRAW_CALL_INFO
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _objectBuffer);
|
||||
batchNum++;
|
||||
// glBindBuffer(GL_SHADER_STORAGE_BUFFER, _objectBuffer);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _objectBuffer[batchNum % 2]);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, bufferData.size(), bufferData.data(), GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||
#else
|
||||
|
@ -171,7 +174,7 @@ void GLBackend::TransformStageState::transfer(const Batch& batch) const {
|
|||
}
|
||||
|
||||
#ifdef GPU_SSBO_DRAW_CALL_INFO
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, TRANSFORM_OBJECT_SLOT, _objectBuffer);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, TRANSFORM_OBJECT_SLOT, _objectBuffer[batchNum % 2]);
|
||||
#else
|
||||
glActiveTexture(GL_TEXTURE0 + TRANSFORM_OBJECT_SLOT);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _objectBufferTexture);
|
||||
|
|
|
@ -37,7 +37,7 @@ struct TransformObject {
|
|||
|
||||
layout(location=15) in ivec2 _drawCallInfo;
|
||||
|
||||
<@if FALSE @>
|
||||
<!<@if @>!>
|
||||
// Disable SSBOs for now
|
||||
layout(std140) buffer transformObjectBuffer {
|
||||
TransformObject _object[];
|
||||
|
@ -45,7 +45,7 @@ layout(std140) buffer transformObjectBuffer {
|
|||
TransformObject getTransformObject() {
|
||||
return _object[_drawCallInfo.x];
|
||||
}
|
||||
<@else@>
|
||||
<! <@else@>
|
||||
uniform samplerBuffer transformObjectBuffer;
|
||||
|
||||
TransformObject getTransformObject() {
|
||||
|
@ -63,7 +63,7 @@ TransformObject getTransformObject() {
|
|||
|
||||
return object;
|
||||
}
|
||||
<@endif@>
|
||||
<@endif@> !>
|
||||
<@endfunc@>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue