Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan #202

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
5d9bf73
Vulkan device implementation
RohacekD Feb 21, 2023
ab0aeb2
Basic shader compiler
RohacekD Feb 21, 2023
769201e
Pipeline compilation
RohacekD Feb 22, 2023
42e7682
First draw call. Honor the triangle
RohacekD Feb 27, 2023
0294e43
Separate pipeline code
RohacekD Mar 21, 2023
fd8fbcf
Better pipeline setup
RohacekD Mar 23, 2023
447a3c6
Vertex buffer creation
RohacekD Mar 23, 2023
0120b83
Use staging buffer for vertex buffer upload
RohacekD Mar 24, 2023
4015a79
Blending params for pipeline
RohacekD Mar 24, 2023
59185c7
Move device-related functions from renderer to device
RohacekD Mar 27, 2023
0a3e992
Index buffers
RohacekD Mar 27, 2023
c8f64a4
Frames in flight added
RohacekD Mar 31, 2023
3dfb6a3
Uniform buffer upload
RohacekD Mar 31, 2023
0e9f860
Init resource manager
RohacekD Mar 31, 2023
47feccb
Pipeline attrib input definition
RohacekD Apr 1, 2023
a10d9e6
Single time command buffer abstraction
RohacekD Apr 1, 2023
ae9bc2e
Update bindings
RohacekD Apr 1, 2023
6b2eadb
Model loading using resource manager
RohacekD Apr 2, 2023
0aea805
Use transfer queue
RohacekD Apr 2, 2023
c99e3bd
Initial try on GPU resource manager
RohacekD Apr 3, 2023
f2476ef
Merge remote-tracking branch 'origin/Vulkan' into Vulkan
RohacekD Apr 3, 2023
49f6a6f
Buffer types, usage and upload
RohacekD Apr 4, 2023
a1fae99
Index buffer moved to handles as well
RohacekD Apr 5, 2023
1bc9ab5
Merge master into vulkan
RohacekD Apr 5, 2023
0a5a6d9
Compilation fix
RohacekD Apr 5, 2023
06c8f0f
GL Buffer allocation
RohacekD Apr 8, 2023
1a1f4de
Texture samplers for vulkan
RohacekD May 11, 2023
2696bfb
Vulkan API
RohacekD May 11, 2023
8217483
Less spam from vulkan
RohacekD May 11, 2023
2ab6454
Image creation moved to resource manager
RohacekD May 22, 2023
e6098f2
Sampler support in resources
RohacekD May 23, 2023
70b5c1e
Sampler in the texture
RohacekD May 25, 2023
2cb7543
Texture view right at the texture
RohacekD May 25, 2023
9d9ef66
Merge remote-tracking branch 'origin/Vulkan' into Vulkan
RohacekD Jun 9, 2023
7d5eb7d
Merge remote-tracking branch 'origin/Vulkan' into Vulkan
RohacekD Jun 9, 2023
274f93f
GLRenderer shader compilation fix
RohacekD Jun 9, 2023
e3c5576
Compilation fixes
RohacekD Jun 9, 2023
092094b
Switch to docking branch imgui
RohacekD Jun 25, 2023
05506fd
Update imGUI
RohacekD Jun 25, 2023
0e8c555
Cleanup GUI menus
RohacekD Jun 25, 2023
3d8a137
Unify API macros for GUI
RohacekD Jun 25, 2023
f86a36c
Fixing compilation
RohacekD Jun 25, 2023
87b71c3
First try of handles rendering
RohacekD Jul 1, 2023
9cd48dc
Unused variable
RohacekD Jul 1, 2023
e49ced8
Pipeline handle
RohacekD Jul 1, 2023
2d271cc
Only name created FBOs
RohacekD Jul 1, 2023
4f86c31
Handles shader
RohacekD Jul 1, 2023
0c99a58
Cleanup renderer interface, Buffer upload API agnostic
RohacekD Jul 1, 2023
130264d
Render all meshes from resource
RohacekD Jul 1, 2023
0fd5491
Access to resource manager unified
RohacekD Jul 1, 2023
907624c
Move static handles component to api agnostic part
RohacekD Jul 1, 2023
6535273
Correct driver for GLFW Window
RohacekD Jul 8, 2023
5555728
First implementation of vulkan render interface
RohacekD Jul 8, 2023
9bc763e
Passing the number of primitives to the call
RohacekD Jul 8, 2023
21ad61e
Pipeline caching, pipeline resource
RohacekD Jul 9, 2023
7632d33
OpenGL pipeline rsource
RohacekD Jul 9, 2023
1ae2ada
ImGui in vulkan renderer
RohacekD Jul 14, 2023
af551b1
More buffers for handles, correct shader, Buffer creationg in OpenGL
RohacekD Jul 14, 2023
15b56c3
Cleanup
RohacekD Jul 14, 2023
736b120
Entity editor first attempt
RohacekD Jul 16, 2023
cb9e1ab
Merge remote-tracking branch 'origin/Vulkan' into Entities
RohacekD Jul 16, 2023
7594b4a
Compilation fix
RohacekD Jul 16, 2023
21944b4
Type selector only supports concrete types
RohacekD Jul 16, 2023
1b2403b
Move Ray trace to generic renderer
RohacekD Jul 31, 2023
37730c4
Merge branch 'Vulkan' into Entities
RohacekD Jul 31, 2023
3b32b65
Merge pull request #203 from MySchoolEngine/Entities
RohacekD Jul 31, 2023
bc6e111
Moving editor stuff to the editor
RohacekD Aug 6, 2023
42e7b7d
Compilation fix
RohacekD Aug 7, 2023
cd756b8
GUI Support for images
RohacekD Aug 9, 2023
7f23652
Vulkan 1.3 enabled for NSight support
RohacekD Aug 9, 2023
6ffbcd0
Crash fix
RohacekD Aug 16, 2023
36560ab
Compilation fix GCC
RohacekD Aug 16, 2023
21df5b5
Merge branch 'Vulkan' of https://github.com/MySchoolEngine/GLEngine i…
RohacekD Dec 26, 2023
37f1f7d
Merge remote-tracking branch 'origin/Vulkan' into Entities
RohacekD Dec 26, 2023
bee5966
Small fixes
RohacekD Jan 1, 2024
d03efd7
Resource handle serialization
RohacekD Jan 28, 2024
1fd8a24
Correct deserialization
RohacekD Feb 4, 2024
c2eed0d
Allow reuse of file dialog
RohacekD Feb 10, 2024
bb380dd
Entity editor saving
RohacekD Feb 10, 2024
40ece9b
Save as and load entity
RohacekD Feb 10, 2024
042a6d9
Merge remote-tracking branch 'origin/Vulkan' into Entities
RohacekD Feb 10, 2024
fd98bc2
Compilation fixes
RohacekD Feb 10, 2024
e3d3757
Prepare for world loading to ray tracing
RohacekD Feb 11, 2024
ac21c73
Merge pull request #204 from MySchoolEngine/Entities
RohacekD Feb 11, 2024
669ea69
Merge branch 'Vulkan' of https://github.com/MySchoolEngine/GLEngine i…
RohacekD Feb 11, 2024
b748907
Merge branch 'Vulkan' of github.com:MySchoolEngine/GLEngine into Vulkan
RohacekD Feb 11, 2024
1f23d78
Compilation fix
RohacekD Feb 11, 2024
5b761bb
Texture input
RohacekD Nov 3, 2024
f0c914b
Merge remote-tracking branch 'origin/master' into Vulkan
RohacekD Nov 7, 2024
fe2c093
Compilation fixes
RohacekD Nov 7, 2024
b2f00c8
Show all the texures at once
RohacekD Nov 7, 2024
fa24479
Allow gui window being closed without guiMGR in caller
RohacekD Nov 16, 2024
953610b
Improvements on TextureManager
RohacekD Nov 18, 2024
4557ff5
Texture resource GUI
RohacekD Nov 24, 2024
937955e
Add changelog
RohacekD Nov 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
[submodule "vendor/RTTR"]
path = vendor/RTTR
url = https://github.com/RohacekD/rttr
[submodule "vendor/slot_map"]
path = vendor/slot_map
url = https://github.com/SergeyMakeev/slot_map
[submodule "vendor/libpng"]
path = vendor/libpng
url = https://github.com/glennrp/libpng
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Change Log
All notable changes to this project will be documented in this file.

## [Unreleased] - 17-11-2024

This version started long ago and aimed for more API agnostic approach to rendering. Aiming for rendering through handles and allow me to optimase the rendering in the future without writing API specific code.

### Added

- `GLEngine::Renderer::ResouceManager` to manage GPU resources.
- `Utils::Reflection::MetaGUI::Texture` first example how to write GUI for `GLEngine::Core::ResourceHandle<T>`
- `GLEngine::Core::Filesystem` for usual path used across engine for unification

### Changed

- `GLEngine::Renderer::C_Material` GUI now allows setting textures
- `GLEngine::Editor::C_ImageEditor` works with handles
- `GLEngine::Core::C_ResourceManager::s_UpdatesBeforeDelete` timeout to unload unused resources
### Fixed
11 changes: 11 additions & 0 deletions Core/Core.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@
<Item Name="[Resource]" Condition="m_Resource._Ptr">*m_Resource._Ptr</Item>
</Expand>
</Type>

<Type Name="GLEngine::Core::ResourceHandle&lt;*&gt;">
<DisplayString Condition="m_Resource._Ptr">{*m_Resource._Ptr}</DisplayString>
<DisplayString Condition="!m_Resource._Ptr">invalid</DisplayString>
<Expand>
<Item Name="[resource]" Condition="m_Resource._Ptr">*(($T1*)m_Resource._Ptr)</Item>
</Expand>
</Type>
<Type Name="GLEngine::Core::Resource">
<DisplayString>{m_State,en}</DisplayString>
</Type>
</AutoVisualizer>
10 changes: 5 additions & 5 deletions Core/Core/EventSystem/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ enum class E_EventCategory


#define EVENT_CLASS_CATEGORY(category) \
virtual Utils::C_BitField<E_EventCategory> GetCategories() const override { return category; }
virtual ::Utils::C_BitField<E_EventCategory> GetCategories() const override { return category; }

//=================================================================================
class CORE_API_EXPORT I_Event {
public:
virtual ~I_Event();
virtual E_EventType GetType() const = 0;
virtual Utils::C_BitField<E_EventCategory> GetCategories() const = 0;
virtual const char* GetName() const = 0;
virtual E_EventType GetType() const = 0;
virtual ::Utils::C_BitField<E_EventCategory> GetCategories() const = 0;
virtual const char* GetName() const = 0;

inline bool IsInCategory(E_EventCategory category) const { return GetCategories() & category; }

Expand All @@ -82,7 +82,7 @@ class CORE_API_EXPORT C_UserEvent : public I_Event {
virtual ~C_UserEvent();

virtual E_EventType GetType() const override;
virtual Utils::C_BitField<E_EventCategory> GetCategories() const override;
virtual ::Utils::C_BitField<E_EventCategory> GetCategories() const override;
virtual const char* GetName() const override;

private:
Expand Down
4 changes: 2 additions & 2 deletions Core/Core/EventSystem/Event/InputEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Core {
// Input event is window dependent
class C_InputEvent : public I_Event {
public:
virtual Utils::C_BitField<E_EventCategory> GetCategories() const override { return GetInputCategory() | E_EventCategory::Input; }
virtual ::Utils::C_BitField<E_EventCategory> GetCategories() const override { return GetInputCategory() | E_EventCategory::Input; }

// window which trigged this event
inline GUID GetWindowGUID() const { return m_WindowID; };
Expand All @@ -23,7 +23,7 @@ class C_InputEvent : public I_Event {
{
}

virtual Utils::C_BitField<E_EventCategory> GetInputCategory() const = 0;
virtual ::Utils::C_BitField<E_EventCategory> GetInputCategory() const = 0;

private:
GUID m_WindowID;
Expand Down
12 changes: 6 additions & 6 deletions Core/Core/EventSystem/Event/KeyboardEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ class C_KeyEvent : public C_InputEvent {
public:
inline int GetKeyCode() const { return m_KeyCode; }

virtual Utils::C_BitField<E_KeyModifiers> GetModifiers() const { return m_Modifiers; }
virtual ::Utils::C_BitField<E_KeyModifiers> GetModifiers() const { return m_Modifiers; }

protected:
C_KeyEvent(int keyCode, GUID window, Utils::C_BitField<E_KeyModifiers> modifiers)
C_KeyEvent(int keyCode, GUID window, ::Utils::C_BitField<E_KeyModifiers> modifiers)
: C_InputEvent(window)
, m_KeyCode(keyCode)
, m_Modifiers(modifiers)
{
}
int m_KeyCode;
Utils::C_BitField<E_KeyModifiers> m_Modifiers;
int m_KeyCode;
::Utils::C_BitField<E_KeyModifiers> m_Modifiers;

virtual Utils::C_BitField<E_EventCategory> GetInputCategory() const override { return E_EventCategory::Keyboard; }
virtual ::Utils::C_BitField<E_EventCategory> GetInputCategory() const override { return E_EventCategory::Keyboard; }
};

//=================================================================================
Expand Down Expand Up @@ -81,6 +81,6 @@ class C_TextInputEvent : public C_InputEvent {
protected:
unsigned int m_Codepoint;

virtual Utils::C_BitField<E_EventCategory> GetInputCategory() const override { return E_EventCategory::Keyboard; }
virtual ::Utils::C_BitField<E_EventCategory> GetInputCategory() const override { return E_EventCategory::Keyboard; }
};
} // namespace GLEngine::Core
2 changes: 1 addition & 1 deletion Core/Core/EventSystem/Event/ResourceEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaseResourceEvent : public I_Event {
~BaseResourceEvent() = default;


Utils::C_BitField<E_EventCategory> GetCategories() const override { return {E_EventCategory::Resource}; }
::Utils::C_BitField<E_EventCategory> GetCategories() const override { return {E_EventCategory::Resource}; }

protected:
ResourceHandleBase m_Handle;
Expand Down
6 changes: 6 additions & 0 deletions Core/Core/Filesystem/Paths.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace GLEngine::Core::Filesystem {
inline const static std::filesystem::path entityFile = ".ent";
inline const static std::filesystem::path entityFolder = "./Entities";
}
3 changes: 2 additions & 1 deletion Core/Core/Resources/Metafile.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <CoreStdafx.h>

#include <Core/Resources/Metafile.h>
#include <Core/Resources/ResourceManager.h>

#include <Utils/Serialization/XMLDeserialize.h>
#include <Utils/Serialization/XMLSerialize.h>
Expand Down Expand Up @@ -39,7 +40,7 @@ bool C_Metafile::Load()
return false;
}

Utils::C_XMLDeserializer d;
Utils::C_XMLDeserializer d(Core::C_ResourceManager::Instance());
auto newThis = d.Deserialize<C_Metafile>(doc);
if (newThis.has_value() == false)
{
Expand Down
12 changes: 12 additions & 0 deletions Core/Core/Resources/Resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

#include <Core/Resources/Resource.h>

#include <rttr/registration>

RTTR_REGISTRATION
{
using namespace GLEngine::Core;

rttr::registration::class_<Resource>("Resource").property("FilePath", &Resource::m_Filepath);


rttr::type::register_wrapper_converter_for_base_classes<std::shared_ptr<Resource>>();
}

namespace GLEngine::Core {

//=================================================================================
Expand Down
44 changes: 36 additions & 8 deletions Core/Core/Resources/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@
#include <Core/CoreApi.h>
#include <Core/EventSystem/EventReciever.h>

namespace GLEngine::Core {
#include <rttr/registration_friend.h>

#define DECLARE_RESOURCE_TYPE(resourceType) \
RTTR_REGISTRATION \
{ \
using namespace GLEngine::Core; \
rttr::registration::class_<ResourceHandle<resourceType>>((resourceType::GetResrourceTypeName() + "Handle").c_str()) \
.constructor<>()(rttr::policy::ctor::as_object) \
.method("AfterDeserialize", &ResourceHandle<resourceType>::AfterDeserialize)(); \
\
rttr::registration::class_<resourceType>(#resourceType).constructor<>()(rttr::policy::ctor::as_std_shared_ptr); \
\
rttr::type::register_wrapper_converter_for_base_classes<std::shared_ptr<resourceType>>(); \
rttr::type::register_converter_func([](std::shared_ptr<resourceType> ptr, bool& ok) -> std::shared_ptr<Resource> { \
ok = true; \
return std::static_pointer_cast<Resource>(ptr); \
}); \
}

namespace GLEngine::Core {

#define DEFINE_RESOURCE_TYPE(resourceType) \
public: \
static std::size_t GetResourceTypeHash() \
{ \
Expand All @@ -16,7 +35,9 @@ public:
{ \
static std::string name(#resourceType); \
return name; \
}
} \
RTTR_ENABLE(Core::Resource) \
public:


enum class ResourceState : std::uint8_t
Expand Down Expand Up @@ -49,18 +70,21 @@ template <class T, class TBaseRes> concept IsBuildableResource = requires(T t, T

template <typename T> concept BuildableResource = requires(T t)
{
IsBeDerivedResource<T> && IsBuildableResource<T, typename T::T_BaseResource>;
IsBeDerivedResource<T>&& IsBuildableResource<T, typename T::T_BaseResource>;
};

class I_ResourceLoader;

// derived resources should take base resource as only constructor argument
class CORE_API_EXPORT Resource : public I_EventReciever {
public:
Resource();
virtual ~Resource();

[[nodiscard]] virtual bool Load(const std::filesystem::path& filepath) = 0;
[[nodiscard]] virtual bool Reload() = 0;
[[nodiscard]] bool Save() const
[[nodiscard]] virtual std::unique_ptr<I_ResourceLoader> GetLoader() = 0;
[[nodiscard]] virtual bool Load(const std::filesystem::path& filepath) = 0;
[[nodiscard]] virtual bool Reload() = 0;
[[nodiscard]] bool Save() const
{
if (!m_Dirty)
return true;
Expand All @@ -77,15 +101,19 @@ class CORE_API_EXPORT Resource : public I_EventReciever {

const std::filesystem::path& GetFilePath() const;

RTTR_ENABLE()
protected:
std::filesystem::path m_Filepath;

virtual bool SaveInternal() const { return false; }

bool m_Dirty = false;
std::filesystem::path m_Filepath;
bool m_Dirty = false;

private:
ResourceState m_State = ResourceState::Empty;
friend class C_ResourceManager;

RTTR_REGISTRATION_FRIEND
};

template <class ResourceType> concept is_resource = std::is_base_of_v<Resource, ResourceType>;
Expand Down
24 changes: 23 additions & 1 deletion Core/Core/Resources/ResourceHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
#include <Core/Resources/ResourceHandle.h>
#include <Core/Resources/ResourceManager.h>

#include <Utils/Reflection/Metadata.h>

#include <rttr/registration>

RTTR_REGISTRATION
{
using namespace GLEngine::Core;
using namespace Utils::Reflection;

rttr::registration::class_<ResourceHandleBase>("ResourceHandleBase")
.constructor<std::shared_ptr<Resource>>()()
.constructor<>()()
.property("Resource", &ResourceHandleBase::m_Resource);
}

namespace GLEngine::Core {

Expand All @@ -29,7 +43,8 @@ ResourceState ResourceHandleBase::GetState() const
//=================================================================================
ResourceHandleBase::~ResourceHandleBase()
{
if (m_Resource.use_count() == 2) {
if (m_Resource.use_count() == 2)
{
C_ResourceManager::Instance().AddResourceToUnusedList(m_Resource);
}
}
Expand All @@ -52,4 +67,11 @@ bool ResourceHandleBase::IsFailed() const
return GetState() == ResourceState::Failed;
}

//=================================================================================
const std::filesystem::path& ResourceHandleBase::GetFilePath() const
{
if (m_Resource)
return m_Resource->GetFilePath();
return "";
}
} // namespace GLEngine::Core
25 changes: 23 additions & 2 deletions Core/Core/Resources/ResourceHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <Core/CoreApi.h>
#include <Core/Resources/Resource.h>

#include <Utils/Serialization/XMLDeserialize.h>

#include <rttr/registration_friend.h>

namespace GLEngine::Core {
class CORE_API_EXPORT ResourceHandleBase {
public:
Expand All @@ -16,13 +20,17 @@ class CORE_API_EXPORT ResourceHandleBase {

explicit operator bool() const { return IsReady(); }

const std::filesystem::path& GetFilePath() const;

RTTR_ENABLE();

protected:
std::shared_ptr<Resource> m_Resource; // nullptr only when no loader exists
RTTR_REGISTRATION_FRIEND;
};

// this forces include of ResourceType definition into headers, can I move it somewhere else?
template <class ResourceType> requires(is_resource<ResourceType>)
class ResourceHandle : public ResourceHandleBase {
template <class ResourceType> requires(is_resource<ResourceType>) class ResourceHandle : public ResourceHandleBase {
public:
ResourceHandle() = default;
ResourceHandle(std::shared_ptr<ResourceType> resource)
Expand All @@ -34,6 +42,19 @@ class ResourceHandle : public ResourceHandleBase {
ResourceType& GetResource();

const std::filesystem::path& GetFilepath() const;

void AfterDeserialize(GLEngine::Utils::C_XMLDeserializer::DeserializeCtx& ctx);

RTTR_ENABLE(ResourceHandleBase);
};

// for usage in maps
template <is_resource ResourceType>
struct ResourceHandleCmp {
bool operator()(const ResourceHandle<ResourceType>& lhs, const ResourceHandle<ResourceType>& rhs) const
{
return lhs.GetFilepath() < rhs.GetFilepath();
}
};

} // namespace GLEngine::Core
Expand Down
9 changes: 9 additions & 0 deletions Core/Core/Resources/ResourceHandle.inl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <Core/Resources/ResourceManager.h>

namespace GLEngine::Core {

//=================================================================================
Expand All @@ -25,4 +27,11 @@ const std::filesystem::path& ResourceHandle<ResourceType>::GetFilepath() const
GLE_ASSERT(m_Resource, "Uninitalized resource");
return m_Resource->GetFilePath();
}

//=================================================================================
template <class ResourceType> requires(is_resource<ResourceType>) void ResourceHandle<ResourceType>::AfterDeserialize(GLEngine::Utils::C_XMLDeserializer::DeserializeCtx& ctx)
{
auto& rm = C_ResourceManager::Instance();
*this = rm.LoadResource<ResourceType>(GetFilePath());
}
} // namespace GLEngine::Core
Loading
Loading