diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 622c8f1081..6faccb1527 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -278,6 +278,7 @@ protected: struct InputStageState { bool _invalidFormat { true }; + bool _lastUpdateStereoState{ false }; bool _hadColorAttribute{ true }; Stream::FormatPointer _format; std::string _formatKey; diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp index 4145eb6061..77e1f90f66 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp @@ -156,6 +156,14 @@ void GLBackend::do_setIndirectBuffer(const Batch& batch, size_t paramOffset) { } void GLBackend::updateInput() { + bool isStereoNow = isStereo(); + // track stereo state change potentially happening wihtout changing the input format + // this is a rare case requesting to invalid the format +#ifdef GPU_STEREO_DRAWCALL_INSTANCED + _input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState); +#endif + _input._lastUpdateStereoState = isStereoNow; + if (_input._invalidFormat) { InputStageState::ActivationCache newActivation; @@ -213,7 +221,7 @@ void GLBackend::updateInput() { (void)CHECK_GL_ERROR(); } #ifdef GPU_STEREO_DRAWCALL_INSTANCED - glVertexBindingDivisor(bufferChannelNum, frequency * (isStereo() ? 2 : 1)); + glVertexBindingDivisor(bufferChannelNum, frequency * (isStereoNow ? 2 : 1)); #else glVertexBindingDivisor(bufferChannelNum, frequency); #endif diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp index 261ec78891..07cb5fa15f 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp @@ -18,7 +18,7 @@ #define DEFAULT_ALLOWED_TEXTURE_MEMORY_MB ((size_t)1024) #define MAX_RESOURCE_TEXTURES_PER_FRAME 2 #define NO_BUFFER_WORK_SLEEP_TIME_MS 2 -//#define THREADED_TEXTURE_BUFFERING 1 +#define THREADED_TEXTURE_BUFFERING 1 static const size_t DEFAULT_ALLOWED_TEXTURE_MEMORY = MB_TO_BYTES(DEFAULT_ALLOWED_TEXTURE_MEMORY_MB); @@ -375,7 +375,6 @@ void GLTextureTransferEngineDefault::populateActiveBufferQueue() { } bool GLTextureTransferEngineDefault::processActiveBufferQueue() { - PROFILE_RANGE(render_gpu_gl, __FUNCTION__); ActiveTransferQueue activeBufferQueue; { Lock lock(_bufferMutex); diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp index 42bd56e6e4..9dcb08f0b7 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp @@ -25,6 +25,14 @@ void GL41Backend::resetInputStage() { } void GL41Backend::updateInput() { + bool isStereoNow = isStereo(); + // track stereo state change potentially happening wihtout changing the input format + // this is a rare case requesting to invalid the format +#ifdef GPU_STEREO_DRAWCALL_INSTANCED + _input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState); +#endif + _input._lastUpdateStereoState = isStereoNow; + if (_input._invalidFormat || _input._invalidBuffers.any()) { if (_input._invalidFormat) { @@ -111,7 +119,7 @@ void GL41Backend::updateInput() { reinterpret_cast<GLvoid*>(pointer + perLocationStride * (GLuint)locNum)); } #ifdef GPU_STEREO_DRAWCALL_INSTANCED - glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency * (isStereo() ? 2 : 1)); + glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency * (isStereoNow ? 2 : 1)); #else glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency); #endif diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp index 34bf6774f7..cc3e609bda 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp @@ -27,6 +27,14 @@ void GL45Backend::resetInputStage() { } void GL45Backend::updateInput() { + bool isStereoNow = isStereo(); + // track stereo state change potentially happening wihtout changing the input format + // this is a rare case requesting to invalid the format +#ifdef GPU_STEREO_DRAWCALL_INSTANCED + _input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState); +#endif + _input._lastUpdateStereoState = isStereoNow; + if (_input._invalidFormat) { InputStageState::ActivationCache newActivation; @@ -84,7 +92,7 @@ void GL45Backend::updateInput() { (void)CHECK_GL_ERROR(); } #ifdef GPU_STEREO_DRAWCALL_INSTANCED - glVertexBindingDivisor(bufferChannelNum, frequency * (isStereo() ? 2 : 1)); + glVertexBindingDivisor(bufferChannelNum, frequency * (isStereoNow ? 2 : 1)); #else glVertexBindingDivisor(bufferChannelNum, frequency); #endif