Showing the changes to interface/src/Application.cpp (1 of 13 files). Show all
Unified · Split
| @@ -1037,6 +1037,8 @@ void Application::initializeUi() { · 1036 unmodified lines | ||
| 1037 | 1037 | |
| 1038 | 1038 | void Application::paintGL() { |
| 1039 | 1039 | PROFILE_RANGE(__FUNCTION__); |
| 1040 | + PerformanceTimer perfTimer("paintGL"); | |
| 1041 | + | |
| 1040 | 1042 | if (nullptr == _displayPlugin) { |
| 1041 | 1043 | return; |
| 1042 | 1044 | } |
| @@ -1063,18 +1065,19 @@ void Application::paintGL() { · 20 unmodified lines | ||
| 1063 | 1065 | lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, |
| 1064 | 1066 | RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); |
| 1065 | 1067 | |
| 1066 | − PerformanceTimer perfTimer("paintGL"); | |
| 1067 | − | |
| 1068 | − | |
| 1069 | 1068 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); |
| 1070 | 1069 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1071 | 1070 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| 1072 | 1071 | resizeGL(); |
| 1073 | 1072 | |
| 1074 | 1073 | // Before anything else, let's sync up the gpuContext with the true glcontext used in case anything happened |
| 1075 | − renderArgs._context->syncCache(); | |
| 1074 | + { | |
| 1075 | + PerformanceTimer perfTimer("syncCache"); | |
| 1076 | + renderArgs._context->syncCache(); | |
| 1077 | + } | |
| 1076 | 1078 | |
| 1077 | 1079 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 1080 | + PerformanceTimer perfTimer("Mirror"); | |
| 1078 | 1081 | auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor(); |
| 1079 | 1082 | |
| 1080 | 1083 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| @@ -1088,7 +1091,7 @@ void Application::paintGL() { · 7 unmodified lines | ||
| 1088 | 1091 | auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w); |
| 1089 | 1092 | |
| 1090 | 1093 | auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer(); |
| 1091 | − doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1094 | + gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1092 | 1095 | batch.setFramebuffer(selfieFbo); |
| 1093 | 1096 | batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f)); |
| 1094 | 1097 | batch.blit(primaryFbo, mirrorRect, selfieFbo, mirrorRectDest); |
| @@ -1106,81 +1109,86 @@ void Application::paintGL() { · 11 unmodified lines | ||
| 1106 | 1109 | _applicationOverlay.renderOverlay(&renderArgs); |
| 1107 | 1110 | } |
| 1108 | 1111 | |
| 1109 | − _myAvatar->startCapture(); | |
| 1110 | − if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | |
| 1111 | − Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); | |
| 1112 | − Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); | |
| 1113 | − Application::getInstance()->cameraMenuChanged(); | |
| 1114 | − } | |
| 1115 | − | |
| 1116 | − // The render mode is default or mirror if the camera is in mirror mode, assigned further below | |
| 1117 | − renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; | |
| 1112 | + { | |
| 1113 | + PerformanceTimer perfTimer("CameraUpdates"); | |
| 1118 | 1114 | |
| 1119 | − // Always use the default eye position, not the actual head eye position. | |
| 1120 | − // Using the latter will cause the camera to wobble with idle animations, | |
| 1121 | − // or with changes from the face tracker | |
| 1122 | − if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | |
| 1123 | − if (isHMDMode()) { | |
| 1124 | − mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix(); | |
| 1125 | − _myCamera.setPosition(extractTranslation(camMat)); | |
| 1126 | − _myCamera.setRotation(glm::quat_cast(camMat)); | |
| 1127 | − } else { | |
| 1128 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); | |
| 1129 | − _myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation()); | |
| 1115 | + _myAvatar->startCapture(); | |
| 1116 | + if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | |
| 1117 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); | |
| 1118 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); | |
| 1119 | + Application::getInstance()->cameraMenuChanged(); | |
| 1130 | 1120 | } |
| 1131 | − } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | |
| 1132 | − if (isHMDMode()) { | |
| 1133 | − glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix()); | |
| 1134 | − _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation); | |
| 1135 | − // Ignore MenuOption::CenterPlayerInView in HMD view | |
| 1136 | − glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix()); | |
| 1137 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1138 | − + _myAvatar->getOrientation() | |
| 1139 | − * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset)); | |
| 1140 | − } else { | |
| 1141 | − _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); | |
| 1142 | − if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 1143 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1144 | − + _myCamera.getRotation() | |
| 1145 | − * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); | |
| 1121 | + | |
| 1122 | + // The render mode is default or mirror if the camera is in mirror mode, assigned further below | |
| 1123 | + renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; | |
| 1124 | + | |
| 1125 | + // Always use the default eye position, not the actual head eye position. | |
| 1126 | + // Using the latter will cause the camera to wobble with idle animations, | |
| 1127 | + // or with changes from the face tracker | |
| 1128 | + if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | |
| 1129 | + if (isHMDMode()) { | |
| 1130 | + mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix(); | |
| 1131 | + _myCamera.setPosition(extractTranslation(camMat)); | |
| 1132 | + _myCamera.setRotation(glm::quat_cast(camMat)); | |
| 1146 | 1133 | } else { |
| 1134 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); | |
| 1135 | + _myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation()); | |
| 1136 | + } | |
| 1137 | + } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | |
| 1138 | + if (isHMDMode()) { | |
| 1139 | + glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix()); | |
| 1140 | + _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation); | |
| 1141 | + // Ignore MenuOption::CenterPlayerInView in HMD view | |
| 1142 | + glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix()); | |
| 1147 | 1143 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() |
| 1148 | 1144 | + _myAvatar->getOrientation() |
| 1149 | − * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); | |
| 1145 | + * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset)); | |
| 1146 | + } else { | |
| 1147 | + _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); | |
| 1148 | + if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 1149 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1150 | + + _myCamera.getRotation() | |
| 1151 | + * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); | |
| 1152 | + } else { | |
| 1153 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1154 | + + _myAvatar->getOrientation() | |
| 1155 | + * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); | |
| 1156 | + } | |
| 1150 | 1157 | } |
| 1158 | + } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 1159 | + if (isHMDMode()) { | |
| 1160 | + glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix()); | |
| 1161 | + _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() | |
| 1162 | + * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation); | |
| 1163 | + glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix()); | |
| 1164 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1165 | + + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) | |
| 1166 | + + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | |
| 1167 | + glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror | |
| 1168 | + + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); | |
| 1169 | + } else { | |
| 1170 | + _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() | |
| 1171 | + * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | |
| 1172 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1173 | + + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) | |
| 1174 | + + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | |
| 1175 | + glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | |
| 1176 | + } | |
| 1177 | + renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | |
| 1151 | 1178 | } |
| 1152 | − } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 1153 | − if (isHMDMode()) { | |
| 1154 | − glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix()); | |
| 1155 | − _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() | |
| 1156 | − * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation); | |
| 1157 | − glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix()); | |
| 1158 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1159 | − + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) | |
| 1160 | − + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | |
| 1161 | − glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror | |
| 1162 | − + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); | |
| 1163 | − } else { | |
| 1164 | − _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() | |
| 1165 | − * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | |
| 1166 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() | |
| 1167 | − + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) | |
| 1168 | − + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | |
| 1169 | − glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | |
| 1179 | + // Update camera position | |
| 1180 | + if (!isHMDMode()) { | |
| 1181 | + _myCamera.update(1.0f / _fps); | |
| 1170 | 1182 | } |
| 1171 | − renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | |
| 1183 | + _myAvatar->endCapture(); | |
| 1172 | 1184 | } |
| 1173 | − // Update camera position | |
| 1174 | − if (!isHMDMode()) { | |
| 1175 | − _myCamera.update(1.0f / _fps); | |
| 1176 | − } | |
| 1177 | − _myAvatar->endCapture(); | |
| 1178 | 1185 | |
| 1179 | 1186 | // Primary rendering pass |
| 1180 | 1187 | auto framebufferCache = DependencyManager::get<FramebufferCache>(); |
| 1181 | 1188 | const QSize size = framebufferCache->getFrameBufferSize(); |
| 1182 | 1189 | { |
| 1183 | 1190 | PROFILE_RANGE(__FUNCTION__ "/mainRender"); |
| 1191 | + PerformanceTimer perfTimer("mainRender"); | |
| 1184 | 1192 | // Viewport is assigned to the size of the framebuffer |
| 1185 | 1193 | renderArgs._viewport = ivec4(0, 0, size.width(), size.height()); |
| 1186 | 1194 | if (displayPlugin->isStereo()) { |
| @@ -1217,7 +1225,7 @@ void Application::paintGL() { · 30 unmodified lines | ||
| 1217 | 1225 | } |
| 1218 | 1226 | displaySide(&renderArgs, _myCamera); |
| 1219 | 1227 | renderArgs._context->enableStereo(false); |
| 1220 | − doInBatch(renderArgs._context, [](gpu::Batch& batch) { | |
| 1228 | + gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) { | |
| 1221 | 1229 | batch.setFramebuffer(nullptr); |
| 1222 | 1230 | }); |
| 1223 | 1231 | } |
| @@ -1225,6 +1233,7 @@ void Application::paintGL() { · 1 unmodified line | ||
| 1225 | 1233 | // Overlay Composition, needs to occur after screen space effects have completed |
| 1226 | 1234 | { |
| 1227 | 1235 | PROFILE_RANGE(__FUNCTION__ "/compositor"); |
| 1236 | + PerformanceTimer perfTimer("compositor"); | |
| 1228 | 1237 | auto primaryFbo = framebufferCache->getPrimaryFramebuffer(); |
| 1229 | 1238 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo)); |
| 1230 | 1239 | if (displayPlugin->isStereo()) { |
| @@ -1249,6 +1258,7 @@ void Application::paintGL() { · 18 unmodified lines | ||
| 1249 | 1258 | // deliver final composited scene to the display plugin |
| 1250 | 1259 | { |
| 1251 | 1260 | PROFILE_RANGE(__FUNCTION__ "/pluginOutput"); |
| 1261 | + PerformanceTimer perfTimer("pluginOutput"); | |
| 1252 | 1262 | auto primaryFbo = framebufferCache->getPrimaryFramebuffer(); |
| 1253 | 1263 | GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0)); |
| 1254 | 1264 | // Ensure the rendering context commands are completed when rendering |
| @@ -1266,24 +1276,29 @@ void Application::paintGL() { · 11 unmodified lines | ||
| 1266 | 1276 | |
| 1267 | 1277 | { |
| 1268 | 1278 | PROFILE_RANGE(__FUNCTION__ "/pluginDisplay"); |
| 1279 | + PerformanceTimer perfTimer("pluginDisplay"); | |
| 1269 | 1280 | displayPlugin->display(finalTexture, toGlm(size)); |
| 1270 | 1281 | } |
| 1271 | 1282 | |
| 1272 | 1283 | { |
| 1273 | 1284 | PROFILE_RANGE(__FUNCTION__ "/bufferSwap"); |
| 1285 | + PerformanceTimer perfTimer("bufferSwap"); | |
| 1274 | 1286 | displayPlugin->finishFrame(); |
| 1275 | 1287 | } |
| 1276 | 1288 | } |
| 1277 | 1289 | |
| 1278 | − _offscreenContext->makeCurrent(); | |
| 1279 | − _frameCount++; | |
| 1280 | − Stats::getInstance()->setRenderDetails(renderArgs._details); | |
| 1290 | + { | |
| 1291 | + PerformanceTimer perfTimer("makeCurrent"); | |
| 1292 | + _offscreenContext->makeCurrent(); | |
| 1293 | + _frameCount++; | |
| 1294 | + Stats::getInstance()->setRenderDetails(renderArgs._details); | |
| 1281 | 1295 | |
| 1282 | − // Reset the gpu::Context Stages | |
| 1283 | − // Back to the default framebuffer; | |
| 1284 | − doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1285 | − batch.resetStages(); | |
| 1286 | − }); | |
| 1296 | + // Reset the gpu::Context Stages | |
| 1297 | + // Back to the default framebuffer; | |
| 1298 | + gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1299 | + batch.resetStages(); | |
| 1300 | + }); | |
| 1301 | + } | |
| 1287 | 1302 | } |
| 1288 | 1303 | |
| 1289 | 1304 | void Application::runTests() { |