From 58d4d193f70977b7807f2ca4b36a3d5c6e1bfe3c Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Sat, 13 Jan 2018 12:22:00 -0800 Subject: [PATCH] Add command line disabling of QML and KTX cache --- CMakeLists.txt | 16 ++++++++++++++-- .../src/model-networking/TextureCache.cpp | 10 +++++----- .../src/model-networking/TextureCache.h | 4 +--- libraries/ui/src/ui/OffscreenQmlSurface.cpp | 16 ++++++++-------- libraries/ui/src/ui/OffscreenQmlSurface.h | 4 +--- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddf57e00a3..46a5ac6b90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,9 +26,11 @@ endif() if (ANDROID OR UWP) option(BUILD_SERVER "Build server components" OFF) option(BUILD_TOOLS "Build tools" OFF) + option(BUILD_INSTALLER "Build installer" OFF) else() option(BUILD_SERVER "Build server components" ON) option(BUILD_TOOLS "Build tools" ON) + option(BUILD_INSTALLER "Build installer" ON) endif() if (SERVER_ONLY) @@ -39,6 +41,8 @@ else() option(BUILD_TESTS "Build tests" ON) endif() +option(DISABLE_QML "Disable QML" OFF) +option(DISABLE_KTX_CACHE "Disable KTX Cache" OFF) if (ANDROID) @@ -64,8 +68,6 @@ foreach(PLATFORM_QT_COMPONENT ${PLATFORM_QT_COMPONENTS}) endforeach() -option(BUILD_INSTALLER "Build installer" ON) - MESSAGE(STATUS "Build server: " ${BUILD_SERVER}) MESSAGE(STATUS "Build client: " ${BUILD_CLIENT}) MESSAGE(STATUS "Build tests: " ${BUILD_TESTS}) @@ -73,6 +75,16 @@ MESSAGE(STATUS "Build tools: " ${BUILD_TOOLS}) MESSAGE(STATUS "Build installer: " ${BUILD_INSTALLER}) MESSAGE(STATUS "GL ES: " ${USE_GLES}) +if (DISABLE_QML) +MESSAGE(STATUS "QML disabled!") +add_definitions(-DDISABLE_QML) +endif() + +if (DISABLE_KTX_CACHE) +MESSAGE(STATUS "KTX cache disabled!") +add_definitions(-DDISABLE_KTX_CACHE) +endif() + if (UNIX AND DEFINED ENV{HIFI_MEMORY_DEBUGGING}) MESSAGE(STATUS "Memory debugging is enabled") endif() diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index bf2f25ddcf..bff41edb68 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -50,7 +50,7 @@ Q_LOGGING_CATEGORY(trace_resource_parse_image, "trace.resource.parse.image") Q_LOGGING_CATEGORY(trace_resource_parse_image_raw, "trace.resource.parse.image.raw") Q_LOGGING_CATEGORY(trace_resource_parse_image_ktx, "trace.resource.parse.image.ktx") -#if ENABLE_KTX_CACHE +#if !defined(DISABLE_KTX_CACHE) const std::string TextureCache::KTX_DIRNAME { "ktx_cache" }; const std::string TextureCache::KTX_EXT { "ktx" }; #endif @@ -63,7 +63,7 @@ static const float SKYBOX_LOAD_PRIORITY { 10.0f }; // Make sure skybox loads fir static const float HIGH_MIPS_LOAD_PRIORITY { 9.0f }; // Make sure high mips loads after skybox but before models TextureCache::TextureCache() { -#if ENABLE_KTX_CACHE +#if !defined(DISABLE_KTX_CACHE) _ktxCache->initialize(); #endif setUnusedResourceCacheSize(0); @@ -746,7 +746,7 @@ void NetworkTexture::handleFinishedInitialLoad() { gpu::TexturePointer texture = textureCache->getTextureByHash(hash); -#if ENABLE_KTX_CACHE +#if !defined(DISABLE_KTX_CACHE) if (!texture) { auto ktxFile = textureCache->_ktxCache->getFile(hash); if (ktxFile) { @@ -933,7 +933,7 @@ void ImageReader::read() { // If we already have a live texture with the same hash, use it auto texture = textureCache->getTextureByHash(hash); -#if ENABLE_KTX_CACHE +#if !defined(DISABLE_KTX_CACHE) // If there is no live texture, check if there's an existing KTX file if (!texture) { auto ktxFile = textureCache->_ktxCache->getFile(hash); @@ -982,7 +982,7 @@ void ImageReader::read() { // Save the image into a KTXFile if (texture && textureCache) { -#if ENABLE_KTX_CACHE +#if !defined(DISABLE_KTX_CACHE) auto memKtx = gpu::Texture::serialize(*texture); // Move the texture into a memory mapped file diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index e58649b9ce..ac3e4b8a99 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -27,8 +27,6 @@ #include "KTXCache.h" -#define ENABLE_KTX_CACHE 0 - namespace gpu { class Batch; } @@ -196,7 +194,7 @@ private: TextureCache(); virtual ~TextureCache(); -#if ENABLE_KTX_CACHE +#if !defined(DISABLE_KTX_CACHE) static const std::string KTX_DIRNAME; static const std::string KTX_EXT; diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index 7ea0cad3d1..e506786705 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -518,7 +518,7 @@ QOpenGLContext* OffscreenQmlSurface::getSharedContext() { void OffscreenQmlSurface::cleanup() { _isCleaned = true; -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) _canvas->makeCurrent(); _renderControl->invalidate(); @@ -540,7 +540,7 @@ void OffscreenQmlSurface::cleanup() { } void OffscreenQmlSurface::render() { -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) if (nsightActive()) { return; } @@ -625,7 +625,7 @@ OffscreenQmlSurface::~OffscreenQmlSurface() { cleanup(); auto engine = _qmlContext->engine(); -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) _canvas->deleteLater(); #endif _rootItem->deleteLater(); @@ -652,7 +652,7 @@ void OffscreenQmlSurface::disconnectAudioOutputTimer() { void OffscreenQmlSurface::create() { qCDebug(uiLogging) << "Building QML surface"; -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) _renderControl = new QMyQuickRenderControl(); connect(_renderControl, &QQuickRenderControl::renderRequested, this, [this] { _render = true; }); connect(_renderControl, &QQuickRenderControl::sceneChanged, this, [this] { _render = _polish = true; }); @@ -702,7 +702,7 @@ void OffscreenQmlSurface::create() { // Find a way to flag older scripts using this mechanism and wanr that this is deprecated _qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(this, _qmlContext)); -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) _renderControl->initialize(_canvas->getContext()); #endif @@ -804,7 +804,7 @@ void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) { return; } -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) qCDebug(uiLogging) << "Offscreen UI resizing to " << newSize.width() << "x" << newSize.height(); gl::withSavedContext([&] { _canvas->makeCurrent(); @@ -1024,7 +1024,7 @@ void OffscreenQmlSurface::updateQuick() { if (_polish) { PROFILE_RANGE(render_qml, "OffscreenQML polish") -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) _renderControl->polishItems(); #endif _polish = false; @@ -1317,7 +1317,7 @@ bool OffscreenQmlSurface::isPaused() const { void OffscreenQmlSurface::setProxyWindow(QWindow* window) { _proxyWindow = window; -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) if (_renderControl) { _renderControl->_renderWindow = window; } diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.h b/libraries/ui/src/ui/OffscreenQmlSurface.h index 13b2426a0a..7aeac8d7c3 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.h +++ b/libraries/ui/src/ui/OffscreenQmlSurface.h @@ -35,8 +35,6 @@ class QQuickWindow; class QQuickItem; class QJSValue; -#define ENABLE_QML_RENDERING 0 - // GPU resources are typically buffered for one copy being used by the renderer, // one copy in flight, and one copy being used by the receiver #define GPU_RESOURCE_BUFFER_SIZE 3 @@ -173,7 +171,7 @@ private: QQmlContext* _qmlContext { nullptr }; QQuickItem* _rootItem { nullptr }; -#if ENABLE_QML_RENDERING +#if !defined(DISABLE_QML) QMyQuickRenderControl* _renderControl{ nullptr }; OffscreenGLCanvas* _canvas { nullptr }; #endif