From 192c72ff99be46b83a6541945d4d40446fad4ad1 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 Nov 2016 09:47:15 -0800 Subject: [PATCH] Update menu, initial state for texture management --- interface/src/Menu.cpp | 18 ++---------- interface/src/Menu.h | 4 +-- libraries/gpu-gl/src/gpu/gl/GLBackend.h | 2 -- .../src/gpu/gl45/GL45BackendTexture.cpp | 7 +---- libraries/gpu/src/gpu/Context.h | 1 - libraries/gpu/src/gpu/Texture.cpp | 29 ++++++++++++------- libraries/gpu/src/gpu/Texture.h | 2 +- 7 files changed, 26 insertions(+), 37 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d357713bff..6207ecdb3c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -387,21 +387,9 @@ Menu::Menu() { }); #ifdef Q_OS_WIN - #define MIN_CORES_FOR_INCREMENTAL_TEXTURES 5 - bool recommendedIncrementalTransfers = (QThread::idealThreadCount() >= MIN_CORES_FOR_INCREMENTAL_TEXTURES); - bool recommendedSparseTextures = recommendedIncrementalTransfers; - - qDebug() << "[TEXTURE TRANSFER SUPPORT]" - << "\n\tidealThreadCount:" << QThread::idealThreadCount() - << "\n\tRECOMMENDED enableSparseTextures:" << recommendedSparseTextures - << "\n\tRECOMMENDED enableIncrementalTextures:" << recommendedIncrementalTransfers; - - gpu::Texture::setEnableIncrementalTextureTransfers(recommendedIncrementalTransfers); - gpu::Texture::setEnableSparseTextures(recommendedSparseTextures); - - // Developer > Render > Enable Dynamic Texture Management + // Developer > Render > Enable Sparse Textures { - auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableDynamicTextureManagement, 0, recommendedSparseTextures); + auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::SparseTextureManagement, 0, gpu::Texture::getEnableSparseTextures()); connect(action, &QAction::triggered, [&](bool checked) { qDebug() << "[TEXTURE TRANSFER SUPPORT] --- Enable Dynamic Texture Management menu option:" << checked; gpu::Texture::setEnableSparseTextures(checked); @@ -410,7 +398,7 @@ Menu::Menu() { // Developer > Render > Enable Incremental Texture Transfer { - auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableIncrementalTextureTransfer, 0, recommendedIncrementalTransfers); + auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::IncrementalTextureTransfer, 0, gpu::Texture::getEnableIncrementalTextureTransfers()); connect(action, &QAction::triggered, [&](bool checked) { qDebug() << "[TEXTURE TRANSFER SUPPORT] --- Enable Incremental Texture Transfer menu option:" << checked; gpu::Texture::setEnableIncrementalTextureTransfers(checked); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 640a3e05d2..87e0e678f1 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -97,8 +97,6 @@ namespace MenuOption { const QString EchoLocalAudio = "Echo Local Audio"; const QString EchoServerAudio = "Echo Server Audio"; const QString EnableCharacterController = "Enable avatar collisions"; - const QString EnableIncrementalTextureTransfer = "Enable Incremental Texture Transfer"; - const QString EnableDynamicTextureManagement = "Enable Dynamic Texture Management"; const QString EnableInverseKinematics = "Enable Inverse Kinematics"; const QString ExpandMyAvatarSimulateTiming = "Expand /myAvatar/simulation"; const QString ExpandMyAvatarTiming = "Expand /myAvatar"; @@ -114,6 +112,7 @@ namespace MenuOption { const QString FrameTimer = "Show Timer"; const QString FullscreenMirror = "Mirror"; const QString Help = "Help..."; + const QString IncrementalTextureTransfer = "Enable Incremental Texture Transfer"; const QString IncreaseAvatarSize = "Increase Avatar Size"; const QString IndependentMode = "Independent Mode"; const QString ActionMotorControl = "Enable Default Motor Control"; @@ -180,6 +179,7 @@ namespace MenuOption { const QString StandingHMDSensorMode = "Standing HMD Sensor Mode"; const QString SimulateEyeTracking = "Simulate"; const QString SMIEyeTracking = "SMI Eye Tracking"; + const QString SparseTextureManagement = "Enable Sparse Texture Management"; const QString Stats = "Stats"; const QString StopAllScripts = "Stop All Scripts"; const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.h b/libraries/gpu-gl/src/gpu/gl/GLBackend.h index 1be279b375..417b090d31 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.h @@ -177,7 +177,6 @@ public: virtual void queueLambda(const std::function lambda) const; bool isTextureManagementSparseEnabled() const override { return (_textureManagement._sparseCapable && Texture::getEnableSparseTextures()); } - bool isTextureManagementIncrementalTransferEnabled() const override { return (_textureManagement._incrementalTransferCapable && Texture::getEnableIncrementalTextureTransfers()); } protected: @@ -369,7 +368,6 @@ protected: struct TextureManagementStageState { bool _sparseCapable { false }; - bool _incrementalTransferCapable { false }; } _textureManagement; virtual void initTextureManagementStage() {} diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index d316116561..275bf654f8 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -148,13 +148,9 @@ uint32_t SparseInfo::getPageCount(const uvec3& dimensions) const { return pageCounts.x * pageCounts.y * pageCounts.z; } - - void GL45Backend::initTextureManagementStage() { - // enable the Sparse Texture on gl45 _textureManagement._sparseCapable = true; - _textureManagement._incrementalTransferCapable = true; // But now let s refine the behavior based on vendor std::string vendor { (const char*)glGetString(GL_VENDOR) }; @@ -383,8 +379,7 @@ void GL45Texture::startTransfer() { } bool GL45Texture::continueTransfer() { - auto backend = _backend.lock(); - if (!backend || !backend->isTextureManagementIncrementalTransferEnabled()) { + if (!Texture::getEnableIncrementalTextureTransfers()) { size_t maxFace = GL_TEXTURE_CUBE_MAP == _target ? CUBE_NUM_FACES : 1; for (uint8_t face = 0; face < maxFace; ++face) { for (uint16_t mipLevel = _minMip; mipLevel <= _maxMip; ++mipLevel) { diff --git a/libraries/gpu/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h index 3564655a3d..19d2ae767f 100644 --- a/libraries/gpu/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -86,7 +86,6 @@ public: void getStats(ContextStats& stats) const { stats = _stats; } virtual bool isTextureManagementSparseEnabled() const = 0; - virtual bool isTextureManagementIncrementalTransferEnabled() const = 0; // These should only be accessed by Backend implementation to repport the buffer and texture allocations, // they are NOT public calls diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 7a13c792cb..33786155db 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -10,13 +10,14 @@ // -#include - #include "Texture.h" #include #include +#include +#include + #include #include "GPULogging.h" @@ -32,16 +33,27 @@ std::atomic Texture::_textureCPUCount{ 0 }; std::atomic Texture::_textureCPUMemoryUsage{ 0 }; std::atomic Texture::_allowedCPUMemoryUsage { 0 }; -std::atomic Texture::_enableSparseTextures { false }; -std::atomic Texture::_enableIncrementalTextureTransfers { false }; + +#define MIN_CORES_FOR_INCREMENTAL_TEXTURES 5 +bool recommendedIncrementalTransfers = (QThread::idealThreadCount() >= MIN_CORES_FOR_INCREMENTAL_TEXTURES); +bool recommendedSparseTextures = recommendedIncrementalTransfers; + +std::atomic Texture::_enableSparseTextures { recommendedIncrementalTransfers }; +std::atomic Texture::_enableIncrementalTextureTransfers { recommendedSparseTextures }; + +struct ReportTextureState { + ReportTextureState() { + qDebug() << "[TEXTURE TRANSFER SUPPORT]" + << "\n\tidealThreadCount:" << QThread::idealThreadCount() + << "\n\tRECOMMENDED enableSparseTextures:" << recommendedSparseTextures + << "\n\tRECOMMENDED enableIncrementalTextures:" << recommendedIncrementalTransfers; + } +} report; void Texture::setEnableSparseTextures(bool enabled) { #ifdef Q_OS_WIN qDebug() << "[TEXTURE TRANSFER SUPPORT] SETTING - Enable Sparse Textures and Dynamic Texture Management:" << enabled; _enableSparseTextures = enabled; - if (!_enableIncrementalTextureTransfers && _enableSparseTextures) { - qDebug() << "[TEXTURE TRANSFER SUPPORT] WARNING - Sparse texture management requires incremental texture transfer enabled."; - } #else qDebug() << "[TEXTURE TRANSFER SUPPORT] Sparse Textures and Dynamic Texture Management not supported on this platform."; #endif @@ -51,9 +63,6 @@ void Texture::setEnableIncrementalTextureTransfers(bool enabled) { #ifdef Q_OS_WIN qDebug() << "[TEXTURE TRANSFER SUPPORT] SETTING - Enable Incremental Texture Transfer:" << enabled; _enableIncrementalTextureTransfers = enabled; - if (!_enableIncrementalTextureTransfers && _enableSparseTextures) { - qDebug() << "[TEXTURE TRANSFER SUPPORT] WARNING - Sparse texture management requires incremental texture transfer enabled."; - } #else qDebug() << "[TEXTURE TRANSFER SUPPORT] Incremental Texture Transfer not supported on this platform."; #endif diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 7233c5b098..2a93ec3066 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -369,7 +369,7 @@ public: // = 1 + log2(max(width, height, depth)) uint16 evalNumMips() const; - static uint16 evalNumMips(const Vec3u& dimnsions); + static uint16 evalNumMips(const Vec3u& dimensions); // Eval the size that the mips level SHOULD have // not the one stored in the Texture