mirror of
https://github.com/lubosz/overte.git
synced 2025-04-06 21:22:44 +02:00
Cleaning the gpu-test app to work with the new deferred pipeline
This commit is contained in:
parent
51594fefa2
commit
9f91dd5bfc
6 changed files with 50 additions and 27 deletions
|
@ -397,7 +397,7 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c
|
|||
const DeferredFramebufferPointer& deferredFramebuffer,
|
||||
const LightingModelPointer& lightingModel,
|
||||
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
|
||||
const gpu::TexturePointer& lowCurvatureNormal,
|
||||
const gpu::FramebufferPointer& lowCurvatureNormalFramebuffer,
|
||||
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) {
|
||||
|
||||
auto args = renderContext->args;
|
||||
|
@ -441,15 +441,17 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c
|
|||
batch.setUniformBuffer(LIGHTING_MODEL_BUFFER_SLOT, lightingModel->getParametersBuffer());
|
||||
|
||||
// Subsurface scattering specific
|
||||
batch.setResourceTexture(DEFERRED_BUFFER_CURVATURE_UNIT, surfaceGeometryFramebuffer->getCurvatureTexture());
|
||||
batch.setResourceTexture(DEFERRED_BUFFER_DIFFUSED_CURVATURE_UNIT, lowCurvatureNormal);
|
||||
|
||||
batch.setUniformBuffer(SCATTERING_PARAMETERS_BUFFER_SLOT, subsurfaceScatteringResource->getParametersBuffer());
|
||||
|
||||
|
||||
batch.setResourceTexture(SCATTERING_LUT_UNIT, subsurfaceScatteringResource->getScatteringTable());
|
||||
batch.setResourceTexture(SCATTERING_SPECULAR_UNIT, subsurfaceScatteringResource->getScatteringSpecular());
|
||||
|
||||
if (surfaceGeometryFramebuffer) {
|
||||
batch.setResourceTexture(DEFERRED_BUFFER_CURVATURE_UNIT, surfaceGeometryFramebuffer->getCurvatureTexture());
|
||||
}
|
||||
if (lowCurvatureNormalFramebuffer) {
|
||||
batch.setResourceTexture(DEFERRED_BUFFER_DIFFUSED_CURVATURE_UNIT, lowCurvatureNormalFramebuffer->getRenderBuffer(0));
|
||||
}
|
||||
if (subsurfaceScatteringResource) {
|
||||
batch.setUniformBuffer(SCATTERING_PARAMETERS_BUFFER_SLOT, subsurfaceScatteringResource->getParametersBuffer());
|
||||
batch.setResourceTexture(SCATTERING_LUT_UNIT, subsurfaceScatteringResource->getScatteringTable());
|
||||
batch.setResourceTexture(SCATTERING_SPECULAR_UNIT, subsurfaceScatteringResource->getScatteringSpecular());
|
||||
}
|
||||
|
||||
// Global directional light and ambient pass
|
||||
|
||||
|
@ -673,10 +675,12 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
|
|||
auto deferredFramebuffer = inputs.get1();
|
||||
auto lightingModel = inputs.get2();
|
||||
auto surfaceGeometryFramebuffer = inputs.get3();
|
||||
auto lowCurvatureNormal = inputs.get4()->getRenderBuffer(0);
|
||||
auto lowCurvatureNormalFramebuffer = inputs.get4();
|
||||
auto subsurfaceScatteringResource = inputs.get5();
|
||||
|
||||
setupJob.run(sceneContext, renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, lowCurvatureNormal, subsurfaceScatteringResource);
|
||||
|
||||
|
||||
setupJob.run(sceneContext, renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, lowCurvatureNormalFramebuffer, subsurfaceScatteringResource);
|
||||
|
||||
lightsJob.run(sceneContext, renderContext, deferredTransform, lightingModel->isPointLightEnabled(), lightingModel->isSpotLightEnabled());
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
const DeferredFramebufferPointer& deferredFramebuffer,
|
||||
const LightingModelPointer& lightingModel,
|
||||
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
|
||||
const gpu::TexturePointer& diffusedCurvature2,
|
||||
const gpu::FramebufferPointer& lowCurvatureNormalFramebuffer,
|
||||
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource);
|
||||
};
|
||||
|
||||
|
|
|
@ -147,5 +147,5 @@ void MakeLightingModel::configure(const Config& config) {
|
|||
|
||||
void MakeLightingModel::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, LightingModelPointer& lightingModel) {
|
||||
|
||||
lightingModel = _lightingModel;
|
||||
lightingModel = _lightingModel;
|
||||
}
|
|
@ -117,6 +117,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
|||
const auto curvatureFramebuffer = surfaceGeometryPassOutputs.getN<SurfaceGeometryPass::Outputs>(1);
|
||||
const auto linearDepthTexture = surfaceGeometryPassOutputs.getN<SurfaceGeometryPass::Outputs>(2);
|
||||
|
||||
// TODO: Push this 2 diffusion stages into surfaceGeometryPass as they are working together
|
||||
const auto diffuseCurvaturePassInputs = BlurGaussianDepthAware::Inputs(curvatureFramebuffer, linearDepthTexture).hasVarying();
|
||||
const auto midCurvatureNormalFramebuffer = addJob<render::BlurGaussianDepthAware>("DiffuseCurvatureMid", diffuseCurvaturePassInputs);
|
||||
const auto lowCurvatureNormalFramebuffer = addJob<render::BlurGaussianDepthAware>("DiffuseCurvatureLow", diffuseCurvaturePassInputs, true); // THis blur pass generates it s render resource
|
||||
|
|
|
@ -97,9 +97,26 @@ void TestWindow::beginFrame() {
|
|||
_renderArgs->_context->syncCache();
|
||||
|
||||
#ifdef DEFERRED_LIGHTING
|
||||
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
|
||||
|
||||
_prepareDeferred.run(_sceneContext, _renderContext, _deferredFramebuffer);
|
||||
gpu::FramebufferPointer primaryFramebuffer;
|
||||
_preparePrimaryFramebuffer.run(_sceneContext, _renderContext, primaryFramebuffer);
|
||||
|
||||
DeferredFrameTransformPointer frameTransform;
|
||||
_generateDeferredFrameTransform.run(_sceneContext, _renderContext, frameTransform);
|
||||
|
||||
LightingModelPointer lightingModel;
|
||||
_generateLightingModel.run(_sceneContext, _renderContext, lightingModel);
|
||||
|
||||
_prepareDeferredInputs.edit0() = primaryFramebuffer;
|
||||
_prepareDeferredInputs.edit1() = lightingModel;
|
||||
_prepareDeferred.run(_sceneContext, _renderContext, _prepareDeferredInputs, _prepareDeferredOutputs);
|
||||
|
||||
|
||||
_renderDeferredInputs.edit0() = frameTransform; // Pass the deferredFrameTransform
|
||||
_renderDeferredInputs.edit1() = _prepareDeferredOutputs.get0(); // Pass the deferredFramebuffer
|
||||
_renderDeferredInputs.edit2() = lightingModel; // Pass the lightingModel
|
||||
// the rest of the renderDeferred inputs can be omitted
|
||||
|
||||
#else
|
||||
gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) {
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLORS, { 0.0f, 0.1f, 0.2f, 1.0f });
|
||||
|
@ -120,7 +137,7 @@ void TestWindow::endFrame() {
|
|||
RenderArgs* args = _renderContext->args;
|
||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
auto deferredFboColorDepthStencil = DependencyManager::get<FramebufferCache>()->getDeferredFramebufferDepthColor();
|
||||
auto deferredFboColorDepthStencil = _prepareDeferredOutputs.get0()->getDeferredFramebufferDepthColor();
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
batch.setFramebuffer(deferredFboColorDepthStencil);
|
||||
|
@ -129,20 +146,14 @@ void TestWindow::endFrame() {
|
|||
batch.setResourceTexture(0, nullptr);
|
||||
});
|
||||
|
||||
DeferredFrameTransformPointer frameTransform;
|
||||
_generateDeferredFrameTransform.run(_sceneContext, _renderContext, frameTransform);
|
||||
|
||||
RenderDeferred::Inputs deferredInputs;
|
||||
deferredInputs.edit0() = frameTransform;
|
||||
deferredInputs.edit1() = _deferredFramebuffer;
|
||||
_renderDeferred.run(_sceneContext, _renderContext, deferredInputs);
|
||||
_renderDeferred.run(_sceneContext, _renderContext, _renderDeferredInputs);
|
||||
|
||||
gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) {
|
||||
PROFILE_RANGE_BATCH(batch, "blit");
|
||||
// Blit to screen
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
// auto framebuffer = framebufferCache->getLightingFramebuffer();
|
||||
auto framebuffer = _deferredFramebuffer->getLightingFramebuffer();
|
||||
auto framebuffer = _prepareDeferredOutputs.get0()->getLightingFramebuffer();
|
||||
batch.blit(framebuffer, _renderArgs->_viewport, nullptr, _renderArgs->_viewport);
|
||||
});
|
||||
#endif
|
||||
|
|
|
@ -35,11 +35,18 @@ protected:
|
|||
render::RenderContextPointer _renderContext{ std::make_shared<render::RenderContext>() };
|
||||
gpu::PipelinePointer _opaquePipeline;
|
||||
model::LightPointer _light { std::make_shared<model::Light>() };
|
||||
|
||||
|
||||
GenerateDeferredFrameTransform _generateDeferredFrameTransform;
|
||||
DeferredFramebufferPointer _deferredFramebuffer;
|
||||
MakeLightingModel _generateLightingModel;
|
||||
PreparePrimaryFramebuffer _preparePrimaryFramebuffer;
|
||||
|
||||
PrepareDeferred::Inputs _prepareDeferredInputs;
|
||||
PrepareDeferred _prepareDeferred;
|
||||
PrepareDeferred::Outputs _prepareDeferredOutputs;
|
||||
|
||||
RenderDeferred::Inputs _renderDeferredInputs;
|
||||
RenderDeferred _renderDeferred;
|
||||
|
||||
#endif
|
||||
|
||||
RenderArgs* _renderArgs { new RenderArgs() };
|
||||
|
|
Loading…
Reference in a new issue