You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Add interpolation modifiers - Ignore #pragma - Fix for strings in attributes - Do translation units separately [CL 2469349 by Rolando Caloca in Main branch]
76 lines
1.5 KiB
C++
76 lines
1.5 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
HlslUtils.cpp - Utils for HLSL.
|
|
=============================================================================*/
|
|
|
|
#include "ShaderCompilerCommon.h"
|
|
#include "HlslUtils.h"
|
|
|
|
namespace CrossCompiler
|
|
{
|
|
namespace Memory
|
|
{
|
|
static struct FPagePoolInstance
|
|
{
|
|
~FPagePoolInstance()
|
|
{
|
|
check(UsedPages.Num() == 0);
|
|
for (int32 Index = 0; Index < FreePages.Num(); ++Index)
|
|
{
|
|
delete FreePages[Index];
|
|
}
|
|
}
|
|
|
|
FPage* AllocatePage()
|
|
{
|
|
FScopeLock ScopeLock(&CriticalSection);
|
|
|
|
if (FreePages.Num() == 0)
|
|
{
|
|
FreePages.Add(new FPage(PageSize));
|
|
}
|
|
|
|
auto* Page = FreePages.Last();
|
|
FreePages.RemoveAt(FreePages.Num() - 1, 1, false);
|
|
UsedPages.Add(Page);
|
|
return Page;
|
|
}
|
|
|
|
void FreePage(FPage* Page)
|
|
{
|
|
FScopeLock ScopeLock(&CriticalSection);
|
|
|
|
int32 Index = UsedPages.Find(Page);
|
|
check(Index >= 0);
|
|
UsedPages.RemoveAt(Index, 1, false);
|
|
FreePages.Add(Page);
|
|
}
|
|
|
|
TArray<FPage*, TInlineAllocator<8> > FreePages;
|
|
TArray<FPage*, TInlineAllocator<8> > UsedPages;
|
|
|
|
FCriticalSection CriticalSection;
|
|
|
|
} GMemoryPagePool;
|
|
|
|
FPage* FPage::AllocatePage()
|
|
{
|
|
#if USE_PAGE_POOLING
|
|
return GMemoryPagePool.AllocatePage();
|
|
#else
|
|
return new FPage(PageSize);
|
|
#endif
|
|
}
|
|
|
|
void FPage::FreePage(FPage* Page)
|
|
{
|
|
#if USE_PAGE_POOLING
|
|
GMemoryPagePool.FreePage(Page);
|
|
#else
|
|
delete Page;
|
|
#endif
|
|
}
|
|
}
|
|
}
|