Changed measure scope.
This commit is contained in:
parent
77e6ebb7d2
commit
d528243112
|
@ -194,8 +194,9 @@ void FPixelReader::WritePixelsToArray(
|
||||||
{
|
{
|
||||||
|
|
||||||
check(IsInRenderingThread());
|
check(IsInRenderingThread());
|
||||||
auto RenderResource =
|
|
||||||
static_cast<const FTextureRenderTarget2DResource *>(RenderTarget.Resource);
|
const FTextureRenderTarget2DResource* RenderResource =
|
||||||
|
static_cast<const FTextureRenderTarget2DResource *>(RenderTarget.Resource);
|
||||||
FTexture2DRHIRef Texture = RenderResource->GetRenderTargetTexture();
|
FTexture2DRHIRef Texture = RenderResource->GetRenderTargetTexture();
|
||||||
if (!Texture)
|
if (!Texture)
|
||||||
{
|
{
|
||||||
|
@ -205,9 +206,13 @@ void FPixelReader::WritePixelsToArray(
|
||||||
|
|
||||||
FIntPoint Rect = RenderResource->GetSizeXY();
|
FIntPoint Rect = RenderResource->GetSizeXY();
|
||||||
|
|
||||||
InRHICmdList.ReadSurfaceData(
|
{
|
||||||
|
|
||||||
|
SCOPE_CYCLE_COUNTER(STAT_CarlaSensorReadRT);
|
||||||
|
InRHICmdList.ReadSurfaceData(
|
||||||
Texture,
|
Texture,
|
||||||
FIntRect(0, 0, Rect.X, Rect.Y),
|
FIntRect(0, 0, Rect.X, Rect.Y),
|
||||||
Pixels,
|
Pixels,
|
||||||
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
|
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -493,7 +493,8 @@ void ASceneCaptureSensor::BeginPlay()
|
||||||
Pixels[i].Init(FColor(), ImageWidth * ImageHeight);
|
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)
|
void ASceneCaptureSensor::Tick(float DeltaTime)
|
||||||
|
@ -520,17 +521,28 @@ void ASceneCaptureSensor::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||||
FCoreDelegates::OnEndFrame.Remove(CaptureDelegate);
|
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()
|
void ASceneCaptureSensor::Capture()
|
||||||
{
|
{
|
||||||
|
|
||||||
check(CaptureRenderTarget != nullptr);
|
check(CaptureRenderTarget != nullptr);
|
||||||
|
check(IsInRenderingThread());
|
||||||
|
|
||||||
ASceneCaptureSensor* This = this;
|
ASceneCaptureSensor* This = this;
|
||||||
ENQUEUE_RENDER_COMMAND(ASceneCaptureSensor_SendPixelsInRenderThread)
|
ENQUEUE_RENDER_COMMAND(ASceneCaptureSensor_SendPixelsInRenderThread)
|
||||||
(
|
(
|
||||||
[This, Sensors=CaptureSensors](FRHICommandListImmediate& RHICmdList) mutable
|
[This, Sensors=CaptureSensors](FRHICommandListImmediate& RHICmdList) mutable
|
||||||
{
|
{
|
||||||
|
|
||||||
NumCaptureSensors++;
|
NumCaptureSensors++;
|
||||||
|
|
||||||
if( NumCaptureSensors < Sensors.Num() )
|
if( NumCaptureSensors < Sensors.Num() )
|
||||||
|
@ -542,8 +554,6 @@ void ASceneCaptureSensor::Capture()
|
||||||
{
|
{
|
||||||
if (Camera && Camera-> HasActorBegunPlay() && !Camera->IsPendingKill())
|
if (Camera && Camera-> HasActorBegunPlay() && !Camera->IsPendingKill())
|
||||||
{
|
{
|
||||||
SCOPE_CYCLE_COUNTER(STAT_CarlaSensorReadRT);
|
|
||||||
|
|
||||||
ASceneCaptureSensor& CameraRef = *Camera;
|
ASceneCaptureSensor& CameraRef = *Camera;
|
||||||
FPixelReader::WritePixelsToArray(
|
FPixelReader::WritePixelsToArray(
|
||||||
*(CameraRef.CaptureRenderTarget),
|
*(CameraRef.CaptureRenderTarget),
|
||||||
|
|
|
@ -281,6 +281,8 @@ protected:
|
||||||
|
|
||||||
uint32 Offset = 0u;
|
uint32 Offset = 0u;
|
||||||
|
|
||||||
|
void SetViewport();
|
||||||
|
|
||||||
void Capture();
|
void Capture();
|
||||||
|
|
||||||
template <typename TSensor>
|
template <typename TSensor>
|
||||||
|
|
Loading…
Reference in New Issue