mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Implement ReleaseReservation
This commit is contained in:
parent
6b947b6906
commit
5166ce3545
@ -1,18 +1,39 @@
|
|||||||
#include "StevesTextureRenderTargetPool.h"
|
#include "StevesTextureRenderTargetPool.h"
|
||||||
|
|
||||||
|
#include "StevesUEHelpers.h"
|
||||||
|
|
||||||
FStevesTextureRenderTargetReservation::~FStevesTextureRenderTargetReservation()
|
FStevesTextureRenderTargetReservation::~FStevesTextureRenderTargetReservation()
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Releasing texture reservation"));
|
UE_LOG(LogStevesUEHelpers, Log, TEXT("FStevesTextureRenderTargetReservation: destruction"));
|
||||||
if (ParentPool.IsValid() && Texture.IsValid())
|
if (ParentPool.IsValid() && Texture.IsValid())
|
||||||
{
|
{
|
||||||
ParentPool.Pin()->ReleaseTextureReservation(Texture.Get());
|
ParentPool.Pin()->ReleaseReservation(Texture.Get());
|
||||||
Texture = nullptr;
|
Texture = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FStevesTextureRenderTargetPool::ReleaseTextureReservation(UTextureRenderTarget2D* Tex)
|
void FStevesTextureRenderTargetPool::ReleaseReservation(UTextureRenderTarget2D* Tex)
|
||||||
{
|
{
|
||||||
// TODO
|
if (!Tex)
|
||||||
|
{
|
||||||
|
UE_LOG(LogStevesUEHelpers, Warning, TEXT("FStevesTextureRenderTargetPool: Attempted to release a null texture"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < Reservations.Num(); ++i)
|
||||||
|
{
|
||||||
|
const FReservationInfo& R = Reservations[i];
|
||||||
|
if (R.Texture.IsValid() && R.Texture.Get() == Tex)
|
||||||
|
{
|
||||||
|
UE_LOG(LogStevesUEHelpers, Verbose, TEXT("FStevesTextureRenderTargetPool: Released texture reservation on %s"), *Tex->GetName());
|
||||||
|
UnreservedTextures.Add(R.Key, Tex);
|
||||||
|
Reservations.RemoveAtSwap(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UE_LOG(LogStevesUEHelpers, Warning, TEXT("FStevesTextureRenderTargetPool: Attempted to release a reservation on %s that was not found"), *Tex->GetName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FStevesTextureRenderTargetReservationPtr FStevesTextureRenderTargetPool::ReserveTexture(FIntPoint Size,
|
FStevesTextureRenderTargetReservationPtr FStevesTextureRenderTargetPool::ReserveTexture(FIntPoint Size,
|
||||||
@ -24,6 +45,7 @@ FStevesTextureRenderTargetReservationPtr FStevesTextureRenderTargetPool::Reserve
|
|||||||
{
|
{
|
||||||
Tex = *Pooled;
|
Tex = *Pooled;
|
||||||
UnreservedTextures.RemoveSingle(Key, Tex);
|
UnreservedTextures.RemoveSingle(Key, Tex);
|
||||||
|
UE_LOG(LogStevesUEHelpers, Verbose, TEXT("FStevesTextureRenderTargetPool: Re-used pooled texture %s"), *Tex->GetName());
|
||||||
}
|
}
|
||||||
else if (Size.X > 0 && Size.Y > 0)
|
else if (Size.X > 0 && Size.Y > 0)
|
||||||
{
|
{
|
||||||
@ -34,6 +56,8 @@ FStevesTextureRenderTargetReservationPtr FStevesTextureRenderTargetPool::Reserve
|
|||||||
Tex->RenderTargetFormat = Format;
|
Tex->RenderTargetFormat = Format;
|
||||||
Tex->InitAutoFormat(Size.X, Size.Y);
|
Tex->InitAutoFormat(Size.X, Size.Y);
|
||||||
Tex->UpdateResourceImmediate(true);
|
Tex->UpdateResourceImmediate(true);
|
||||||
|
|
||||||
|
UE_LOG(LogStevesUEHelpers, Verbose, TEXT("FStevesTextureRenderTargetPool: Created new texture %s"), *Tex->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record reservation
|
// Record reservation
|
||||||
|
@ -96,7 +96,7 @@ protected:
|
|||||||
friend struct FStevesTextureRenderTargetReservation;
|
friend struct FStevesTextureRenderTargetReservation;
|
||||||
/// Release a reservation on a texture, allowing it back into the pool
|
/// Release a reservation on a texture, allowing it back into the pool
|
||||||
/// Protected because only FStevesTextureRenderTargetReservation will need to do this.
|
/// Protected because only FStevesTextureRenderTargetReservation will need to do this.
|
||||||
void ReleaseTextureReservation(UTextureRenderTarget2D* Tex);
|
void ReleaseReservation(UTextureRenderTarget2D* Tex);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user