/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Foundation/Platform/Win/PageAllocator_Win.cpp
40 строк
1 KB
Jan Krassnigg
Further refactor of platform specific code (#1415)
23 окт 2024, 21:36
Не верифицирован
23 окт 2024, 21:36
8b313ab
Код
Авторство
О чём код?
#include <Foundation/FoundationPCH.h> #if EZ_ENABLED(EZ_PLATFORM_WINDOWS) # include <Foundation/Memory/MemoryTracker.h> # include <Foundation/Memory/PageAllocator.h> # include <Foundation/System/SystemInformation.h> # include <Foundation/Time/Time.h> // static void* ezPageAllocator::AllocatePage(size_t uiSize) { ezTime fAllocationTime = ezTime::Now(); void* ptr = ::VirtualAlloc(nullptr, uiSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); EZ_ASSERT_DEV(ptr != nullptr, "Could not allocate memory pages. Error Code '{0}'", ezArgErrorCode(::GetLastError())); size_t uiAlign = ezSystemInformation::Get().GetMemoryPageSize(); EZ_CHECK_ALIGNMENT(ptr, uiAlign); if constexpr (ezAllocatorTrackingMode::Default >= ezAllocatorTrackingMode::AllocationStats) { ezMemoryTracker::AddAllocation(ezPageAllocator::GetId(), ezAllocatorTrackingMode::Default, ptr, uiSize, uiAlign, ezTime::Now() - fAllocationTime); } return ptr; } // static void ezPageAllocator::DeallocatePage(void* pPtr) { if constexpr (ezAllocatorTrackingMode::Default >= ezAllocatorTrackingMode::AllocationStats) { ezMemoryTracker::RemoveAllocation(ezPageAllocator::GetId(), pPtr); } EZ_VERIFY(::VirtualFree(pPtr, 0, MEM_RELEASE), "Could not free memory pages. Error Code '{0}'", ezArgErrorCode(::GetLastError())); } #endif