History

Exploring how to solve the mirror fullscreen bug

samcake committed 10 years ago

Commit 1ddbc151 parent 28d28682 files · +36 −6Browse files

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

Unified · Split

interface/src/Application.cpp+34−4
@@ -1273,6 +1273,9 @@ void Application::paintGL() { · 1272 unmodified lines
1273 // Primary rendering pass1273 // Primary rendering pass
1274 auto framebufferCache = DependencyManager::get<FramebufferCache>();1274 auto framebufferCache = DependencyManager::get<FramebufferCache>();
1275 const QSize size = framebufferCache->getFrameBufferSize();1275 const QSize size = framebufferCache->getFrameBufferSize();
1276
1277 auto finalFramebuffer = framebufferCache->getFramebuffer();
1278
1276 {1279 {
1277 PROFILE_RANGE(__FUNCTION__ "/mainRender");1280 PROFILE_RANGE(__FUNCTION__ "/mainRender");
1278 PerformanceTimer perfTimer("mainRender");1281 PerformanceTimer perfTimer("mainRender");
@@ -1326,9 +1329,34 @@ void Application::paintGL() { · 47 unmodified lines
1326 }1329 }
1327 displaySide(&renderArgs, _myCamera);1330 displaySide(&renderArgs, _myCamera);
1328 renderArgs._context->enableStereo(false);1331 renderArgs._context->enableStereo(false);
1329 gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) {1332 /* gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) {
1330 batch.setFramebuffer(nullptr);1333 batch.setFramebuffer(nullptr);
1331 });1334 });
1335 */
1336 float ratio = ((float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale());
1337 // Flip the src and destination rect horizontally to do the mirror
1338 auto mirrorRect = glm::ivec4(0, 0, _mirrorViewRect.width() * ratio, _mirrorViewRect.height() * ratio);
1339 auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
1340
1341 auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
1342 /**
1343 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1344 batch.setFramebuffer(finalFramebuffer);
1345 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1346 batch.blit(primaryFbo, mirrorRect, finalFramebuffer, mirrorRectDest);
1347 batch.setFramebuffer(nullptr);
1348 });
1349 */
1350 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1351 gpu::Vec4i rect;
1352 rect.z = size.width();
1353 rect.w = size.height();
1354 batch.setFramebuffer(finalFramebuffer);
1355 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1356 batch.blit(primaryFbo, rect, finalFramebuffer, rect);
1357 // batch.setFramebuffer(nullptr);
1358 });
1359
1332 }1360 }
1333 1361
1334 // Overlay Composition, needs to occur after screen space effects have completed1362 // Overlay Composition, needs to occur after screen space effects have completed
@@ -1336,7 +1364,8 @@ void Application::paintGL() { · 1 unmodified line
1336 {1364 {
1337 PROFILE_RANGE(__FUNCTION__ "/compositor");1365 PROFILE_RANGE(__FUNCTION__ "/compositor");
1338 PerformanceTimer perfTimer("compositor");1366 PerformanceTimer perfTimer("compositor");
1339 auto primaryFbo = framebufferCache->getPrimaryFramebuffer();1367 // auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
1368 auto primaryFbo = finalFramebuffer;
1340 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));1369 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
1341 if (displayPlugin->isStereo()) {1370 if (displayPlugin->isStereo()) {
1342 QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height()));1371 QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height()));
@@ -1361,7 +1390,8 @@ void Application::paintGL() { · 18 unmodified lines
1361 {1390 {
1362 PROFILE_RANGE(__FUNCTION__ "/pluginOutput");1391 PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
1363 PerformanceTimer perfTimer("pluginOutput");1392 PerformanceTimer perfTimer("pluginOutput");
1364 auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();1393 auto scratchFramebuffer = finalFramebuffer;
1394 /* auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();
1365 auto scratchFramebuffer = framebufferCache->getFramebuffer();1395 auto scratchFramebuffer = framebufferCache->getFramebuffer();
1366 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {1396 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1367 gpu::Vec4i rect;1397 gpu::Vec4i rect;
@@ -1371,7 +1401,7 @@ void Application::paintGL() { · 3 unmodified lines
1371 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));1401 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1372 batch.blit(primaryFramebuffer, rect, scratchFramebuffer, rect);1402 batch.blit(primaryFramebuffer, rect, scratchFramebuffer, rect);
1373 batch.setFramebuffer(nullptr);1403 batch.setFramebuffer(nullptr);
1374 });1404 });*/
1375 auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0);1405 auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0);
1376 GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer);1406 GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer);
1377 Q_ASSERT(0 != finalTexture);1407 Q_ASSERT(0 != finalTexture);