diff --git a/InstancedMeshLines/Content/ExampleMap.umap b/InstancedMeshLines/Content/ExampleMap.umap index fadd933fc66bf8d79521fab877e4261c2a6ec129..432ab86d6b1b7f29d12017cdcfe98c67dc89a309 100644 Binary files a/InstancedMeshLines/Content/ExampleMap.umap and b/InstancedMeshLines/Content/ExampleMap.umap differ diff --git a/InstancedMeshLines/Content/ExampleMap_BuiltData.uasset b/InstancedMeshLines/Content/ExampleMap_BuiltData.uasset index d67265b5d9869ce3c2003fe114e65474f97d9d2c..ca6d2ada6d90f40b3ee5eb8f1b6fb10f9cbe9c22 100644 Binary files a/InstancedMeshLines/Content/ExampleMap_BuiltData.uasset and b/InstancedMeshLines/Content/ExampleMap_BuiltData.uasset differ diff --git a/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp b/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp index ec35353186093565212b51ebf07b4fe098a071c3..9801ba51ff71d3c2ca72e17c346ac93d40735600 100644 --- a/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp +++ b/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp @@ -181,6 +181,7 @@ void UGPUInstancedLineComponent::PostInitProperties() } +#if WITH_EDITOR void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) { if (PropertyChangedEvent.Property != NULL) @@ -222,6 +223,7 @@ void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedCha } Super::PostEditChangeChainProperty(PropertyChangedEvent); } +#endif // Doesn't do anything yet, just as a testing function to see execution order on Unreal startup. void UGPUInstancedLineComponent::PostLoad() @@ -797,16 +799,24 @@ bool UGPUInstancedLineComponent::UpdateLinesDataDirectly(int32 LineIdStart, TArr if (LineIdStart + Points.Num() > LinearLineData.Num()) return false; - - FMemory::Memcpy(LinearLineData.GetData() + LineIdStart, Points.GetData(), Points.Num() * sizeof(FVector4)); + { + TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::UpdateLines - Memcopy LinearLineData")) + FMemory::Memcpy(LinearLineData.GetData() + LineIdStart, Points.GetData(), Points.Num() * sizeof(FVector4)); + } const int32 X = LineIdStart % TextureWidth; const int32 Y = LineIdStart / TextureWidth; - - // Copy for now - TArray<FVector4>* TextureData = new TArray<FVector4>(MoveTemp(Points)); + TArray<FVector4>* TextureData; + { + // Copy for now + TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::UpdateLines - MoveTemp Texture Data")) + TextureData = new TArray<FVector4>(MoveTemp(Points)); + } 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(), [](auto InTextureData, auto InRegions) { diff --git a/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h b/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h index d2af8882cf674788d48b1342236b28b56fd0cbac..1f2c98f84507f3eddc99f5616b9f7efb4c7a0f5a 100644 --- a/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h +++ b/InstancedMeshLines/Plugins/InstancedMeshLineRendering/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h @@ -106,7 +106,10 @@ protected: virtual void BeginPlay() override; virtual void PostInitProperties() override; +#if WITH_EDITOR virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override; +#endif + virtual void PostLoad() override; virtual void OnComponentCreated() override; virtual void BeginDestroy() override; diff --git a/InstancedMeshLines/Source/InstancedMeshLines/Private/GPULineActor.cpp b/InstancedMeshLines/Source/InstancedMeshLines/Private/GPULineActor.cpp index c6f79812e48a789b15cb701f6089bb4418807773..c8f000b85ea68f0a44184c8893257d1ef55e0d20 100644 --- a/InstancedMeshLines/Source/InstancedMeshLines/Private/GPULineActor.cpp +++ b/InstancedMeshLines/Source/InstancedMeshLines/Private/GPULineActor.cpp @@ -30,7 +30,7 @@ void AGPULineActor::BeginPlay() const uint32 MaxLines = Lines; const uint32 MaxSegments = Segments; TArray<FVector> Points; - Points.SetNumZeroed(MaxSegments + 1); + Points.SetNumUninitialized(MaxSegments + 1); for(uint32 i = 0; i < MaxLines; ++i) { @@ -65,8 +65,10 @@ void AGPULineActor::Tick(float DeltaTime) } 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 int32 NPoints = GPUInstancedLineComponent->GetNumberOfPointsInLine(0);