From 92e1fe8e5ced10a08e0b899e5bf12c80fdb79347 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Fri, 8 Dec 2017 18:02:27 +0100 Subject: [PATCH] Removed jitter samples from shader and added name to batches in DEBUG mode to ease render debug --- interface/src/Application.cpp | 10 +- interface/src/Application_render.cpp | 2 +- interface/src/SecondaryCamera.cpp | 4 +- interface/src/ui/ApplicationOverlay.cpp | 2 +- .../hmd/DebugHmdDisplayPlugin.cpp | 6 +- .../display-plugins/hmd/HmdDisplayPlugin.cpp | 12 ++ .../display-plugins/hmd/HmdDisplayPlugin.h | 6 +- libraries/gpu/src/gpu/Batch.cpp | 12 +- libraries/gpu/src/gpu/Batch.h | 7 +- libraries/gpu/src/gpu/Context.cpp | 4 +- libraries/gpu/src/gpu/Context.h | 4 +- .../src/AmbientOcclusionEffect.cpp | 4 +- .../render-utils/src/AntialiasingEffect.cpp | 110 ++++++++---------- .../render-utils/src/AntialiasingEffect.h | 37 +++--- .../render-utils/src/BackgroundStage.cpp | 2 +- libraries/render-utils/src/BloomEffect.cpp | 8 +- .../render-utils/src/DebugDeferredBuffer.cpp | 2 +- .../src/DeferredFrameTransform.cpp | 2 +- .../src/DeferredLightingEffect.cpp | 2 +- libraries/render-utils/src/DrawHaze.cpp | 2 +- .../render-utils/src/HighlightEffect.cpp | 10 +- .../render-utils/src/RenderDeferredTask.cpp | 27 +++-- .../render-utils/src/RenderForwardTask.cpp | 8 +- .../render-utils/src/RenderShadowTask.cpp | 2 +- .../render-utils/src/StencilMaskPass.cpp | 2 +- .../render-utils/src/SubsurfaceScattering.cpp | 8 +- .../render-utils/src/SurfaceGeometryPass.cpp | 4 +- .../render-utils/src/ToneMappingEffect.cpp | 2 +- .../render-utils/src/VelocityBufferPass.cpp | 2 +- libraries/render-utils/src/ZoneRenderer.cpp | 2 +- libraries/render-utils/src/taa.slf | 13 +-- libraries/render-utils/src/taa.slh | 36 +----- libraries/render-utils/src/taa_blend.slf | 29 +---- libraries/render/src/render/BlurTask.cpp | 4 +- .../render/src/render/DrawSceneOctree.cpp | 4 +- libraries/render/src/render/DrawStatus.cpp | 2 +- libraries/render/src/render/DrawTask.cpp | 6 +- libraries/render/src/render/ResampleTask.cpp | 2 +- .../utilities/render/antialiasing.qml | 15 --- tests/gpu-test/src/TestWindow.cpp | 10 +- tests/gpu-test/src/main.cpp | 2 +- tests/render-perf/src/main.cpp | 2 +- tests/render-texture-load/src/main.cpp | 4 +- 43 files changed, 178 insertions(+), 256 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d7fb88f42e..5aa69a485b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5070,10 +5070,10 @@ void Application::update(float deltaTime) { { QMutexLocker viewLocker(&_viewMutex); // adjust near clip plane to account for sensor scaling. - auto adjustedProjection = glm::perspective(_viewFrustum.getFieldOfView(), - _viewFrustum.getAspectRatio(), - DEFAULT_NEAR_CLIP * sensorToWorldScale, - _viewFrustum.getFarClip()); + auto adjustedProjection = glm::perspective(glm::radians(_fieldOfView.get()), + getActiveDisplayPlugin()->getRecommendedAspectRatio(), + DEFAULT_NEAR_CLIP * sensorToWorldScale, + DEFAULT_FAR_CLIP); _viewFrustum.setProjection(adjustedProjection); _viewFrustum.calculate(); } @@ -5095,7 +5095,7 @@ void Application::update(float deltaTime) { resizeGL(); } - this->updateCamera(appRenderArgs._renderArgs); + updateCamera(appRenderArgs._renderArgs); appRenderArgs._eyeToWorld = _myCamera.getTransform(); appRenderArgs._isStereo = false; diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index 1231e5834b..d1a315e398 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -93,7 +93,7 @@ void Application::paintGL() { _gpuContext->beginFrame(HMDSensorPose); // Reset the gpu::Context Stages // Back to the default framebuffer; - gpu::doInBatch(_gpuContext, [&](gpu::Batch& batch) { + gpu::doInBatch("Application_render::gpuContextReset", _gpuContext, [&](gpu::Batch& batch) { batch.resetStages(); }); } diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index 4cfa4d6156..a4fd89e576 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -107,7 +107,7 @@ public: args->_displayMode = RenderArgs::MONO; args->_renderMode = RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("SecondaryCameraJob::run", args->_context, [&](gpu::Batch& batch) { batch.disableContextStereo(); batch.disableContextViewCorrection(); }); @@ -196,7 +196,7 @@ public: args->_displayMode = cachedArgs->_displayMode; args->_renderMode = cachedArgs->_renderMode; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("EndSecondaryCameraFrame::run", args->_context, [&](gpu::Batch& batch) { batch.restoreContextStereo(); batch.restoreContextViewCorrection(); }); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index a99fe002ee..dade3a714f 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -64,7 +64,7 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) { } // Execute the batch into our framebuffer - doInBatch(renderArgs->_context, [&](gpu::Batch& batch) { + doInBatch("ApplicationOverlay::render", renderArgs->_context, [&](gpu::Batch& batch) { PROFILE_RANGE_BATCH(batch, "ApplicationOverlayRender"); renderArgs->_batch = &batch; batch.enableStereo(false); diff --git a/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp index 2cce1403b7..e01a205a3c 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp @@ -51,6 +51,7 @@ bool DebugHmdDisplayPlugin::internalActivate() { }, true, _isAutoRotateEnabled); _ipd = 0.0327499993f * 2.0f; + // Would be nice to know why the left and right projection matrices are slightly dissymetrical _eyeProjections[0][0] = vec4{ 0.759056330, 0.000000000, 0.000000000, 0.000000000 }; _eyeProjections[0][1] = vec4{ 0.000000000, 0.682773232, 0.000000000, 0.000000000 }; _eyeProjections[0][2] = vec4{ -0.0580431037, -0.00619550655, -1.00000489, -1.00000000 }; @@ -59,8 +60,9 @@ bool DebugHmdDisplayPlugin::internalActivate() { _eyeProjections[1][1] = vec4{ 0.000000000, 0.678060353, 0.000000000, 0.000000000 }; _eyeProjections[1][2] = vec4{ 0.0578232110, -0.00669418881, -1.00000489, -1.000000000 }; _eyeProjections[1][3] = vec4{ 0.000000000, 0.000000000, -0.0800003856, 0.000000000 }; - _eyeInverseProjections[0] = glm::inverse(_eyeProjections[0]); - _eyeInverseProjections[1] = glm::inverse(_eyeProjections[1]); + // No need to do so here as this will done in Parent::internalActivate + //_eyeInverseProjections[0] = glm::inverse(_eyeProjections[0]); + //_eyeInverseProjections[1] = glm::inverse(_eyeProjections[1]); _eyeOffsets[0][3] = vec4{ -0.0327499993, 0.0, 0.0149999997, 1.0 }; _eyeOffsets[1][3] = vec4{ 0.0327499993, 0.0, 0.0149999997, 1.0 }; _renderTargetSize = { 3024, 1680 }; diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 1d7fee38eb..c99fafff89 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -57,6 +57,18 @@ QRect HmdDisplayPlugin::getRecommendedHUDRect() const { return CompositorHelper::VIRTUAL_SCREEN_RECOMMENDED_OVERLAY_RECT; } +glm::mat4 HmdDisplayPlugin::getEyeToHeadTransform(Eye eye) const { + return _eyeOffsets[eye]; +} + +glm::mat4 HmdDisplayPlugin::getEyeProjection(Eye eye, const glm::mat4& baseProjection) const { + return _eyeProjections[eye]; +} + +glm::mat4 HmdDisplayPlugin::getCullingProjection(const glm::mat4& baseProjection) const { + return _cullingProjection; +} + #define DISABLE_PREVIEW_MENU_ITEM_DELAY_MS 500 bool HmdDisplayPlugin::internalActivate() { diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h index d2d30df093..78d5904c7d 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h @@ -26,9 +26,9 @@ public: ~HmdDisplayPlugin(); bool isHmd() const override final { return true; } float getIPD() const override final { return _ipd; } - glm::mat4 getEyeToHeadTransform(Eye eye) const override final { return _eyeOffsets[eye]; } - glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override { return _eyeProjections[eye]; } - glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override { return _cullingProjection; } + glm::mat4 getEyeToHeadTransform(Eye eye) const override final; + glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override; + glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override; glm::uvec2 getRecommendedUiSize() const override final; glm::uvec2 getRecommendedRenderSize() const override final { return _renderTargetSize; } bool isDisplayVisible() const override { return isHmdMounted(); } diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index c432e19368..6a07b2bb61 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -37,7 +37,14 @@ size_t Batch::_dataMax { BATCH_PREALLOCATE_MIN }; size_t Batch::_objectsMax { BATCH_PREALLOCATE_MIN }; size_t Batch::_drawCallInfosMax { BATCH_PREALLOCATE_MIN }; -Batch::Batch() { +Batch::Batch(const char* name) { +#ifdef DEBUG + if (name) { + _name = name; + } +#else + (void*)name; +#endif _commands.reserve(_commandsMax); _commandOffsets.reserve(_commandOffsetsMax); _params.reserve(_paramsMax); @@ -48,6 +55,9 @@ Batch::Batch() { Batch::Batch(const Batch& batch_) { Batch& batch = *const_cast(&batch_); +#ifdef DEBUG + _name = batch_._name; +#endif _commands.swap(batch._commands); _commandOffsets.swap(batch._commandOffsets); _params.swap(batch._params); diff --git a/libraries/gpu/src/gpu/Batch.h b/libraries/gpu/src/gpu/Batch.h index fca220c224..4f328747ac 100644 --- a/libraries/gpu/src/gpu/Batch.h +++ b/libraries/gpu/src/gpu/Batch.h @@ -91,7 +91,7 @@ public: void captureDrawCallInfo(); void captureNamedDrawCallInfo(std::string name); - Batch(); + Batch(const char* name = nullptr); Batch(const Batch& batch); ~Batch(); @@ -482,6 +482,11 @@ public: bool _enableSkybox { false }; protected: + +#ifdef DEBUG + std::string _name; +#endif + friend class Context; friend class Frame; diff --git a/libraries/gpu/src/gpu/Context.cpp b/libraries/gpu/src/gpu/Context.cpp index 24128524da..a33f375614 100644 --- a/libraries/gpu/src/gpu/Context.cpp +++ b/libraries/gpu/src/gpu/Context.cpp @@ -108,7 +108,7 @@ void Context::executeFrame(const FramePointer& frame) const { consumeFrameUpdates(frame); _backend->setStereoState(frame->stereoState); { - Batch beginBatch; + Batch beginBatch("Context::executeFrame::begin"); _frameRangeTimer->begin(beginBatch); _backend->render(beginBatch); @@ -117,7 +117,7 @@ void Context::executeFrame(const FramePointer& frame) const { _backend->render(batch); } - Batch endBatch; + Batch endBatch("Context::executeFrame::end"); _frameRangeTimer->end(endBatch); _backend->render(endBatch); } diff --git a/libraries/gpu/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h index 7b7575e9ed..6358c17108 100644 --- a/libraries/gpu/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -274,8 +274,8 @@ protected: typedef std::shared_ptr ContextPointer; template -void doInBatch(std::shared_ptr context, F f) { - gpu::Batch batch; +void doInBatch(const char* name, std::shared_ptr context, F f) { + gpu::Batch batch(name); f(batch); context->appendFrameBatch(batch); } diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp index 83753131c8..1dfe793576 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -385,7 +385,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte auto firstHBlurPipeline = getHBlurPipeline(); auto lastVBlurPipeline = getVBlurPipeline(); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("AmbientOcclusionEffect::run", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); _gpuTimer->begin(batch); @@ -518,7 +518,7 @@ void DebugAmbientOcclusion::run(const render::RenderContextPointer& renderContex auto debugPipeline = getDebugPipeline(); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("DebugAmbientOcclusion::run", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(sourceViewport); diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index a0935d76d9..ec91de263c 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -24,7 +24,10 @@ #include "ViewFrustum.h" #include "GeometryCache.h" #include "FramebufferCache.h" -/* + +#define ANTIALIASING_USE_TAA 1 + +#if !ANTIALIASING_USE_TAA #include "fxaa_vert.h" #include "fxaa_frag.h" #include "fxaa_blend_frag.h" @@ -110,7 +113,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("Antialiasing::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(args->_viewport); @@ -167,17 +170,14 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const DependencyManager::get()->renderQuad(batch, bottomLeft, topRight, texCoordTopLeft, texCoordBottomRight, color, _geometryId); }); } -*/ +#else #include "taa_frag.h" #include "fxaa_blend_frag.h" #include "taa_blend_frag.h" - - const int AntialiasingPass_ParamsSlot = 0; const int AntialiasingPass_FrameTransformSlot = 1; -const int AntialiasingPass_JitterBufferSlot = 2; const int AntialiasingPass_HistoryMapSlot = 0; const int AntialiasingPass_SourceMapSlot = 1; @@ -209,7 +209,6 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() { slotBindings.insert(gpu::Shader::Binding(std::string("taaParamsBuffer"), AntialiasingPass_ParamsSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), AntialiasingPass_FrameTransformSlot)); - slotBindings.insert(gpu::Shader::Binding(std::string("taaJitterBuffer"), AntialiasingPass_JitterBufferSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("historyMap"), AntialiasingPass_HistoryMapSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("sourceMap"), AntialiasingPass_SourceMapSlot)); @@ -259,7 +258,6 @@ const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() { gpu::Shader::BindingSet slotBindings; slotBindings.insert(gpu::Shader::Binding(std::string("taaParamsBuffer"), AntialiasingPass_ParamsSlot)); - slotBindings.insert(gpu::Shader::Binding(std::string("taaJitterBuffer"), AntialiasingPass_JitterBufferSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), AntialiasingPass_FrameTransformSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("nextMap"), AntialiasingPass_NextMapSlot)); @@ -285,7 +283,6 @@ void Antialiasing::configure(const Config& config) { _params.edit().blend = config.blend; _params.edit().covarianceGamma = config.covarianceGamma; - _params.edit().setUnjitter(config.unjitter); _params.edit().setConstrainColor(config.constrainColor); _params.edit().setCovarianceClipColor(config.covarianceClipColor); _params.edit().setClipExactColor(config.clipExactColor); @@ -301,7 +298,6 @@ void Antialiasing::configure(const Config& config) { _params.edit().setDebugCursor(config.debugCursorTexcoord); _params.edit().setDebugOrbZoom(config.debugOrbZoom); - _params.edit().setShowJitterSequence(config.showJitterSequence); _params.edit().setShowClosestFragment(config.showClosestFragment); } @@ -313,10 +309,9 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const RenderArgs* args = renderContext->args; auto& deferredFrameTransform = inputs.get0(); - auto& jitterBuffer = inputs.get1(); - auto& sourceBuffer = inputs.get2(); - auto& linearDepthBuffer = inputs.get3(); - auto& velocityBuffer = inputs.get4(); + auto& sourceBuffer = inputs.get1(); + auto& linearDepthBuffer = inputs.get2(); + auto& velocityBuffer = inputs.get3(); int width = sourceBuffer->getWidth(); int height = sourceBuffer->getHeight(); @@ -343,7 +338,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const int nextFrame = (_currentFrame++) % 2; int prevFrame = (nextFrame + 1) % 2; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("Antialiasing::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(args->_viewport); @@ -356,7 +351,6 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const batch.setUniformBuffer(AntialiasingPass_ParamsSlot, _params); batch.setUniformBuffer(AntialiasingPass_FrameTransformSlot, deferredFrameTransform->getFrameTransformBuffer()); - batch.setUniformBuffer(AntialiasingPass_JitterBufferSlot, jitterBuffer); batch.setFramebuffer(_antialiasingBuffer[nextFrame]); batch.setPipeline(getAntialiasingPipeline()); @@ -376,7 +370,6 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const batch.setUniformBuffer(AntialiasingPass_ParamsSlot, nullptr); batch.setUniformBuffer(AntialiasingPass_FrameTransformSlot, nullptr); - batch.setUniformBuffer(AntialiasingPass_JitterBufferSlot, nullptr); batch.setResourceTexture(AntialiasingPass_DepthMapSlot, nullptr); batch.setResourceTexture(AntialiasingPass_HistoryMapSlot, nullptr); @@ -387,7 +380,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const void JitterSampleConfig::setIndex(int current) { - _index = (current) % JitterSample::SampleSequence::SEQUENCE_LENGTH; + _index = (current) % JitterSample::SEQUENCE_LENGTH; emit dirty(); } @@ -446,11 +439,11 @@ int JitterSampleConfig::play() { return _state; } - - -template class Halton { +template +class Halton { public: - float eval(int index) { + + float eval(int index) const { float f = 1.0f; float r = 0.0f; float invB = 1.0f / (float)B; @@ -458,12 +451,14 @@ public: while (index > 0) { f = f * invB; - r = r + f * (float) (index % B); + r = r + f * (float)(index % B); index = index / B; + } return r; } + }; @@ -474,9 +469,6 @@ JitterSample::SampleSequence::SampleSequence(){ for (int i = 0; i < SEQUENCE_LENGTH; i++) { offsets[i] = glm::vec2(genX.eval(i), genY.eval(i)); - } - - for (int i = 0; i < SEQUENCE_LENGTH; i++) { offsets[i] -= vec2(0.5f); } offsets[SEQUENCE_LENGTH] = glm::vec2(0.0f); @@ -486,68 +478,60 @@ void JitterSample::configure(const Config& config) { _freeze = config.freeze; if (config.stop || _freeze) { auto pausedIndex = config.getIndex(); - if (_jitterBuffer->currentIndex != pausedIndex) { - _jitterBuffer.edit().currentIndex = pausedIndex; + if (_sampleSequence.currentIndex != pausedIndex) { + _sampleSequence.currentIndex = pausedIndex; } } else { - if (_jitterBuffer->currentIndex < 0) { - _jitterBuffer.edit().currentIndex = config.getIndex(); + if (_sampleSequence.currentIndex < 0) { + _sampleSequence.currentIndex = config.getIndex(); } } _scale = config.scale; } -void JitterSample::run(const render::RenderContextPointer& renderContext, JitterBuffer& jitterBuffer) { - auto& current = _jitterBuffer.edit().currentIndex; + +void JitterSample::run(const render::RenderContextPointer& renderContext) { + auto& current = _sampleSequence.currentIndex; if (!_freeze) { if (current >= 0) { - current = (current + 1) % SampleSequence::SEQUENCE_LENGTH; - } - else { + current = (current + 1) % SEQUENCE_LENGTH; + } else { current = -1; } } - auto viewFrustum = renderContext->args->getViewFrustum(); - auto projMat = viewFrustum.getProjection(); - auto theNear = viewFrustum.getNearClip(); + auto args = renderContext->args; + auto viewFrustum = args->getViewFrustum(); + auto jit = _sampleSequence.offsets[(current < 0 ? SEQUENCE_LENGTH : current)]; + auto width = (float)args->_viewport.z; + auto height = (float)args->_viewport.w; - auto jit = jitterBuffer.get().offsets[(current < 0 ? SampleSequence::SEQUENCE_LENGTH : current)]; - auto width = (float)renderContext->args->_viewport.z; - auto height = (float)renderContext->args->_viewport.w; + auto jx = 2.0f * jit.x / width; + auto jy = 2.0f * jit.y / height; - auto jx = 2.0 * jit.x / width; - auto jy = 2.0 * jit.y / height; + if (!args->isStereo()) { + auto projMat = viewFrustum.getProjection(); - - bool isStereo = renderContext->args->isStereo(); - if (!isStereo) { projMat[2][0] += jx; projMat[2][1] += jy; viewFrustum.setProjection(projMat); - renderContext->args->pushViewFrustum(viewFrustum); - - } - else { - + viewFrustum.calculate(); + args->setViewFrustum(viewFrustum); + } else { mat4 projMats[2]; - renderContext->args->_context->getStereoProjections(projMats); + args->_context->getStereoProjections(projMats); + + jx *= 2.0f; - auto sjx = jx * 2.0f; - - for (int i = 0; i < 2; i++) { - projMats[i][2][0] += sjx; - projMats[i][2][1] += jy; + auto& projMat = projMats[i]; + projMat[2][0] += jx; + projMat[2][1] += jy; } - renderContext->args->_context->setStereoProjections(projMats); - + args->_context->setStereoProjections(projMats); } - - - - jitterBuffer = _jitterBuffer; } +#endif \ No newline at end of file diff --git a/libraries/render-utils/src/AntialiasingEffect.h b/libraries/render-utils/src/AntialiasingEffect.h index 957d14a9bb..1362a7c7b3 100644 --- a/libraries/render-utils/src/AntialiasingEffect.h +++ b/libraries/render-utils/src/AntialiasingEffect.h @@ -57,27 +57,27 @@ private: class JitterSample { public: - struct SampleSequence { - SampleSequence(); - static const int SEQUENCE_LENGTH{ 16 }; - glm::vec2 offsets[SEQUENCE_LENGTH + 1]; - int sequenceLength{ SEQUENCE_LENGTH }; - int currentIndex{ 0 }; - + enum { + SEQUENCE_LENGTH = 16 }; - using JitterBuffer = gpu::StructBuffer; - using Config = JitterSampleConfig; - using JobModel = render::Job::ModelO; + using JobModel = render::Job::Model; void configure(const Config& config); - void run(const render::RenderContextPointer& renderContext, JitterBuffer& jitterBuffer); - + void run(const render::RenderContextPointer& renderContext); private: - JitterBuffer _jitterBuffer; + struct SampleSequence { + SampleSequence(); + + glm::vec2 offsets[SEQUENCE_LENGTH + 1]; + int sequenceLength{ SEQUENCE_LENGTH }; + int currentIndex{ 0 }; + }; + + SampleSequence _sampleSequence; float _scale{ 1.0 }; bool _freeze{ false }; }; @@ -88,7 +88,6 @@ class AntialiasingConfig : public render::Job::Config { Q_PROPERTY(float blend MEMBER blend NOTIFY dirty) Q_PROPERTY(float covarianceGamma MEMBER covarianceGamma NOTIFY dirty) - Q_PROPERTY(bool unjitter MEMBER unjitter NOTIFY dirty) Q_PROPERTY(bool constrainColor MEMBER constrainColor NOTIFY dirty) Q_PROPERTY(bool covarianceClipColor MEMBER covarianceClipColor NOTIFY dirty) Q_PROPERTY(bool clipExactColor MEMBER clipExactColor NOTIFY dirty) @@ -102,7 +101,6 @@ class AntialiasingConfig : public render::Job::Config { Q_PROPERTY(glm::vec2 debugCursorTexcoord MEMBER debugCursorTexcoord NOTIFY dirty) Q_PROPERTY(float debugOrbZoom MEMBER debugOrbZoom NOTIFY dirty) - Q_PROPERTY(bool showJitterSequence MEMBER showJitterSequence NOTIFY dirty) Q_PROPERTY(bool showClosestFragment MEMBER showClosestFragment NOTIFY dirty) public: @@ -111,7 +109,6 @@ public: float blend{ 0.1f }; - bool unjitter{ false }; bool constrainColor{ true }; bool covarianceClipColor{ true }; float covarianceGamma{ 1.0f }; @@ -126,7 +123,6 @@ public: bool debug { false }; bool showCursorPixel { false }; - bool showJitterSequence{ false }; bool showClosestFragment{ false }; signals: @@ -146,9 +142,6 @@ struct TAAParams { glm::vec4 pixelInfo{ 0.5f, 0.5f, 2.0f, 0.0f }; glm::vec4 regionInfo{ 0.0f, 0.0f, 1.0f, 0.0f }; - void setUnjitter(bool enabled) { SET_BIT(flags.y, 0, enabled); } - bool isUnjitter() const { return (bool)GET_BIT(flags.y, 0); } - void setConstrainColor(bool enabled) { SET_BIT(flags.y, 1, enabled); } bool isConstrainColor() const { return (bool)GET_BIT(flags.y, 1); } @@ -173,16 +166,14 @@ struct TAAParams { void setDebugOrbZoom(float orbZoom) { pixelInfo.z = orbZoom; } float getDebugOrbZoom() const { return pixelInfo.z; } - void setShowJitterSequence(bool enabled) { SET_BIT(flags.x, 2, enabled); } void setShowClosestFragment(bool enabled) { SET_BIT(flags.x, 3, enabled); } - }; using TAAParamsBuffer = gpu::StructBuffer; class Antialiasing { public: - using Inputs = render::VaryingSet5 < DeferredFrameTransformPointer, JitterSample::JitterBuffer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, VelocityFramebufferPointer > ; + using Inputs = render::VaryingSet4 < DeferredFrameTransformPointer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, VelocityFramebufferPointer > ; using Config = AntialiasingConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render-utils/src/BackgroundStage.cpp b/libraries/render-utils/src/BackgroundStage.cpp index 2d2c0ed150..f246ab7e60 100644 --- a/libraries/render-utils/src/BackgroundStage.cpp +++ b/libraries/render-utils/src/BackgroundStage.cpp @@ -93,7 +93,7 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, PerformanceTimer perfTimer("skybox"); auto args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawBackgroundStage::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.enableSkybox(true); diff --git a/libraries/render-utils/src/BloomEffect.cpp b/libraries/render-utils/src/BloomEffect.cpp index 9d9367a6d5..07af501de3 100644 --- a/libraries/render-utils/src/BloomEffect.cpp +++ b/libraries/render-utils/src/BloomEffect.cpp @@ -75,7 +75,7 @@ void BloomThreshold::run(const render::RenderContextPointer& renderContext, cons glm::ivec4 viewport{ 0, 0, bufferSize.x, bufferSize.y }; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("BloomThreshold::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(viewport); @@ -135,7 +135,7 @@ void BloomApply::run(const render::RenderContextPointer& renderContext, const In const auto blur2FB = inputs.get3(); const glm::ivec4 viewport{ 0, 0, framebufferSize.x, framebufferSize.y }; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("BloomApply::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(frameBuffer); @@ -180,7 +180,7 @@ void BloomDraw::run(const render::RenderContextPointer& renderContext, const Inp _pipeline = gpu::Pipeline::create(program, state); } - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("BloomDraw::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(frameBuffer); @@ -238,7 +238,7 @@ void DebugBloom::run(const render::RenderContextPointer& renderContext, const In _pipeline = gpu::Pipeline::create(program, state); } - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DebugBloom::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(frameBuffer); diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index f9d8c4af38..9f1b5e0fd3 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -416,7 +416,7 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I auto& ambientOcclusionFramebuffer = inputs.get3(); auto& velocityFramebuffer = inputs.get4(); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DebugDeferredBuffer::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(args->_viewport); diff --git a/libraries/render-utils/src/DeferredFrameTransform.cpp b/libraries/render-utils/src/DeferredFrameTransform.cpp index cee5786847..d6dc9e1372 100644 --- a/libraries/render-utils/src/DeferredFrameTransform.cpp +++ b/libraries/render-utils/src/DeferredFrameTransform.cpp @@ -42,7 +42,7 @@ void DeferredFrameTransform::update(RenderArgs* args) { args->getViewFrustum().evalProjectionMatrix(frameTransformBuffer.projectionMono); - // Running in stero ? + // Running in stereo ? bool isStereo = args->isStereo(); if (!isStereo) { frameTransformBuffer.projection[0] = frameTransformBuffer.projectionMono; diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 646b19198b..a2e29f57d3 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -407,7 +407,7 @@ void PrepareDeferred::run(const RenderContextPointer& renderContext, const Input outputs.edit0() = _deferredFramebuffer; outputs.edit1() = _deferredFramebuffer->getLightingFramebuffer(); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("PrepareDeferred::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 4431c1bbc3..59cdc2dbf4 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -155,7 +155,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu auto sourceFramebufferSize = glm::ivec2(inputBuffer->getDimensions()); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawHaze::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(outputBuffer); diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index 7c58e5ba66..6fa50fbb68 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -161,7 +161,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c // Clear the framebuffer without stereo // Needs to be distinct from the other batch because using the clear call // while stereo is enabled triggers a warning - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawHighlightMask::run::begin", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(ressources->getDepthFramebuffer()); batch.clearDepthStencilFramebuffer(1.0f, 0); @@ -174,7 +174,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c render::ItemBounds itemBounds; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawHighlightMask::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; auto maskPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder); @@ -212,7 +212,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c _boundsBuffer->setData(itemBounds.size() * sizeof(render::ItemBound), (const gpu::Byte*) itemBounds.data()); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawHighlightMask::run::end", args->_context, [&](gpu::Batch& batch) { // Setup camera, projection and viewport for all items batch.setViewportTransform(args->_viewport); batch.setProjectionTransform(projMat); @@ -279,7 +279,7 @@ void DrawHighlight::run(const render::RenderContextPointer& renderContext, const shaderParameters._size.y = size; } - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawHighlight::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(destinationFrameBuffer); @@ -352,7 +352,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons assert(renderContext->args->hasViewFrustum()); RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DebugHighlight::run", args->_context, [&](gpu::Batch& batch) { batch.setViewportTransform(args->_viewport); batch.setFramebuffer(highlightRessources->getColorFramebuffer()); diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 60fdc75e5e..3aa931aba7 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -92,7 +92,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren fadeEffect->build(task, opaques); - const auto jitterBuffer = task.addJob("JitterCam"); + task.addJob("JitterCam"); // Prepare deferred, generate the shared Deferred Frame Transform const auto deferredFrameTransform = task.addJob("DeferredFrameTransform"); @@ -238,6 +238,10 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("DrawOverlayInFrontTransparentBounds", overlaysInFrontTransparent); } + // AA job to be revisited + const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, primaryFramebuffer, linearDepthTarget, velocityBuffer).asVarying(); + task.addJob("Antialiasing", antialiasingInputs); + // Debugging stages { // Debugging Deferred buffer job @@ -268,11 +272,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("DrawZoneStack", deferredFrameTransform); } - // AA job to be revisited - const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, jitterBuffer, primaryFramebuffer, linearDepthTarget, velocityBuffer).asVarying(); - - task.addJob("Antialiasing", antialiasingInputs); - // Composite the HUD and HUD overlays task.addJob("HUD"); @@ -297,13 +296,13 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren void BeginGPURangeTimer::run(const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) { timer = _gpuTimer; - gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("BeginGPURangeTimer::run", renderContext->args->_context, [&](gpu::Batch& batch) { _gpuTimer->begin(batch); }); } void EndGPURangeTimer::run(const render::RenderContextPointer& renderContext, const gpu::RangeTimerPointer& timer) { - gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("EndGPURangeTimer::run", renderContext->args->_context, [&](gpu::Batch& batch) { timer->end(batch); }); @@ -323,7 +322,7 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs& RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawDeferred::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; // Setup camera, projection and viewport for all items @@ -370,7 +369,7 @@ void DrawStateSortDeferred::run(const RenderContextPointer& renderContext, const RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawStateSortDeferred::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; // Setup camera, projection and viewport for all items @@ -434,14 +433,14 @@ void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& // Needs to be distinct from the other batch because using the clear call // while stereo is enabled triggers a warning if (_opaquePass) { - gpu::doInBatch(args->_context, [&](gpu::Batch& batch){ + gpu::doInBatch("DrawOverlay3D::run::clear", args->_context, [&](gpu::Batch& batch){ batch.enableStereo(false); batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(), 1.f, 0, false); }); } // Render the items - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawOverlay3D::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); @@ -473,7 +472,7 @@ void CompositeHUD::run(const RenderContextPointer& renderContext) { } // Grab the HUD texture - gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("CompositeHUD::run", renderContext->args->_context, [&](gpu::Batch& batch) { if (renderContext->args->_hudOperator) { renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE); } @@ -499,7 +498,7 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer // Blit primary to blit FBO auto primaryFbo = srcFramebuffer; - gpu::doInBatch(renderArgs->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("Blit::run", renderArgs->_context, [&](gpu::Batch& batch) { batch.setFramebuffer(blitFbo); if (renderArgs->_renderMode == RenderArgs::MIRROR_RENDER_MODE) { diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index c83251c605..6aaeae7bcc 100755 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -84,7 +84,7 @@ void PrepareFramebuffer::run(const RenderContextPointer& renderContext, } auto args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("PrepareFramebuffer::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); @@ -104,7 +104,7 @@ void Draw::run(const RenderContextPointer& renderContext, const Inputs& items) { RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("RenderForward::Draw::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; // Setup projection @@ -141,7 +141,7 @@ const gpu::PipelinePointer Stencil::getPipeline() { void Stencil::run(const RenderContextPointer& renderContext) { RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("RenderForward::Stencil::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.enableStereo(false); @@ -158,7 +158,7 @@ void DrawBackground::run(const RenderContextPointer& renderContext, const Inputs& background) { RenderArgs* args = renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("RenderForward::DrawBackground::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.enableSkybox(true); diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index 7a6e3dc74f..5557b1af59 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -153,7 +153,7 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con args->popViewFrustum(); args->pushViewFrustum(adjustedShadowFrustum); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("RenderShadowMap::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.enableStereo(false); diff --git a/libraries/render-utils/src/StencilMaskPass.cpp b/libraries/render-utils/src/StencilMaskPass.cpp index f71111b64e..54811937fd 100644 --- a/libraries/render-utils/src/StencilMaskPass.cpp +++ b/libraries/render-utils/src/StencilMaskPass.cpp @@ -81,7 +81,7 @@ void PrepareStencil::run(const RenderContextPointer& renderContext, const gpu::F return; } - doInBatch(args->_context, [&](gpu::Batch& batch) { + doInBatch("PrepareStencil::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(args->_viewport); diff --git a/libraries/render-utils/src/SubsurfaceScattering.cpp b/libraries/render-utils/src/SubsurfaceScattering.cpp index 1786898e57..ef1fdcaa78 100644 --- a/libraries/render-utils/src/SubsurfaceScattering.cpp +++ b/libraries/render-utils/src/SubsurfaceScattering.cpp @@ -322,7 +322,7 @@ void diffuseProfileGPU(gpu::TexturePointer& profileMap, RenderArgs* args) { auto makeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("diffuseProfile")); makeFramebuffer->setRenderBuffer(0, profileMap); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("SubsurfaceScattering::diffuseProfileGPU", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(glm::ivec4(0, 0, width, height)); @@ -359,7 +359,7 @@ void diffuseScatterGPU(const gpu::TexturePointer& profileMap, gpu::TexturePointe auto makeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("diffuseScatter")); makeFramebuffer->setRenderBuffer(0, lut); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("SubsurfaceScattering::diffuseScatterGPU", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(glm::ivec4(0, 0, width, height)); @@ -396,7 +396,7 @@ void computeSpecularBeckmannGPU(gpu::TexturePointer& beckmannMap, RenderArgs* ar auto makeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("computeSpecularBeckmann")); makeFramebuffer->setRenderBuffer(0, beckmannMap); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("SubsurfaceScattering::computeSpecularBeckmannGPU", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(glm::ivec4(0, 0, width, height)); @@ -537,7 +537,7 @@ void DebugSubsurfaceScattering::run(const render::RenderContextPointer& renderCo // const auto light = DependencyManager::get()->getLightStage()->getLight(0); const auto light = lightStage->getLight(0); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("DebugSubsurfaceScattering::run", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); diff --git a/libraries/render-utils/src/SurfaceGeometryPass.cpp b/libraries/render-utils/src/SurfaceGeometryPass.cpp index c4eea7ce7f..740a6978f2 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.cpp +++ b/libraries/render-utils/src/SurfaceGeometryPass.cpp @@ -174,7 +174,7 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con auto halfViewport = depthViewport >> 1; float clearLinearDepth = args->getViewFrustum().getFarClip() * 2.0f; - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("LinearDepthPass::run", args->_context, [=](gpu::Batch& batch) { _gpuTimer->begin(batch); batch.enableStereo(false); @@ -466,7 +466,7 @@ void SurfaceGeometryPass::run(const render::RenderContextPointer& renderContext, _diffusePass.getParameters()->setLinearDepthPosFar(args->getViewFrustum().getFarClip()); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("SurfaceGeometryPass::run", args->_context, [=](gpu::Batch& batch) { _gpuTimer->begin(batch); batch.enableStereo(false); diff --git a/libraries/render-utils/src/ToneMappingEffect.cpp b/libraries/render-utils/src/ToneMappingEffect.cpp index 72d692c5b2..ff036df3dd 100644 --- a/libraries/render-utils/src/ToneMappingEffect.cpp +++ b/libraries/render-utils/src/ToneMappingEffect.cpp @@ -62,7 +62,7 @@ void ToneMappingEffect::render(RenderArgs* args, const gpu::TexturePointer& ligh init(); } auto framebufferSize = glm::ivec2(lightingBuffer->getDimensions()); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("ToneMappingEffect::render", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(destinationFramebuffer); diff --git a/libraries/render-utils/src/VelocityBufferPass.cpp b/libraries/render-utils/src/VelocityBufferPass.cpp index 26dc1c6848..7553d16271 100644 --- a/libraries/render-utils/src/VelocityBufferPass.cpp +++ b/libraries/render-utils/src/VelocityBufferPass.cpp @@ -118,7 +118,7 @@ void VelocityBufferPass::run(const render::RenderContextPointer& renderContext, auto fullViewport = args->_viewport; - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("VelocityBufferPass::run", args->_context, [=](gpu::Batch& batch) { _gpuTimer->begin(batch); batch.enableStereo(false); diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index 3d1fe33267..7a94f5d570 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -170,7 +170,7 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I } - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("DebugZoneLighting::run", args->_context, [=](gpu::Batch& batch) { batch.setViewportTransform(args->_viewport); auto viewFrustum = args->getViewFrustum(); diff --git a/libraries/render-utils/src/taa.slf b/libraries/render-utils/src/taa.slf index b4ad713a7a..57334e8ab5 100644 --- a/libraries/render-utils/src/taa.slf +++ b/libraries/render-utils/src/taa.slf @@ -20,22 +20,13 @@ layout(location = 0) out vec4 outFragColor; void main() { vec2 fragUV = varTexCoord0; - - - - vec2 texelSize = taa_getTexelSize(); - - vec2 fragJitterPix = taa_getCurrentJitterSample(); - if (taa_unjitter()) { - fragUV -= fragJitterPix * texelSize; - } // Debug region before debug or fxaa region X -/* float distToRegionFXAA = fragUV.x - taa_getRegionFXAA().x; + float distToRegionFXAA = fragUV.x - taa_getRegionFXAA().x; if (distToRegionFXAA > 0.0) { outFragColor = vec4(taa_evalFXAA(fragUV), 1.0); return; - }*/ + } // vec3 nearFragUV = taa_findClosestFragment3x3(fragUV); // vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy); diff --git a/libraries/render-utils/src/taa.slh b/libraries/render-utils/src/taa.slh index d276f2870d..6d5addba49 100644 --- a/libraries/render-utils/src/taa.slh +++ b/libraries/render-utils/src/taa.slh @@ -13,31 +13,6 @@ <@include DeferredTransform.slh@> <$declareDeferredFrameTransform()$> -const int SEQUENCE_LENGTH = 16; -const int INFO_INDEX = SEQUENCE_LENGTH / 2; -struct JitterSequence { - vec4 offsets[INFO_INDEX + 1]; -}; -layout(std140) uniform taaJitterBuffer { - JitterSequence sequence; -}; - -vec2 taa_getJitterSample(int index) { - return vec2((bool(index & 0x01) ? sequence.offsets[index >> 1].zw : sequence.offsets[index >> 1].xy)); -} - -int taa_getJitterSequenceLength() { - return floatBitsToInt(sequence.offsets[INFO_INDEX].z); -} - -int taa_getCurrentJitterIndex() { - return floatBitsToInt(sequence.offsets[INFO_INDEX].w); -} - -vec2 taa_getCurrentJitterSample() { - return taa_getJitterSample(taa_getCurrentJitterIndex()); -} - <@include gpu/Color.slh@> uniform sampler2D depthMap; @@ -67,27 +42,22 @@ bool taa_showDebugCursor() { return GET_BIT(params.flags.x, 1); } -bool taa_showJitterSequence() { - return GET_BIT(params.flags.x, 2); -} - bool taa_showClosestFragment() { return GET_BIT(params.flags.x, 3); } - -bool taa_unjitter() { - return GET_BIT(params.flags.y, 0); -} bool taa_constrainColor() { return GET_BIT(params.flags.y, 1); } + bool taa_covarianceClipColor() { return GET_BIT(params.flags.y, 2); } + bool taa_clipExactColor() { return GET_BIT(params.flags.y, 3); } + bool taa_feedbackColor() { return GET_BIT(params.flags.y, 4); } diff --git a/libraries/render-utils/src/taa_blend.slf b/libraries/render-utils/src/taa_blend.slf index 3d040af9db..8b32ee2fb0 100644 --- a/libraries/render-utils/src/taa_blend.slf +++ b/libraries/render-utils/src/taa_blend.slf @@ -28,10 +28,6 @@ void main(void) { vec2 imageSize = getWidthHeight(0); vec2 texelSize = getInvWidthHeight(); - vec2 fragJitterPix = taa_getCurrentJitterSample(); - - - vec2 pixPos = varTexCoord0 * imageSize; vec2 pixVelocity = imageSize * texture(velocityMap, varTexCoord0).xy; float pixVelocityLength = length(pixVelocity); @@ -44,7 +40,7 @@ void main(void) { vec2 cursorUVRaw = taa_getDebugCursorTexcoord(); vec2 cursorPosRaw = floor(cursorUVRaw * imageSize) + vec2(0.5); vec3 cursorFrag = taa_findClosestFragment3x3(cursorUVRaw); - vec2 cursorUV = cursorUVRaw - fragJitterPix * texelSize; + vec2 cursorUV = cursorUVRaw; vec2 cursorPos = cursorUV * imageSize; vec2 cursorVelocity = texture(velocityMap, cursorUV).xy; vec2 cursorPrevUV = cursorUV - cursorVelocity; @@ -117,29 +113,6 @@ void main(void) { } } - if (taa_showJitterSequence()) { - float tenPercentHeight = 0.1 * imageSize.y; - vec2 jitterRegionSize = vec2(tenPercentHeight); - vec2 jitterRegionPos = (pixPos - vec2(tenPercentHeight, imageSize.y - tenPercentHeight)); - if ((all(lessThan(jitterRegionPos, jitterRegionSize)) && all(greaterThan(jitterRegionPos, vec2(0.0))))) { - - float niceDotR2 = 4.0; - - //int sequenceLength = taa_getJitterSequenceLength(); - int sequenceLength = SEQUENCE_LENGTH; - for (int s = 0; s < sequenceLength; s++) { - vec2 pixToSampleVec = jitterRegionPos - (vec2(0.5) + taa_getJitterSample(s)) * jitterRegionSize; - float radius2 = (s == taa_getCurrentJitterIndex() ? 4.0 * niceDotR2 : niceDotR2); - float distToSample2 = dot(pixToSampleVec, pixToSampleVec); - if (distToSample2 < radius2) { - outFragColor = vec4(mix( outFragColor.rgb, colorRamp(float(s) / float(sequenceLength)), 1.0 - distToSample2 / radius2), 1.0); - return; - } - } - - } - } - // Debug region before debug or fxaa region X float distToRegionDebug = varTexCoord0.x - taa_getRegionDebug().x; float distToRegionFXAA = varTexCoord0.x - taa_getRegionFXAA().x; diff --git a/libraries/render/src/render/BlurTask.cpp b/libraries/render/src/render/BlurTask.cpp index 2be6f8fad2..eb01835a8c 100644 --- a/libraries/render/src/render/BlurTask.cpp +++ b/libraries/render/src/render/BlurTask.cpp @@ -286,7 +286,7 @@ void BlurGaussian::run(const RenderContextPointer& renderContext, const gpu::Fra _parameters->setWidthHeight(blurredFramebuffer->getWidth(), blurredFramebuffer->getHeight(), args->isStereo()); _parameters->setTexcoordTransform(gpu::Framebuffer::evalSubregionTexcoordTransformCoefficients(textureSize, viewport)); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("BlurGaussian::run", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(viewport); @@ -401,7 +401,7 @@ void BlurGaussianDepthAware::run(const RenderContextPointer& renderContext, cons _parameters->setDepthPerspective(args->getViewFrustum().getProjection()[1][1]); _parameters->setLinearDepthPosFar(args->getViewFrustum().getFarClip()); - gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { + gpu::doInBatch("BlurGaussianDepthAware::run", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); batch.setViewportTransform(sourceViewport); diff --git a/libraries/render/src/render/DrawSceneOctree.cpp b/libraries/render/src/render/DrawSceneOctree.cpp index 36663a454a..f663c2bb82 100644 --- a/libraries/render/src/render/DrawSceneOctree.cpp +++ b/libraries/render/src/render/DrawSceneOctree.cpp @@ -94,7 +94,7 @@ void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemS std::static_pointer_cast(renderContext->jobConfig)->numFreeCells = (int)scene->getSpatialTree().getNumFreeCells(); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawSceneOctree::run", args->_context, [&](gpu::Batch& batch) { glm::mat4 projMat; Transform viewMat; args->getViewFrustum().evalProjectionMatrix(projMat); @@ -201,7 +201,7 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite RenderArgs* args = renderContext->args; auto& scene = renderContext->_scene; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawItemSelection::run", args->_context, [&](gpu::Batch& batch) { glm::mat4 projMat; Transform viewMat; args->getViewFrustum().evalProjectionMatrix(projMat); diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index 148e104453..6c636de382 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -163,7 +163,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds } // Allright, something to render let's do it - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawStatus::run", args->_context, [&](gpu::Batch& batch) { glm::mat4 projMat; Transform viewMat; args->getViewFrustum().evalProjectionMatrix(projMat); diff --git a/libraries/render/src/render/DrawTask.cpp b/libraries/render/src/render/DrawTask.cpp index 0f4137e38d..088b641162 100755 --- a/libraries/render/src/render/DrawTask.cpp +++ b/libraries/render/src/render/DrawTask.cpp @@ -143,7 +143,7 @@ void DrawLight::run(const RenderContextPointer& renderContext, const ItemBounds& RenderArgs* args = renderContext->args; // render lights - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawLight::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; renderItems(renderContext, inLights, _maxDrawn); args->_batch = nullptr; @@ -191,7 +191,7 @@ void DrawBounds::run(const RenderContextPointer& renderContext, _drawBuffer->setData(numItems * sizeOfItemBound, (const gpu::Byte*) items.data()); - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawBounds::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; // Setup projection @@ -262,7 +262,7 @@ void DrawFrustum::run(const render::RenderContextPointer& renderContext, const I } // Render the frustums in wireframe - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawFrustum::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); diff --git a/libraries/render/src/render/ResampleTask.cpp b/libraries/render/src/render/ResampleTask.cpp index 65c0ff45b9..07f7367582 100644 --- a/libraries/render/src/render/ResampleTask.cpp +++ b/libraries/render/src/render/ResampleTask.cpp @@ -66,7 +66,7 @@ void HalfDownsample::run(const RenderContextPointer& renderContext, const gpu::F const auto bufferSize = resampledFrameBuffer->getSize(); glm::ivec4 viewport{ 0, 0, bufferSize.x, bufferSize.y }; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("HalfDownsample::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(resampledFrameBuffer); diff --git a/scripts/developer/utilities/render/antialiasing.qml b/scripts/developer/utilities/render/antialiasing.qml index 566f7ee01a..26b9e09c09 100644 --- a/scripts/developer/utilities/render/antialiasing.qml +++ b/scripts/developer/utilities/render/antialiasing.qml @@ -85,21 +85,6 @@ Rectangle { onClicked: { Render.getConfig("RenderMainView.JitterCam").next(); } } } - Row { - spacing: 10 - HifiControls.CheckBox { - boxSize: 20 - text: "Unjitter" - checked: Render.getConfig("RenderMainView.Antialiasing")["unjitter"] - onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["unjitter"] = checked } - } - HifiControls.CheckBox { - boxSize: 20 - text: "Show Sequence" - checked: Render.getConfig("RenderMainView.Antialiasing")["showJitterSequence"] - onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["showJitterSequence"] = checked } - } - } Separator {} Column { spacing: 10 diff --git a/tests/gpu-test/src/TestWindow.cpp b/tests/gpu-test/src/TestWindow.cpp index 9ae78527cc..f5fc1cea85 100644 --- a/tests/gpu-test/src/TestWindow.cpp +++ b/tests/gpu-test/src/TestWindow.cpp @@ -114,14 +114,14 @@ void TestWindow::beginFrame() { // the rest of the renderDeferred inputs can be omitted #else - gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("TestWindow::beginFrame", _renderArgs->_context, [&](gpu::Batch& batch) { batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLORS, { 0.0f, 0.1f, 0.2f, 1.0f }); batch.clearDepthFramebuffer(1e4); batch.setViewportTransform({ 0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio() }); }); #endif - gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("TestWindow::beginFrame", _renderArgs->_context, [&](gpu::Batch& batch) { batch.setViewportTransform(_renderArgs->_viewport); batch.setStateScissorRect(_renderArgs->_viewport); batch.setProjectionTransform(_projectionMatrix); @@ -131,7 +131,7 @@ void TestWindow::beginFrame() { void TestWindow::endFrame() { #ifdef DEFERRED_LIGHTING RenderArgs* args = _renderContext->args; - gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("TestWindow::endFrame::begin", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; auto deferredFboColorDepthStencil = _prepareDeferredOutputs.get0()->getDeferredFramebufferDepthColor(); batch.setViewportTransform(args->_viewport); @@ -144,7 +144,7 @@ void TestWindow::endFrame() { _renderDeferred.run(_renderContext, _renderDeferredInputs); - gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("TestWindow::endFrame::blit", _renderArgs->_context, [&](gpu::Batch& batch) { PROFILE_RANGE_BATCH(batch, "blit"); // Blit to screen auto framebufferCache = DependencyManager::get(); @@ -154,7 +154,7 @@ void TestWindow::endFrame() { }); #endif - gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("TestWindow::endFrame::finish", _renderArgs->_context, [&](gpu::Batch& batch) { batch.resetStages(); }); _glContext.swapBuffers(this); diff --git a/tests/gpu-test/src/main.cpp b/tests/gpu-test/src/main.cpp index d37be7c790..8aa70ce22f 100644 --- a/tests/gpu-test/src/main.cpp +++ b/tests/gpu-test/src/main.cpp @@ -146,7 +146,7 @@ class MyTestWindow : public TestWindow { return; } - gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("main::renderFrame", _renderArgs->_context, [&](gpu::Batch& batch) { batch.setViewTransform(_camera); _renderArgs->_batch = &batch; _currentTest->renderTest(_currentTestId, _renderArgs); diff --git a/tests/render-perf/src/main.cpp b/tests/render-perf/src/main.cpp index c70a74cd7f..f964a01dab 100644 --- a/tests/render-perf/src/main.cpp +++ b/tests/render-perf/src/main.cpp @@ -921,7 +921,7 @@ private: void render(RenderArgs* renderArgs) { auto& gpuContext = renderArgs->_context; gpuContext->beginFrame(); - gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) { + gpu::doInBatch("QTestWindow::render", gpuContext, [&](gpu::Batch& batch) { batch.resetStages(); }); PROFILE_RANGE(render, __FUNCTION__); diff --git a/tests/render-texture-load/src/main.cpp b/tests/render-texture-load/src/main.cpp index 67b80d9ba8..3dbb4987a4 100644 --- a/tests/render-texture-load/src/main.cpp +++ b/tests/render-texture-load/src/main.cpp @@ -561,12 +561,12 @@ private: void render() { auto& gpuContext = _renderThread._gpuContext; gpuContext->beginFrame(); - gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) { + gpu::doInBatch("RenderThread::render::begin", gpuContext, [&](gpu::Batch& batch) { batch.resetStages(); }); auto framebuffer = DependencyManager::get()->getFramebuffer(); - gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) { + gpu::doInBatch("RenderThread::render", gpuContext, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(framebuffer); batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(1, 0, 0, 1));