Merge remote-tracking branch 'origin/master' into gi

This commit is contained in:
Wojciech Figat
2022-04-21 12:57:08 +02:00
78 changed files with 604 additions and 311 deletions

View File

@@ -74,10 +74,7 @@ void ForwardPass::Dispose()
void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTexture* output)
{
PROFILE_GPU_CPU("Forward");
// Cache data
auto device = GPUDevice::Instance;
auto context = device->GetMainContext();
auto context = GPUDevice::Instance->GetMainContext();
auto& view = renderContext.View;
auto mainCache = renderContext.List;
@@ -141,6 +138,6 @@ void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTex
// Run forward pass
view.Pass = DrawPass::Forward;
context->SetRenderTarget(depthBufferHandle, output->View());
mainCache->ExecuteDrawCalls(renderContext, forwardList);
mainCache->ExecuteDrawCalls(renderContext, forwardList, input->View());
}
}

View File

@@ -554,7 +554,7 @@ bool CanUseInstancing(DrawPass pass)
return pass == DrawPass::GBuffer || pass == DrawPass::Depth;
}
void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsList& list)
void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsList& list, GPUTextureView* input)
{
if (list.IsEmpty())
return;
@@ -626,6 +626,7 @@ DRAW:
// Execute draw calls
MaterialBase::BindParameters bindParams(context, renderContext);
bindParams.Input = input;
if (useInstancing)
{
int32 instanceBufferOffset = 0;

View File

@@ -570,9 +570,10 @@ public:
/// </summary>
/// <param name="renderContext">The rendering context.</param>
/// <param name="listType">The collected draw calls list type.</param>
API_FUNCTION() FORCE_INLINE void ExecuteDrawCalls(API_PARAM(Ref) const RenderContext& renderContext, DrawCallsListType listType)
/// <param name="input">The input scene color. It's optional and used in forward/postFx rendering.</param>
API_FUNCTION() FORCE_INLINE void ExecuteDrawCalls(API_PARAM(Ref) const RenderContext& renderContext, DrawCallsListType listType, GPUTextureView* input = nullptr)
{
ExecuteDrawCalls(renderContext, DrawCallsLists[(int32)listType]);
ExecuteDrawCalls(renderContext, DrawCallsLists[(int32)listType], input);
}
/// <summary>
@@ -580,7 +581,8 @@ public:
/// </summary>
/// <param name="renderContext">The rendering context.</param>
/// <param name="list">The collected draw calls list.</param>
void ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsList& list);
/// <param name="input">The input scene color. It's optional and used in forward/postFx rendering.</param>
void ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsList& list, GPUTextureView* input = nullptr);
};
/// <summary>

View File

@@ -448,8 +448,9 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext)
}
// Run forward pass
auto forwardPassResult = renderContext.Buffers->RT1_FloatRGB;
ForwardPass::Instance()->Render(renderContext, lightBuffer, forwardPassResult);
GPUTexture* frameBuffer = renderContext.Buffers->RT1_FloatRGB;
GPUTexture* tempBuffer = renderContext.Buffers->RT2_FloatRGB;
ForwardPass::Instance()->Render(renderContext, lightBuffer, frameBuffer);
// Cleanup
context->ResetRenderTarget();
@@ -462,16 +463,10 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext)
{
context->SetRenderTarget(task->GetOutputView());
context->SetViewportAndScissors(task->GetOutputViewport());
context->Draw(forwardPassResult);
context->Draw(frameBuffer);
return;
}
// Prepare buffers for post processing frame
GPUTexture* frameBuffer = renderContext.Buffers->RT1_FloatRGB;
GPUTexture* tempBuffer = renderContext.Buffers->RT2_FloatRGB;
if (forwardPassResult == tempBuffer)
Swap(frameBuffer, tempBuffer);
// Material and Custom PostFx
renderContext.List->RunMaterialPostFxPass(context, renderContext, MaterialPostFxLocation::BeforePostProcessingPass, frameBuffer, tempBuffer);
renderContext.List->RunCustomPostFxPass(context, renderContext, PostProcessEffectLocation::BeforePostProcessingPass, frameBuffer, tempBuffer);

View File

@@ -42,13 +42,10 @@ PACK_STRUCT(struct Data
float TemporalScale;
float RayTraceStep;
float NoTemporalEffect;
float TemporalEffect;
float Intensity;
float FadeOutDistance;
Vector3 Dummy0;
float InvFadeDistance;
Matrix ViewMatrix;
Matrix ViewProjectionMatrix;
});
@@ -248,11 +245,10 @@ void ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPUTexture
data.MaxColorMiplevel = settings.UseColorBufferMips ? (float)colorBufferMips - 2.0f : 0.0f;
data.RayTraceStep = static_cast<float>(settings.DepthResolution) / (float)width;
data.Intensity = settings.Intensity;
data.FadeOutDistance = settings.FadeOutDistance;
data.InvFadeDistance = 1.0f / settings.FadeDistance;
data.FadeOutDistance = Math::Max(settings.FadeOutDistance, 100.0f);
data.TemporalScale = settings.TemporalScale;
data.TemporalResponse = settings.TemporalResponse;
data.NoTemporalEffect = useTemporal ? 0.0f : 1.0f;
data.TemporalEffect = useTemporal ? 1.0f : 0.0f;
if (useTemporal)
{
const float time = Time::Draw.UnscaledTime.GetTotalSeconds();