Skip to content

Commit

Permalink
ReleaseObjects / Removed RenderGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
Daethalus committed May 19, 2024
1 parent 689364d commit 00efd43
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 649 deletions.
2 changes: 1 addition & 1 deletion Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_include_directories(FyrionEngine PRIVATE ThirdParty/concurrentqueue)
target_include_directories(FyrionEngine PRIVATE ThirdParty/dxc/include)

target_compile_definitions(FyrionEngine PUBLIC FMT_LIB_EXPORT=1)
target_link_libraries(FyrionEngine PRIVATE mimalloc glfw vma volk vulkan-sdk freetype nfd SPIRV-Cross SPIRV-Reflect)
target_link_libraries(FyrionEngine PRIVATE mimalloc glfw vma volk vulkan-sdk freetype nfd SPIRV-Reflect)

add_binary_file(FyrionEngine ThirdParty/dxc dxcompiler)

Expand Down
13 changes: 13 additions & 0 deletions Engine/Source/Fyrion/Core/Registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ namespace Fyrion
}
}

void TypeHandler::Release(VoidPtr instance) const
{
if (m_fnRelease)
{
m_fnRelease(this, instance);
}
}

void TypeHandler::Destructor(VoidPtr instance) const
{
if (m_fnDestructor)
Expand Down Expand Up @@ -432,6 +440,11 @@ namespace Fyrion
m_typeHandler.m_fnDestructor = destructor;
}

void TypeBuilder::SetFnRelease(TypeHandler::FnRelease fnRelease)
{
m_typeHandler.m_fnRelease = fnRelease;
}

void TypeBuilder::SetFnMove(TypeHandler::FnMove fnMove)
{
m_typeHandler.m_fnMove = fnMove;
Expand Down
50 changes: 34 additions & 16 deletions Engine/Source/Fyrion/Core/Registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ namespace Fyrion

typedef VoidPtr (*FnCast)(const TypeHandler* typeHandler, VoidPtr derived);


template<typename T>
struct ReleaseHandler
{
static void Release(T& value)
{
}
};


struct FunctionInfo
{
TypeID functionId{};
Expand Down Expand Up @@ -236,10 +246,9 @@ namespace Fyrion
typedef void (*FnDestructor)(const TypeHandler* typeHandler, VoidPtr instance);
typedef void (*FnCopy)(const TypeHandler* typeHandler, ConstPtr source, VoidPtr dest);
typedef void (*FnMove)(const TypeHandler* typeHandler, VoidPtr source, VoidPtr dest);

typedef void (*FnRelease)(const TypeHandler* typeHandler, VoidPtr instance);
friend class TypeBuilder;
private:

String m_name{};
String m_simpleName{};
TypeInfo m_typeInfo{};
Expand All @@ -248,6 +257,7 @@ namespace Fyrion
FnCopy m_fnCopy{};
FnDestructor m_fnDestructor{};
FnMove m_fnMove{};
FnRelease m_fnRelease{};

HashMap<usize, SharedPtr<ConstructorHandler>> m_constructors{};
Array<ConstructorHandler*> m_constructorArray{};
Expand Down Expand Up @@ -280,11 +290,12 @@ namespace Fyrion
const TypeInfo& GetTypeInfo() const;
u32 GetVersion() const;

void Destroy(VoidPtr instance, Allocator& allocator = MemoryGlobals::GetDefaultAllocator()) const;
void Destructor(VoidPtr instance) const;
void Copy(ConstPtr source, VoidPtr dest) const;
void Move(VoidPtr source, VoidPtr dest) const;
VoidPtr Cast(TypeID typeId, VoidPtr instance) const;
void Destroy(VoidPtr instance, Allocator& allocator = MemoryGlobals::GetDefaultAllocator()) const;
void Release(VoidPtr instance) const;
void Destructor(VoidPtr instance) const;
void Copy(ConstPtr source, VoidPtr dest) const;
void Move(VoidPtr source, VoidPtr dest) const;
VoidPtr Cast(TypeID typeId, VoidPtr instance) const;

VoidPtr NewInstance(Allocator& allocator = MemoryGlobals::GetDefaultAllocator()) const
{
Expand Down Expand Up @@ -392,15 +403,15 @@ namespace Fyrion
public:
TypeBuilder(TypeHandler& typeHandler);

void SetFnDestroy(TypeHandler::FnDestroy fnDestroy);
void SetFnCopy(TypeHandler::FnCopy fnCopy);
void SetFnDestructor(TypeHandler::FnDestructor destructor);
void SetFnMove(TypeHandler::FnMove fnMove);

ConstructorBuilder NewConstructor(TypeID* ids, FieldInfo* params, usize size);
FieldBuilder NewField(const StringView& fieldName);
FunctionBuilder NewFunction(const FunctionHandlerCreation& creation);
void AddBaseType(TypeID typeId, FnCast fnCast);
void SetFnDestroy(TypeHandler::FnDestroy fnDestroy);
void SetFnCopy(TypeHandler::FnCopy fnCopy);
void SetFnDestructor(TypeHandler::FnDestructor destructor);
void SetFnMove(TypeHandler::FnMove fnMove);
void SetFnRelease(TypeHandler::FnRelease fnRelease);
ConstructorBuilder NewConstructor(TypeID* ids, FieldInfo* params, usize size);
FieldBuilder NewField(const StringView& fieldName);
FunctionBuilder NewFunction(const FunctionHandlerCreation& creation);
void AddBaseType(TypeID typeId, FnCast fnCast);

TypeHandler& GetTypeHandler() const;

Expand Down Expand Up @@ -815,6 +826,7 @@ namespace Fyrion
static void CopyImpl(const TypeHandler* typeHandler, ConstPtr source, VoidPtr dest) {};
static void DestructorImpl(const TypeHandler* typeHandler, VoidPtr instance){};
static void MoveImpl(const TypeHandler* typeHandler, VoidPtr origin, VoidPtr destination) {};
static void ReleaseImpl(const TypeHandler* typeHandler, VoidPtr instance) {};
};

template<typename Type>
Expand Down Expand Up @@ -860,6 +872,11 @@ namespace Fyrion
FY_ASSERT(false, "type is not move or copy constructible");
}
}

static void ReleaseImpl(const TypeHandler* typeHandler, VoidPtr instance)
{
ReleaseHandler<Type>::Release(*static_cast<Type*>(instance));
}
};


Expand All @@ -879,6 +896,7 @@ namespace Fyrion
typeBuilder.SetFnCopy(&NativeTypeHandlerFuncs<Type>::CopyImpl);
typeBuilder.SetFnDestructor(&NativeTypeHandlerFuncs<Type>::DestructorImpl);
typeBuilder.SetFnMove(&NativeTypeHandlerFuncs<Type>::MoveImpl);
typeBuilder.SetFnRelease(&NativeTypeHandlerFuncs<Type>::ReleaseImpl);
}

auto Constructor()
Expand Down
Loading

0 comments on commit 00efd43

Please sign in to comment.