History

Fixing UI

Brad Davis committed 8 years ago

Commit 105dffe1 parent fd01f1c11 files · +469 −399Browse files

Showing the changes to libraries/render-utils/src/RenderDeferredTask.cpp (1 of 11 files). Show all

Unified · Split

libraries/render-utils/src/RenderDeferredTask.cpp+1−191
@@ -25,6 +25,7 @@ · 24 unmodified lines
25#include <render/DrawSceneOctree.h>25#include <render/DrawSceneOctree.h>
26#include <render/BlurTask.h>26#include <render/BlurTask.h>
27 27
28#include "RenderCommonTask.h"
28#include "LightingModel.h"29#include "LightingModel.h"
29#include "StencilMaskPass.h"30#include "StencilMaskPass.h"
30#include "DebugDeferredBuffer.h"31#include "DebugDeferredBuffer.h"
@@ -289,23 +290,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 258 unmodified lines
289 task.addJob<Blit>("Blit", primaryFramebuffer);290 task.addJob<Blit>("Blit", primaryFramebuffer);
290}291}
291 292
292void BeginGPURangeTimer::run(const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) {
293 timer = _gpuTimer;
294 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
295 _gpuTimer->begin(batch);
296 });
297}
298
299void EndGPURangeTimer::run(const render::RenderContextPointer& renderContext, const gpu::RangeTimerPointer& timer) {
300 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
301 timer->end(batch);
302 });
303
304 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
305 config->setGPUBatchRunTime(timer->getGPUAverage(), timer->getBatchAverage());
306}
307
308
309void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs& inputs) {293void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
310 assert(renderContext->args);294 assert(renderContext->args);
311 assert(renderContext->args->hasViewFrustum());295 assert(renderContext->args->hasViewFrustum());
@@ -410,177 +394,3 @@ void DrawStateSortDeferred::run(const RenderContextPointer& renderContext, const · 98 unmodified lines
410 config->setNumDrawn((int)inItems.size());394 config->setNumDrawn((int)inItems.size());
411}395}
412 396
413DrawOverlay3D::DrawOverlay3D(bool opaque) :
414 _shapePlumber(std::make_shared<ShapePlumber>()),
415 _opaquePass(opaque) {
416 initOverlay3DPipelines(*_shapePlumber);
417}
418
419void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
420 assert(renderContext->args);
421 assert(renderContext->args->hasViewFrustum());
422
423 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
424
425 const auto& inItems = inputs.get0();
426 const auto& lightingModel = inputs.get1();
427
428 config->setNumDrawn((int)inItems.size());
429 emit config->numDrawnChanged();
430
431 if (!inItems.empty()) {
432 RenderArgs* args = renderContext->args;
433
434 // Clear the framebuffer without stereo
435 // Needs to be distinct from the other batch because using the clear call
436 // while stereo is enabled triggers a warning
437 if (_opaquePass) {
438 gpu::doInBatch(args->_context, [&](gpu::Batch& batch){
439 batch.enableStereo(false);
440 batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(), 1.f, 0, false);
441 });
442 }
443
444 // Render the items
445 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
446 args->_batch = &batch;
447 batch.setViewportTransform(args->_viewport);
448 batch.setStateScissorRect(args->_viewport);
449
450 glm::mat4 projMat;
451 Transform viewMat;
452 args->getViewFrustum().evalProjectionMatrix(projMat);
453 args->getViewFrustum().evalViewTransform(viewMat);
454
455 batch.setProjectionTransform(projMat);
456 batch.setViewTransform(viewMat);
457
458 // Setup lighting model for all items;
459 batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer());
460
461 renderShapes(renderContext, _shapePlumber, inItems, _maxDrawn);
462 args->_batch = nullptr;
463 });
464 }
465}
466
467void CompositeHUD::run(const RenderContextPointer& renderContext) {
468 assert(renderContext->args);
469 assert(renderContext->args->_context);
470
471 // We do not want to render HUD elements in secondary camera
472 if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) {
473 return;
474 }
475
476 // Grab the HUD texture
477 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
478 if (renderContext->args->_hudOperator) {
479 renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE);
480 }
481 });
482}
483
484void Blit::run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer) {
485 assert(renderContext->args);
486 assert(renderContext->args->_context);
487
488 RenderArgs* renderArgs = renderContext->args;
489 auto blitFbo = renderArgs->_blitFramebuffer;
490
491 if (!blitFbo) {
492 qCWarning(renderutils) << "Blit::run - no blit frame buffer.";
493 return;
494 }
495
496 // Determine size from viewport
497 int width = renderArgs->_viewport.z;
498 int height = renderArgs->_viewport.w;
499
500 // Blit primary to blit FBO
501 auto primaryFbo = srcFramebuffer;
502
503 gpu::doInBatch(renderArgs->_context, [&](gpu::Batch& batch) {
504 batch.setFramebuffer(blitFbo);
505
506 if (renderArgs->_renderMode == RenderArgs::MIRROR_RENDER_MODE) {
507 if (renderArgs->isStereo()) {
508 gpu::Vec4i srcRectLeft;
509 srcRectLeft.z = width / 2;
510 srcRectLeft.w = height;
511
512 gpu::Vec4i srcRectRight;
513 srcRectRight.x = width / 2;
514 srcRectRight.z = width;
515 srcRectRight.w = height;
516
517 gpu::Vec4i destRectLeft;
518 destRectLeft.x = srcRectLeft.z;
519 destRectLeft.z = srcRectLeft.x;
520 destRectLeft.y = srcRectLeft.y;
521 destRectLeft.w = srcRectLeft.w;
522
523 gpu::Vec4i destRectRight;
524 destRectRight.x = srcRectRight.z;
525 destRectRight.z = srcRectRight.x;
526 destRectRight.y = srcRectRight.y;
527 destRectRight.w = srcRectRight.w;
528
529 // Blit left to right and right to left in stereo
530 batch.blit(primaryFbo, srcRectRight, blitFbo, destRectLeft);
531 batch.blit(primaryFbo, srcRectLeft, blitFbo, destRectRight);
532 } else {
533 gpu::Vec4i srcRect;
534 srcRect.z = width;
535 srcRect.w = height;
536
537 gpu::Vec4i destRect;
538 destRect.x = width;
539 destRect.y = 0;
540 destRect.z = 0;
541 destRect.w = height;
542
543 batch.blit(primaryFbo, srcRect, blitFbo, destRect);
544 }
545 } else {
546 gpu::Vec4i rect;
547 rect.z = width;
548 rect.w = height;
549
550 batch.blit(primaryFbo, rect, blitFbo, rect);
551 }
552 });
553}
554
555void ExtractFrustums::run(const render::RenderContextPointer& renderContext, Output& output) {
556 assert(renderContext->args);
557 assert(renderContext->args->_context);
558
559 RenderArgs* args = renderContext->args;
560
561 // Return view frustum
562 auto& viewFrustum = output[VIEW_FRUSTUM].edit<ViewFrustumPointer>();
563 if (!viewFrustum) {
564 viewFrustum = std::make_shared<ViewFrustum>(args->getViewFrustum());
565 } else {
566 *viewFrustum = args->getViewFrustum();
567 }
568
569 // Return shadow frustum
570 auto lightStage = args->_scene->getStage<LightStage>(LightStage::getName());
571 for (auto i = 0; i < SHADOW_CASCADE_FRUSTUM_COUNT; i++) {
572 auto& shadowFrustum = output[SHADOW_CASCADE0_FRUSTUM+i].edit<ViewFrustumPointer>();
573 if (lightStage) {
574 auto globalShadow = lightStage->getCurrentKeyShadow();
575
576 if (globalShadow && i<(int)globalShadow->getCascadeCount()) {
577 auto& cascade = globalShadow->getCascade(i);
578 shadowFrustum = cascade.getFrustum();
579 } else {
580 shadowFrustum.reset();
581 }
582 } else {
583 shadowFrustum.reset();
584 }
585 }
586}

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