Proper allocation of the resource in forward and starting to remove the ui as we have it

This commit is contained in:
Sam Gateau 2019-06-19 17:33:26 -07:00
parent b2631e89e9
commit b5e4a47375
7 changed files with 49 additions and 31 deletions

View file

@ -3743,13 +3743,6 @@ void Application::resizeGL() {
auto renderResolutionScale = getRenderResolutionScale();
if (displayPlugin->getRenderResolutionScale() != renderResolutionScale) {
auto renderConfig = _graphicsEngine.getRenderEngine()->getConfiguration();
assert(renderConfig);
auto mainView = renderConfig->getConfig("RenderMainView.RenderDeferredTask");
// mainView can be null if we're rendering in forward mode
if (mainView) {
mainView->setProperty("resolutionScale", renderResolutionScale);
}
displayPlugin->setRenderResolutionScale(renderResolutionScale);
}

View file

@ -30,11 +30,13 @@ void RenderScriptingInterface::loadSettings() {
_shadowsEnabled = (_shadowsEnabledSetting.get());
_ambientOcclusionEnabled = (_ambientOcclusionEnabledSetting.get());
_antialiasingEnabled = (_antialiasingEnabledSetting.get());
_viewportResolutionScale = (_viewportResolutionScaleSetting.get());
});
forceRenderMethod((RenderMethod)_renderMethod);
forceShadowsEnabled(_shadowsEnabled);
forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);
forceAntialiasingEnabled(_antialiasingEnabled);
forceViewportResolutionScale(_viewportResolutionScale);
}
RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() const {
@ -159,7 +161,7 @@ void RenderScriptingInterface::setViewportResolutionScale(float scale) {
void RenderScriptingInterface::forceViewportResolutionScale(float scale) {
_renderSettingLock.withWriteLock([&] {
_viewportResolutionScale = (scale);
// _antialiasingEnabledSetting.set(enabled);
_viewportResolutionScaleSetting.set(scale);
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
assert(renderConfig);
@ -173,19 +175,5 @@ void RenderScriptingInterface::forceViewportResolutionScale(float scale) {
if (forwardView) {
forwardView->setProperty("resolutionScale", _viewportResolutionScale);
}
/*
auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled);
if (enabled) {
mainViewJitterCamConfig->play();
mainViewAntialiasingConfig->setDebugFXAA(false);
}
else {
mainViewJitterCamConfig->none();
mainViewAntialiasingConfig->setDebugFXAA(true);
}
}*/
});
}

View file

@ -159,6 +159,7 @@ private:
Setting::Handle<bool> _shadowsEnabledSetting { "shadowsEnabled", true };
Setting::Handle<bool> _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", false };
Setting::Handle<bool> _antialiasingEnabledSetting { "antialiasingEnabled", true };
Setting::Handle<float> _viewportResolutionScaleSetting { "viewportResolutionScale", 1.0f };
// Force assign both setting AND runtime value to the parameter value
void forceRenderMethod(RenderMethod renderMethod);

View file

@ -199,6 +199,35 @@ void NewFramebuffer::run(const render::RenderContextPointer& renderContext, cons
output = _outputFramebuffer;
}
void NewOrDefaultFramebuffer::run(const render::RenderContextPointer& renderContext, const Input& input, Output& output) {
RenderArgs* args = renderContext->args;
// auto frameSize = input;
glm::uvec2 frameSize(args->_viewport.z, args->_viewport.w);
output.reset();
// First if the default Framebuffer is the correct size then use it
auto destBlitFbo = args->_blitFramebuffer;
if (destBlitFbo && destBlitFbo->getSize() == frameSize) {
output = destBlitFbo;
return;
}
// Else use the lodal Framebuffer
if (_outputFramebuffer && _outputFramebuffer->getSize() != frameSize) {
_outputFramebuffer.reset();
}
if (!_outputFramebuffer) {
_outputFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("newFramebuffer.out"));
auto colorFormat = gpu::Element::COLOR_SRGBA_32;
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
auto colorTexture = gpu::Texture::createRenderBuffer(colorFormat, frameSize.x, frameSize.y, gpu::Texture::SINGLE_MIP, defaultSampler);
_outputFramebuffer->setRenderBuffer(0, colorTexture);
}
output = _outputFramebuffer;
}
void ResolveFramebuffer::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
RenderArgs* args = renderContext->args;
auto srcFbo = inputs.get0();

View file

@ -96,6 +96,17 @@ private:
gpu::FramebufferPointer _outputFramebuffer;
};
class NewOrDefaultFramebuffer {
public:
using Input = glm::uvec2;
using Output = gpu::FramebufferPointer;
using JobModel = render::Job::ModelIO<NewOrDefaultFramebuffer, Input, Output>;
void run(const render::RenderContextPointer& renderContext, const Input& input, Output& output);
private:
gpu::FramebufferPointer _outputFramebuffer;
};
class ResolveFramebuffer {
public:
using Inputs = render::VaryingSet2<gpu::FramebufferPointer, gpu::FramebufferPointer>;

View file

@ -144,28 +144,24 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
}
#if defined(Q_OS_ANDROID)
const auto resolveInputs =
ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
// Just resolve the msaa
const auto resolveInputs = ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
const auto toneMappedBuffer = resolvedFramebuffer;
#else
const auto newResolvedFramebuffer = task.addJob<NewFramebuffer>("MakeResolvingFramebuffer");
const auto newResolvedFramebuffer = task.addJob<NewOrDefaultFramebuffer>("MakeResolvingFramebuffer");
const auto resolveInputs = ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, newResolvedFramebuffer).asVarying();
// Just resolve the msaa
const auto resolveInputs = ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, newResolvedFramebuffer).asVarying();
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
// Lighting Buffer ready for tone mapping
// Forward rendering on GLES doesn't support tonemapping to and from the same FBO, so we specify
// the output FBO as null, which causes the tonemapping to target the blit framebuffer
// const auto toneMappingInputs = ToneMappingDeferred::Inputs(resolvedFramebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
// const auto toneMappingInputs = ToneMappingDeferred::Input(resolvedFramebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
const auto toneMappingInputs = ToneMappingDeferred::Input(resolvedFramebuffer, resolvedFramebuffer).asVarying();
// const auto toneMappingInputs = ToneMappingDeferred::Input(resolvedFramebuffer, newResolvedFramebuffer).asVarying();
const auto toneMappedBuffer = task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
#endif

View file

@ -34,8 +34,8 @@ Column {
label: "Viewport Resolution Scale"
object: Render
property: "viewportResolutionScale"
min: 0.1
max: 1.1
min: 0.5
max: 1.0
}
}