Add RenderBuffers::LinkedCustomBuffers to reuse main game viewport rendered state (eg. GI) in sub-rendered view

This commit is contained in:
Wojtek Figat
2023-02-01 11:05:29 +01:00
parent 831af77eff
commit ab51ecddb4
6 changed files with 14 additions and 15 deletions

View File

@@ -128,6 +128,8 @@ void RenderBuffers::SetUseAlpha(bool value)
const RenderBuffers::CustomBuffer* RenderBuffers::FindCustomBuffer(const StringView& name) const
{
if (LinkedCustomBuffers)
return LinkedCustomBuffers->FindCustomBuffer(name);
for (const CustomBuffer* e : CustomBuffers)
{
if (e->Name == name)
@@ -196,6 +198,7 @@ bool RenderBuffers::Init(int32 width, int32 height)
void RenderBuffers::Release()
{
LastEyeAdaptationTime = 0;
LinkedCustomBuffers = nullptr;
for (int32 i = 0; i < _resources.Count(); i++)
_resources[i]->ReleaseGPU();

View File

@@ -178,6 +178,8 @@ public:
template<class T>
T* GetCustomBuffer(const StringView& name)
{
if (LinkedCustomBuffers)
return LinkedCustomBuffers->GetCustomBuffer<T>(name);
CustomBuffer* result = (CustomBuffer*)FindCustomBuffer(name);
if (!result)
{
@@ -206,6 +208,11 @@ public:
/// </remarks>
API_FIELD(ReadOnly) GPUTexture* MotionVectors;
/// <summary>
/// External Render Buffers used to redirect FindCustomBuffer/GetCustomBuffer calls. Can be linked to other rendering task (eg. main game viewport) to reuse graphics effect state from it (eg. use GI from main game view in in-game camera renderer).
/// </summary>
API_FIELD() RenderBuffers* LinkedCustomBuffers = nullptr;
public:
/// <summary>
/// Allocates the buffers.