You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Share sampler state objects between textures
#rb none #ROBOMERGE-OWNER: dmitriy.dyomin #ROBOMERGE-AUTHOR: dmitriy.dyomin #ROBOMERGE-SOURCE: CL 11596383 via CL 11596386 via CL 11596387 #ROBOMERGE-BOT: (v656-11643781) [CL 11722115 by dmitriy dyomin in Main branch]
This commit is contained in:
@@ -796,3 +796,36 @@ void FMipBiasFade::SetNewMipCount( float ActualMipCount, float TargetMipCount, d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FTextureSamplerStateCache : public FRenderResource
|
||||
{
|
||||
public:
|
||||
TMap<FSamplerStateInitializerRHI, FRHISamplerState*> Samplers;
|
||||
|
||||
virtual void ReleaseRHI() override
|
||||
{
|
||||
for (auto Pair : Samplers)
|
||||
{
|
||||
Pair.Value->Release();
|
||||
}
|
||||
Samplers.Empty();
|
||||
}
|
||||
};
|
||||
|
||||
TGlobalResource<FTextureSamplerStateCache> GTextureSamplerStateCache;
|
||||
|
||||
FRHISamplerState* FTexture::GetOrCreateSamplerState(const FSamplerStateInitializerRHI& Initializer)
|
||||
{
|
||||
FRHISamplerState** Found = GTextureSamplerStateCache.Samplers.Find(Initializer);
|
||||
if (Found)
|
||||
{
|
||||
return *Found;
|
||||
}
|
||||
|
||||
FSamplerStateRHIRef NewState = RHICreateSamplerState(Initializer);
|
||||
|
||||
// Add an extra reference so we don't have TRefCountPtr in the maps
|
||||
NewState->AddRef();
|
||||
GTextureSamplerStateCache.Samplers.Add(Initializer, NewState);
|
||||
return NewState;
|
||||
}
|
||||
Reference in New Issue
Block a user