mirror of
https://github.com/zeldaret/botw
synced 2026-08-22 06:28:58 -04:00
ksys/phys: Add HavokMemoryAllocator
This commit is contained in:
@@ -57,6 +57,7 @@ add_library(hkStubs OBJECT
|
||||
|
||||
Havok/Common/Base/Memory/Allocator/hkMemoryAllocator.h
|
||||
Havok/Common/Base/Memory/Allocator/Lifo/hkLifoAllocator.h
|
||||
Havok/Common/Base/Memory/Allocator/Malloc/hkMallocAllocator.h
|
||||
Havok/Common/Base/Memory/Router/hkMemoryRouter.h
|
||||
Havok/Common/Base/Memory/Util/hkMemUtil.h
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <Havok/Common/Base/hkBase.h>
|
||||
|
||||
class hkMallocAllocator : public hkMemoryAllocator {
|
||||
public:
|
||||
explicit hkMallocAllocator(int align = HK_REAL_ALIGNMENT)
|
||||
: m_align(align), m_currentUsed(0), m_peakUse(0) {}
|
||||
|
||||
void* blockAlloc(int numBytes) override;
|
||||
void blockFree(void* p, int numBytes) override;
|
||||
|
||||
void getMemoryStatistics(hkMemoryAllocator::MemoryStatistics& u) const override;
|
||||
int getAllocatedSize(const void* obj, int nbytes) const override;
|
||||
void resetPeakMemoryStatistics() override;
|
||||
|
||||
int m_align;
|
||||
|
||||
static hkMemoryAllocator* m_defaultMallocAllocator;
|
||||
|
||||
protected:
|
||||
hkUint32 m_unused;
|
||||
hkUint32 m_currentUsed;
|
||||
hkUint32 m_peakUse;
|
||||
};
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
#include <Havok/Common/Base/Types/hkBaseTypes.h>
|
||||
|
||||
#define HK_DECLARE_PLACEMENT_ALLOCATOR() \
|
||||
HK_FORCE_INLINE void* operator new(hk_size_t, void* p) { return p; } \
|
||||
HK_FORCE_INLINE void operator delete(void*, void*) {} \
|
||||
HK_FORCE_INLINE void operator delete(void*, hk_size_t) {}
|
||||
|
||||
class hkMemorySnapshot;
|
||||
|
||||
template <typename T>
|
||||
@@ -16,6 +21,8 @@ struct hkSizeOfTypeOrVoid<void> {
|
||||
|
||||
class hkMemoryAllocator {
|
||||
public:
|
||||
HK_DECLARE_PLACEMENT_ALLOCATOR()
|
||||
|
||||
using MemoryWalkCallback = void (*)(void* start, hk_size_t size, bool allocated, int pool,
|
||||
void* param);
|
||||
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
class hkBaseObject {
|
||||
public:
|
||||
HK_DECLARE_PLACEMENT_ALLOCATOR()
|
||||
|
||||
HK_FORCE_INLINE explicit hkBaseObject(hkFinishLoadedObjectFlag flag) {}
|
||||
|
||||
virtual ~hkBaseObject() = default;
|
||||
virtual void __first_virtual_table_function__() {} // NOLINT(bugprone-reserved-identifier)
|
||||
|
||||
protected:
|
||||
HK_FORCE_INLINE hkBaseObject() = default;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <Havok/Common/Base/Object/hkReferencedObject.h>
|
||||
#include <Havok/Common/Base/hkBase.h>
|
||||
|
||||
const hkClass* hkReferencedObject::getClassType() const {
|
||||
return nullptr;
|
||||
|
||||
@@ -9,6 +9,9 @@ using hkFloat32 = float;
|
||||
using hkDouble64 = double;
|
||||
using hkReal = hkFloat32;
|
||||
#define HK_REAL_IS_FLOAT
|
||||
#define HK_FLOAT_ALIGNMENT 16
|
||||
#define HK_DOUBLE_ALIGNMENT 32
|
||||
#define HK_REAL_ALIGNMENT HK_FLOAT_ALIGNMENT
|
||||
|
||||
using hkChar = char;
|
||||
using hkInt8 = std::int8_t;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <Havok/Common/Base/Types/hkBaseDefs.h>
|
||||
#include <Havok/Common/Base/Types/hkBaseTypes.h>
|
||||
|
||||
#include <Havok/Common/Base/Memory/Allocator/hkMemoryAllocator.h>
|
||||
|
||||
#include <Havok/Common/Base/Object/hkBaseObject.h>
|
||||
#include <Havok/Common/Base/Object/hkReferencedObject.h>
|
||||
#include <Havok/Common/Base/Types/hkBaseDefs.h>
|
||||
#include <Havok/Common/Base/Types/hkBaseTypes.h>
|
||||
#include <Havok/Common/Base/Types/hkRefPtr.h>
|
||||
#include <Havok/Common/Base/Types/hkRefVariant.h>
|
||||
#include <Havok/Common/Base/Types/hkUFloat8.h>
|
||||
|
||||
Reference in New Issue
Block a user