added optional output buffer to ToneMapAndResampleTask

This commit is contained in:
Anna 2019-07-29 16:27:54 -07:00
parent 3a437cf190
commit d3107efb82
4 changed files with 48 additions and 39 deletions

View file

@ -12,7 +12,9 @@ include_hifi_library_headers(hfm)
# tell CMake to exclude qrc_fonts.cpp for policy CMP0071 # tell CMake to exclude qrc_fonts.cpp for policy CMP0071
set_property(SOURCE qrc_fonts.cpp PROPERTY SKIP_AUTOMOC ON) set_property(SOURCE qrc_fonts.cpp PROPERTY SKIP_AUTOMOC ON)
if (NOT ANDROID) if (ANDROID)
target_link_libraries(${TARGET_NAME} android log)
else()
target_nsight() target_nsight()
endif () endif ()

View file

@ -145,8 +145,14 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
const auto resolveInputs = ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, newResolvedFramebuffer).asVarying(); const auto resolveInputs = ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, newResolvedFramebuffer).asVarying();
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs); const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
const auto toneMappedBuffer = task.addJob<ToneMapAndResample>("ToneMapAndResample", resolvedFramebuffer); #if defined(Q_OS_ANDROID)
const auto destFramebuffer = static_cast<gpu::FramebufferPointer>(nullptr);
#else
const auto destFramebuffer = resolvedFramebuffer;
#endif
const auto toneMappingInputs = ToneMapAndResample::Input(resolvedFramebuffer, destFramebuffer).asVarying();
const auto toneMappedBuffer = task.addJob<ToneMapAndResample>("ToneMapAndResample", toneMappingInputs);
// HUD Layer // HUD Layer
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(toneMappedBuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying(); const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(toneMappedBuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying();
task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs); task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs);

View file

@ -3,7 +3,7 @@
// libraries/render-utils/src // libraries/render-utils/src
// //
// Created by Anna Brewer on 7/3/19. // Created by Anna Brewer on 7/3/19.
// Copyright 2015 High Fidelity, Inc. // Copyright 2019 High Fidelity, Inc.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -61,28 +61,28 @@ void ToneMapAndResample::configure(const Config& config) {
setToneCurve((ToneCurve)config.curve); setToneCurve((ToneCurve)config.curve);
} }
void ToneMapAndResample::run(const RenderContextPointer& renderContext, const Input& input, gpu::FramebufferPointer& resampledFrameBuffer) { void ToneMapAndResample::run(const RenderContextPointer& renderContext, const Input& input, Output& output) {
assert(renderContext->args); assert(renderContext->args);
assert(renderContext->args->hasViewFrustum()); assert(renderContext->args->hasViewFrustum());
RenderArgs* args = renderContext->args; RenderArgs* args = renderContext->args;
auto sourceFramebuffer = input;
auto lightingBuffer = input->getRenderBuffer(0); auto lightingBuffer = input.get0()->getRenderBuffer(0);
auto resampledFramebuffer = input.get1();
resampledFrameBuffer = args->_blitFramebuffer; if (!resampledFramebuffer) {
resampledFramebuffer = args->_blitFramebuffer;
if (!lightingBuffer || !resampledFrameBuffer) {
return;
} }
if (resampledFrameBuffer != sourceFramebuffer) { if (!lightingBuffer || !resampledFramebuffer) {
return;
}
if (!_pipeline) { if (!_pipeline) {
init(); init();
} }
const auto bufferSize = resampledFrameBuffer->getSize(); const auto bufferSize = resampledFramebuffer->getSize();
auto srcBufferSize = glm::ivec2(lightingBuffer->getDimensions()); auto srcBufferSize = glm::ivec2(lightingBuffer->getDimensions());
@ -90,7 +90,7 @@ void ToneMapAndResample::run(const RenderContextPointer& renderContext, const In
gpu::doInBatch("Resample::run", args->_context, [&](gpu::Batch& batch) { gpu::doInBatch("Resample::run", args->_context, [&](gpu::Batch& batch) {
batch.enableStereo(false); batch.enableStereo(false);
batch.setFramebuffer(resampledFrameBuffer); batch.setFramebuffer(resampledFramebuffer);
batch.setViewportTransform(destViewport); batch.setViewportTransform(destViewport);
batch.setProjectionTransform(glm::mat4()); batch.setProjectionTransform(glm::mat4());
@ -105,5 +105,6 @@ void ToneMapAndResample::run(const RenderContextPointer& renderContext, const In
// Set full final viewport // Set full final viewport
args->_viewport = destViewport; args->_viewport = destViewport;
}
output = resampledFramebuffer;
} }

View file

@ -3,7 +3,7 @@
// libraries/render-utils/src // libraries/render-utils/src
// //
// Created by Anna Brewer on 7/3/19. // Created by Anna Brewer on 7/3/19.
// Copyright 2015 High Fidelity, Inc. // Copyright 2019 High Fidelity, Inc.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -59,7 +59,7 @@ public:
ToneCurve getToneCurve() const { return (ToneCurve)_parametersBuffer.get<Parameters>()._toneCurve; } ToneCurve getToneCurve() const { return (ToneCurve)_parametersBuffer.get<Parameters>()._toneCurve; }
// Inputs: lightingFramebuffer, destinationFramebuffer // Inputs: lightingFramebuffer, destinationFramebuffer
using Input = gpu::FramebufferPointer; using Input = render::VaryingSet2<gpu::FramebufferPointer, gpu::FramebufferPointer>;
using Output = gpu::FramebufferPointer; using Output = gpu::FramebufferPointer;
using Config = ToneMappingConfig; using Config = ToneMappingConfig;
using JobModel = render::Job::ModelIO<ToneMapAndResample, Input, Output, Config>; using JobModel = render::Job::ModelIO<ToneMapAndResample, Input, Output, Config>;