History

TransitionStage + FadeJob compiling but not linked to entity events

Olivier Prat committed 9 years ago

Commit 06d69d02 parents 4256a1f d15c4ea87 files · +1613 −729Browse files

Showing the changes to interface/src/Application.cpp (1 of 87 files). Show all

Unified · Split

interface/src/Application.cpp+378−133
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <QtCore/QCommandLineParser>
2626 #include <QtCore/QMimeData>
2727 #include <QtCore/QThreadPool>
28+#include <QtConcurrent/QtConcurrentRun>
2829
2930 #include <QtGui/QScreen>
3031 #include <QtGui/QWindow>
@@ -111,10 +112,7 @@ · 80 unmodified lines
111112 #include <plugins/InputConfiguration.h>
112113 #include <RecordingScriptingInterface.h>
113114 #include <RenderableWebEntityItem.h>
114−#include <RenderShadowTask.h>
115−#include <render/RenderFetchCullSortTask.h>
116−#include <RenderDeferredTask.h>
117−#include <RenderForwardTask.h>
115+#include <UpdateSceneTask.h>
118116 #include <RenderViewTask.h>
119117 #include <SecondaryCamera.h>
120118 #include <ResourceCache.h>
@@ -480,6 +478,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 359 unmodified lines
480478 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
481479 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);
482480 bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt);
481+ // get dir to use for cache
482+ static const auto CACHE_SWITCH = "--cache";
483+ QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH);
484+ if (!cacheDir.isEmpty()) {
485+ qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
486+ }
483487
484488 Setting::init();
485489
@@ -993,12 +997,67 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 507 unmodified lines
993997
994998 // add firstRun flag from settings to launch event
995999 Setting::Handle<bool> firstRun { Settings::firstRun, true };
996− properties["first_run"] = firstRun.get();
997−
998− // add the user's machine ID to the launch event
999− properties["machine_fingerprint"] = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
10001000
1001− UserActivityLogger::getInstance().logAction("launch", properties);
1001+ // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
1002+ auto& userActivityLogger = UserActivityLogger::getInstance();
1003+ if (!userActivityLogger.isDisabledSettingSet()) {
1004+ // the user activity logger is opt-out for Interface
1005+ // but it's defaulted to disabled for other targets
1006+ // so we need to enable it here if it has never been disabled by the user
1007+ userActivityLogger.disable(false);
1008+ }
1009+
1010+ if (userActivityLogger.isEnabled()) {
1011+ // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
1012+ // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
1013+ static const QString TESTER = "HIFI_TESTER";
1014+ auto gpuIdent = GPUIdent::getInstance();
1015+ auto glContextData = getGLContextData();
1016+ QJsonObject properties = {
1017+ { "version", applicationVersion() },
1018+ { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
1019+ { "previousSessionCrashed", _previousSessionCrashed },
1020+ { "previousSessionRuntime", sessionRunTime.get() },
1021+ { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
1022+ { "kernel_type", QSysInfo::kernelType() },
1023+ { "kernel_version", QSysInfo::kernelVersion() },
1024+ { "os_type", QSysInfo::productType() },
1025+ { "os_version", QSysInfo::productVersion() },
1026+ { "gpu_name", gpuIdent->getName() },
1027+ { "gpu_driver", gpuIdent->getDriver() },
1028+ { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) },
1029+ { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
1030+ { "gl_version", glContextData["version"] },
1031+ { "gl_vender", glContextData["vendor"] },
1032+ { "gl_sl_version", glContextData["sl_version"] },
1033+ { "gl_renderer", glContextData["renderer"] },
1034+ { "ideal_thread_count", QThread::idealThreadCount() }
1035+ };
1036+ auto macVersion = QSysInfo::macVersion();
1037+ if (macVersion != QSysInfo::MV_None) {
1038+ properties["os_osx_version"] = QSysInfo::macVersion();
1039+ }
1040+ auto windowsVersion = QSysInfo::windowsVersion();
1041+ if (windowsVersion != QSysInfo::WV_None) {
1042+ properties["os_win_version"] = QSysInfo::windowsVersion();
1043+ }
1044+
1045+ ProcessorInfo procInfo;
1046+ if (getProcessorInfo(procInfo)) {
1047+ properties["processor_core_count"] = procInfo.numProcessorCores;
1048+ properties["logical_processor_count"] = procInfo.numLogicalProcessors;
1049+ properties["processor_l1_cache_count"] = procInfo.numProcessorCachesL1;
1050+ properties["processor_l2_cache_count"] = procInfo.numProcessorCachesL2;
1051+ properties["processor_l3_cache_count"] = procInfo.numProcessorCachesL3;
1052+ }
1053+
1054+ properties["first_run"] = firstRun.get();
1055+
1056+ // add the user's machine ID to the launch event
1057+ properties["machine_fingerprint"] = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
1058+
1059+ userActivityLogger.logAction("launch", properties);
1060+ }
10021061
10031062 // Tell our entity edit sender about our known jurisdictions
10041063 _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
@@ -1220,8 +1279,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 215 unmodified lines
12201279 settingsTimer->stop();
12211280 // Delete it (this will trigger the thread destruction
12221281 settingsTimer->deleteLater();
1223− // Mark the settings thread as finished, so we know we can safely save in the main application
1224− // shutdown code
1282+ // Mark the settings thread as finished, so we know we can safely save in the main application
1283+ // shutdown code
12251284 _settingsGuard.trigger();
12261285 });
12271286
@@ -1958,6 +2017,7 @@ void Application::initializeGL() { · 730 unmodified lines
19582017 render::CullFunctor cullFunctor = LODManager::shouldRender;
19592018 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
19602019 bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
2020+ _renderEngine->addJob<UpdateSceneTask>("UpdateScene");
19612021 _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);
19622022 _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
19632023 _renderEngine->load();
@@ -2166,48 +2226,74 @@ void Application::paintGL() { · 202 unmodified lines
21662226 return;
21672227 }
21682228
2169− auto displayPlugin = getActiveDisplayPlugin();
2170− // FIXME not needed anymore?
2171− _offscreenContext->makeCurrent();
2229+ DisplayPluginPointer displayPlugin;
2230+ {
2231+ PROFILE_RANGE(render, "/getActiveDisplayPlugin");
2232+ displayPlugin = getActiveDisplayPlugin();
2233+ }
21722234
2173− // If a display plugin loses it's underlying support, it
2174− // needs to be able to signal us to not use it
2175− if (!displayPlugin->beginFrameRender(_frameCount)) {
2176− _inPaint = false;
2177− updateDisplayMode();
2178− return;
2235+ {
2236+ PROFILE_RANGE(render, "/offscreenMakeCurrent");
2237+ // FIXME not needed anymore?
2238+ _offscreenContext->makeCurrent();
2239+ }
2240+
2241+ {
2242+ PROFILE_RANGE(render, "/pluginBeginFrameRender");
2243+ // If a display plugin loses it's underlying support, it
2244+ // needs to be able to signal us to not use it
2245+ if (!displayPlugin->beginFrameRender(_frameCount)) {
2246+ _inPaint = false;
2247+ updateDisplayMode();
2248+ return;
2249+ }
21792250 }
21802251
21812252 // update the avatar with a fresh HMD pose
2182− getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose());
2253+ {
2254+ PROFILE_RANGE(render, "/updateAvatar");
2255+ getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose());
2256+ }
21832257
21842258 auto lodManager = DependencyManager::get<LODManager>();
21852259
2260+ RenderArgs renderArgs;
21862261 {
2187− QMutexLocker viewLocker(&_viewMutex);
2188− _viewFrustum.calculate();
2262+ PROFILE_RANGE(render, "/buildFrustrumAndArgs");
2263+ {
2264+ QMutexLocker viewLocker(&_viewMutex);
2265+ _viewFrustum.calculate();
2266+ }
2267+ renderArgs = RenderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(),
2268+ lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
2269+ RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
2270+ {
2271+ QMutexLocker viewLocker(&_viewMutex);
2272+ renderArgs.setViewFrustum(_viewFrustum);
2273+ }
21892274 }
2190− RenderArgs renderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(),
2191− lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
2192− RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
2275+
21932276 {
2194− QMutexLocker viewLocker(&_viewMutex);
2195− renderArgs.setViewFrustum(_viewFrustum);
2277+ PROFILE_RANGE(render, "/resizeGL");
2278+ PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
2279+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2280+ PerformanceWarning warn(showWarnings, "Application::paintGL()");
2281+ resizeGL();
21962282 }
21972283
2198− PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
2199− bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2200− PerformanceWarning warn(showWarnings, "Application::paintGL()");
2201− resizeGL();
2284+ {
2285+ PROFILE_RANGE(render, "/gpuContextReset");
2286+ _gpuContext->beginFrame(getHMDSensorPose());
2287+ // Reset the gpu::Context Stages
2288+ // Back to the default framebuffer;
2289+ gpu::doInBatch(_gpuContext, [&](gpu::Batch& batch) {
2290+ batch.resetStages();
2291+ });
2292+ }
22022293
2203− _gpuContext->beginFrame(getHMDSensorPose());
2204− // Reset the gpu::Context Stages
2205− // Back to the default framebuffer;
2206− gpu::doInBatch(_gpuContext, [&](gpu::Batch& batch) {
2207− batch.resetStages();
2208− });
22092294
22102295 {
2296+ PROFILE_RANGE(render, "/renderOverlay");
22112297 PerformanceTimer perfTimer("renderOverlay");
22122298 // NOTE: There is no batch associated with this renderArgs
22132299 // the ApplicationOverlay class assumes it's viewport is setup to be the device size
@@ -2218,114 +2304,127 @@ void Application::paintGL() { · 4 unmodified lines
22182304
22192305 glm::vec3 boomOffset;
22202306 {
2221− PerformanceTimer perfTimer("CameraUpdates");
2307+ PROFILE_RANGE(render, "/updateCamera");
2308+ {
2309+ PerformanceTimer perfTimer("CameraUpdates");
22222310
2223− auto myAvatar = getMyAvatar();
2224− boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
2311+ auto myAvatar = getMyAvatar();
2312+ boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
22252313
2226− if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2227− Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
2228− Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
2229− cameraMenuChanged();
2230− }
2314+ if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2315+ Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
2316+ Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
2317+ cameraMenuChanged();
2318+ }
22312319
2232− // The render mode is default or mirror if the camera is in mirror mode, assigned further below
2233− renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
2320+ // The render mode is default or mirror if the camera is in mirror mode, assigned further below
2321+ renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
22342322
2235− // Always use the default eye position, not the actual head eye position.
2236− // Using the latter will cause the camera to wobble with idle animations,
2237− // or with changes from the face tracker
2238− if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
2239− if (isHMDMode()) {
2240− mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2241− _myCamera.setPosition(extractTranslation(camMat));
2242− _myCamera.setOrientation(glm::quat_cast(camMat));
2243− } else {
2244− _myCamera.setPosition(myAvatar->getDefaultEyePosition());
2245− _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation());
2246− }
2247− } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2248− if (isHMDMode()) {
2249− auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2250− _myCamera.setOrientation(glm::normalize(glm::quat_cast(hmdWorldMat)));
2251− _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2252− myAvatar->getOrientation() * boomOffset);
2253− } else {
2254− _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
2255− if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
2256− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2257− + _myCamera.getOrientation() * boomOffset);
2323+ // Always use the default eye position, not the actual head eye position.
2324+ // Using the latter will cause the camera to wobble with idle animations,
2325+ // or with changes from the face tracker
2326+ if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
2327+ if (isHMDMode()) {
2328+ mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2329+ _myCamera.setPosition(extractTranslation(camMat));
2330+ _myCamera.setOrientation(glm::quat_cast(camMat));
22582331 } else {
2259− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2260− + myAvatar->getOrientation() * boomOffset);
2332+ _myCamera.setPosition(myAvatar->getDefaultEyePosition());
2333+ _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation());
22612334 }
2262− }
2263− } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2264− if (isHMDMode()) {
2265− auto mirrorBodyOrientation = myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
2266−
2267− glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2268− // Mirror HMD yaw and roll
2269− glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation);
2270− mirrorHmdEulers.y = -mirrorHmdEulers.y;
2271− mirrorHmdEulers.z = -mirrorHmdEulers.z;
2272− glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers);
2335+ } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2336+ if (isHMDMode()) {
2337+ auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2338+ _myCamera.setOrientation(glm::normalize(glm::quat_cast(hmdWorldMat)));
2339+ _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2340+ myAvatar->getOrientation() * boomOffset);
2341+ } else {
2342+ _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
2343+ if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
2344+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2345+ + _myCamera.getOrientation() * boomOffset);
2346+ } else {
2347+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2348+ + myAvatar->getOrientation() * boomOffset);
2349+ }
2350+ }
2351+ } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2352+ if (isHMDMode()) {
2353+ auto mirrorBodyOrientation = myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
22732354
2274− glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
2355+ glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2356+ // Mirror HMD yaw and roll
2357+ glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation);
2358+ mirrorHmdEulers.y = -mirrorHmdEulers.y;
2359+ mirrorHmdEulers.z = -mirrorHmdEulers.z;
2360+ glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers);
22752361
2276− _myCamera.setOrientation(worldMirrorRotation);
2362+ glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
22772363
2278− glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2279− // Mirror HMD lateral offsets
2280− hmdOffset.x = -hmdOffset.x;
2364+ _myCamera.setOrientation(worldMirrorRotation);
22812365
2282− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2283− + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2284− + mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
2285− + mirrorBodyOrientation * hmdOffset);
2286− } else {
2287− _myCamera.setOrientation(myAvatar->getWorldAlignedOrientation()
2288− * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
2289− _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2290− + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2291− + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
2292− glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
2293− }
2294− renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
2295− } else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
2296− EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer();
2297− if (cameraEntity != nullptr) {
2298− if (isHMDMode()) {
2299− glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2300− _myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
23012366 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2302− _myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
2367+ // Mirror HMD lateral offsets
2368+ hmdOffset.x = -hmdOffset.x;
2369+
2370+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2371+ + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2372+ + mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
2373+ + mirrorBodyOrientation * hmdOffset);
23032374 } else {
2304− _myCamera.setOrientation(cameraEntity->getRotation());
2305− _myCamera.setPosition(cameraEntity->getPosition());
2375+ _myCamera.setOrientation(myAvatar->getWorldAlignedOrientation()
2376+ * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
2377+ _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2378+ + glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
2379+ + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
2380+ glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
2381+ }
2382+ renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
2383+ } else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
2384+ EntityItemPointer cameraEntity = _myCamera.getCameraEntityPointer();
2385+ if (cameraEntity != nullptr) {
2386+ if (isHMDMode()) {
2387+ glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2388+ _myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
2389+ glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2390+ _myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
2391+ } else {
2392+ _myCamera.setOrientation(cameraEntity->getRotation());
2393+ _myCamera.setPosition(cameraEntity->getPosition());
2394+ }
23062395 }
23072396 }
2308− }
2309− // Update camera position
2310− if (!isHMDMode()) {
2311− _myCamera.update(1.0f / _frameCounter.rate());
2397+ // Update camera position
2398+ if (!isHMDMode()) {
2399+ _myCamera.update(1.0f / _frameCounter.rate());
2400+ }
23122401 }
23132402 }
23142403
2315− getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform());
2404+ {
2405+ PROFILE_RANGE(render, "/updateCompositor");
2406+ getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform());
2407+ }
23162408
2317− // Primary rendering pass
2318− auto framebufferCache = DependencyManager::get<FramebufferCache>();
2319− const QSize size = framebufferCache->getFrameBufferSize();
2320− // Final framebuffer that will be handled to the display-plugin
2321− auto finalFramebuffer = framebufferCache->getFramebuffer();
2409+ gpu::FramebufferPointer finalFramebuffer;
2410+ QSize finalFramebufferSize;
2411+ {
2412+ PROFILE_RANGE(render, "/getOutputFramebuffer");
2413+ // Primary rendering pass
2414+ auto framebufferCache = DependencyManager::get<FramebufferCache>();
2415+ finalFramebufferSize = framebufferCache->getFrameBufferSize();
2416+ // Final framebuffer that will be handled to the display-plugin
2417+ finalFramebuffer = framebufferCache->getFramebuffer();
2418+ }
23222419
23232420 {
23242421 PROFILE_RANGE(render, "/mainRender");
23252422 PerformanceTimer perfTimer("mainRender");
23262423 renderArgs._boomOffset = boomOffset;
2424+ // FIXME is this ever going to be different from the size previously set in the render args
2425+ // in the overlay render?
23272426 // Viewport is assigned to the size of the framebuffer
2328− renderArgs._viewport = ivec4(0, 0, size.width(), size.height());
2427+ renderArgs._viewport = ivec4(0, 0, finalFramebufferSize.width(), finalFramebufferSize.height());
23292428 if (displayPlugin->isStereo()) {
23302429 // Stereo modes will typically have a larger projection matrix overall,
23312430 // so we ask for the 'mono' projection matrix, which for stereo and HMD
@@ -3625,6 +3724,133 @@ bool Application::shouldPaint(float nsecsElapsed) { · 1293 unmodified lines
36253724 #include <TCHAR.h>
36263725 #include <pdh.h>
36273726 #pragma comment(lib, "pdh.lib")
3727+#pragma comment(lib, "ntdll.lib")
3728+
3729+extern "C" {
3730+ enum SYSTEM_INFORMATION_CLASS {
3731+ SystemBasicInformation = 0,
3732+ SystemProcessorPerformanceInformation = 8,
3733+ };
3734+
3735+ struct SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
3736+ LARGE_INTEGER IdleTime;
3737+ LARGE_INTEGER KernelTime;
3738+ LARGE_INTEGER UserTime;
3739+ LARGE_INTEGER DpcTime;
3740+ LARGE_INTEGER InterruptTime;
3741+ ULONG InterruptCount;
3742+ };
3743+
3744+ struct SYSTEM_BASIC_INFORMATION {
3745+ ULONG Reserved;
3746+ ULONG TimerResolution;
3747+ ULONG PageSize;
3748+ ULONG NumberOfPhysicalPages;
3749+ ULONG LowestPhysicalPageNumber;
3750+ ULONG HighestPhysicalPageNumber;
3751+ ULONG AllocationGranularity;
3752+ ULONG_PTR MinimumUserModeAddress;
3753+ ULONG_PTR MaximumUserModeAddress;
3754+ ULONG_PTR ActiveProcessorsAffinityMask;
3755+ CCHAR NumberOfProcessors;
3756+ };
3757+
3758+ NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemInformation(
3759+ _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
3760+ _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
3761+ _In_ ULONG SystemInformationLength,
3762+ _Out_opt_ PULONG ReturnLength
3763+ );
3764+
3765+}
3766+template <typename T>
3767+NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, T& t) {
3768+ return NtQuerySystemInformation(SystemInformationClass, &t, (ULONG)sizeof(T), nullptr);
3769+}
3770+
3771+template <typename T>
3772+NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, std::vector<T>& t) {
3773+ return NtQuerySystemInformation(SystemInformationClass, t.data(), (ULONG)(sizeof(T) * t.size()), nullptr);
3774+}
3775+
3776+
3777+template <typename T>
3778+void updateValueAndDelta(std::pair<T, T>& pair, T newValue) {
3779+ auto& value = pair.first;
3780+ auto& delta = pair.second;
3781+ delta = (value != 0) ? newValue - value : 0;
3782+ value = newValue;
3783+}
3784+
3785+struct MyCpuInfo {
3786+ using ValueAndDelta = std::pair<LONGLONG, LONGLONG>;
3787+ std::string name;
3788+ ValueAndDelta kernel { 0, 0 };
3789+ ValueAndDelta user { 0, 0 };
3790+ ValueAndDelta idle { 0, 0 };
3791+ float kernelUsage { 0.0f };
3792+ float userUsage { 0.0f };
3793+
3794+ void update(const SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION& cpuInfo) {
3795+ updateValueAndDelta(kernel, cpuInfo.KernelTime.QuadPart);
3796+ updateValueAndDelta(user, cpuInfo.UserTime.QuadPart);
3797+ updateValueAndDelta(idle, cpuInfo.IdleTime.QuadPart);
3798+ auto totalTime = kernel.second + user.second + idle.second;
3799+ if (totalTime != 0) {
3800+ kernelUsage = (FLOAT)kernel.second / totalTime;
3801+ userUsage = (FLOAT)user.second / totalTime;
3802+ } else {
3803+ kernelUsage = userUsage = 0.0f;
3804+ }
3805+ }
3806+};
3807+
3808+void updateCpuInformation() {
3809+ static std::once_flag once;
3810+ static SYSTEM_BASIC_INFORMATION systemInfo {};
3811+ static SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION cpuTotals;
3812+ static std::vector<SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION> cpuInfos;
3813+ static std::vector<MyCpuInfo> myCpuInfos;
3814+ static MyCpuInfo myCpuTotals;
3815+ std::call_once(once, [&] {
3816+ NtQuerySystemInformation( SystemBasicInformation, systemInfo);
3817+ cpuInfos.resize(systemInfo.NumberOfProcessors);
3818+ myCpuInfos.resize(systemInfo.NumberOfProcessors);
3819+ for (size_t i = 0; i < systemInfo.NumberOfProcessors; ++i) {
3820+ myCpuInfos[i].name = "cpu." + std::to_string(i);
3821+ }
3822+ myCpuTotals.name = "cpu.total";
3823+ });
3824+ NtQuerySystemInformation(SystemProcessorPerformanceInformation, cpuInfos);
3825+
3826+ // Zero the CPU totals.
3827+ memset(&cpuTotals, 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION));
3828+ for (size_t i = 0; i < systemInfo.NumberOfProcessors; ++i) {
3829+ auto& cpuInfo = cpuInfos[i];
3830+ // KernelTime includes IdleTime.
3831+ cpuInfo.KernelTime.QuadPart -= cpuInfo.IdleTime.QuadPart;
3832+
3833+ // Update totals
3834+ cpuTotals.IdleTime.QuadPart += cpuInfo.IdleTime.QuadPart;
3835+ cpuTotals.KernelTime.QuadPart += cpuInfo.KernelTime.QuadPart;
3836+ cpuTotals.UserTime.QuadPart += cpuInfo.UserTime.QuadPart;
3837+
3838+ // Update friendly structure
3839+ auto& myCpuInfo = myCpuInfos[i];
3840+ myCpuInfo.update(cpuInfo);
3841+ PROFILE_COUNTER(app, myCpuInfo.name.c_str(), {
3842+ { "kernel", myCpuInfo.kernelUsage },
3843+ { "user", myCpuInfo.userUsage }
3844+ });
3845+ }
3846+
3847+ myCpuTotals.update(cpuTotals);
3848+ PROFILE_COUNTER(app, myCpuTotals.name.c_str(), {
3849+ { "kernel", myCpuTotals.kernelUsage },
3850+ { "user", myCpuTotals.userUsage }
3851+ });
3852+}
3853+
36283854
36293855 static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
36303856 static int numProcessors;
@@ -3677,6 +3903,26 @@ void getCpuUsage(vec3& systemAndUser) { · 46 unmodified lines
36773903 systemAndUser.z = (float)counterVal.doubleValue;
36783904 }
36793905
3906+void setupCpuMonitorThread() {
3907+ initCpuUsage();
3908+ auto cpuMonitorThread = QThread::currentThread();
3909+
3910+ QTimer* timer = new QTimer();
3911+ timer->setInterval(50);
3912+ QObject::connect(timer, &QTimer::timeout, [] {
3913+ updateCpuInformation();
3914+ vec3 kernelUserAndSystem;
3915+ getCpuUsage(kernelUserAndSystem);
3916+ PROFILE_COUNTER(app, "cpuProcess", { { "system", kernelUserAndSystem.x }, { "user", kernelUserAndSystem.y } });
3917+ PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });
3918+ });
3919+ QObject::connect(cpuMonitorThread, &QThread::finished, [=] {
3920+ timer->deleteLater();
3921+ cpuMonitorThread->deleteLater();
3922+ });
3923+ timer->start();
3924+}
3925+
36803926 #endif
36813927
36823928
@@ -3697,15 +3943,17 @@ void Application::idle(float nsecsElapsed) { · 14 unmodified lines
36973943 }
36983944
36993945 #ifdef Q_OS_WIN
3946+ // If tracing is enabled then monitor the CPU in a separate thread
37003947 static std::once_flag once;
3701− std::call_once(once, [] {
3702− initCpuUsage();
3948+ std::call_once(once, [&] {
3949+ if (trace_app().isDebugEnabled()) {
3950+ QThread* cpuMonitorThread = new QThread(qApp);
3951+ cpuMonitorThread->setObjectName("cpuMonitorThread");
3952+ QObject::connect(cpuMonitorThread, &QThread::started, [this] { setupCpuMonitorThread(); });
3953+ QObject::connect(qApp, &QCoreApplication::aboutToQuit, cpuMonitorThread, &QThread::quit);
3954+ cpuMonitorThread->start();
3955+ }
37033956 });
3704−
3705− vec3 kernelUserAndSystem;
3706− getCpuUsage(kernelUserAndSystem);
3707− PROFILE_COUNTER(app, "cpuProcess", { { "system", kernelUserAndSystem.x }, { "user", kernelUserAndSystem.y } });
3708− PROFILE_COUNTER(app, "cpuSystem", { { "system", kernelUserAndSystem.z } });
37093957 #endif
37103958
37113959
@@ -5175,7 +5423,7 @@ namespace render { · 1463 unmodified lines
51755423
51765424 auto& batch = *args->_batch;
51775425 DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch);
5178− renderWorldBox(batch);
5426+ renderWorldBox(args, batch);
51795427 }
51805428 }
51815429 }
@@ -5238,10 +5486,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 56 unmodified lines
52385486 }
52395487
52405488 {
5241− PerformanceTimer perfTimer("SceneProcessTransaction");
52425489 _main3DScene->enqueueTransaction(transaction);
5243−
5244− _main3DScene->processTransactionQueue();
52455490 }
52465491
52475492 // For now every frame pass the renderContext

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t