I can’t remember my exact train of thought here, but I found a “solution” … or rather a workaround where this bug doesn’t exist:
When using the PF_FloatRGBA format for the TextureRenderTargetCube …
UTextureRenderTargetCube* RenderTarget = NewObject<UTextureRenderTargetCube>();
RenderTarget->Init(2048, PF_FloatRGBA);
RenderTarget->UpdateResourceImmediate();
TextureTarget = RenderTarget;
… it’s ok to cast to a FTextureRenderTargetCubeResource:
if (TextureTarget != NULL)
{
FTextureRenderTargetCubeResource* RTResource = (FTextureRenderTargetCubeResource*)TextureTarget->GameThread_GetRenderTargetResource();
if (RTResource->IsInitialized() && RTResource != NULL)
{
if (!RTResource->ReadPixels(ImageDataPosX, FReadSurfaceDataFlags(RCM_UNorm, CubeFace_PosX))) UE_LOG(LogTemp, Warning, TEXT("LiDAR: PosX failed"));
This works because in D3D12RenderTarget.cpp then the method RHIReadSurfaceFloatData is used instead of GetStagingTexture. And since they both do the same more or less (to my very limited understanding), but RHIReadSurfaceFloatData doesn’t have the stupid/broken assertion it now works. Just need to convert the results to FColor and from BGR to RGB, but otherwise now it does what it should and I’m able to access all sides of the cube … yay just a week spent for a bug in the engine.
Let me know if there’s an alternative solution or if this assertion is intentional and how to avoid it …
cheers.