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
25#include <QtCore/QCommandLineParser>25#include <QtCore/QCommandLineParser>
26#include <QtCore/QMimeData>26#include <QtCore/QMimeData>
27#include <QtCore/QThreadPool>27#include <QtCore/QThreadPool>
28#include <QtConcurrent/QtConcurrentRun>
28 29
29#include <QtGui/QScreen>30#include <QtGui/QScreen>
30#include <QtGui/QWindow>31#include <QtGui/QWindow>
@@ -111,10 +112,7 @@ · 80 unmodified lines
111#include <plugins/InputConfiguration.h>112#include <plugins/InputConfiguration.h>
112#include <RecordingScriptingInterface.h>113#include <RecordingScriptingInterface.h>
113#include <RenderableWebEntityItem.h>114#include <RenderableWebEntityItem.h>
114#include <RenderShadowTask.h>115#include <UpdateSceneTask.h>
115#include <render/RenderFetchCullSortTask.h>
116#include <RenderDeferredTask.h>
117#include <RenderForwardTask.h>
118#include <RenderViewTask.h>116#include <RenderViewTask.h>
119#include <SecondaryCamera.h>117#include <SecondaryCamera.h>
120#include <ResourceCache.h>118#include <ResourceCache.h>
@@ -480,6 +478,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 359 unmodified lines
480 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";478 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
481 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);479 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);
482 bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt);480 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 }
483 487
484 Setting::init();488 Setting::init();
485 489
@@ -993,12 +997,67 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 507 unmodified lines
993 997
994 // add firstRun flag from settings to launch event998 // add firstRun flag from settings to launch event
995 Setting::Handle<bool> firstRun { Settings::firstRun, true };999 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());
1000 1000
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 }
1002 1061
1003 // Tell our entity edit sender about our known jurisdictions1062 // Tell our entity edit sender about our known jurisdictions
1004 _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);1063 _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
@@ -1220,8 +1279,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 215 unmodified lines
1220 settingsTimer->stop();1279 settingsTimer->stop();
1221 // Delete it (this will trigger the thread destruction1280 // Delete it (this will trigger the thread destruction
1222 settingsTimer->deleteLater();1281 settingsTimer->deleteLater();
1223 // Mark the settings thread as finished, so we know we can safely save in the main application 1282 // Mark the settings thread as finished, so we know we can safely save in the main application
1224 // shutdown code 1283 // shutdown code
1225 _settingsGuard.trigger();1284 _settingsGuard.trigger();
1226 });1285 });
1227 1286
@@ -1958,6 +2017,7 @@ void Application::initializeGL() { · 730 unmodified lines
1958 render::CullFunctor cullFunctor = LODManager::shouldRender;2017 render::CullFunctor cullFunctor = LODManager::shouldRender;
1959 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";2018 static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
1960 bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);2019 bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
2020 _renderEngine->addJob<UpdateSceneTask>("UpdateScene");
1961 _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);2021 _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);
1962 _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);2022 _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
1963 _renderEngine->load();2023 _renderEngine->load();
@@ -2166,48 +2226,74 @@ void Application::paintGL() { · 202 unmodified lines
2166 return;2226 return;
2167 }2227 }
2168 2228
2169 auto displayPlugin = getActiveDisplayPlugin();2229 DisplayPluginPointer displayPlugin;
2170 // FIXME not needed anymore?2230 {
2171 _offscreenContext->makeCurrent();2231 PROFILE_RANGE(render, "/getActiveDisplayPlugin");
2232 displayPlugin = getActiveDisplayPlugin();
2233 }
2172 2234
2173 // If a display plugin loses it's underlying support, it2235 {
2174 // needs to be able to signal us to not use it2236 PROFILE_RANGE(render, "/offscreenMakeCurrent");
2175 if (!displayPlugin->beginFrameRender(_frameCount)) {2237 // FIXME not needed anymore?
2176 _inPaint = false;2238 _offscreenContext->makeCurrent();
2177 updateDisplayMode();2239 }
2178 return;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 }
2179 }2250 }
2180 2251
2181 // update the avatar with a fresh HMD pose2252 // update the avatar with a fresh HMD pose
2182 getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose());2253 {
2254 PROFILE_RANGE(render, "/updateAvatar");
2255 getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose());
2256 }
2183 2257
2184 auto lodManager = DependencyManager::get<LODManager>();2258 auto lodManager = DependencyManager::get<LODManager>();
2185 2259
2260 RenderArgs renderArgs;
2186 {2261 {
2187 QMutexLocker viewLocker(&_viewMutex);2262 PROFILE_RANGE(render, "/buildFrustrumAndArgs");
2188 _viewFrustum.calculate();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 }
2189 }2274 }
2190 RenderArgs renderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(),2275
2191 lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
2192 RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
2193 {2276 {
2194 QMutexLocker viewLocker(&_viewMutex);2277 PROFILE_RANGE(render, "/resizeGL");
2195 renderArgs.setViewFrustum(_viewFrustum);2278 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
2279 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2280 PerformanceWarning warn(showWarnings, "Application::paintGL()");
2281 resizeGL();
2196 }2282 }
2197 2283
2198 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));2284 {
2199 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);2285 PROFILE_RANGE(render, "/gpuContextReset");
2200 PerformanceWarning warn(showWarnings, "Application::paintGL()");2286 _gpuContext->beginFrame(getHMDSensorPose());
2201 resizeGL();2287 // Reset the gpu::Context Stages
2288 // Back to the default framebuffer;
2289 gpu::doInBatch(_gpuContext, [&](gpu::Batch& batch) {
2290 batch.resetStages();
2291 });
2292 }
2202 2293
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 });
2209 2294
2210 {2295 {
2296 PROFILE_RANGE(render, "/renderOverlay");
2211 PerformanceTimer perfTimer("renderOverlay");2297 PerformanceTimer perfTimer("renderOverlay");
2212 // NOTE: There is no batch associated with this renderArgs2298 // NOTE: There is no batch associated with this renderArgs
2213 // the ApplicationOverlay class assumes it's viewport is setup to be the device size2299 // the ApplicationOverlay class assumes it's viewport is setup to be the device size
@@ -2218,114 +2304,127 @@ void Application::paintGL() { · 4 unmodified lines
2218 2304
2219 glm::vec3 boomOffset;2305 glm::vec3 boomOffset;
2220 {2306 {
2221 PerformanceTimer perfTimer("CameraUpdates");2307 PROFILE_RANGE(render, "/updateCamera");
2308 {
2309 PerformanceTimer perfTimer("CameraUpdates");
2222 2310
2223 auto myAvatar = getMyAvatar();2311 auto myAvatar = getMyAvatar();
2224 boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;2312 boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
2225 2313
2226 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {2314 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2227 Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);2315 Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
2228 Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));2316 Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
2229 cameraMenuChanged();2317 cameraMenuChanged();
2230 }2318 }
2231 2319
2232 // The render mode is default or mirror if the camera is in mirror mode, assigned further below2320 // The render mode is default or mirror if the camera is in mirror mode, assigned further below
2233 renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;2321 renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
2234 2322
2235 // Always use the default eye position, not the actual head eye position.2323 // 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,2324 // Using the latter will cause the camera to wobble with idle animations,
2237 // or with changes from the face tracker2325 // or with changes from the face tracker
2238 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {2326 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
2239 if (isHMDMode()) {2327 if (isHMDMode()) {
2240 mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();2328 mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2241 _myCamera.setPosition(extractTranslation(camMat));2329 _myCamera.setPosition(extractTranslation(camMat));
2242 _myCamera.setOrientation(glm::quat_cast(camMat));2330 _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);
2258 } else {2331 } else {
2259 _myCamera.setPosition(myAvatar->getDefaultEyePosition()2332 _myCamera.setPosition(myAvatar->getDefaultEyePosition());
2260 + myAvatar->getOrientation() * boomOffset);2333 _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation());
2261 }2334 }
2262 }2335 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2263 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {2336 if (isHMDMode()) {
2264 if (isHMDMode()) {2337 auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
2265 auto mirrorBodyOrientation = myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));2338 _myCamera.setOrientation(glm::normalize(glm::quat_cast(hmdWorldMat)));
2266 2339 _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2267 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());2340 myAvatar->getOrientation() * boomOffset);
2268 // Mirror HMD yaw and roll2341 } else {
2269 glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation);2342 _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
2270 mirrorHmdEulers.y = -mirrorHmdEulers.y;2343 if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
2271 mirrorHmdEulers.z = -mirrorHmdEulers.z;2344 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2272 glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers);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));
2273 2354
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);
2275 2361
2276 _myCamera.setOrientation(worldMirrorRotation);2362 glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
2277 2363
2278 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());2364 _myCamera.setOrientation(worldMirrorRotation);
2279 // Mirror HMD lateral offsets
2280 hmdOffset.x = -hmdOffset.x;
2281 2365
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);
2301 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());2366 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);
2303 } else {2374 } else {
2304 _myCamera.setOrientation(cameraEntity->getRotation());2375 _myCamera.setOrientation(myAvatar->getWorldAlignedOrientation()
2305 _myCamera.setPosition(cameraEntity->getPosition());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 }
2306 }2395 }
2307 }2396 }
2308 }2397 // Update camera position
2309 // Update camera position2398 if (!isHMDMode()) {
2310 if (!isHMDMode()) {2399 _myCamera.update(1.0f / _frameCounter.rate());
2311 _myCamera.update(1.0f / _frameCounter.rate());2400 }
2312 }2401 }
2313 }2402 }
2314 2403
2315 getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform());2404 {
2405 PROFILE_RANGE(render, "/updateCompositor");
2406 getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform());
2407 }
2316 2408
2317 // Primary rendering pass2409 gpu::FramebufferPointer finalFramebuffer;
2318 auto framebufferCache = DependencyManager::get<FramebufferCache>();2410 QSize finalFramebufferSize;
2319 const QSize size = framebufferCache->getFrameBufferSize();2411 {
2320 // Final framebuffer that will be handled to the display-plugin2412 PROFILE_RANGE(render, "/getOutputFramebuffer");
2321 auto finalFramebuffer = framebufferCache->getFramebuffer();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 }
2322 2419
2323 {2420 {
2324 PROFILE_RANGE(render, "/mainRender");2421 PROFILE_RANGE(render, "/mainRender");
2325 PerformanceTimer perfTimer("mainRender");2422 PerformanceTimer perfTimer("mainRender");
2326 renderArgs._boomOffset = boomOffset;2423 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?
2327 // Viewport is assigned to the size of the framebuffer2426 // 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());
2329 if (displayPlugin->isStereo()) {2428 if (displayPlugin->isStereo()) {
2330 // Stereo modes will typically have a larger projection matrix overall,2429 // Stereo modes will typically have a larger projection matrix overall,
2331 // so we ask for the 'mono' projection matrix, which for stereo and HMD2430 // 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
3625#include <TCHAR.h>3724#include <TCHAR.h>
3626#include <pdh.h>3725#include <pdh.h>
3627#pragma comment(lib, "pdh.lib")3726#pragma comment(lib, "pdh.lib")
3727#pragma comment(lib, "ntdll.lib")
3728
3729extern "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}
3766template <typename T>
3767NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, T& t) {
3768 return NtQuerySystemInformation(SystemInformationClass, &t, (ULONG)sizeof(T), nullptr);
3769}
3770
3771template <typename T>
3772NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, std::vector<T>& t) {
3773 return NtQuerySystemInformation(SystemInformationClass, t.data(), (ULONG)(sizeof(T) * t.size()), nullptr);
3774}
3775
3776
3777template <typename T>
3778void 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
3785struct 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
3808void 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
3628 3854
3629static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;3855static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
3630static int numProcessors;3856static int numProcessors;
@@ -3677,6 +3903,26 @@ void getCpuUsage(vec3& systemAndUser) { · 46 unmodified lines
3677 systemAndUser.z = (float)counterVal.doubleValue;3903 systemAndUser.z = (float)counterVal.doubleValue;
3678}3904}
3679 3905
3906void 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
3680#endif3926#endif
3681 3927
3682 3928
@@ -3697,15 +3943,17 @@ void Application::idle(float nsecsElapsed) { · 14 unmodified lines
3697 }3943 }
3698 3944
3699#ifdef Q_OS_WIN3945#ifdef Q_OS_WIN
3946 // If tracing is enabled then monitor the CPU in a separate thread
3700 static std::once_flag once;3947 static std::once_flag once;
3701 std::call_once(once, [] {3948 std::call_once(once, [&] {
3702 initCpuUsage();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 }
3703 });3956 });
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 } });
3709#endif3957#endif
3710 3958
3711 3959
@@ -5175,7 +5423,7 @@ namespace render { · 1463 unmodified lines
5175 5423
5176 auto& batch = *args->_batch;5424 auto& batch = *args->_batch;
5177 DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch);5425 DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch);
5178 renderWorldBox(batch);5426 renderWorldBox(args, batch);
5179 }5427 }
5180 }5428 }
5181}5429}
@@ -5238,10 +5486,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 56 unmodified lines
5238 }5486 }
5239 5487
5240 {5488 {
5241 PerformanceTimer perfTimer("SceneProcessTransaction");
5242 _main3DScene->enqueueTransaction(transaction);5489 _main3DScene->enqueueTransaction(transaction);
5243
5244 _main3DScene->processTransactionQueue();
5245 }5490 }
5246 5491
5247 // For now every frame pass the renderContext5492 // 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