Skip to content

CAD DTM Rendering #858

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
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
81e440a
Update examples
Przemog1 Feb 27, 2025
f83d462
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla …
Przemog1 Mar 7, 2025
be37c6a
Updated examples
Przemog1 Mar 20, 2025
c9e0926
Implemented height shading
Przemog1 Mar 26, 2025
896d0c4
update examples
Erfan-Ahmadi Mar 30, 2025
25eceed
update examples
Erfan-Ahmadi Apr 10, 2025
df77044
update examples
Erfan-Ahmadi Apr 10, 2025
a327c29
Updated examples
Przemog1 Apr 12, 2025
3bf7c61
Updated examples
Przemog1 Apr 14, 2025
a77ca95
Updated_examples
Przemog1 Apr 14, 2025
4ed3af9
update examples
Erfan-Ahmadi Apr 15, 2025
631c63e
update examples
Erfan-Ahmadi Apr 15, 2025
f85956d
Updated examples
Przemog1 Apr 15, 2025
2456127
update examples
Erfan-Ahmadi Apr 15, 2025
7674e43
Updated examples
Przemog1 Apr 19, 2025
6030045
update examples
Erfan-Ahmadi Apr 21, 2025
f997894
update examples
Erfan-Ahmadi Apr 21, 2025
38d5ee2
update examples
Erfan-Ahmadi Apr 22, 2025
ca49224
Updated examples
Przemog1 Apr 22, 2025
2218dfe
Resolved conflicts, merged master
Przemog1 Apr 22, 2025
ab57b02
Updated examples
Przemog1 Apr 22, 2025
38baf9f
Updated examples
Przemog1 Apr 23, 2025
f810b5d
Updated examples
Przemog1 Apr 24, 2025
e19e644
update examples
Erfan-Ahmadi Apr 25, 2025
5c27651
update examples
Erfan-Ahmadi May 1, 2025
6d2011f
update examples tests
Erfan-Ahmadi May 2, 2025
0d6542a
update examples
Erfan-Ahmadi May 2, 2025
095eda5
update examples
Erfan-Ahmadi May 2, 2025
93297f2
update examples
Erfan-Ahmadi May 3, 2025
219b3b0
update examples
Erfan-Ahmadi May 4, 2025
3540cc9
update examples
Erfan-Ahmadi May 5, 2025
b4290eb
Merge branch 'master' into dtm
Erfan-Ahmadi May 5, 2025
02488df
update examples
Erfan-Ahmadi May 5, 2025
8c93578
update examples
Erfan-Ahmadi May 12, 2025
7e428bd
LRUCache new functionalities
Erfan-Ahmadi May 13, 2025
460475b
small dumb fix
Erfan-Ahmadi May 13, 2025
0f3f207
update examples
Erfan-Ahmadi May 13, 2025
6efb44c
update examples
Erfan-Ahmadi May 14, 2025
ddba6e4
fix suballocated descriptorset destructor and cull_frees
Erfan-Ahmadi May 14, 2025
d418ad5
update examples
Erfan-Ahmadi May 14, 2025
4a3720e
update example
Erfan-Ahmadi May 14, 2025
c4bc0c1
Fix IGPUDescriptorSet holding on to descriptors ref at correct arrayE…
Erfan-Ahmadi May 15, 2025
08ff1df
Fix IGPUDescriptorSet holding on to mutableSamplers
Erfan-Ahmadi May 15, 2025
2cf7ec8
SubAllocatedDescriptorSet to hold onto additional refcounted objects
Erfan-Ahmadi May 15, 2025
1c95943
Updated examples
Przemog1 May 15, 2025
9fd1360
Resolved conflicts, merged dtm
Przemog1 May 15, 2025
2e61c53
Resolved conflicts, merged master
Przemog1 May 15, 2025
24dfb15
Updated examples_tests
Przemog1 May 15, 2025
37785e5
fix wrong check for nullDescriptors feature
Erfan-Ahmadi May 15, 2025
667e30d
update examples
Erfan-Ahmadi May 16, 2025
8b094b4
small LRUCache comment to help with usage
Erfan-Ahmadi May 16, 2025
7c04af6
update examples
Erfan-Ahmadi May 16, 2025
4378a7b
Merge branch 'master' into dtm
Erfan-Ahmadi May 18, 2025
315ce86
update examples
Erfan-Ahmadi May 18, 2025
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
16 changes: 15 additions & 1 deletion include/nbl/core/containers/LRUCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class ResizableLRUCache : protected impl::LRUCacheBase<Key, Value, MapHash, MapE
return nullptr;
}

//remove element at key if present
// remove element at key if present
inline void erase(const Key& key)
{
bool success;
Expand All @@ -400,6 +400,20 @@ class ResizableLRUCache : protected impl::LRUCacheBase<Key, Value, MapHash, MapE
m_shortcut_map.erase(iterator);
}
}

// returns key for least recently used
// use in evictin callback to know which Key is being evicted
inline const Key* get_least_recently_used() const
{
if (m_shortcut_map.size() > 0)
return &base_t::m_list.getBack()->data.first;
else
return nullptr;
}

inline size_t size() const { return m_shortcut_map.size(); }

inline bool empty() const { return size() <= 0ull; }

/**
* @brief Resizes the cache by extending its capacity so it can hold more elements. Returns a bool indicating if capacity was indeed increased.
Expand Down
30 changes: 20 additions & 10 deletions include/nbl/video/alloc/SubAllocatedDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
class DeferredFreeFunctor
{
public:
inline DeferredFreeFunctor(SubAllocatedDescriptorSet* composed, uint32_t binding, size_type count, const value_type* addresses)
: m_addresses(std::move(core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<value_type>>(count))),
m_binding(binding), m_composed(composed)
using ref_t = core::smart_refctd_ptr<const core::IReferenceCounted>;

template<typename T> requires std::is_base_of_v<core::IReferenceCounted,T>
inline DeferredFreeFunctor(SubAllocatedDescriptorSet* composed, uint32_t binding, size_type count, const value_type* addresses, const T*const *const objectsToHold)
: m_addresses(core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<value_type>>(count))
, m_objectsToHold(core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<ref_t>>(count))
, m_binding(binding)
, m_composed(composed)
{
memcpy(m_addresses->data(), addresses, count * sizeof(value_type));
for (size_t i=0u; i<count; i++)
(*m_objectsToHold)[i] = objectsToHold ? ref_t(objectsToHold[i]) : nullptr;
}
inline DeferredFreeFunctor(DeferredFreeFunctor&& other)
{
Expand All @@ -58,11 +65,13 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
{
m_composed = other.m_composed;
m_addresses = other.m_addresses;
m_objectsToHold = other.m_objectsToHold;
m_binding = other.m_binding;

// Nullifying other
other.m_composed = nullptr;
other.m_addresses = nullptr;
other.m_objectsToHold = nullptr;
other.m_binding = 0;
return *this;
}
Expand Down Expand Up @@ -99,6 +108,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
}
protected:
core::smart_refctd_dynamic_array<value_type> m_addresses;
core::smart_refctd_dynamic_array<ref_t> m_objectsToHold;
SubAllocatedDescriptorSet* m_composed; // TODO: shouldn't be called `composed`, maybe `parent` or something
uint32_t m_binding;
};
Expand Down Expand Up @@ -209,9 +219,9 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
remainingFrees = cull_frees();
} while (remainingFrees > 0);

for (uint32_t i = 0; i < m_allocatableRanges.size(); i++)
for (auto& it : m_allocatableRanges)
{
auto& range = m_allocatableRanges[i];
auto& range = it.second;
if (range.reservedSize == 0)
continue;
assert(range.eventHandler->getTimelines().size() == 0);
Expand Down Expand Up @@ -355,10 +365,11 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
}

// defers based on the conservative estimation if `futureWait` needs to be waited on, if doesn't will call nullify descriiptors internally immediately
inline void multi_deallocate(uint32_t binding, size_type count, const value_type* addr, const ISemaphore::SWaitInfo& futureWait) noexcept
template<typename T=core::IReferenceCounted>
inline void multi_deallocate(uint32_t binding, size_type count, const value_type* addr, const ISemaphore::SWaitInfo& futureWait, const T*const *const objectsToDrop=nullptr) noexcept
{
if (futureWait.semaphore)
multi_deallocate(binding, futureWait, DeferredFreeFunctor(this, binding, count, addr));
multi_deallocate(binding, futureWait, DeferredFreeFunctor(this, binding, count, addr, objectsToDrop));
else
{
core::vector<IGPUDescriptorSet::SDropDescriptorSet> nulls(count);
Expand All @@ -376,10 +387,9 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
uint32_t frees = 0;
core::vector<IGPUDescriptorSet::SDropDescriptorSet> nulls(m_totalDeferredFrees);
auto outNulls = nulls.data();
for (uint32_t i = 0; i < m_allocatableRanges.size(); i++)
for (auto& it : m_allocatableRanges)
{
auto& it = m_allocatableRanges[i];
frees += it.eventHandler->poll(outNulls).eventsLeft;
frees += it.second.eventHandler->poll(outNulls).eventsLeft;
}
getDevice()->nullifyDescriptors({nulls.data(),outNulls});
return frees;
Expand Down
2 changes: 1 addition & 1 deletion src/nbl/video/CVulkanLogicalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ void CVulkanLogicalDevice::updateDescriptorSets_impl(const SUpdateDescriptorSets
void CVulkanLogicalDevice::nullifyDescriptors_impl(const SDropDescriptorSetsParams& params)
{
const auto& drops = params.drops;
if (getEnabledFeatures().nullDescriptor)
if (!getEnabledFeatures().nullDescriptor)
{
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/nbl/video/CVulkanPhysicalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,8 @@ core::smart_refctd_ptr<ILogicalDevice> CVulkanPhysicalDevice::createLogicalDevic

enableExtensionIfAvailable(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME);

enableExtensionIfAvailable(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME);
VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR fragmentShaderBarycentricFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR, nullptr};
enableExtensionIfAvailable(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME,&fragmentShaderBarycentricFeatures);

VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR subgroupUniformControlFlowFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR,nullptr };
enableExtensionIfAvailable(VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME,&subgroupUniformControlFlowFeatures);
Expand Down
4 changes: 2 additions & 2 deletions src/nbl/video/IGPUDescriptorSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ void IGPUDescriptorSet::processWrite(const IGPUDescriptorSet::SWriteDescriptorSe

for (auto j = 0; j < write.count; ++j)
{
descriptors[j] = write.info[j].desc;
descriptors[j + write.arrayElement] = write.info[j].desc;

if (mutableSamplers)
mutableSamplers[j] = write.info[j].info.combinedImageSampler.sampler;
mutableSamplers[j + write.arrayElement] = write.info[j].info.combinedImageSampler.sampler;
}
auto& bindingRedirect = m_layout->getDescriptorRedirect(validationResult.type);
auto bindingCreateFlags = bindingRedirect.getCreateFlags(validationResult.descriptorRedirectBindingIndex);
Expand Down