mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
Enabling sbo
This commit is contained in:
parent
298300e42f
commit
c1ed0e2e14
6 changed files with 20 additions and 37 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
|
||||
|
||||
|
||||
|
|
|
@ -559,9 +559,6 @@ void GLBackend::resetStages() {
|
|||
|
||||
#define ADD_COMMAND_GL(call) _commands.push_back(COMMAND_##call); _commandOffsets.push_back(_params.size());
|
||||
|
||||
//#define DO_IT_NOW(call, offset) runLastCommand();
|
||||
#define DO_IT_NOW(call, offset)
|
||||
|
||||
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||
#define GET_UNIFORM_LOCATION(shaderUniformLoc) _pipeline._programShader->getUniformLocation(isStereo(), shaderUniformLoc)
|
||||
#else
|
||||
|
@ -576,9 +573,6 @@ void Batch::_glActiveBindTexture(GLenum unit, GLenum target, GLuint texture) {
|
|||
_params.push_back(texture);
|
||||
_params.push_back(target);
|
||||
_params.push_back(unit);
|
||||
|
||||
|
||||
DO_IT_NOW(_glActiveBindTexture, 3);
|
||||
}
|
||||
void GLBackend::do_glActiveBindTexture(Batch& batch, size_t paramOffset) {
|
||||
glActiveTexture(batch._params[paramOffset + 2]._uint);
|
||||
|
@ -596,9 +590,8 @@ void Batch::_glUniform1i(GLint location, GLint v0) {
|
|||
ADD_COMMAND_GL(glUniform1i);
|
||||
_params.push_back(v0);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform1i, 1);
|
||||
}
|
||||
|
||||
void GLBackend::do_glUniform1i(Batch& batch, size_t paramOffset) {
|
||||
if (_pipeline._program == 0) {
|
||||
// We should call updatePipeline() to bind the program but we are not doing that
|
||||
|
@ -620,8 +613,6 @@ void Batch::_glUniform1f(GLint location, GLfloat v0) {
|
|||
ADD_COMMAND_GL(glUniform1f);
|
||||
_params.push_back(v0);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform1f, 1);
|
||||
}
|
||||
void GLBackend::do_glUniform1f(Batch& batch, size_t paramOffset) {
|
||||
if (_pipeline._program == 0) {
|
||||
|
@ -643,8 +634,6 @@ void Batch::_glUniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
|||
_params.push_back(v1);
|
||||
_params.push_back(v0);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform2f, 1);
|
||||
}
|
||||
|
||||
void GLBackend::do_glUniform2f(Batch& batch, size_t paramOffset) {
|
||||
|
@ -668,8 +657,6 @@ void Batch::_glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
|||
_params.push_back(v1);
|
||||
_params.push_back(v0);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform3f, 1);
|
||||
}
|
||||
|
||||
void GLBackend::do_glUniform3f(Batch& batch, size_t paramOffset) {
|
||||
|
@ -696,8 +683,6 @@ void Batch::_glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLf
|
|||
_params.push_back(v1);
|
||||
_params.push_back(v0);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform4f, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -724,8 +709,6 @@ void Batch::_glUniform3fv(GLint location, GLsizei count, const GLfloat* value) {
|
|||
_params.push_back(cacheData(count * VEC3_SIZE, value));
|
||||
_params.push_back(count);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform3fv, 3);
|
||||
}
|
||||
void GLBackend::do_glUniform3fv(Batch& batch, size_t paramOffset) {
|
||||
if (_pipeline._program == 0) {
|
||||
|
@ -750,8 +733,6 @@ void Batch::_glUniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
|||
_params.push_back(cacheData(count * VEC4_SIZE, value));
|
||||
_params.push_back(count);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform4fv, 3);
|
||||
}
|
||||
void GLBackend::do_glUniform4fv(Batch& batch, size_t paramOffset) {
|
||||
if (_pipeline._program == 0) {
|
||||
|
@ -776,8 +757,6 @@ void Batch::_glUniform4iv(GLint location, GLsizei count, const GLint* value) {
|
|||
_params.push_back(cacheData(count * VEC4_SIZE, value));
|
||||
_params.push_back(count);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniform4iv, 3);
|
||||
}
|
||||
void GLBackend::do_glUniform4iv(Batch& batch, size_t paramOffset) {
|
||||
if (_pipeline._program == 0) {
|
||||
|
@ -802,8 +781,6 @@ void Batch::_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpo
|
|||
_params.push_back(transpose);
|
||||
_params.push_back(count);
|
||||
_params.push_back(location);
|
||||
|
||||
DO_IT_NOW(_glUniformMatrix4fv, 4);
|
||||
}
|
||||
void GLBackend::do_glUniformMatrix4fv(Batch& batch, size_t paramOffset) {
|
||||
if (_pipeline._program == 0) {
|
||||
|
@ -828,8 +805,6 @@ void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
|
|||
_params.push_back(blue);
|
||||
_params.push_back(green);
|
||||
_params.push_back(red);
|
||||
|
||||
DO_IT_NOW(_glColor4f, 4);
|
||||
}
|
||||
void GLBackend::do_glColor4f(Batch& batch, size_t paramOffset) {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "Context.h"
|
||||
|
||||
// PIck one from the 3
|
||||
// Pick one from the 3: THis version is the most efficient as of now
|
||||
#define GPU_STEREO_TECHNIQUE_DOUBLED_SIMPLE
|
||||
//#define GPU_STEREO_TECHNIQUE_DOUBLED_SMARTER
|
||||
//#define GPU_STEREO_TECHNIQUE_INSTANCED
|
||||
|
@ -461,7 +461,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 };
|
||||
|
|
|
@ -43,7 +43,7 @@ bool compileShader(GLenum shaderDomain, const std::string& shaderSource, const s
|
|||
|
||||
// Assign the source
|
||||
const int NUM_SOURCE_STRINGS = 3;
|
||||
const GLchar* srcstr[] = { "#version 410 core\n", defines.c_str(), shaderSource.c_str() };
|
||||
const GLchar* srcstr[] = { "#version 430 core\n", defines.c_str(), shaderSource.c_str() };
|
||||
glShaderSource(glshader, NUM_SOURCE_STRINGS, srcstr, NULL);
|
||||
|
||||
// Compile !
|
||||
|
|
|
@ -67,7 +67,9 @@ void GLBackend::do_setDepthRangeTransform(Batch& batch, size_t paramOffset) {
|
|||
}
|
||||
|
||||
void GLBackend::initTransform() {
|
||||
glGenBuffers(1, &_transform._objectBuffer);
|
||||
|
||||
glGenBuffers(2, _transform._objectBuffer);
|
||||
// glGenBuffers(1, &_transform._objectBuffer);
|
||||
glGenBuffers(1, &_transform._cameraBuffer);
|
||||
glGenBuffers(1, &_transform._drawCallInfoBuffer);
|
||||
#ifndef GPU_SSBO_DRAW_CALL_INFO
|
||||
|
@ -80,7 +82,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
|
||||
|
@ -160,7 +163,10 @@ 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]);
|
||||
//glBindBuffer(GL_SHADER_STORAGE_BUFFER, _objectBuffer);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, bufferData.size(), bufferData.data(), GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||
#else
|
||||
|
@ -186,7 +192,8 @@ 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]);
|
||||
// glBindBufferBase(GL_SHADER_STORAGE_BUFFER, TRANSFORM_OBJECT_SLOT, _objectBuffer);
|
||||
#else
|
||||
glActiveTexture(GL_TEXTURE0 + TRANSFORM_OBJECT_SLOT);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _objectBufferTexture);
|
||||
|
|
|
@ -83,7 +83,7 @@ struct TransformObject {
|
|||
|
||||
layout(location=15) in ivec2 _drawCallInfo;
|
||||
|
||||
<@if FALSE @>
|
||||
<!<@if FALSE @>!>
|
||||
// Disable SSBOs for now
|
||||
layout(std140) buffer transformObjectBuffer {
|
||||
TransformObject _object[];
|
||||
|
@ -91,7 +91,7 @@ layout(std140) buffer transformObjectBuffer {
|
|||
TransformObject getTransformObject() {
|
||||
return _object[_drawCallInfo.x];
|
||||
}
|
||||
<@else@>
|
||||
<!<@else@>
|
||||
uniform samplerBuffer transformObjectBuffer;
|
||||
|
||||
TransformObject getTransformObject() {
|
||||
|
@ -109,7 +109,7 @@ TransformObject getTransformObject() {
|
|||
|
||||
return object;
|
||||
}
|
||||
<@endif@>
|
||||
<@endif@>!>
|
||||
<@endfunc@>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue