Skip to content
Snippets Groups Projects
Commit edede160 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

- Fixed an issue with packaging the project due to missing #if WITH_EDITOR.

- Significantly improved performance of GPULineActor demo case by not initializing arrays to 0.
- Added further scoped stats for performance review.
parent 11e90590
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -181,6 +181,7 @@ void UGPUInstancedLineComponent::PostInitProperties() ...@@ -181,6 +181,7 @@ void UGPUInstancedLineComponent::PostInitProperties()
} }
#if WITH_EDITOR
void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent)
{ {
if (PropertyChangedEvent.Property != NULL) if (PropertyChangedEvent.Property != NULL)
...@@ -222,6 +223,7 @@ void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedCha ...@@ -222,6 +223,7 @@ void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedCha
} }
Super::PostEditChangeChainProperty(PropertyChangedEvent); Super::PostEditChangeChainProperty(PropertyChangedEvent);
} }
#endif
// Doesn't do anything yet, just as a testing function to see execution order on Unreal startup. // Doesn't do anything yet, just as a testing function to see execution order on Unreal startup.
void UGPUInstancedLineComponent::PostLoad() void UGPUInstancedLineComponent::PostLoad()
...@@ -797,16 +799,24 @@ bool UGPUInstancedLineComponent::UpdateLinesDataDirectly(int32 LineIdStart, TArr ...@@ -797,16 +799,24 @@ bool UGPUInstancedLineComponent::UpdateLinesDataDirectly(int32 LineIdStart, TArr
if (LineIdStart + Points.Num() > LinearLineData.Num()) if (LineIdStart + Points.Num() > LinearLineData.Num())
return false; return false;
{
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::UpdateLines - Memcopy LinearLineData"))
FMemory::Memcpy(LinearLineData.GetData() + LineIdStart, Points.GetData(), Points.Num() * sizeof(FVector4)); FMemory::Memcpy(LinearLineData.GetData() + LineIdStart, Points.GetData(), Points.Num() * sizeof(FVector4));
}
const int32 X = LineIdStart % TextureWidth; const int32 X = LineIdStart % TextureWidth;
const int32 Y = LineIdStart / TextureWidth; const int32 Y = LineIdStart / TextureWidth;
TArray<FVector4>* TextureData;
{
// Copy for now // Copy for now
TArray<FVector4>* TextureData = new TArray<FVector4>(MoveTemp(Points)); TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::UpdateLines - MoveTemp Texture Data"))
TextureData = new TArray<FVector4>(MoveTemp(Points));
}
int32 NumberOfRegions = 0; int32 NumberOfRegions = 0;
const FUpdateTextureRegion2D* Regions = CalculateTextureRegions(FIntPoint(X, Y), TextureData->Num(), NumberOfRegions); FUpdateTextureRegion2D* Regions;
{
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::UpdateLines - Calculate Texture Regions"))
Regions = CalculateTextureRegions(FIntPoint(X, Y), TextureData->Num(), NumberOfRegions);
}
PositionTexture->UpdateTextureRegions(0, NumberOfRegions, Regions, TextureWidth * sizeof(FVector4), sizeof(FVector4), (uint8*)TextureData->GetData(), PositionTexture->UpdateTextureRegions(0, NumberOfRegions, Regions, TextureWidth * sizeof(FVector4), sizeof(FVector4), (uint8*)TextureData->GetData(),
[](auto InTextureData, auto InRegions) [](auto InTextureData, auto InRegions)
{ {
......
...@@ -106,7 +106,10 @@ protected: ...@@ -106,7 +106,10 @@ protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;
virtual void PostInitProperties() override; virtual void PostInitProperties() override;
#if WITH_EDITOR
virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override; virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
#endif
virtual void PostLoad() override; virtual void PostLoad() override;
virtual void OnComponentCreated() override; virtual void OnComponentCreated() override;
virtual void BeginDestroy() override; virtual void BeginDestroy() override;
......
...@@ -30,7 +30,7 @@ void AGPULineActor::BeginPlay() ...@@ -30,7 +30,7 @@ void AGPULineActor::BeginPlay()
const uint32 MaxLines = Lines; const uint32 MaxLines = Lines;
const uint32 MaxSegments = Segments; const uint32 MaxSegments = Segments;
TArray<FVector> Points; TArray<FVector> Points;
Points.SetNumZeroed(MaxSegments + 1); Points.SetNumUninitialized(MaxSegments + 1);
for(uint32 i = 0; i < MaxLines; ++i) for(uint32 i = 0; i < MaxLines; ++i)
{ {
...@@ -65,8 +65,10 @@ void AGPULineActor::Tick(float DeltaTime) ...@@ -65,8 +65,10 @@ void AGPULineActor::Tick(float DeltaTime)
} }
TArray<FVector4> Points; TArray<FVector4> Points;
Points.SetNumZeroed(MaxLines * (MaxSegments + 1)); {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ABasicLineActor::Tick - InitArray"))
Points.SetNumUninitialized(MaxLines * (MaxSegments + 1));
}
const float TotalTime = UGameplayStatics::GetTimeSeconds(GetWorld()) * 0.1; const float TotalTime = UGameplayStatics::GetTimeSeconds(GetWorld()) * 0.1;
const int32 NPoints = GPUInstancedLineComponent->GetNumberOfPointsInLine(0); const int32 NPoints = GPUInstancedLineComponent->GetNumberOfPointsInLine(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment