From f9857c7ac4d89898c43daa5f8ffdfcaf1920d72e Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 14 Sep 2016 12:15:14 -0700 Subject: [PATCH] Disable threaded texture transfers --- libraries/gpu-gl/src/gpu/gl/GLBackend.cpp | 4 ++++ .../gpu-gl/src/gpu/gl/GLTextureTransfer.cpp | 18 ++++++++---------- .../gpu-gl/src/gpu/gl/GLTextureTransfer.h | 13 ++++++------- .../gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp index e3f391126b..1385a56f65 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp @@ -679,6 +679,10 @@ void GLBackend::recycle() const { glDeleteQueries((GLsizei)ids.size(), ids.data()); } } + +#ifndef THREADED_TEXTURE_TRANSFER + gl::GLTexture::_textureTransferHelper->process(); +#endif } void GLBackend::setCameraCorrection(const Mat4& correction) { diff --git a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp index c66ea39f56..4cb8e4fad1 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp @@ -35,6 +35,8 @@ GLTextureTransferHelper::GLTextureTransferHelper() { initialize(true, QThread::LowPriority); // Clean shutdown on UNIX, otherwise _canvas is freed early connect(qApp, &QCoreApplication::aboutToQuit, [&] { terminate(); }); +#else + initialize(false, QThread::LowPriority); #endif } @@ -43,23 +45,18 @@ GLTextureTransferHelper::~GLTextureTransferHelper() { if (isStillRunning()) { terminate(); } +#else + terminate(); #endif } void GLTextureTransferHelper::transferTexture(const gpu::TexturePointer& texturePointer) { GLTexture* object = Backend::getGPUObject(*texturePointer); -#ifdef THREADED_TEXTURE_TRANSFER Backend::incrementTextureGPUTransferCount(); object->setSyncState(GLSyncState::Pending); Lock lock(_mutex); _pendingTextures.push_back(texturePointer); -#else - for (object->startTransfer(); object->continueTransfer(); ) { } - object->finishTransfer(); - object->_contentStamp = texturePointer->getDataStamp(); - object->setSyncState(GLSyncState::Transferred); -#endif } void GLTextureTransferHelper::setup() { @@ -101,7 +98,6 @@ void GLTextureTransferHelper::shutdown() { } bool GLTextureTransferHelper::process() { -#ifdef THREADED_TEXTURE_TRANSFER // Take any new textures off the queue TextureList newTransferTextures; { @@ -123,7 +119,9 @@ bool GLTextureTransferHelper::process() { // No transfers in progress, sleep if (_transferringTextures.empty()) { +#ifdef THREADED_TEXTURE_TRANSFER QThread::usleep(1); +#endif return true; } @@ -159,6 +157,7 @@ bool GLTextureTransferHelper::process() { _textureIterator = _transferringTextures.erase(_textureIterator); } +#ifdef THREADED_TEXTURE_TRANSFER if (!_transferringTextures.empty()) { // Don't saturate the GPU clientWait(); @@ -166,8 +165,7 @@ bool GLTextureTransferHelper::process() { // Don't saturate the CPU QThread::msleep(1); } -#else - QThread::msleep(1); #endif + return true; } diff --git a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.h b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.h index d2207df7e6..a880f42394 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.h +++ b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.h @@ -18,7 +18,7 @@ #include "GLShared.h" #ifdef Q_OS_WIN -#define THREADED_TEXTURE_TRANSFER +//#define THREADED_TEXTURE_TRANSFER #endif namespace gpu { namespace gl { @@ -33,7 +33,6 @@ public: ~GLTextureTransferHelper(); void transferTexture(const gpu::TexturePointer& texturePointer); -protected: void setup() override; void shutdown() override; bool process() override; @@ -41,6 +40,11 @@ protected: private: #ifdef THREADED_TEXTURE_TRANSFER ::gl::OffscreenContext _context; + // Framebuffers / renderbuffers for forcing access to the texture on the transfer thread + GLuint _drawRenderbuffer { 0 }; + GLuint _drawFramebuffer { 0 }; + GLuint _readFramebuffer { 0 }; +#endif // A mutex for protecting items access on the render and transfer threads Mutex _mutex; // Textures that have been submitted for transfer @@ -50,11 +54,6 @@ private: TextureList _transferringTextures; TextureListIterator _textureIterator; - // Framebuffers / renderbuffers for forcing access to the texture on the transfer thread - GLuint _drawRenderbuffer { 0 }; - GLuint _drawFramebuffer { 0 }; - GLuint _readFramebuffer { 0 }; -#endif }; } } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index ac1f4fddca..852af02287 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -26,7 +26,7 @@ using namespace gpu::gl; using namespace gpu::gl45; static const QString DEBUG_FLAG("HIFI_ENABLE_SPARSE_TEXTURES"); -static bool enableSparseTextures = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG); +static bool enableSparseTextures = true; // QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG); // Allocate 1 MB of buffer space for paged transfers #define DEFAULT_PAGE_BUFFER_SIZE (1024*1024)