Files
UnrealEngineUWP/Engine/Source/Runtime/Renderer/Private/VT/TexturePageLocks.h
jeremy moore ebd6bed396 Optimization for FVirtualTextureProducer::Release
Accelerate lookup of tiles per producer in ForceUnlockAllTiles
#rb jeanfrancois.dube
#preflight 6179b6d14c74960001ea6bca
#lockdown michal.valient

#ROBOMERGE-AUTHOR: jeremy.moore
#ROBOMERGE-SOURCE: CL 17962450 via CL 18008146 via CL 18370529 via CL 18370609
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18370666 by jeremy moore in ue5-release-engine-test branch]
2021-12-03 13:52:23 -05:00

37 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Containers/HashTable.h"
#include "VirtualTexturing.h"
/**
* This tracks lock counts for individual VT tiles
* We need to track lock counts for all tiles, since different allocated VTs may try to lock/unlock the same pages,
* and we need a way to know when a given tile is no longer locked by anything
*/
class FTexturePageLocks
{
public:
FTexturePageLocks();
/** Lock/Unlock return true if the lock state was changed */
bool Lock(const FVirtualTextureLocalTile& Tile);
bool Unlock(const FVirtualTextureLocalTile& Tile);
/** Force-unlock all tiles using the given producer, returns list of all tiles that were unlocked */
void ForceUnlockAll(const FVirtualTextureProducerHandle& ProducerHandle, TArray<FVirtualTextureLocalTile>& OutUnlockedTiles);
bool IsLocked(const FVirtualTextureLocalTile& Tile) const;
private:
uint32 AcquireIndex();
FHashTable TileHash;
FHashTable ProducerToTileIndex;
TArray<FVirtualTextureLocalTile> LockedTiles;
TArray<uint16> LockCounts;
TArray<uint32> FreeIndices;
};