diff --git a/.gitmodules b/.gitmodules index 00482441de..c3667f0301 100644 --- a/.gitmodules +++ b/.gitmodules @@ -36,9 +36,6 @@ [submodule "3rdparty/gli"] path = 3rdparty/gli url = git@github.com:Devsh-Graphics-Programming/gli.git -[submodule "3rdparty/parallel-hashmap"] - path = 3rdparty/parallel-hashmap - url = git@github.com:Devsh-Graphics-Programming/parallel-hashmap.git [submodule "3rdparty/jitify"] path = 3rdparty/jitify url = git@github.com:Devsh-Graphics-Programming/jitify.git @@ -121,3 +118,6 @@ [submodule "docker/msvc-winsdk"] path = docker/msvc-winsdk url = ../docker-nanoserver-msvc-winsdk +[submodule "3rdparty/gtl"] + path = 3rdparty/gtl + url = https://github.com/greg7mdp/gtl.git diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index b242904db1..d70875a065 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -522,7 +522,7 @@ add_dependencies(3rdparty ${NBL_3RDPARTY_TARGETS}) NBL_ADJUST_FOLDERS(3rdaprty) -nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/parallel-hashmap/parallel_hashmap") +nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/gtl/include") # parent scope exports, must be at the end of the file set(_NBL_3RDPARTY_TARGETS_ diff --git a/3rdparty/gtl b/3rdparty/gtl new file mode 160000 index 0000000000..6ad66cd6d3 --- /dev/null +++ b/3rdparty/gtl @@ -0,0 +1 @@ +Subproject commit 6ad66cd6d3824128300f78aeeffc54294e147bc7 diff --git a/3rdparty/parallel-hashmap b/3rdparty/parallel-hashmap deleted file mode 160000 index fd7b8fb87d..0000000000 --- a/3rdparty/parallel-hashmap +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fd7b8fb87d74cc990591c3443b2ef21e9e137500 diff --git a/examples_tests b/examples_tests index 1b3c19cb84..2872604536 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 1b3c19cb84d618f20c77469c86a665544889aff7 +Subproject commit 28726045367f9bbab5668e324af6a69bcfbb264c diff --git a/include/nbl/asset/utils/CDirQuantCacheBase.h b/include/nbl/asset/utils/CDirQuantCacheBase.h index 462d414a73..c4e7174013 100644 --- a/include/nbl/asset/utils/CDirQuantCacheBase.h +++ b/include/nbl/asset/utils/CDirQuantCacheBase.h @@ -10,7 +10,7 @@ #include #include -#include "parallel-hashmap/parallel_hashmap/phmap_dump.h" +#include "gtl/include/gtl/phmap_dump.hpp" #include "nbl/core/declarations.h" @@ -282,7 +282,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl:: backup.swap(particularCache); CBufferPhmapInputArchive buffWrap(buffer); - bool loadingSuccess = particularCache.load(buffWrap); + bool loadingSuccess = particularCache.phmap_load(buffWrap); if (!replaceCurrentContents || !loadingSuccess) particularCache.merge(std::move(backup)); @@ -333,7 +333,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl:: return false; CBufferPhmapOutputArchive buffWrap(buffer); - return std::get>(cache).dump(buffWrap); + return std::get>(cache).phmap_dump(buffWrap); } //! @@ -488,7 +488,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl:: template static inline size_t getSerializedCacheSizeInBytes_impl(size_t capacity) { - return 1u+sizeof(size_t)*2u+phmap::priv::Group::kWidth+(sizeof(typename cache_type_t::slot_type)+1u)*capacity; + return 1u+sizeof(size_t)*2u+gtl::priv::Group::kWidth+(sizeof(typename cache_type_t::slot_type)+1u)*capacity; } template static inline bool validateSerializedCache(const SBufferRange& buffer) diff --git a/include/nbl/asset/utils/phmap_deserialization.h b/include/nbl/asset/utils/phmap_deserialization.h index fa4dd1637e..351f019a83 100644 --- a/include/nbl/asset/utils/phmap_deserialization.h +++ b/include/nbl/asset/utils/phmap_deserialization.h @@ -1,9 +1,8 @@ // Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O. // This file is part of the "Nabla Engine". // For conditions of distribution and use, see copyright notice in nabla.h - -#ifndef __NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED__ -#define __NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED__ +#ifndef _NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED_ +#define _NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED_ #include "nbl/core/declarations.h" #include "nbl/asset/ICPUBuffer.h" @@ -20,7 +19,7 @@ class CBufferPhmapInputArchive } // TODO: protect against reading out of the buffer range - bool load(char* p, size_t sz) + bool loadBinary(void* p, size_t sz) { memcpy(p, buffPtr, sz); buffPtr += sz; @@ -29,7 +28,7 @@ class CBufferPhmapInputArchive } template - typename std::enable_if::value,bool>::type load(V* v) + typename std::enable_if::value,bool>::type loadBinary(V* v) { memcpy(reinterpret_cast(v), buffPtr, sizeof(V)); buffPtr += sizeof(V); diff --git a/include/nbl/asset/utils/phmap_serialization.h b/include/nbl/asset/utils/phmap_serialization.h index 9a6e368c6b..5a2b783380 100644 --- a/include/nbl/asset/utils/phmap_serialization.h +++ b/include/nbl/asset/utils/phmap_serialization.h @@ -1,9 +1,8 @@ // Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O. // This file is part of the "Nabla Engine". // For conditions of distribution and use, see copyright notice in nabla.h - -#ifndef __NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED__ -#define __NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED__ +#ifndef _NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED_ +#define _NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED_ #include "nbl/core/declarations.h" #include "nbl/asset/ICPUBuffer.h" @@ -20,7 +19,7 @@ class CBufferPhmapOutputArchive } // TODO: protect against writing out of bounds as defined by SBufferRange - bool dump(const char* p, size_t sz) + bool saveBinary(const void* p, size_t sz) { memcpy(bufferPtr, p, sz); bufferPtr += sz; @@ -29,7 +28,7 @@ class CBufferPhmapOutputArchive } template - typename std::enable_if::value,bool>::type dump(const V& v) + typename std::enable_if::value,bool>::type saveBinary(const V& v) { memcpy(bufferPtr, reinterpret_cast(&v), sizeof(V)); bufferPtr += sizeof(V); diff --git a/include/nbl/core/decl/Types.h b/include/nbl/core/decl/Types.h index 1b3c816c1a..e7eb91f674 100644 --- a/include/nbl/core/decl/Types.h +++ b/include/nbl/core/decl/Types.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "nbl/core/memory/new_delete.h" @@ -62,7 +62,7 @@ template, class Allocator=allocator > using set = std::set; template, class KeyEqual=std::equal_to, class Allocator=allocator > > -using unordered_map = phmap::flat_hash_map; +using unordered_map = gtl::flat_hash_map; // template unordered_map::size_type erase_if(unordered_map& c, Pred pred) @@ -84,7 +84,7 @@ using unordered_multimap = std::unordered_multimap; template, class KeyEqual=std::equal_to, class Allocator=allocator > using unordered_multiset = std::unordered_multiset; template, class KeyEqual=std::equal_to, class Allocator=allocator > -using unordered_set = phmap::flat_hash_set; +using unordered_set = gtl::flat_hash_set; template > diff --git a/include/nbl/video/ILogicalDevice.h b/include/nbl/video/ILogicalDevice.h index def3ee0979..6298afeb27 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -366,6 +366,11 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe // Create an ImageView that can actually be used by shaders (@see ICPUImageView) inline core::smart_refctd_ptr createImageView(IGPUImageView::SCreationParams&& params) { + if (!params.image) + { + NBL_LOG_ERROR("The image is null"); + return nullptr; + } if (!params.image->wasCreatedBy(this)) { NBL_LOG_ERROR("The image was not created by this device"); diff --git a/src/nbl/video/IPhysicalDevice.cpp b/src/nbl/video/IPhysicalDevice.cpp index ded519c1ca..dca2a47289 100644 --- a/src/nbl/video/IPhysicalDevice.cpp +++ b/src/nbl/video/IPhysicalDevice.cpp @@ -417,6 +417,9 @@ asset::E_FORMAT IPhysicalDevice::promoteBufferFormat(const SBufferFormatPromotio asset::E_FORMAT IPhysicalDevice::promoteImageFormat(const SImageFormatPromotionRequest req, const IGPUImage::TILING tiling) const { + if (req.originalFormat==asset::EF_UNKNOWN) + return req.originalFormat; + format_image_cache_t& cache = tiling==IGPUImage::TILING::LINEAR ? this->m_formatPromotionCache.linearTilingImages : this->m_formatPromotionCache.optimalTilingImages; diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 3ce684e0b7..e511c7bf64 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -3721,7 +3721,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult auto pruneStaging = [&]()->void { auto& stagingCache = std::get>(retval.m_stagingCaches); - phmap::erase_if(stagingCache,[&retval](const auto& entry)->bool + gtl::erase_if(stagingCache,[&retval](const auto& entry)->bool { if (entry.first->getReferenceCount()==1) { @@ -5565,7 +5565,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul auto checkDependents = [&]()->void { auto& stagingCache = std::get>(reservations.m_stagingCaches); - phmap::erase_if(stagingCache,[&](auto& item)->bool + gtl::erase_if(stagingCache,[&](auto& item)->bool { auto* pGpuObj = item.first; // rescan all the GPU objects and find out if they depend on anything that failed, if so add to failure set