Hi!
I have a function in my plugin that Frame-Capture the FrameBuffers comming from a RenderTarget. this function works well and still working in the 5.0 , but in the 5.0 the memory consumed by the RenderRequest are not being released exausting the system reaching the maximmum memory avaliable.
This is my Function:
void UIVR_CameraComponent::OnBackBufferReady(SWindow& SlateWindow, const FTexture2DRHIRef& BackBuffer)
{
if (IsInRenderingThread())
{
if (!IVR_RenderTarget)return;
if (!IVR_RenderTarget->GetResource())return;
// Init new RenderRequest
TSharedPtr<FRenderRequest> renderRequest = MakeShareable(new FRenderRequest);
//Get the Cached Texture Info
FRHICommandListImmediate& RHICmdList = GRHICommandList.GetImmediateCommandList();
//We need the pointer to the cached texture to free at the end...
FRHITexture2D* CachedTexture = IVR_RenderTarget->GetResource()->TextureRHI->GetTexture2D();
struct FReadSurfaceContext
{
FTexture2DRHIRef Texture;
TArray<FColor>* OutData;
FIntRect Rect;
FReadSurfaceDataFlags Flags;
};
// Setup GPU command
FReadSurfaceContext readSurfaceContext = {
CachedTexture,
renderRequest->Image,
FIntRect(0,0,CachedTexture->GetSizeXY().X,CachedTexture->GetSizeXY().Y),
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX)
};
ENQUEUE_RENDER_COMMAND(SceneDrawCompletion)(
[readSurfaceContext](FRHICommandListImmediate& RHICmdList)
{
RHICmdList.ReadSurfaceData(
readSurfaceContext.Texture,
readSurfaceContext.Rect,
*readSurfaceContext.OutData,
readSurfaceContext.Flags
);
});
// Notifiy new task in RenderQueue
IVR_RenderQueue->push(renderRequest);
// Set RenderCommandFence
renderRequest->RenderFence.BeginFence();
}
}
The function works like a charm! But i found in the release notes of Unreal 5.0 the following item:
Rendering
Upgrade Notes:
- Cleaned up render target pool system by deprecating legacy MSAA split-texture creation and removing the old event viewer. Projects should use RDG when allocating MSAA render targets which require resolves.
So, i belive somehow this are affeting this function, and now my doubt is:
What is the code now that replaces this function? How can i use RDG to do the same task?
Any help will be much appreciated becouse all the users of my little plugin are suffering with the system being exausted and i already check all the points that can be optimized(The only point still to be fixed are on this function now).
Kind Regards.