mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-13 21:27:21 +02:00
Disable threaded texture transfers
This commit is contained in:
parent
07ccbc6f82
commit
f9857c7ac4
4 changed files with 19 additions and 18 deletions
|
@ -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) {
|
||||
|
|
|
@ -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<GLTexture>(*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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
} }
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue