It seems RHICreateTexture2D
does not exist any more in UE5.3? I cannot find it in doc.
How should I update the following code to UE5?
void ASceneVideoCapture::OnBackBufferReady_RenderThread(SWindow& SlateWindow, const FTexture2DRHIRef& BackBuffer)
{
FTexture2DRHIRef GameBuffer = BackBuffer;
FRHIResourceCreateInfo CreateInfo(TEXT("Texture"));
FRHITextureCreateDesc TextureCreateDesc = FRHITextureCreateDesc::Create2D(TEXT("TextureOfCopy"), GameBuffer->GetSizeX(), GameBuffer->GetSizeY(), GameBuffer->GetFormat());
FTexture2DRHIRef CopiedTexture = RHICreateTexture2D(
GameBuffer->GetSizeX(),
GameBuffer->GetSizeY(),
GameBuffer->GetFormat(),
GameBuffer->GetNumMips(),
GameBuffer->GetNumSamples(),
ETextureCreateFlags::CPUReadback,
CreateInfo
);
FRHICommandListImmediate& RHICmdList = FRHICommandListExecutor::GetImmediateCommandList();
RHICmdList.CopyTexture(GameBuffer, CopiedTexture, FRHICopyTextureInfo{});
void* RawData = nullptr;
int32 Width = 0, Height = 0;
RHICmdList.MapStagingSurface(CopiedTexture, RawData, Width, Height);
// ...
RHICmdList.UnmapStagingSurface(CopiedTexture);
}