CARLA
Loading...
Searching...
No Matches
RHIGPUReadbackPool.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
8
9FRHIGPUTextureReadback *FRHIGPUReadbackPool::Acquire(int32 &OutSlotIndex)
10{
11 FScopeLock ScopeLock(&Lock);
12
13 for (int32 Index = 0; Index < Slots.Num(); ++Index)
14 {
15 if (!InUse[Index])
16 {
17 InUse[Index] = true;
18 if (!Slots[Index].IsValid())
19 {
20 Slots[Index] = MakeUnique<FRHIGPUTextureReadback>(*DebugName);
21 }
22 OutSlotIndex = Index;
23 return Slots[Index].Get();
24 }
25 }
26
27 if (Slots.Num() < MaxSize)
28 {
29 const int32 NewIndex = Slots.Add(MakeUnique<FRHIGPUTextureReadback>(*DebugName));
30 InUse.Add(true);
31 OutSlotIndex = NewIndex;
32 return Slots[NewIndex].Get();
33 }
34
35 OutSlotIndex = INDEX_NONE;
36 return nullptr;
37}
38
39void FRHIGPUReadbackPool::Release(int32 SlotIndex)
40{
41 FScopeLock ScopeLock(&Lock);
42 if (SlotIndex >= 0 && SlotIndex < InUse.Num())
43 {
44 InUse[SlotIndex] = false;
45 }
46}
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
FRHIGPUTextureReadback * Acquire(int32 &OutSlotIndex)
FCriticalSection Lock
void Release(int32 SlotIndex)
TArray< TUniquePtr< FRHIGPUTextureReadback > > Slots