Skip to content

Commit 8fe90da

Browse files
committed
pull from 'master'
2 parents 1468690 + 0632553 commit 8fe90da

File tree

151 files changed

+3802
-8446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+3802
-8446
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@
102102
[submodule "3rdparty/imguizmo"]
103103
path = 3rdparty/imguizmo
104104
url = git@github.com:Devsh-Graphics-Programming/ImGuizmo.git
105+
[submodule "3rdparty/git-version-tracking"]
106+
path = 3rdparty/git-version-tracking
107+
url = git@github.com:Devsh-Graphics-Programming/cmake-git-version-tracking.git

3rdparty/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ add_library(spirv_cross OBJECT
275275
)
276276
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
277277

278+
# cmake-git-version-tracking
279+
add_subdirectory(git-version-tracking EXCLUDE_FROM_ALL)
280+
NBL_ADD_GIT_TRACKING_META_LIBRARY(nabla "${NBL_ROOT_PATH}")
281+
NBL_ADD_GIT_TRACKING_META_LIBRARY(dxc "${CMAKE_CURRENT_SOURCE_DIR}/dxc/dxc")
282+
NBL_GENERATE_GIT_TRACKING_META()
283+
278284
if(NBL_BUILD_IMGUI)
279285
add_library(imgui STATIC
280286
"imgui/imconfig.h"

3rdparty/git-version-tracking

Submodule git-version-tracking added at 6980df4

3rdparty/parallel-hashmap

Submodule parallel-hashmap updated 53 files

__init__.py

Whitespace-only changes.

examples_tests

Submodule examples_tests updated 101 files

include/nabla.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#ifndef __NABLA_H_INCLUDED__
1818
#define __NABLA_H_INCLUDED__
1919

20+
// meta info
21+
#include "git_info.h"
22+
23+
namespace nbl {
24+
NBL_API2 const gtml::GitInfo& getGitInfo(gtml::E_GIT_REPO_META repo);
25+
}
26+
2027
// core lib
2128
#include "nbl/core/declarations.h"
2229

include/nbl/asset/IAsset.h

Lines changed: 23 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ class IAssetManager;
2323
2424
@see ICPUBuffer
2525
26-
Actually an Asset is a class deriving from it that can be anything like cpu-side meshes scenes, texture data and material pipelines,
27-
but must be serializable into/from .baw file format, unless it comes from an extension (nbl::ext),
28-
so forth cached. There are different asset types you can find at IAsset::E_TYPE.
26+
Actually an Asset is a class deriving from it that can be anything like cpu-side meshes scenes, texture data and material pipelines.
27+
There are different asset types you can find at IAsset::E_TYPE.
2928
IAsset doesn't provide direct instantiation (virtual destructor), much like IReferenceCounted.
3029
3130
Asset type's naming-convention is ICPU_x, where _x is a name of an Asset, eg. ICPUBuffer, ICPUMesh e.t.c
@@ -41,13 +40,6 @@ class IAssetManager;
4140
class IAsset : virtual public core::IReferenceCounted
4241
{
4342
public:
44-
enum E_MUTABILITY : uint32_t
45-
{
46-
EM_MUTABLE = 0u,
47-
EM_CPU_PERSISTENT = 0b01u,
48-
EM_IMMUTABLE = 0b11u,
49-
};
50-
5143
/**
5244
Values of E_TYPE represents an Asset type.
5345
@@ -78,7 +70,6 @@ class IAsset : virtual public core::IReferenceCounted
7870
Pay attention that an Asset type represents one single bit, so there is a limit to 64 bits.
7971
8072
*/
81-
8273
enum E_TYPE : uint64_t
8374
{
8475
ET_BUFFER = 1ull<<0, //!< asset::ICPUBuffer
@@ -155,140 +146,44 @@ class IAsset : virtual public core::IReferenceCounted
155146
return core::smart_refctd_ptr_static_cast<assetType>(std::move(rootAsset));
156147
}
157148

158-
//!
159-
inline IAsset() : isDummyObjectForCacheAliasing{false}, m_mutability{EM_MUTABLE} {}
160-
161-
//! Returns correct size reserved associated with an Asset and its data
162-
/**
163-
Some containers like std::vector reserves usually more memory than they actually need.
164-
Similar behaviour appears here and it is actually necessary to reserve the correct amount of memory when writing to file.
165-
The value returned can be greater than memory actually needed and that symbolizes the name "conservative".
166-
167-
Additionally the size is used to determine compression level while writing process is performed.
168-
As you expect, the bigger the size returned the more likely it is to be compressed with a more expensive (slower) algorithm.
169-
*/
170-
virtual size_t conservativeSizeEstimate() const = 0; // TODO: this shouldn't be a method of IAsset but BlobSerializable ?
149+
//! To be implemented by derived classes. Returns a type of an Asset
150+
virtual E_TYPE getAssetType() const = 0;
171151

172152
//! creates a copy of the asset, duplicating dependant resources up to a certain depth (default duplicate everything)
173153
virtual core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const = 0;
174154

175-
// TODO: `_other` should probably be const qualified!
176-
inline bool restoreFromDummy(IAsset* _other, uint32_t _levelsBelow = (~0u))
177-
{
178-
assert(getAssetType() == _other->getAssetType());
179-
180-
if (!canBeRestoredFrom(_other))
181-
return false;
182-
183-
restoreFromDummy_impl(_other, _levelsBelow);
184-
isDummyObjectForCacheAliasing = false;
185-
return true;
186-
}
155+
//!
156+
inline bool isMutable() const {return m_mutable;}
187157

188-
inline bool willBeRestoredFrom(const IAsset* _other) const
158+
//!
159+
virtual size_t getDependantCount() const = 0;
160+
inline IAsset* getDependant(const size_t ix)
189161
{
190-
assert(getAssetType() == _other->getAssetType());
191-
192-
if (getMutability() != EM_MUTABLE)
193-
return false;
194-
if (_other->getMutability() != EM_MUTABLE)
195-
return false;
196-
if (!isADummyObjectForCache())
197-
return false;
198-
if (_other->isADummyObjectForCache())
199-
return false;
200-
201-
return true;
162+
if (ix<getDependantCount())
163+
return getDependant_impl(ix);
164+
return nullptr;
202165
}
203-
204-
205-
inline E_MUTABILITY getMutability() const { return m_mutability; }
206-
inline bool isMutable() const { return getMutability() == EM_MUTABLE; }
207-
inline bool canBeConvertedToDummy() const { return !isADummyObjectForCache() && getMutability() < EM_CPU_PERSISTENT; }
208-
209-
// TODO: add a null and type check here, delegate rest to an `impl`
210-
virtual bool canBeRestoredFrom(const IAsset* _other) const = 0;
211-
212-
// returns if `this` is dummy or any of its dependencies up to `_levelsBelow` levels below
213-
inline bool isAnyDependencyDummy(uint32_t _levelsBelow = ~0u) const
166+
inline const IAsset* getDependant(const size_t ix) const
214167
{
215-
if (isADummyObjectForCache())
216-
return true;
217-
218-
return _levelsBelow ? isAnyDependencyDummy_impl(_levelsBelow) : false;
168+
IAsset* const retval = const_cast<IAsset*>(this)->getDependant(ix);
169+
return retval;
219170
}
220171

221172
protected:
222-
inline static void restoreFromDummy_impl_call(IAsset* _this_child, IAsset* _other_child, uint32_t _levelsBelow)
223-
{
224-
_this_child->restoreFromDummy_impl(_other_child, _levelsBelow);
225-
}
226-
227-
virtual void restoreFromDummy_impl(IAsset* _other, uint32_t _levelsBelow) = 0;
228-
229-
// returns if any of `this`'s up to `_levelsBelow` levels below is dummy
230-
virtual bool isAnyDependencyDummy_impl(uint32_t _levelsBelow) const { return false; }
231-
232-
inline void clone_common(IAsset* _clone) const
233-
{
234-
assert(!isDummyObjectForCacheAliasing);
235-
_clone->isDummyObjectForCacheAliasing = false;
236-
_clone->m_mutability = EM_MUTABLE;
237-
}
238-
inline bool isImmutable_debug()
239-
{
240-
const bool imm = getMutability() == EM_IMMUTABLE;
241-
//_NBL_DEBUG_BREAK_IF(imm);
242-
return imm;
243-
}
244-
245-
private:
246-
friend IAssetManager;
247-
248-
protected:
249-
bool isDummyObjectForCacheAliasing; //!< A bool for setting whether Asset is in dummy state. @see convertToDummyObject(uint32_t referenceLevelsBelowToConvert)
250-
251-
E_MUTABILITY m_mutability;
252-
253-
//! To be implemented by base classes, dummies must retain references to other assets
254-
//! but cleans up all other resources which are not assets.
255-
/**
256-
Dummy object is an object which is converted to GPU object or which is about to be converted to GPU object.
257-
Take into account that\b convertToDummyObject(uint32_t referenceLevelsBelowToConvert) itself doesn't perform exactly converting to GPU object\b.
258-
259-
@see IAssetManager::convertAssetToEmptyCacheHandle(IAsset* _asset, core::smart_refctd_ptr<core::IReferenceCounted>&& _gpuObject)
260-
261-
If an Asset is being converted to a GPU object, its resources are no longer needed in RAM memory,
262-
so everything it has allocated becomes deleted, but the Asset itself remains untouched, so that is the
263-
pointer for an Asset and the memory allocated for that pointer. It's because it's needed as a key by some
264-
functions that find GPU objects. It involves all CPU objects (Assets).
265-
266-
So an Asset signed as dummy becomes GPU object and deletes some resources in RAM memory.
267-
268-
@param referenceLevelsBelowToConvert says how many times to recursively call `convertToDummyObject` on its references.
269-
*/
270-
virtual void convertToDummyObject(uint32_t referenceLevelsBelowToConvert=0u) = 0;
271-
272-
inline void convertToDummyObject_common(uint32_t referenceLevelsBelowToConvert)
273-
{
274-
if (canBeConvertedToDummy())
275-
isDummyObjectForCacheAliasing = true;
276-
}
277-
278-
//! Checks if the object is either not dummy or dummy but in some cache for a purpose
279-
inline bool isInValidState() { return !isDummyObjectForCacheAliasing /* || !isCached TODO*/; }
280-
173+
inline IAsset() = default;
281174
//! Pure virtual destructor to ensure no instantiation
282175
NBL_API2 virtual ~IAsset() = 0;
283176

284-
public:
285-
//! To be implemented by derived classes. Returns a type of an Asset
286-
virtual E_TYPE getAssetType() const = 0;
177+
virtual IAsset* getDependant_impl(const size_t ix) = 0;
287178

288-
//! Returning isDummyObjectForCacheAliasing, specifies whether Asset in dummy state
289-
inline bool isADummyObjectForCache() const { return isDummyObjectForCacheAliasing; }
179+
private:
180+
friend IAssetManager;
181+
bool m_mutable = true;
290182
};
291183

184+
template<typename T>
185+
concept Asset = std::is_base_of_v<IAsset,T>;
186+
292187
}
293188

294189
#endif

0 commit comments

Comments
 (0)