Changed measure scope.

This commit is contained in:
codeffee 2020-07-16 13:07:35 +02:00 committed by bernat
parent 77e6ebb7d2
commit d528243112
3 changed files with 24 additions and 7 deletions

View File

@ -194,8 +194,9 @@ void FPixelReader::WritePixelsToArray(
{
check(IsInRenderingThread());
auto RenderResource =
static_cast<const FTextureRenderTarget2DResource *>(RenderTarget.Resource);
const FTextureRenderTarget2DResource* RenderResource =
static_cast<const FTextureRenderTarget2DResource *>(RenderTarget.Resource);
FTexture2DRHIRef Texture = RenderResource->GetRenderTargetTexture();
if (!Texture)
{
@ -205,9 +206,13 @@ void FPixelReader::WritePixelsToArray(
FIntPoint Rect = RenderResource->GetSizeXY();
InRHICmdList.ReadSurfaceData(
{
SCOPE_CYCLE_COUNTER(STAT_CarlaSensorReadRT);
InRHICmdList.ReadSurfaceData(
Texture,
FIntRect(0, 0, Rect.X, Rect.Y),
Pixels,
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
}
}

View File

@ -493,7 +493,8 @@ void ASceneCaptureSensor::BeginPlay()
Pixels[i].Init(FColor(), ImageWidth * ImageHeight);
}
CaptureDelegate = FCoreDelegates::OnEndFrame.AddUObject(this, &ASceneCaptureCamera::Capture);
//CaptureDelegate = FCoreDelegates::OnBeginFrame.AddUObject(this, &ASceneCaptureCamera::SetViewport);
CaptureDelegate = FCoreDelegates::OnEndFrameRT.AddUObject(this, &ASceneCaptureCamera::Capture);
}
void ASceneCaptureSensor::Tick(float DeltaTime)
@ -520,17 +521,28 @@ void ASceneCaptureSensor::EndPlay(const EEndPlayReason::Type EndPlayReason)
FCoreDelegates::OnEndFrame.Remove(CaptureDelegate);
}
void ASceneCaptureSensor::SetViewport()
{
ENQUEUE_RENDER_COMMAND(ASceneCaptureSensor_SetViewport)
(
[](FRHICommandListImmediate& RHICmdList) mutable
{
RHICmdList.SetViewport(0, 0, 0.0f, 800, 600, 0.0f);
}
);
}
void ASceneCaptureSensor::Capture()
{
check(CaptureRenderTarget != nullptr);
check(IsInRenderingThread());
ASceneCaptureSensor* This = this;
ENQUEUE_RENDER_COMMAND(ASceneCaptureSensor_SendPixelsInRenderThread)
(
[This, Sensors=CaptureSensors](FRHICommandListImmediate& RHICmdList) mutable
{
NumCaptureSensors++;
if( NumCaptureSensors < Sensors.Num() )
@ -542,8 +554,6 @@ void ASceneCaptureSensor::Capture()
{
if (Camera && Camera-> HasActorBegunPlay() && !Camera->IsPendingKill())
{
SCOPE_CYCLE_COUNTER(STAT_CarlaSensorReadRT);
ASceneCaptureSensor& CameraRef = *Camera;
FPixelReader::WritePixelsToArray(
*(CameraRef.CaptureRenderTarget),

View File

@ -281,6 +281,8 @@ protected:
uint32 Offset = 0u;
void SetViewport();
void Capture();
template <typename TSensor>