-
Notifications
You must be signed in to change notification settings - Fork 42
Impl IRenderObject & TRenderPtr
#194
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
Open
Mozz3d
wants to merge
18
commits into
wopss:master
Choose a base branch
from
Mozz3d:render-data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
204c0e7
Impl `IRenderData` & `TRenderPtr` + organize render types
Mozz3d d79207d
Fix includes
Mozz3d c01b49f
Fix incorrect include in `RenderData.hpp`
Mozz3d 28cbf7e
Remove incorrect noexcept specifiers
Mozz3d e25f17c
`IRenderData` -> `IRenderObject` + semantic improvements
Mozz3d 5ad913f
Fix incorrect `TRenderPtr` friend declaration & method access
Mozz3d 9f3945b
Fix (still) incorrect `TRenderPtr` friend declaration
Mozz3d 6925a3c
Merge branch 'master' into render-data
Mozz3d 1a401b1
Suggested changes
Mozz3d b7a6e02
Merge branch 'render-data' of https://github.com/Mozz3d/RED4ext.SDK i…
Mozz3d 948dc4b
Move `TRenderPtr` dtor + fix access in `IRenderObject`
Mozz3d 089d321
Reintroduce odd `this` check
Mozz3d d9cc9c0
Merge branch 'master' into render-data
Mozz3d 3cf99b5
Suggested changes
Mozz3d ccb241e
Merge branch 'master' into render-data
Mozz3d 231bb9a
Avoid using `std::atomic`
Mozz3d fb1b08f
Merge branch 'render-data' of https://github.com/Mozz3d/RED4ext.SDK i…
Mozz3d 5282f1b
uint32_t
Mozz3d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| #pragma once | ||
|
|
||
| #include <RED4ext/Memory/Utils.hpp> | ||
|
|
||
| namespace RED4ext | ||
| { | ||
| struct IRenderData | ||
| { | ||
| using AllocatorType = Memory::RenderDataAllocator; | ||
|
|
||
| virtual Memory::IAllocator* GetAllocator() | ||
| { | ||
| return AllocatorType::Get(); | ||
| } | ||
|
|
||
| virtual void Destroy() | ||
| { | ||
| if (this) | ||
| { | ||
| Memory::Delete(this); | ||
| } | ||
| } | ||
|
|
||
| virtual ~IRenderData() = default; | ||
|
|
||
| void Release() | ||
| { | ||
| if (--refCount < 1) | ||
| Destroy(); | ||
| } | ||
|
|
||
| void AddRef() | ||
| { | ||
| refCount++; | ||
| } | ||
|
|
||
| std::atomic<int32_t> refCount = 1; | ||
| }; | ||
| RED4EXT_ASSERT_SIZE(IRenderData, 0x10); | ||
|
|
||
| template<std::derived_from<IRenderData> T = IRenderData> | ||
| class TRenderPtr | ||
| { | ||
| TRenderPtr() = default; | ||
|
|
||
| ~TRenderPtr() | ||
| { | ||
| Release(); | ||
| } | ||
|
|
||
| TRenderPtr(std::nullptr_t) noexcept | ||
| { | ||
| } | ||
|
|
||
| template<std::derived_from<IRenderData> U> | ||
| explicit TRenderPtr(U* aPointer) noexcept | ||
| : m_instance(aPointer) | ||
| { | ||
| } | ||
|
|
||
| TRenderPtr(const TRenderPtr& aOther) noexcept | ||
| : m_instance(aOther.m_instance) | ||
| { | ||
| if (m_instance) | ||
| m_instance->AddRef(); | ||
| } | ||
|
|
||
| TRenderPtr(TRenderPtr&& aOther) noexcept | ||
| { | ||
| Swap(aOther); | ||
| } | ||
|
|
||
| operator bool() const noexcept | ||
| { | ||
| return m_instance != nullptr; | ||
| } | ||
|
|
||
| TRenderPtr& operator=(const TRenderPtr& aRhs) noexcept | ||
| { | ||
| TRenderPtr(aRhs).Swap(*this); | ||
| return *this; | ||
| } | ||
|
|
||
| TRenderPtr& operator=(TRenderPtr&& aRhs) noexcept | ||
| { | ||
| Swap(aRhs); | ||
| return *this; | ||
| } | ||
|
|
||
| T* operator->() const noexcept | ||
| { | ||
| return m_instance; | ||
| } | ||
|
|
||
| void Swap(TRenderPtr& aOther) noexcept | ||
| { | ||
| std::swap(m_instance, aOther.m_instance); | ||
| } | ||
|
|
||
| T* GetPtr() const noexcept | ||
| { | ||
| return m_instance; | ||
| } | ||
|
|
||
| private: | ||
| void Release() | ||
| { | ||
| if (m_instance) | ||
| m_instance->Release(); | ||
| } | ||
|
|
||
| T* m_instance = nullptr; | ||
| }; | ||
| RED4EXT_ASSERT_SIZE(TRenderPtr<>, 0x08); | ||
| } // namespace RED4ext | ||
2 changes: 1 addition & 1 deletion
2
include/RED4ext/RenderProxy-inl.hpp → ...ude/RED4ext/Rendering/RenderProxy-inl.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
include/RED4ext/RenderResource.hpp → include/RED4ext/Rendering/RenderResource.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.