forked from BGTU/computer-graphics-0
30 lines
954 B
C++
30 lines
954 B
C++
#include <algorithm>
|
|
#include <cstdlib>
|
|
#include <cassert>
|
|
#include <new>
|
|
#include <bgtu/computer_graphics_lab_work/utilities/default_renderer_linear.hpp>
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <Windows.h>
|
|
|
|
namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
|
DefaultVoxelDrawerCache::ZElementAllocationBuffer::Page *DefaultVoxelDrawerCache::ZElementAllocationBuffer::_native_extend() {
|
|
SYSTEM_INFO si;
|
|
GetSystemInfo(&si);
|
|
|
|
std::size_t size = max(si.dwPageSize, si.dwAllocationGranularity);
|
|
|
|
void *raw = VirtualAlloc(nullptr, max(si.dwPageSize, si.dwAllocationGranularity), MEM_COMMIT, PAGE_READWRITE);
|
|
if (raw == nullptr) throw std::bad_alloc{};
|
|
return this->last_page = new(raw)Page(this->last_page, Page::calc_capacity(size));
|
|
}
|
|
|
|
|
|
void DefaultVoxelDrawerCache::ZElementAllocationBuffer::_native_free_page(DefaultVoxelDrawerCache::ZElementAllocationBuffer::Page *p) {
|
|
VirtualFree(p, 0, MEM_DECOMMIT | MEM_RELEASE);
|
|
}
|
|
}
|
|
#else
|
|
# error ""
|
|
#endif |