From 54daf6032c99125b12642e5bf9a9d047913b2f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=9E=8D=E9=9B=AA=E6=97=B6=E5=88=86?= Date: Mon, 4 Dec 2023 17:06:45 +0800 Subject: [PATCH] do not call render() for disabled passes --- src/core/window.cpp | 1 + src/main/renderer.cpp | 1 + src/render/passes/accumulate/accumulate.cu | 1 - src/render/passes/denoise/denoise.cpp | 2 -- src/render/passes/errormeasure/errormeasure.cpp | 2 +- src/render/passes/tonemapping/tonemapping.cu | 1 - 6 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/window.cpp b/src/core/window.cpp index 5838f7e3..f348f2ac 100644 --- a/src/core/window.cpp +++ b/src/core/window.cpp @@ -417,6 +417,7 @@ void DeviceManager::render() { beginFrame(); for (auto it : mRenderPasses) it->beginFrame(mRenderContext.get()); for (auto it : mRenderPasses) { + if (!it->enabled()) continue; if (it->isCudaPass()) mRenderContext->sychronizeCuda(); it->render(mRenderContext.get()); if (it->isCudaPass()) mRenderContext->sychronizeVulkan(); diff --git a/src/main/renderer.cpp b/src/main/renderer.cpp index 50653f97..db7c4cc8 100644 --- a/src/main/renderer.cpp +++ b/src/main/renderer.cpp @@ -83,6 +83,7 @@ void RenderApp::render() { mpUIRenderer->beginFrame(getRenderContext()); for (auto it : mRenderPasses) it->beginFrame(getRenderContext()); for (auto it : mRenderPasses) { + if (!it->enabled()) continue; if (it->isCudaPass()) getRenderContext()->sychronizeCuda(); it->render(getRenderContext()); if (it->isCudaPass()) getRenderContext()->sychronizeVulkan(); diff --git a/src/render/passes/accumulate/accumulate.cu b/src/render/passes/accumulate/accumulate.cu index d673b1bb..fde5c011 100644 --- a/src/render/passes/accumulate/accumulate.cu +++ b/src/render/passes/accumulate/accumulate.cu @@ -13,7 +13,6 @@ void AccumulatePass::reset() { } void AccumulatePass::render(RenderContext *context) { - if (!mEnable) return; PROFILE("Accumulate pass"); if (mScene->getChanges()) reset(); static size_t lastResetFrame = 0; diff --git a/src/render/passes/denoise/denoise.cpp b/src/render/passes/denoise/denoise.cpp index 2d141348..4a17d881 100644 --- a/src/render/passes/denoise/denoise.cpp +++ b/src/render/passes/denoise/denoise.cpp @@ -131,7 +131,6 @@ void DenoiseBackend::setPixelFormat(PixelFormat format) { } void DenoisePass::render(RenderContext *context) { - if (!mEnable) return; PROFILE("Denoise"); auto size = context->getRenderTarget()->getSize(); CudaRenderTarget cudaFrame = context->getColorTexture()->getCudaRenderTarget(); @@ -148,7 +147,6 @@ void DenoisePass::render(RenderContext *context) { void DenoisePass::renderUI() { ui::Checkbox("Enabled", &mEnable); - if (!mEnable) return; if (ui::Checkbox("Use geometry buffer", &mUseGeometry)) { Log(Fatal, "Denoising guided by geometry features is not implemented yet TaT"); mBackend.setHaveGeometry(mUseGeometry); diff --git a/src/render/passes/errormeasure/errormeasure.cpp b/src/render/passes/errormeasure/errormeasure.cpp index 2544f411..e28245b7 100644 --- a/src/render/passes/errormeasure/errormeasure.cpp +++ b/src/render/passes/errormeasure/errormeasure.cpp @@ -15,8 +15,8 @@ void ErrorMeasurePass::beginFrame(RenderContext* context) { } void ErrorMeasurePass::render(RenderContext *context) { + PROFILE("Metric calculation"); if (mNeedsEvaluate && mReferenceImage && mReferenceImage->isValid()) { - PROFILE("Metric calculation"); CHECK_LOG(mReferenceImage->getSize() == getFrameSize(), "ErrorMeasure::Reference image size does not match frame size!"); size_t n_elememts = getFrameSize()[0] * getFrameSize()[1]; diff --git a/src/render/passes/tonemapping/tonemapping.cu b/src/render/passes/tonemapping/tonemapping.cu index d1398228..467bdcc6 100644 --- a/src/render/passes/tonemapping/tonemapping.cu +++ b/src/render/passes/tonemapping/tonemapping.cu @@ -55,7 +55,6 @@ void ToneMappingPass::renderUI() { } void ToneMappingPass::render(RenderContext *context) { - if (!mEnable) return; PROFILE("Tong mapping pass"); CUstream &stream = gpContext->cudaStream; RGB colorTransform = RGB(mExposureCompensation);