mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into fix/qml-audio-shutdown-order
This commit is contained in:
commit
4913654f44
29 changed files with 265 additions and 59 deletions
|
@ -215,6 +215,9 @@ Item {
|
|||
StatText {
|
||||
text: " Commited Memory: " + root.gpuTextureMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Framebuffer Memory: " + root.gpuTextureFramebufferMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Sparse Memory: " + root.gpuTextureSparseMemory + " MB";
|
||||
visible: 0 != root.gpuSparseTextureEnabled;
|
||||
|
@ -225,6 +228,9 @@ Item {
|
|||
StatText {
|
||||
text: " Count: " + root.gpuTextures;
|
||||
}
|
||||
StatText {
|
||||
text: "GL Swapchain Memory: " + root.glContextSwapchainMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: "QML Texture Memory: " + root.qmlTextureMemory + " MB";
|
||||
}
|
||||
|
|
|
@ -858,7 +858,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
{ "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
|
||||
{ "gl_version", glContextData["version"] },
|
||||
{ "gl_vender", glContextData["vendor"] },
|
||||
{ "gl_sl_version", glContextData["slVersion"] },
|
||||
{ "gl_sl_version", glContextData["sl_version"] },
|
||||
{ "gl_renderer", glContextData["renderer"] },
|
||||
{ "ideal_thread_count", QThread::idealThreadCount() }
|
||||
};
|
||||
|
@ -1173,10 +1173,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
properties["process_memory_used"] = static_cast<qint64>(memInfo.processUsedMemoryBytes);
|
||||
}
|
||||
|
||||
// content location and build info - useful for filtering stats
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
auto currentDomain = addressManager->currentShareableAddress(true).toString(); // domain only
|
||||
auto currentPath = addressManager->currentPath(true); // with orientation
|
||||
properties["current_domain"] = currentDomain;
|
||||
properties["current_path"] = currentPath;
|
||||
properties["build_version"] = BuildInfo::VERSION;
|
||||
|
||||
auto displayPlugin = qApp->getActiveDisplayPlugin();
|
||||
|
||||
properties["fps"] = _frameCounter.rate();
|
||||
properties["target_frame_rate"] = getTargetFrameRate();
|
||||
properties["render_rate"] = displayPlugin->renderRate();
|
||||
properties["present_rate"] = displayPlugin->presentRate();
|
||||
properties["new_frame_present_rate"] = displayPlugin->newFramePresentRate();
|
||||
properties["dropped_frame_rate"] = displayPlugin->droppedFrameRate();
|
||||
|
@ -1222,6 +1231,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
||||
properties["using_hmd"] = isHMDMode();
|
||||
|
||||
auto glInfo = getGLContextData();
|
||||
properties["gl_info"] = glInfo;
|
||||
properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory());
|
||||
|
||||
auto hmdHeadPose = getHMDSensorPose();
|
||||
properties["hmd_head_pose_changed"] = isHMDMode() && (hmdHeadPose != lastHMDHeadPose);
|
||||
lastHMDHeadPose = hmdHeadPose;
|
||||
|
@ -1478,6 +1491,7 @@ void Application::updateHeartbeat() const {
|
|||
|
||||
void Application::aboutToQuit() {
|
||||
emit beforeAboutToQuit();
|
||||
DependencyManager::get<AudioClient>()->beforeAboutToQuit();
|
||||
|
||||
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
|
||||
if (inputPlugin->isActive()) {
|
||||
|
@ -1576,9 +1590,17 @@ void Application::cleanupBeforeQuit() {
|
|||
// destroy Audio so it and its threads have a chance to go down safely
|
||||
DependencyManager::destroy<AudioClient>();
|
||||
DependencyManager::destroy<AudioInjectorManager>();
|
||||
|
||||
// shutdown render engine
|
||||
_main3DScene = nullptr;
|
||||
_renderEngine = nullptr;
|
||||
|
||||
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
DependencyManager::destroy<Preferences>();
|
||||
|
||||
_entityClipboard->eraseAllOctreeElements();
|
||||
_entityClipboard.reset();
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "Application.h"
|
||||
#include "Avatar.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "InterfaceLogging.h"
|
||||
#include "Menu.h"
|
||||
#include "MyAvatar.h"
|
||||
#include "SceneScriptingInterface.h"
|
||||
|
@ -208,11 +209,15 @@ AvatarSharedPointer AvatarManager::addAvatar(const QUuid& sessionUUID, const QWe
|
|||
auto rawRenderableAvatar = std::static_pointer_cast<Avatar>(newAvatar);
|
||||
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
render::PendingChanges pendingChanges;
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars()) {
|
||||
rawRenderableAvatar->addToScene(rawRenderableAvatar, scene, pendingChanges);
|
||||
if (scene) {
|
||||
render::PendingChanges pendingChanges;
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars()) {
|
||||
rawRenderableAvatar->addToScene(rawRenderableAvatar, scene, pendingChanges);
|
||||
}
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(interfaceapp) << "AvatarManager::addAvatar() : Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
|
||||
return newAvatar;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <PerfStat.h>
|
||||
#include <plugins/DisplayPlugin.h>
|
||||
|
||||
#include <gl/Context.h>
|
||||
|
||||
#include "BandwidthRecorder.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
@ -289,9 +291,13 @@ void Stats::updateStats(bool force) {
|
|||
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
|
||||
STAT_UPDATE(gpuTextures, (int)gpu::Context::getTextureGPUCount());
|
||||
STAT_UPDATE(gpuTexturesSparse, (int)gpu::Context::getTextureGPUSparseCount());
|
||||
|
||||
STAT_UPDATE(glContextSwapchainMemory, (int)BYTES_TO_MB(gl::Context::getSwapchainMemoryUsage()));
|
||||
|
||||
STAT_UPDATE(qmlTextureMemory, (int)BYTES_TO_MB(OffscreenQmlSurface::getUsedTextureMemory()));
|
||||
STAT_UPDATE(gpuTextureMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureVirtualMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUVirtualMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureFramebufferMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUFramebufferMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureSparseMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUSparseMemoryUsage()));
|
||||
STAT_UPDATE(gpuSparseTextureEnabled, gpu::Texture::getEnableSparseTextures() ? 1 : 0);
|
||||
STAT_UPDATE(gpuFreeMemory, (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory()));
|
||||
|
|
|
@ -90,9 +90,11 @@ class Stats : public QQuickItem {
|
|||
STATS_PROPERTY(int, gpuBuffers, 0)
|
||||
STATS_PROPERTY(int, gpuTextures, 0)
|
||||
STATS_PROPERTY(int, gpuTexturesSparse, 0)
|
||||
STATS_PROPERTY(int, glContextSwapchainMemory, 0)
|
||||
STATS_PROPERTY(int, qmlTextureMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureVirtualMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureFramebufferMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureSparseMemory, 0)
|
||||
STATS_PROPERTY(int, gpuSparseTextureEnabled, 0)
|
||||
STATS_PROPERTY(int, gpuFreeMemory, 0)
|
||||
|
@ -181,12 +183,14 @@ signals:
|
|||
void localInternalChanged();
|
||||
void localLeavesChanged();
|
||||
void timingStatsChanged();
|
||||
void glContextSwapchainMemoryChanged();
|
||||
void qmlTextureMemoryChanged();
|
||||
void gpuBuffersChanged();
|
||||
void gpuTexturesChanged();
|
||||
void gpuTexturesSparseChanged();
|
||||
void gpuTextureMemoryChanged();
|
||||
void gpuTextureVirtualMemoryChanged();
|
||||
void gpuTextureFramebufferMemoryChanged();
|
||||
void gpuTextureSparseMemoryChanged();
|
||||
void gpuSparseTextureEnabledChanged();
|
||||
void gpuFreeMemoryChanged();
|
||||
|
|
|
@ -82,10 +82,10 @@ public:
|
|||
|
||||
CheckDevicesThread(AudioClient* audioClient)
|
||||
: _audioClient(audioClient) {
|
||||
}
|
||||
|
||||
connect(qApp, &QCoreApplication::aboutToQuit, [this] {
|
||||
_quit = true;
|
||||
});
|
||||
void beforeAboutToQuit() {
|
||||
_quit = true;
|
||||
}
|
||||
|
||||
void run() override {
|
||||
|
@ -159,10 +159,10 @@ AudioClient::AudioClient() :
|
|||
_outputDevices = getDeviceNames(QAudio::AudioOutput);
|
||||
|
||||
// start a thread to detect any device changes
|
||||
QThread* checkDevicesThread = new CheckDevicesThread(this);
|
||||
checkDevicesThread->setObjectName("CheckDevices Thread");
|
||||
checkDevicesThread->setPriority(QThread::LowPriority);
|
||||
checkDevicesThread->start();
|
||||
_checkDevicesThread = new CheckDevicesThread(this);
|
||||
_checkDevicesThread->setObjectName("CheckDevices Thread");
|
||||
_checkDevicesThread->setPriority(QThread::LowPriority);
|
||||
_checkDevicesThread->start();
|
||||
|
||||
configureReverb();
|
||||
|
||||
|
@ -177,6 +177,7 @@ AudioClient::AudioClient() :
|
|||
}
|
||||
|
||||
AudioClient::~AudioClient() {
|
||||
delete _checkDevicesThread;
|
||||
stop();
|
||||
if (_codec && _encoder) {
|
||||
_codec->releaseEncoder(_encoder);
|
||||
|
@ -184,6 +185,11 @@ AudioClient::~AudioClient() {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioClient::beforeAboutToQuit() {
|
||||
static_cast<CheckDevicesThread*>(_checkDevicesThread)->beforeAboutToQuit();
|
||||
}
|
||||
|
||||
|
||||
void AudioClient::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) {
|
||||
qCDebug(audioclient) << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec;
|
||||
selectAudioFormat(recievedCodec);
|
||||
|
|
|
@ -155,6 +155,8 @@ public slots:
|
|||
void audioMixerKilled();
|
||||
void toggleMute();
|
||||
|
||||
void beforeAboutToQuit();
|
||||
|
||||
virtual void setIsStereoInput(bool stereo) override;
|
||||
|
||||
void toggleAudioNoiseReduction() { _isNoiseGateEnabled = !_isNoiseGateEnabled; }
|
||||
|
@ -332,6 +334,8 @@ private:
|
|||
CodecPluginPointer _codec;
|
||||
QString _selectedCodecName;
|
||||
Encoder* _encoder { nullptr }; // for outbound mic stream
|
||||
|
||||
QThread* _checkDevicesThread { nullptr };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -128,11 +128,15 @@ void EntityTreeRenderer::clear() {
|
|||
|
||||
// remove all entities from the scene
|
||||
auto scene = _viewState->getMain3DScene();
|
||||
render::PendingChanges pendingChanges;
|
||||
foreach(auto entity, _entitiesInScene) {
|
||||
entity->removeFromScene(entity, scene, pendingChanges);
|
||||
if (scene) {
|
||||
render::PendingChanges pendingChanges;
|
||||
foreach(auto entity, _entitiesInScene) {
|
||||
entity->removeFromScene(entity, scene, pendingChanges);
|
||||
}
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
_entitiesInScene.clear();
|
||||
|
||||
// reset the zone to the default (while we load the next scene)
|
||||
|
@ -901,8 +905,12 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
|
|||
auto entity = _entitiesInScene.take(entityID);
|
||||
render::PendingChanges pendingChanges;
|
||||
auto scene = _viewState->getMain3DScene();
|
||||
entity->removeFromScene(entity, scene, pendingChanges);
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
if (scene) {
|
||||
entity->removeFromScene(entity, scene, pendingChanges);
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(entitiesrenderer) << "EntityTreeRenderer::deletingEntity(), Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,10 +927,14 @@ void EntityTreeRenderer::addEntityToScene(EntityItemPointer entity) {
|
|||
// here's where we add the entity payload to the scene
|
||||
render::PendingChanges pendingChanges;
|
||||
auto scene = _viewState->getMain3DScene();
|
||||
if (entity->addToScene(entity, scene, pendingChanges)) {
|
||||
_entitiesInScene.insert(entity->getEntityItemID(), entity);
|
||||
if (scene) {
|
||||
if (entity->addToScene(entity, scene, pendingChanges)) {
|
||||
_entitiesInScene.insert(entity->getEntityItemID(), entity);
|
||||
}
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(entitiesrenderer) << "EntityTreeRenderer::addEntityToScene(), Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <render/Scene.h>
|
||||
#include <EntityItem.h>
|
||||
#include "AbstractViewStateInterface.h"
|
||||
#include "EntitiesRendererLogging.h"
|
||||
|
||||
|
||||
// These or the icon "name" used by the render item status value, they correspond to the atlas texture used by the DrawItemStatus
|
||||
|
@ -79,10 +80,14 @@ public:
|
|||
render::PendingChanges pendingChanges;
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
|
||||
pendingChanges.updateItem<RenderableEntityItemProxy>(_myItem, [](RenderableEntityItemProxy& data) {
|
||||
});
|
||||
if (scene) {
|
||||
pendingChanges.updateItem<RenderableEntityItemProxy>(_myItem, [](RenderableEntityItemProxy& data) {
|
||||
});
|
||||
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(entitiesrenderer) << "SimpleRenderableEntityItem::notifyChanged(), Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -248,9 +248,12 @@ void RenderableZoneEntityItem::notifyBoundChanged() {
|
|||
}
|
||||
render::PendingChanges pendingChanges;
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
if (scene) {
|
||||
pendingChanges.updateItem<RenderableZoneEntityItemMeta>(_myMetaItem, [](RenderableZoneEntityItemMeta& data) {
|
||||
});
|
||||
|
||||
pendingChanges.updateItem<RenderableZoneEntityItemMeta>(_myMetaItem, [](RenderableZoneEntityItemMeta& data) {
|
||||
});
|
||||
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(entitiesrenderer) << "RenderableZoneEntityItem::notifyBoundChanged(), Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,27 @@ static bool enableDebugLogger = QProcessEnvironment::systemEnvironment().contain
|
|||
|
||||
using namespace gl;
|
||||
|
||||
|
||||
std::atomic<size_t> Context::_totalSwapchainMemoryUsage { 0 };
|
||||
|
||||
size_t Context::getSwapchainMemoryUsage() { return _totalSwapchainMemoryUsage.load(); }
|
||||
|
||||
size_t Context::evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize) {
|
||||
return width * height * pixelSize;
|
||||
}
|
||||
|
||||
void Context::updateSwapchainMemoryUsage(size_t prevSize, size_t newSize) {
|
||||
if (prevSize == newSize) {
|
||||
return;
|
||||
}
|
||||
if (newSize > prevSize) {
|
||||
_totalSwapchainMemoryUsage.fetch_add(newSize - prevSize);
|
||||
} else {
|
||||
_totalSwapchainMemoryUsage.fetch_sub(prevSize - newSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Context* Context::PRIMARY = nullptr;
|
||||
|
||||
Context::Context() {}
|
||||
|
@ -78,18 +99,35 @@ void Context::release() {
|
|||
if (PRIMARY == this) {
|
||||
PRIMARY = nullptr;
|
||||
}
|
||||
}
|
||||
updateSwapchainMemoryCounter();
|
||||
}
|
||||
|
||||
Context::~Context() {
|
||||
release();
|
||||
}
|
||||
|
||||
void Context::updateSwapchainMemoryCounter() {
|
||||
if (_window) {
|
||||
auto newSize = _window->size();
|
||||
auto newMemSize = gl::Context::evalSurfaceMemoryUsage(newSize.width(), newSize.height(), (uint32_t) _swapchainPixelSize);
|
||||
gl::Context::updateSwapchainMemoryUsage(_swapchainMemoryUsage, newMemSize);
|
||||
_swapchainMemoryUsage = newMemSize;
|
||||
} else {
|
||||
// No window ? no more swapchain
|
||||
gl::Context::updateSwapchainMemoryUsage(_swapchainMemoryUsage, 0);
|
||||
_swapchainMemoryUsage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Context::setWindow(QWindow* window) {
|
||||
release();
|
||||
_window = window;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
_hwnd = (HWND)window->winId();
|
||||
#endif
|
||||
|
||||
updateSwapchainMemoryCounter();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -98,6 +136,8 @@ static const char* PRIMARY_CONTEXT_PROPERTY_NAME = "com.highfidelity.gl.primaryC
|
|||
bool Context::makeCurrent() {
|
||||
BOOL result = wglMakeCurrent(_hdc, _hglrc);
|
||||
assert(result);
|
||||
updateSwapchainMemoryCounter();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -217,6 +257,11 @@ void Context::create() {
|
|||
wglChoosePixelFormatARB(_hdc, &formatAttribs[0], NULL, 1, &pixelFormat, &numFormats);
|
||||
DescribePixelFormat(_hdc, pixelFormat, sizeof(pfd), &pfd);
|
||||
}
|
||||
// The swap chain pixel size for swap chains is : rgba32 + depth24stencil8
|
||||
// We don't apply the length of the swap chain into this pixelSize since it is not vsible for the Process (on windows).
|
||||
_swapchainPixelSize = 32 + 32;
|
||||
updateSwapchainMemoryCounter();
|
||||
|
||||
SetPixelFormat(_hdc, pixelFormat, &pfd);
|
||||
{
|
||||
std::vector<int> contextAttribs;
|
||||
|
@ -277,6 +322,8 @@ void OffscreenContext::create() {
|
|||
_window->setSurfaceType(QSurface::OpenGLSurface);
|
||||
_window->create();
|
||||
setWindow(_window);
|
||||
QSize windowSize = _window->size() * _window->devicePixelRatio();
|
||||
qCDebug(glLogging) << "New Offscreen GLContext, window size = " << windowSize.width() << " , " << windowSize.height();
|
||||
QGuiApplication::processEvents();
|
||||
}
|
||||
Parent::create();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <QtGlobal>
|
||||
#include <atomic>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <Windows.h>
|
||||
|
@ -23,7 +24,7 @@ class QThread;
|
|||
|
||||
namespace gl {
|
||||
|
||||
class Context {
|
||||
class Context {
|
||||
protected:
|
||||
QWindow* _window { nullptr };
|
||||
static Context* PRIMARY;
|
||||
|
@ -57,6 +58,17 @@ class Context {
|
|||
virtual void create();
|
||||
QOpenGLContext* qglContext();
|
||||
void moveToThread(QThread* thread);
|
||||
|
||||
static size_t evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize);
|
||||
static size_t getSwapchainMemoryUsage();
|
||||
static void updateSwapchainMemoryUsage(size_t prevSize, size_t newSize);
|
||||
|
||||
private:
|
||||
static std::atomic<size_t> _totalSwapchainMemoryUsage;
|
||||
|
||||
size_t _swapchainMemoryUsage { 0 };
|
||||
size_t _swapchainPixelSize { 0 };
|
||||
void updateSwapchainMemoryCounter();
|
||||
};
|
||||
|
||||
class OffscreenContext : public Context {
|
||||
|
@ -67,6 +79,7 @@ class Context {
|
|||
virtual ~OffscreenContext();
|
||||
void create() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // hifi_gpu_GPUConfig_h
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <QtPlatformHeaders/QWGLNativeContext>
|
||||
#endif
|
||||
|
||||
#include "GLHelpers.h"
|
||||
|
||||
using namespace gl;
|
||||
|
||||
void Context::destroyContext(QOpenGLContext* context) {
|
||||
|
@ -45,6 +47,7 @@ void Context::moveToThread(QThread* thread) {
|
|||
|
||||
#ifndef Q_OS_WIN
|
||||
bool Context::makeCurrent() {
|
||||
updateSwapchainMemoryCounter();
|
||||
return _context->makeCurrent(_window);
|
||||
}
|
||||
|
||||
|
@ -70,6 +73,9 @@ void Context::create() {
|
|||
}
|
||||
_context->setFormat(getDefaultOpenGLSurfaceFormat());
|
||||
_context->create();
|
||||
|
||||
_swapchainPixelSize = evalGLFormatSwapchainPixelSize(_context->format());
|
||||
updateSwapchainMemoryCounter();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,17 @@
|
|||
|
||||
#include <QtOpenGL/QGL>
|
||||
|
||||
size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format) {
|
||||
size_t pixelSize = format.redBufferSize() + format.greenBufferSize() + format.blueBufferSize() + format.alphaBufferSize();
|
||||
// We don't apply the length of the swap chain into this pixelSize since it is not vsible for the Process (on windows).
|
||||
// Let s keep this here remember that:
|
||||
// if (format.swapBehavior() > 0) {
|
||||
// pixelSize *= format.swapBehavior(); // multiply the color buffer pixel size by the actual swapchain depth
|
||||
// }
|
||||
pixelSize += format.stencilBufferSize() + format.depthBufferSize();
|
||||
return pixelSize;
|
||||
}
|
||||
|
||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
||||
static QSurfaceFormat format;
|
||||
static std::once_flag once;
|
||||
|
@ -35,17 +46,22 @@ int glVersionToInteger(QString glVersion) {
|
|||
}
|
||||
|
||||
QJsonObject getGLContextData() {
|
||||
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
||||
QString glslVersion = QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
QString glVendor = QString((const char*) glGetString(GL_VENDOR));
|
||||
QString glRenderer = QString((const char*)glGetString(GL_RENDERER));
|
||||
static QJsonObject result;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
||||
QString glslVersion = QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
QString glVendor = QString((const char*) glGetString(GL_VENDOR));
|
||||
QString glRenderer = QString((const char*)glGetString(GL_RENDERER));
|
||||
|
||||
return QJsonObject {
|
||||
{ "version", glVersion },
|
||||
{ "slVersion", glslVersion },
|
||||
{ "vendor", glVendor },
|
||||
{ "renderer", glRenderer },
|
||||
};
|
||||
result = QJsonObject {
|
||||
{ "version", glVersion },
|
||||
{ "sl_version", glslVersion },
|
||||
{ "vendor", glVendor },
|
||||
{ "renderer", glRenderer },
|
||||
};
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
QThread* RENDER_THREAD = nullptr;
|
||||
|
|
|
@ -26,6 +26,8 @@ class QGLFormat;
|
|||
template<class F>
|
||||
void setGLFormatVersion(F& format, int major = 4, int minor = 5) { format.setVersion(major, minor); }
|
||||
|
||||
size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format);
|
||||
|
||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
|
||||
QJsonObject getGLContextData();
|
||||
int glVersionToInteger(QString glVersion);
|
||||
|
|
|
@ -17,11 +17,15 @@
|
|||
#include <QtGui/QOffscreenSurface>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
|
||||
#include "Context.h"
|
||||
#include "GLHelpers.h"
|
||||
#include "GLLogging.h"
|
||||
|
||||
|
||||
OffscreenGLCanvas::OffscreenGLCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){
|
||||
OffscreenGLCanvas::OffscreenGLCanvas() :
|
||||
_context(new QOpenGLContext),
|
||||
_offscreenSurface(new QOffscreenSurface)
|
||||
{
|
||||
}
|
||||
|
||||
OffscreenGLCanvas::~OffscreenGLCanvas() {
|
||||
|
@ -56,7 +60,6 @@ bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
|||
bool OffscreenGLCanvas::makeCurrent() {
|
||||
bool result = _context->makeCurrent(_offscreenSurface);
|
||||
Q_ASSERT(result);
|
||||
|
||||
std::call_once(_reportOnce, [this]{
|
||||
qCDebug(glLogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION));
|
||||
qCDebug(glLogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
|
|
|
@ -13,7 +13,7 @@ using namespace gpu;
|
|||
using namespace gpu::gl;
|
||||
|
||||
GLFramebuffer::~GLFramebuffer() {
|
||||
if (_id) {
|
||||
if (_id) {
|
||||
auto backend = _backend.lock();
|
||||
if (backend) {
|
||||
backend->releaseFramebuffer(_id);
|
||||
|
|
|
@ -181,6 +181,10 @@ GLTexture::~GLTexture() {
|
|||
// the GL45Texture destructor for doing any required work tracking GPU stats
|
||||
backend->releaseTexture(_id, _size);
|
||||
}
|
||||
|
||||
if (!_external && !_transferrable) {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(_size, 0);
|
||||
}
|
||||
}
|
||||
Backend::updateTextureGPUVirtualMemoryUsage(_virtualSize, 0);
|
||||
}
|
||||
|
@ -217,6 +221,9 @@ void GLTexture::withPreservedTexture(std::function<void()> f) const {
|
|||
}
|
||||
|
||||
void GLTexture::setSize(GLuint size) const {
|
||||
if (!_external && !_transferrable) {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(_size, size);
|
||||
}
|
||||
Backend::updateTextureGPUMemoryUsage(_size, size);
|
||||
const_cast<GLuint&>(_size) = size;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,8 @@ std::atomic<Buffer::Size> Context::_bufferGPUMemoryUsage { 0 };
|
|||
std::atomic<uint32_t> Context::_textureGPUCount{ 0 };
|
||||
std::atomic<uint32_t> Context::_textureGPUSparseCount { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUVirtualMemoryUsage{ 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUVirtualMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUFramebufferMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUSparseMemoryUsage { 0 };
|
||||
std::atomic<uint32_t> Context::_textureGPUTransferCount { 0 };
|
||||
|
||||
|
@ -262,6 +263,17 @@ void Context::updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newOb
|
|||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUFramebufferMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUFramebufferMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUFramebufferMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUSparseMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
|
@ -310,6 +322,10 @@ Context::Size Context::getTextureGPUVirtualMemoryUsage() {
|
|||
return _textureGPUVirtualMemoryUsage.load();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUFramebufferMemoryUsage() {
|
||||
return _textureGPUFramebufferMemoryUsage.load();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUSparseMemoryUsage() {
|
||||
return _textureGPUSparseMemoryUsage.load();
|
||||
}
|
||||
|
@ -329,6 +345,7 @@ void Backend::incrementTextureGPUSparseCount() { Context::incrementTextureGPUSpa
|
|||
void Backend::decrementTextureGPUSparseCount() { Context::decrementTextureGPUSparseCount(); }
|
||||
void Backend::updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUVirtualMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUFramebufferMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUSparseMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::incrementTextureGPUTransferCount() { Context::incrementTextureGPUTransferCount(); }
|
||||
void Backend::decrementTextureGPUTransferCount() { Context::decrementTextureGPUTransferCount(); }
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
static void updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void incrementTextureGPUTransferCount();
|
||||
static void decrementTextureGPUTransferCount();
|
||||
|
||||
|
@ -210,6 +211,7 @@ public:
|
|||
static Size getFreeGPUMemory();
|
||||
static Size getTextureGPUMemoryUsage();
|
||||
static Size getTextureGPUVirtualMemoryUsage();
|
||||
static Size getTextureGPUFramebufferMemoryUsage();
|
||||
static Size getTextureGPUSparseMemoryUsage();
|
||||
static uint32_t getTextureGPUTransferCount();
|
||||
|
||||
|
@ -249,6 +251,7 @@ protected:
|
|||
static void updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUSparseMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUFramebufferMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void incrementTextureGPUTransferCount();
|
||||
static void decrementTextureGPUTransferCount();
|
||||
|
||||
|
@ -264,6 +267,7 @@ protected:
|
|||
static std::atomic<Size> _textureGPUMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUSparseMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUVirtualMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUFramebufferMemoryUsage;
|
||||
static std::atomic<uint32_t> _textureGPUTransferCount;
|
||||
|
||||
|
||||
|
|
|
@ -102,6 +102,11 @@ Texture::Size Texture::getTextureGPUVirtualMemoryUsage() {
|
|||
return Context::getTextureGPUVirtualMemoryUsage();
|
||||
}
|
||||
|
||||
|
||||
Texture::Size Texture::getTextureGPUFramebufferMemoryUsage() {
|
||||
return Context::getTextureGPUFramebufferMemoryUsage();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureGPUSparseMemoryUsage() {
|
||||
return Context::getTextureGPUSparseMemoryUsage();
|
||||
}
|
||||
|
|
|
@ -154,6 +154,7 @@ public:
|
|||
static uint32_t getTextureGPUSparseCount();
|
||||
static Size getTextureGPUMemoryUsage();
|
||||
static Size getTextureGPUVirtualMemoryUsage();
|
||||
static Size getTextureGPUFramebufferMemoryUsage();
|
||||
static Size getTextureGPUSparseMemoryUsage();
|
||||
static uint32_t getTextureGPUTransferCount();
|
||||
static Size getAllowedGPUMemoryUsage();
|
||||
|
|
|
@ -47,7 +47,7 @@ bool AddressManager::isConnected() {
|
|||
return DependencyManager::get<NodeList>()->getDomainHandler().isConnected();
|
||||
}
|
||||
|
||||
QUrl AddressManager::currentAddress() const {
|
||||
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
||||
QUrl hifiURL;
|
||||
|
||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||
|
@ -57,7 +57,9 @@ QUrl AddressManager::currentAddress() const {
|
|||
hifiURL.setPort(_port);
|
||||
}
|
||||
|
||||
hifiURL.setPath(currentPath());
|
||||
if (!domainOnly) {
|
||||
hifiURL.setPath(currentPath());
|
||||
}
|
||||
|
||||
return hifiURL;
|
||||
}
|
||||
|
@ -69,8 +71,7 @@ QUrl AddressManager::currentFacingAddress() const {
|
|||
return hifiURL;
|
||||
}
|
||||
|
||||
|
||||
QUrl AddressManager::currentShareableAddress() const {
|
||||
QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
|
||||
if (!_shareablePlaceName.isEmpty()) {
|
||||
// if we have a shareable place name use that instead of whatever the current host is
|
||||
QUrl hifiURL;
|
||||
|
@ -78,11 +79,13 @@ QUrl AddressManager::currentShareableAddress() const {
|
|||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||
hifiURL.setHost(_shareablePlaceName);
|
||||
|
||||
hifiURL.setPath(currentPath());
|
||||
if (!domainOnly) {
|
||||
hifiURL.setPath(currentPath());
|
||||
}
|
||||
|
||||
return hifiURL;
|
||||
} else {
|
||||
return currentAddress();
|
||||
return currentAddress(domainOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,9 @@ public:
|
|||
bool isConnected();
|
||||
const QString& getProtocol() { return HIFI_URL_SCHEME; };
|
||||
|
||||
QUrl currentAddress() const;
|
||||
QUrl currentAddress(bool domainOnly = false) const;
|
||||
QUrl currentFacingAddress() const;
|
||||
QUrl currentShareableAddress() const;
|
||||
QUrl currentShareableAddress(bool domainOnly = false) const;
|
||||
QUrl currentFacingShareableAddress() const;
|
||||
QString currentPath(bool withOrientation = true) const;
|
||||
QString currentFacingPath() const;
|
||||
|
|
|
@ -862,8 +862,12 @@ void Model::setURL(const QUrl& url) {
|
|||
{
|
||||
render::PendingChanges pendingChanges;
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
removeFromScene(scene, pendingChanges);
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
if (scene) {
|
||||
removeFromScene(scene, pendingChanges);
|
||||
scene->enqueuePendingChanges(pendingChanges);
|
||||
} else {
|
||||
qCWarning(renderutils) << "Model::setURL(), Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
}
|
||||
|
||||
_needsReload = true;
|
||||
|
|
|
@ -48,6 +48,10 @@ Scene::Scene(glm::vec3 origin, float size) :
|
|||
_items.push_back(Item()); // add the itemID #0 to nothing
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
qDebug() << "Scene::~Scene()";
|
||||
}
|
||||
|
||||
ItemID Scene::allocateID() {
|
||||
// Just increment and return the proevious value initialized at 0
|
||||
return _IDAllocator.fetch_add(1);
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef std::queue<PendingChanges> PendingChangesQueue;
|
|||
class Scene {
|
||||
public:
|
||||
Scene(glm::vec3 origin, float size);
|
||||
~Scene() {}
|
||||
~Scene();
|
||||
|
||||
// This call is thread safe, can be called from anywhere to allocate a new ID
|
||||
ItemID allocateID();
|
||||
|
|
|
@ -47,7 +47,7 @@ void RunningMarker::startRunningMarker() {
|
|||
|
||||
RunningMarker::~RunningMarker() {
|
||||
deleteRunningMarkerFile();
|
||||
_runningMarkerTimer->stop();
|
||||
QMetaObject::invokeMethod(_runningMarkerTimer, "stop", Qt::BlockingQueuedConnection);
|
||||
_runningMarkerThread->quit();
|
||||
_runningMarkerTimer->deleteLater();
|
||||
_runningMarkerThread->deleteLater();
|
||||
|
|
|
@ -304,9 +304,9 @@ function setEnabled(value) {
|
|||
|
||||
var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable";
|
||||
var handleMessage = function(channel, message, sender) {
|
||||
print("Got away message");
|
||||
if (channel == CHANNEL_AWAY_ENABLE) {
|
||||
setEnabled(message == 'enable');
|
||||
if (channel === CHANNEL_AWAY_ENABLE) {
|
||||
print("away.js | Got message on Hifi-Away-Enable: ", message);
|
||||
setEnabled(message === 'enable');
|
||||
}
|
||||
}
|
||||
Messages.subscribe(CHANNEL_AWAY_ENABLE);
|
||||
|
@ -343,6 +343,7 @@ Script.scriptEnding.connect(function () {
|
|||
Controller.disableMapping(eventMappingName);
|
||||
Controller.mousePressEvent.disconnect(goActive);
|
||||
Controller.keyPressEvent.disconnect(maybeGoActive);
|
||||
Messages.messageReceived.disconnect(handleMessage);
|
||||
});
|
||||
|
||||
if (HMD.active && !HMD.mounted) {
|
||||
|
|
Loading…
Reference in a new issue