diff --git a/code/application/game/filter.cc b/code/application/game/filter.cc index eb7061152..d9e8f5dcb 100644 --- a/code/application/game/filter.cc +++ b/code/application/game/filter.cc @@ -125,7 +125,7 @@ Filter FilterBuilder::CreateFilter(FilterCreateInfo info) { n_assert(info.numInclusive > 0); - uint32_t filter = filterAllocator.Alloc(); + Ids::Id32 filter = filterAllocator.Alloc(); ComponentArray inclusiveArray; inclusiveArray.Resize(info.numInclusive); diff --git a/code/foundation/ids/id.h b/code/foundation/ids/id.h index ddffc6802..6f5779071 100644 --- a/code/foundation/ids/id.h +++ b/code/foundation/ids/id.h @@ -43,16 +43,23 @@ }; \ static constexpr x Invalid##x = Ids::InvalidId16; -#define ID_32_24_8_NAMED_TYPE(x, id32_name, id24_name, id8_name) struct x { \ +#define ID_32_24_8_NAMED_TYPE(x, id32_name, id24_name, id8_name, combined_name) struct x { \ Ids::Id32 id32_name : 32;\ - Ids::Id32 id24_name : 24;\ - Ids::Id32 id8_name: 8;\ + union\ + {\ + struct\ + {\ + Ids::Id32 id24_name : 24;\ + Ids::Id32 id8_name: 8;\ + };\ + Ids::Id32 combined_name;\ + };\ constexpr x() : id32_name(Ids::InvalidId32), id24_name(Ids::InvalidId24), id8_name(Ids::InvalidId8) {};\ constexpr x(const Ids::Id32 id32, const Ids::Id24 id24, const Ids::Id8 id8) : id32_name(id32), id24_name(id24), id8_name(id8){} \ - constexpr x(const Ids::Id64 id) : id32_name(Ids::Id::GetHigh(id)), id24_name(Ids::Id::GetBig(Ids::Id::GetLow(id))), id8_name(Ids::Id::GetTiny(Ids::Id::GetLow(id))) {};\ + constexpr x(const Ids::Id64 id) : id32_name(Ids::Id::GetHigh(id)), id24_name(Ids::Index(Ids::Id::GetLow(id))), id8_name(Ids::Generation(Ids::Id::GetLow(id))) {};\ explicit constexpr operator Ids::Id64() const { return Ids::Id::MakeId32_24_8(id32_name, id24_name, id8_name); }\ static constexpr x Invalid() { return Ids::Id::MakeId32_24_8(Ids::InvalidId32, Ids::InvalidId24, Ids::InvalidId8); }\ - constexpr uint32_t HashCode() const { return (uint32_t)Ids::Id::MakeId24_8(id24_name, id8_name); }\ + constexpr uint32_t HashCode() const { return (uint32_t)combined_name; }\ constexpr Ids::Id64 HashCode64() const { return Ids::Id::MakeId32_24_8(id32_name, id24_name, id8_name); }\ const bool operator==(const x& rhs) const { return id32_name == rhs.id32_name && id24_name == rhs.id24_name && id8_name == rhs.id8_name; }\ const bool operator!=(const x& rhs) const { return id32_name != rhs.id32_name || id24_name != rhs.id24_name || id8_name != rhs.id8_name; }\ @@ -61,20 +68,34 @@ template constexpr T As() const { static_assert(sizeof(T) == sizeof(x), "Can only convert between ID types of equal size"); T ret; memcpy((void*)&ret, this, sizeof(T)); return ret; }; \ }; \ static constexpr x Invalid##x = Ids::Id::MakeId32_24_8(Ids::InvalidId32, Ids::InvalidId24, Ids::InvalidId8); -#define ID_32_24_8_TYPE(x) ID_32_24_8_NAMED_TYPE(x, id32, id24, id8) +#define ID_32_24_8_TYPE(x) ID_32_24_8_NAMED_TYPE(x, parent, index, generation, id) -#define ID_24_8_24_8_NAMED_TYPE(x, id24_0_name, id8_0_name, id24_1_name, id8_1_name) struct x { \ - Ids::Id32 id24_0_name : 24;\ - Ids::Id8 id8_0_name : 8;\ - Ids::Id32 id24_1_name : 24;\ - Ids::Id8 id8_1_name : 8;\ - constexpr x() : id24_0_name(Ids::InvalidId24), id8_0_name(Ids::InvalidId8), id24_1_name(Ids::InvalidId24), id8_1_name(Ids::InvalidId8) {};\ +#define ID_24_8_24_8_NAMED_TYPE(x, id24_0_name, id8_0_name, id24_1_name, id8_1_name, combined0_name, combined1_name) struct x { \ + union\ + {\ + struct\ + {\ + Ids::Id32 id24_0_name : 24;\ + Ids::Id8 id8_0_name : 8;\ + };\ + Ids::Id32 combined0_name;\ + };\ + union\ + {\ + struct\ + {\ + Ids::Id32 id24_1_name : 24;\ + Ids::Id8 id8_1_name : 8;\ + };\ + Ids::Id32 combined1_name;\ + };\ + constexpr x() : combined0_name(Ids::InvalidId32), combined1_name(Ids::InvalidId32) {};\ constexpr x(const Ids::Id24 id24_0, const Ids::Id8 id8_0, const Ids::Id24 id24_1, const Ids::Id8 id8_1) : id24_0_name(id24_0), id8_0_name(id8_0), id24_1_name(id24_1), id8_1_name(id8_1) {} \ - constexpr x(const Ids::Id64 id) : id24_0_name(Ids::Id::GetBig(Ids::Id::GetHigh(id))), id8_0_name(Ids::Id::GetTiny(Ids::Id::GetHigh(id))), id24_1_name(Ids::Id::GetBig(Ids::Id::GetLow(id))), id8_1_name(Ids::Id::GetTiny(Ids::Id::GetLow(id))) {};\ + constexpr x(const Ids::Id64 id) : combined0_name(Ids::Id::GetLow(id)), combined1_name(Ids::Id::GetHigh(id)) {};\ explicit constexpr operator Ids::Id64() const { return Ids::Id::MakeId24_8_24_8(id24_0_name, id8_0_name, id24_1_name, id8_1_name); }\ - static constexpr x Invalid() { return Ids::Id::MakeId24_8_24_8(Ids::InvalidId24, Ids::InvalidId8, Ids::InvalidId24, Ids::InvalidId8); }\ - constexpr Ids::Id32 AllocId() const { return Ids::Id::MakeId24_8(id24_1_name, id8_1_name); }\ - constexpr uint32_t HashCode() const { return (uint32_t)Ids::Id::MakeId24_8(id24_0_name, id8_0_name); }\ + static constexpr x Invalid() { return Ids::InvalidId64; }\ + constexpr Ids::Id32 AllocId() const { return combined1_name; }\ + constexpr uint32_t HashCode() const { return (uint32_t)combined0_name; }\ constexpr Ids::Id64 HashCode64() const { return Ids::Id::MakeId24_8_24_8(id24_0_name, id8_0_name, id24_1_name, id8_1_name); }\ const bool operator==(const x& rhs) const { return id24_0_name == rhs.id24_0_name && id8_0_name == rhs.id8_0_name && id24_1_name == rhs.id24_1_name && id8_1_name == rhs.id8_1_name; }\ const bool operator!=(const x& rhs) const { return id24_0_name != rhs.id24_0_name || id8_0_name != rhs.id8_0_name || id24_1_name != rhs.id24_1_name || id8_1_name != rhs.id8_1_name; }\ @@ -83,17 +104,24 @@ template constexpr T As() const { static_assert(sizeof(T) == sizeof(x), "Can only convert between ID types of equal size"); T ret; memcpy((void*)&ret, this, sizeof(T)); return ret; }; \ }; \ static constexpr x Invalid##x = Ids::Id::MakeId24_8_24_8(Ids::InvalidId24, Ids::InvalidId8, Ids::InvalidId24, Ids::InvalidId8); -#define ID_24_8_24_8_TYPE(x) ID_24_8_24_8_NAMED_TYPE(x, id24_0, id8_0, id24_1, id8_1) +#define ID_24_8_24_8_TYPE(x) ID_24_8_24_8_NAMED_TYPE(x, index0, generation0, index1, generation1, id0, id1) -#define ID_24_8_NAMED_TYPE(x, id24_name, id8_name) struct x { \ - Ids::Id32 id24_name : 24; \ - Ids::Id32 id8_name : 8; \ +#define ID_24_8_NAMED_TYPE(x, id24_name, id8_name, combined_name) struct x { \ + union \ + {\ + struct\ + {\ + Ids::Id32 id24_name : 24; \ + Ids::Id32 id8_name : 8; \ + };\ + Ids::Id32 combined_name;\ + }; \ constexpr x() : id24_name(Ids::InvalidId24), id8_name(Ids::InvalidId8) {} \ constexpr x(const Ids::Id24 id0, const Ids::Id8 id1) : id24_name(id0), id8_name(id1) {} \ - constexpr x(const Ids::Id32 id) : id24_name(Ids::Id::GetBig(id)), id8_name(Ids::Id::GetTiny(id)) {};\ - explicit constexpr operator Ids::Id32() const { return Ids::Id::MakeId24_8(id24_name, id8_name); }\ - static constexpr x Invalid() { return Ids::Id::MakeId24_8(Ids::InvalidId24, Ids::InvalidId8); }\ - constexpr uint32_t HashCode() const { return (uint32_t)Ids::Id::MakeId24_8(id24_name, id8_name); }\ + constexpr x(const Ids::Id32 id) : combined_name(id) {};\ + explicit constexpr operator Ids::Id32() const { return combined_name; }\ + static constexpr x Invalid() { return Ids::InvalidId32; }\ + constexpr uint32_t HashCode() const { return (uint32_t)combined_name; }\ const bool operator==(const x& rhs) const { return id24_name == rhs.id24_name && id8_name == rhs.id8_name; }\ const bool operator!=(const x& rhs) const { return id24_name != rhs.id24_name || id8_name != rhs.id8_name; }\ const bool operator<(const x& rhs) const { return HashCode() < rhs.HashCode(); }\ @@ -101,7 +129,7 @@ template constexpr T As() const { static_assert(sizeof(T) == sizeof(x), "Can only convert between ID types of equal size"); T ret; memcpy((void*)&ret, this, sizeof(T)); return ret; }; \ }; \ static constexpr x Invalid##x = Ids::Id::MakeId24_8(Ids::InvalidId24, Ids::InvalidId8); -#define ID_24_8_TYPE(x) ID_24_8_NAMED_TYPE(x, id24, id8) +#define ID_24_8_TYPE(x) ID_24_8_NAMED_TYPE(x, index, generation, id) namespace Ids { diff --git a/code/foundation/ids/idallocator.h b/code/foundation/ids/idallocator.h index df7dffcde..80f481e29 100644 --- a/code/foundation/ids/idallocator.h +++ b/code/foundation/ids/idallocator.h @@ -30,6 +30,7 @@ #include "util/tupleutility.h" #include "util/arrayallocator.h" #include "util/arrayallocatorsafe.h" +#include "idgenerationpool.h" namespace Ids { @@ -42,36 +43,57 @@ class IdAllocator : public Util::ArrayAllocator IdAllocator(uint32_t maxid = 0xFFFFFFFF) : maxId(maxid) {}; /// Allocate an object. - uint32_t Alloc() + Ids::Id32 Alloc() { /// @note This purposefully hides the default allocation method and should definetly not be virtual! - - uint32_t index; - if (this->freeIds.Size() > 0) + Ids::Id32 id; + if (this->pool.Allocate(id)) { - index = this->freeIds.Back(); - this->freeIds.EraseBack(); - } - else - { - index = Util::ArrayAllocator::Alloc(); - n_assert2(this->maxId > index, "max amount of allocations exceeded!\n"); + Util::ArrayAllocator::Alloc(); + n_assert2(this->maxId > Ids::Index(id), "max amount of allocations exceeded!\n"); } - return index; + return id; } /// Deallocate an object. Just places it in freeids array for recycling - void Dealloc(uint32_t index) + void Dealloc(Ids::Id32 id) { // TODO: We could possibly get better performance when defragging if we insert it in reverse order (high to low) - this->freeIds.Append(index); + this->pool.Deallocate(id); + } + + /// Set element + template + inline void Set(const Ids::Id32 id, const Util::tuple_array_t& type) + { + Util::ArrayAllocator::template Set(Ids::Index(id), type); } - /// Returns the list of free ids. - Util::Array& FreeIds() + /// Set elements + inline void Set(const Ids::Id32 id, TYPES... values) { - return this->freeIds; + Util::ArrayAllocator::Set(Ids::Index(id), values...); + } + + /// Get element + template + inline Util::tuple_array_t& Get(const Ids::Id32 id) + { + return Util::ArrayAllocator::template Get(Ids::Index(id)); + } + + /// Const get element + template + inline const Util::tuple_array_t& ConstGet(const Ids::Id32 id) const + { + return Util::ArrayAllocator::template ConstGet(Ids::Index(id)); + } + + /// Get the free ids list from the pool + inline Util::Queue& FreeIds() + { + return this->pool.FreeIds(); } /// return number of allocated ids @@ -82,7 +104,7 @@ class IdAllocator : public Util::ArrayAllocator private: uint32_t maxId = 0xFFFFFFFF; - Util::Array freeIds; + Ids::IdGenerationPool pool; }; #define _DECL_ACQUIRE_RELEASE(ty) \ @@ -98,12 +120,8 @@ class IdAllocator : public Util::ArrayAllocator }; #define _IMPL_ACQUIRE_RELEASE(ty, allocator) \ - bool ty##Acquire(const ty id) { return allocator.Acquire(id.id24); } \ - void ty##Release(const ty id) { allocator.Release(id.id24); } - -#define _IMPL_ACQUIRE_RELEASE_RESOURCE(ty, allocator) \ - bool ty##Acquire(const ty id) { return allocator.Acquire(id.resourceId); } \ - void ty##Release(const ty id) { allocator.Release(id.resourceId); } + bool ty##Acquire(const ty id) { return allocator.Acquire(id.id); } \ + void ty##Release(const ty id) { allocator.Release(id.id); } template class IdAllocatorSafe : public Util::ArrayAllocatorSafe @@ -115,40 +133,86 @@ class IdAllocatorSafe : public Util::ArrayAllocatorSafe }; /// Allocate an object. - uint32_t Alloc() + Ids::Id32 Alloc() { /// @note This purposefully hides the default allocation method and should definitely not be virtual! this->allocationLock.Lock(); - uint32_t index; - if (this->freeIds.Size() > 0) + Ids::Id32 id; + if (this->pool.Allocate(id)) { - index = this->freeIds.Back(); - this->owners[index] = Threading::Thread::GetMyThreadId(); - this->freeIds.EraseBack(); + alloc_for_each_in_tuple(this->objects); + this->owners.Append(Threading::Thread::GetMyThreadId()); + n_assert2(MAX_ALLOCS > Ids::Index(id), "max amount of allocations exceeded!\n"); } else { - alloc_for_each_in_tuple(this->objects); - index = this->size++; - this->owners.Append(Threading::Thread::GetMyThreadId()); - n_assert2(MAX_ALLOCS > index, "max amount of allocations exceeded!\n"); + this->owners[Ids::Index(id)] = Threading::Thread::GetMyThreadId(); } this->allocationLock.Unlock(); - return index; + return id; + } + + /// Set element + template + inline void Set(const Ids::Id32 id, const Util::tuple_array_t& type) + { + Util::ArrayAllocatorSafe::template Set(Ids::Index(id), type); + } + + /// Set elements + inline void Set(const Ids::Id32 id, TYPES... values) + { + Util::ArrayAllocatorSafe::Set(Ids::Index(id), values...); + } + + /// Get element + template + inline Util::tuple_array_t& Get(const Ids::Id32 id) + { + return Util::ArrayAllocatorSafe::template Get(Ids::Index(id)); + } + + /// Const get element + template + inline const Util::tuple_array_t& ConstGet(const Ids::Id32 id) const + { + return Util::ArrayAllocatorSafe::template ConstGet(Ids::Index(id)); + } + + /// Get the free ids list from the pool + inline Util::Queue& FreeIds() + { + return this->pool.FreeIds(); + } + + /// Spinlock to acquire + void TryAcquire(const Ids::Id32 id) + { + Util::ArrayAllocatorSafe::TryAcquire(Ids::Index(id)); + } + /// Acquire element, asserts if false and returns true if this call acquired + bool Acquire(const Ids::Id32 id) + { + return Util::ArrayAllocatorSafe::Acquire(Ids::Index(id)); + } + /// Release an object, the next thread that acquires may use this instance as it fits + void Release(const Ids::Id32 id) + { + Util::ArrayAllocatorSafe::Release(Ids::Index(id)); } /// Deallocate an object. Just places it in freeids array for recycling - void Dealloc(uint32_t index) + void Dealloc(Ids::Id32 id) { // TODO: We could possibly get better performance when defragging if we insert it in reverse order (high to low) this->allocationLock.Lock(); - this->freeIds.Append(index); + this->pool.Deallocate(id); this->allocationLock.Unlock(); } private: - Util::Array freeIds; + Ids::IdGenerationPool pool; }; } // namespace Ids diff --git a/code/foundation/ids/idgenerationpool.h b/code/foundation/ids/idgenerationpool.h index 0fd0a893e..c1a789c27 100644 --- a/code/foundation/ids/idgenerationpool.h +++ b/code/foundation/ids/idgenerationpool.h @@ -53,6 +53,8 @@ class IdGenerationPool void Deallocate(Id32 id); /// check if valid bool IsValid(Id32 id) const; + /// Get free ids + Util::Queue& FreeIds(); private: /// array containing generation value for every index @@ -66,7 +68,7 @@ class IdGenerationPool //------------------------------------------------------------------------------ /** */ -static Id24 +constexpr static Id24 Index(const Id32 id) { return id & ID_MASK; @@ -75,7 +77,7 @@ Index(const Id32 id) //------------------------------------------------------------------------------ /** */ -static generation_t +constexpr static generation_t Generation(const Id32 id) { return (id >> ID_BITS) & GENERATION_MASK; @@ -93,5 +95,14 @@ CreateId(const Id24 index, generation_t generation) return id; } +//------------------------------------------------------------------------------ +/** +*/ +inline Util::Queue& +IdGenerationPool::FreeIds() +{ + return this->freeIds; +} + } // namespace Ids //------------------------------------------------------------------------------ diff --git a/code/foundation/util/arrayallocator.h b/code/foundation/util/arrayallocator.h index 6885eb799..c638a0fe6 100644 --- a/code/foundation/util/arrayallocator.h +++ b/code/foundation/util/arrayallocator.h @@ -67,7 +67,7 @@ class ArrayAllocator /// same as 32 bit get, but const template - const tuple_array_t& Get(const uint32_t index) const; + const tuple_array_t& ConstGet(const uint32_t index) const; /// set single item template @@ -268,7 +268,7 @@ ArrayAllocator::Get(const uint32_t index) template template inline const tuple_array_t& -ArrayAllocator::Get(const uint32_t index) const +ArrayAllocator::ConstGet(const uint32_t index) const { return std::get(this->objects)[index]; } diff --git a/code/physics/physics/streamactorpool.cc b/code/physics/physics/streamactorpool.cc index 4f9ebb2da..185237dd2 100644 --- a/code/physics/physics/streamactorpool.cc +++ b/code/physics/physics/streamactorpool.cc @@ -63,8 +63,8 @@ StreamActorPool::Setup() ActorId StreamActorPool::CreateActorInstance(ActorResourceId id, Math::mat4 const& trans, ActorType type, uint64_t userData, IndexT scene) { - __LockName(&this->allocator, lock, id.resourceId); - ActorInfo& info = this->allocator.Get<0>(id.resourceId); + __LockName(&this->allocator, lock, id.id); + ActorInfo& info = this->allocator.Get<0>(id.id); Math::vec3 outScale; Math::quat outRotation; Math::vec3 outTranslation; Math::decompose(trans, outScale, outRotation, outTranslation); @@ -114,8 +114,8 @@ StreamActorPool::DiscardActorInstance(ActorId id) Actor& actor = ActorContext::GetActor(id); if (actor.res != ActorResourceId::Invalid()) { - __LockName(&this->allocator, lock, actor.res.resourceId); - ActorInfo& info = this->allocator.Get<0>(actor.res.resourceId); + __LockName(&this->allocator, lock, actor.res.id); + ActorInfo& info = this->allocator.Get<0>(actor.res.id); info.instanceCount--; } ActorContext::DiscardActor(id); @@ -516,9 +516,7 @@ StreamActorPool::InitializeResource(const Ids::Id32 entry, const Util::StringAto Ids::Id32 id = allocator.Alloc(); allocator.Set(id, actorInfo); - ActorResourceId ret; - ret.resourceId = id; - ret.resourceType = Physics::ActorIdType; + ActorResourceId ret = id; return ret; } @@ -528,8 +526,8 @@ StreamActorPool::InitializeResource(const Ids::Id32 entry, const Util::StringAto void StreamActorPool::Unload(const Resources::ResourceId id) { - __LockName(&this->allocator, lock, id.resourceId); - ActorInfo& info = this->allocator.Get<0>(id.resourceId); + __LockName(&this->allocator, lock, id.resource); + ActorInfo& info = this->allocator.Get<0>(id.resource); n_assert2(info.instanceCount == 0, "Actor has active Instances"); const Util::StringAtom tag = this->GetTag(id); @@ -538,7 +536,7 @@ StreamActorPool::Unload(const Resources::ResourceId id) i->release(); } info.shapes.Clear(); - allocator.Dealloc(id.resourceId); + allocator.Dealloc(id.resource); } diff --git a/code/render/characters/skeleton.cc b/code/render/characters/skeleton.cc index c0310bce6..b1090e37c 100644 --- a/code/render/characters/skeleton.cc +++ b/code/render/characters/skeleton.cc @@ -20,9 +20,7 @@ CreateSkeleton(const SkeletonCreateInfo& info) skeletonAllocator.Set(id, info.jointIndexMap); skeletonAllocator.Set(id, info.idleSamples); - SkeletonId ret; - ret.id24 = id; - ret.id8 = CoreGraphics::SkeletonIdType; + SkeletonId ret = id; return ret; } @@ -32,7 +30,7 @@ CreateSkeleton(const SkeletonCreateInfo& info) void DestroySkeleton(const SkeletonId id) { - skeletonAllocator.Dealloc(id.id24); + skeletonAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -41,7 +39,7 @@ DestroySkeleton(const SkeletonId id) const SizeT SkeletonGetNumJoints(const SkeletonId id) { - return skeletonAllocator.Get(id.id24).Size(); + return skeletonAllocator.Get(id.id).Size(); } //------------------------------------------------------------------------------ @@ -50,7 +48,7 @@ SkeletonGetNumJoints(const SkeletonId id) const Util::FixedArray& SkeletonGetJoints(const SkeletonId id) { - return skeletonAllocator.Get(id.id24); + return skeletonAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -59,7 +57,7 @@ SkeletonGetJoints(const SkeletonId id) const Util::FixedArray& SkeletonGetBindPose(const SkeletonId id) { - return skeletonAllocator.Get(id.id24); + return skeletonAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -68,7 +66,7 @@ SkeletonGetBindPose(const SkeletonId id) const IndexT SkeletonGetJointIndex(const SkeletonId id, const Util::StringAtom& name) { - return skeletonAllocator.Get(id.id24)[name]; + return skeletonAllocator.Get(id.id)[name]; } //------------------------------------------------------------------------------ @@ -77,7 +75,7 @@ SkeletonGetJointIndex(const SkeletonId id, const Util::StringAtom& name) const Util::FixedArray& SkeletonGetIdleSamples(const SkeletonId id) { - return skeletonAllocator.Get(id.id24); + return skeletonAllocator.Get(id.id); } } // namespace Characters diff --git a/code/render/characters/skeletonloader.cc b/code/render/characters/skeletonloader.cc index 1ec8a5a97..ef156656e 100644 --- a/code/render/characters/skeletonloader.cc +++ b/code/render/characters/skeletonloader.cc @@ -92,9 +92,7 @@ SkeletonLoader::InitializeResource(const Ids::Id32 entry, const Util::StringAtom auto id = skeletonResourceAllocator.Alloc(); skeletonResourceAllocator.Set<0>(id, skeletons); - SkeletonResourceId ret; - ret.resourceId = id; - ret.resourceType = CoreGraphics::SkeletonResourceIdType; + SkeletonResourceId ret = id; return ret; } diff --git a/code/render/characters/skeletonresource.cc b/code/render/characters/skeletonresource.cc index b0bf7a77c..0ab299cb9 100644 --- a/code/render/characters/skeletonresource.cc +++ b/code/render/characters/skeletonresource.cc @@ -16,7 +16,7 @@ SkeletonResourceAllocator skeletonResourceAllocator; const SkeletonId SkeletonResourceGetSkeleton(const SkeletonResourceId id, IndexT index) { - return skeletonResourceAllocator.Get<0>(id.resourceId)[index]; + return skeletonResourceAllocator.Get<0>(id.id)[index]; } //------------------------------------------------------------------------------ @@ -26,12 +26,12 @@ SkeletonResourceGetSkeleton(const SkeletonResourceId id, IndexT index) void DestroySkeletonResource(const SkeletonResourceId id) { - auto skeletons = skeletonResourceAllocator.Get<0>(id.resourceId); + auto skeletons = skeletonResourceAllocator.Get<0>(id.id); for (IndexT i = 0; i < skeletons.Size(); i++) { DestroySkeleton(skeletons[i]); } - skeletonResourceAllocator.Dealloc(id.resourceId); + skeletonResourceAllocator.Dealloc(id.id); } } // namespace Characters diff --git a/code/render/coreanimation/animation.cc b/code/render/coreanimation/animation.cc index 4ac73f6e7..dfb0fe17a 100644 --- a/code/render/coreanimation/animation.cc +++ b/code/render/coreanimation/animation.cc @@ -23,9 +23,7 @@ CreateAnimation(const AnimationCreateInfo& info) animAllocator.Set(id, info.indices); animAllocator.Set(id, info.keyBuffer); - AnimationId ret; - ret.id24 = id; - ret.id8 = CoreGraphics::AnimResourceIdType; + AnimationId ret = id; return ret; } @@ -34,13 +32,13 @@ CreateAnimation(const AnimationCreateInfo& info) */ void DestroyAnimation(const AnimationId id) { - animAllocator.Get(id.id24).Clear(); - animAllocator.Get(id.id24).Clear(); - animAllocator.Get(id.id24).Clear(); - animAllocator.Get(id.id24).Clear(); - animAllocator.Get(id.id24)->Discard(); - animAllocator.Set(id.id24, nullptr); - animAllocator.Dealloc(id.id24); + animAllocator.Get(id.id).Clear(); + animAllocator.Get(id.id).Clear(); + animAllocator.Get(id.id).Clear(); + animAllocator.Get(id.id).Clear(); + animAllocator.Get(id.id)->Discard(); + animAllocator.Set(id.id, nullptr); + animAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -49,7 +47,7 @@ void DestroyAnimation(const AnimationId id) const Util::FixedArray& AnimGetClips(const AnimationId& id) { - return animAllocator.Get(id.id24); + return animAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -58,7 +56,7 @@ AnimGetClips(const AnimationId& id) const AnimClip& AnimGetClip(const AnimationId& id, const IndexT index) { - return animAllocator.Get(id.id24)[index]; + return animAllocator.Get(id.id)[index]; } //------------------------------------------------------------------------------ @@ -67,7 +65,7 @@ AnimGetClip(const AnimationId& id, const IndexT index) const Ptr& AnimGetBuffer(const AnimationId& id) { - return animAllocator.Get(id.id24); + return animAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -76,7 +74,7 @@ AnimGetBuffer(const AnimationId& id) const Util::FixedArray& AnimGetCurves(const AnimationId& id) { - return animAllocator.Get(id.id24); + return animAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -85,7 +83,7 @@ AnimGetCurves(const AnimationId& id) const IndexT AnimGetIndex(const AnimationId& id, const Util::StringAtom& name) { - return animAllocator.Get(id.id24)[name]; + return animAllocator.Get(id.id)[name]; } } // namespace CoreAnimation diff --git a/code/render/coreanimation/animationloader.cc b/code/render/coreanimation/animationloader.cc index bb25ff4bc..29da214b6 100644 --- a/code/render/coreanimation/animationloader.cc +++ b/code/render/coreanimation/animationloader.cc @@ -134,9 +134,7 @@ AnimationLoader::InitializeResource(const Ids::Id32 entry, const Util::StringAto auto id = animationResourceAllocator.Alloc(); animationResourceAllocator.Set<0>(id, animations); - AnimationResourceId ret; - ret.resourceId = id; - ret.resourceType = CoreGraphics::AnimResourceIdType; + AnimationResourceId ret = id; return ret; } diff --git a/code/render/coreanimation/animationresource.cc b/code/render/coreanimation/animationresource.cc index e297e5727..848e8b2fc 100644 --- a/code/render/coreanimation/animationresource.cc +++ b/code/render/coreanimation/animationresource.cc @@ -14,7 +14,7 @@ AnimationResourceAllocator animationResourceAllocator; const AnimationId AnimationResourceGetAnimation(const AnimationResourceId id, IndexT index) { - return animationResourceAllocator.Get<0>(id.resourceId)[index]; + return animationResourceAllocator.Get<0>(id.id)[index]; } //------------------------------------------------------------------------------ @@ -23,12 +23,12 @@ AnimationResourceGetAnimation(const AnimationResourceId id, IndexT index) void DestroyAnimationResource(const AnimationResourceId id) { - auto animations = animationResourceAllocator.Get<0>(id.resourceId); + auto animations = animationResourceAllocator.Get<0>(id.id); for (IndexT i = 0; i < animations.Size(); i++) { DestroyAnimation(animations[i]); } - animationResourceAllocator.Dealloc(id.resourceId); + animationResourceAllocator.Dealloc(id.id); } } // namespace CoreAnimation diff --git a/code/render/coregraphics/base/shaderserverbase.h b/code/render/coregraphics/base/shaderserverbase.h index e9ac3cfb1..3199ffd62 100644 --- a/code/render/coregraphics/base/shaderserverbase.h +++ b/code/render/coregraphics/base/shaderserverbase.h @@ -148,9 +148,7 @@ ShaderServerBase::GetShader(Resources::ResourceName resId) const { n_assert_fmt(this->shaders.Contains(resId), "%s not found!\n This might be a problem with your export. Check the exports folder!\n", resId.Value()); Resources::ResourceId shader = this->shaders[resId]; - CoreGraphics::ShaderId ret; - ret.resourceId = shader.resourceId; - ret.resourceType = shader.resourceType; + CoreGraphics::ShaderId ret = shader.resource; return ret; } diff --git a/code/render/coregraphics/config.h b/code/render/coregraphics/config.h index 29a9e7ff3..62b73566b 100644 --- a/code/render/coregraphics/config.h +++ b/code/render/coregraphics/config.h @@ -34,45 +34,6 @@ union InputAssemblyKey bool operator<(const InputAssemblyKey& rhs) const { return this->key < rhs.key; } }; -enum IdType -{ - BufferIdType, - TextureIdType, - TextureViewIdType, - VertexLayoutIdType, - ShaderIdType, - ShaderProgramIdType, - ShaderStateIdType, - ShaderInstanceIdType, - ShaderConstantIdType, - CommandBufferIdType, - CommandBufferPoolIdType, - MeshIdType, - MeshResourceIdType, - ModelIdType, - EventIdType, - BarrierIdType, - SemaphoreIdType, - FenceIdType, - WindowIdType, - SkeletonIdType, - SkeletonResourceIdType, - PassIdType, - AnimResourceIdType, - AnimIdType, - ResourceTableIdType, - ResourceTableLayoutIdType, - ResourcePipelineIdType, - SamplerIdType, - MaterialIdType, - SubmissionContextIdType, - PipelineIdType, - ImageIdType, - BlasIdType, - BlasInstanceIdType, - TlasIdType -}; - enum QueueType { GraphicsQueueType, diff --git a/code/render/coregraphics/debug/meshpagehandler.cc b/code/render/coregraphics/debug/meshpagehandler.cc index e7686ee05..a53afb881 100644 --- a/code/render/coregraphics/debug/meshpagehandler.cc +++ b/code/render/coregraphics/debug/meshpagehandler.cc @@ -130,12 +130,6 @@ MeshPageHandler::HandleMeshInfoRequest(const Util::String& resId, const Ptr htmlWriter = HtmlPageWriter::Create(); htmlWriter->SetStream(responseContentStream); htmlWriter->SetTitle("Nebula Mesh Info"); @@ -297,13 +291,6 @@ MeshPageHandler::HandleVertexDumpRequest(const Util::String& resId, IndexT minVe { return HttpStatus::NotFound; } - if (id.resourceType != MeshIdType) - { - // resource exists but is not a mesh - return HttpStatus::NotFound; - } - - Ptr htmlWriter = HtmlPageWriter::Create(); htmlWriter->SetStream(responseContentStream); diff --git a/code/render/coregraphics/debug/shaderpagehandler.cc b/code/render/coregraphics/debug/shaderpagehandler.cc index 757ca3c67..d42838e07 100644 --- a/code/render/coregraphics/debug/shaderpagehandler.cc +++ b/code/render/coregraphics/debug/shaderpagehandler.cc @@ -116,12 +116,6 @@ ShaderPageHandler::HandleShaderInfoRequest(const Util::String& resId, const Ptr< return HttpStatus::NotFound; } - if (id.resourceType != ShaderIdType) - { - // id is not a shader type! - return HttpStatus::NotFound; - } - Ptr htmlWriter = HtmlPageWriter::Create(); htmlWriter->SetStream(responseContentStream); htmlWriter->SetTitle("Nebula Shader Info"); diff --git a/code/render/coregraphics/debug/texturepagehandler.cc b/code/render/coregraphics/debug/texturepagehandler.cc index d8cbfc1cd..af6f4f3fe 100644 --- a/code/render/coregraphics/debug/texturepagehandler.cc +++ b/code/render/coregraphics/debug/texturepagehandler.cc @@ -193,12 +193,6 @@ TexturePageHandler::HandleImageRequest(const Dictionary& query, c return HttpStatus::NotFound; } - if (id.resourceType != TextureIdType) - { - // resource exists but is not a texture - return HttpStatus::NotFound; - } - // attach a StreamTextureSaver to the texture // NOTE: the StreamSaver is expected to set the media type on the stream! HttpStatus::Code httpStatus = HttpStatus::InternalServerError; @@ -226,12 +220,6 @@ TexturePageHandler::HandleTextureInfoRequest(const Util::String& resId, const Pt return HttpStatus::NotFound; } - if (id.resourceType != TextureIdType) - { - // resource exists but is not a texture - return HttpStatus::NotFound; - } - Ptr htmlWriter = HtmlPageWriter::Create(); htmlWriter->SetStream(responseContentStream); htmlWriter->SetTitle("Nebula Texture Info"); diff --git a/code/render/coregraphics/glfw/glfwwindow.cc b/code/render/coregraphics/glfw/glfwwindow.cc index c20229d6f..a658d17b0 100644 --- a/code/render/coregraphics/glfw/glfwwindow.cc +++ b/code/render/coregraphics/glfw/glfwwindow.cc @@ -220,8 +220,8 @@ MouseButtonFunc(const CoreGraphics::WindowId& id, int button, int action, int mo return; } - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); - const CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); + const CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id); double x, y; glfwGetCursorPos(wnd, &x, &y); @@ -236,7 +236,7 @@ MouseButtonFunc(const CoreGraphics::WindowId& id, int button, int action, int mo void MouseFunc(const CoreGraphics::WindowId& id, double xpos, double ypos) { - const CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id24); + const CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id); vec2 absMousePos((float)xpos, (float)ypos); vec2 pos; pos.set((float)xpos / float(mode.GetWidth()), (float)ypos / float(mode.GetHeight())); @@ -286,7 +286,7 @@ FocusFunc(const CoreGraphics::WindowId& id, int focus) void EnableCallbacks(const CoreGraphics::WindowId & id) { - GLFWwindow* window = glfwWindowAllocator.Get(id.id24); + GLFWwindow* window = glfwWindowAllocator.Get(id.id); glfwSetKeyCallback(window, staticKeyFunc); glfwSetMouseButtonCallback(window, staticMouseButtonFunc); glfwSetCursorPosCallback(window, staticMouseFunc); @@ -304,7 +304,7 @@ EnableCallbacks(const CoreGraphics::WindowId & id) void DisableCallbacks(const CoreGraphics::WindowId & id) { - GLFWwindow* window = glfwWindowAllocator.Get(id.id24); + GLFWwindow* window = glfwWindowAllocator.Get(id.id); glfwSetKeyCallback(window, nullptr); glfwSetMouseButtonCallback(window, nullptr); glfwSetCursorPosCallback(window, nullptr); @@ -332,9 +332,7 @@ InternalSetupFunction(const WindowCreateInfo& info, const Util::Blob& windowData Ids::Id32 windowId = glfwWindowAllocator.Alloc(); - WindowId id; - id.id24 = windowId; - id.id8 = WindowIdType; + WindowId id = windowId; glfwWindowAllocator.Set(windowId, info); glfwWindowAllocator.Set(windowId, { 0, 0, true, info.vsync }); @@ -344,9 +342,9 @@ InternalSetupFunction(const WindowCreateInfo& info, const Util::Blob& windowData // get original window, if this is the first window, then the parent window will simply be nullptr GLFWwindow* wnd = nullptr; const CoreGraphics::WindowId origWindow = CoreGraphics::DisplayDevice::Instance()->GetMainWindow(); - if (origWindow != Ids::InvalidId32) wnd = glfwWindowAllocator.Get(origWindow.id24); + if (origWindow.index != Ids::InvalidId32) wnd = glfwWindowAllocator.Get(origWindow.id); - CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id24); + CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id); mode = info.mode; #if __VULKAN__ @@ -405,7 +403,7 @@ InternalSetupFunction(const WindowCreateInfo& info, const Util::Blob& windowData glfwSwapInterval(info.vsync ? 1 : 0); #if __VULKAN__ - Vulkan::VkSwapchainInfo& swapInfo = glfwWindowAllocator.Get(id.id24); + Vulkan::VkSwapchainInfo& swapInfo = glfwWindowAllocator.Get(id.id); VkResult res = glfwCreateWindowSurface(Vulkan::GetInstance(), wnd, nullptr, &swapInfo.surface); n_assert(res == VK_SUCCESS); @@ -434,7 +432,7 @@ InternalSetupFunction(const WindowCreateInfo& info, const Util::Blob& windowData void ResizeFunc(const CoreGraphics::WindowId& id, int width, int height) { - ResizeInfo& info = glfwWindowAllocator.Get(id.id24); + ResizeInfo& info = glfwWindowAllocator.Get(id.id); // only resize if size is not 0 if (width != 0 && height != 0) @@ -480,7 +478,7 @@ EmbedWindow(const Util::Blob& windowData) void DestroyWindow(const WindowId id) { - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); GLFW::DisableCallbacks(id); delete (WindowId*)glfwGetWindowUserPointer(wnd); glfwDestroyWindow(wnd); @@ -489,7 +487,7 @@ DestroyWindow(const WindowId id) // discard swapchain Vulkan::DiscardVulkanSwapchain(id); // wait for queues to empty - VkWindowSwapInfo& wndInfo = glfwWindowAllocator.Get(id.id24); + VkWindowSwapInfo& wndInfo = glfwWindowAllocator.Get(id.id); CoreGraphics::WaitAndClearPendingCommands(); vkDeviceWaitIdle(wndInfo.dev); #endif @@ -497,7 +495,7 @@ DestroyWindow(const WindowId id) // close event GLFW::GLFWDisplayDevice::Instance()->NotifyEventHandlers(DisplayEvent(DisplayEvent::WindowClose, id)); - glfwWindowAllocator.Dealloc(id.id24); + glfwWindowAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -506,7 +504,7 @@ DestroyWindow(const WindowId id) void WindowResize(const WindowId id, SizeT newWidth, SizeT newHeight) { - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); glfwSetWindowSize(wnd, newWidth, newHeight); } @@ -516,7 +514,7 @@ WindowResize(const WindowId id, SizeT newWidth, SizeT newHeight) void WindowSetTitle(const WindowId id, const Util::String & title) { - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); glfwSetWindowTitle(wnd, title.AsCharPtr()); } @@ -526,8 +524,8 @@ WindowSetTitle(const WindowId id, const Util::String & title) void WindowApplyFullscreen(const WindowId id, Adapter::Code monitor, bool b) { - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); - const CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); + const CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id); if (wnd && b) { @@ -558,7 +556,7 @@ WindowApplyFullscreen(const WindowId id, Adapter::Code monitor, bool b) void WindowSetCursorVisible(const WindowId id, bool b) { - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); glfwSetInputMode(wnd, GLFW_CURSOR, b ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN); } @@ -569,7 +567,7 @@ WindowSetCursorVisible(const WindowId id, bool b) void WindowSetCursorLocked(const WindowId id, bool b) { - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); glfwSetInputMode(wnd, GLFW_CURSOR, b ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN); } @@ -588,23 +586,23 @@ WindowMakeCurrent(const WindowId id) void WindowPresent(const WindowId id, const IndexT frameIndex) { - IndexT& frame = glfwWindowAllocator.Get(id.id24); + IndexT& frame = glfwWindowAllocator.Get(id.id); if (frame != frameIndex) { #if __VULKAN__ Vulkan::Present(id); #elif - GLFWwindow* wnd = glfwWindowAllocator.Get(id.id24); + GLFWwindow* wnd = glfwWindowAllocator.Get(id.id); glfwSwapBuffers(wnd); #endif frame = frameIndex; - ResizeInfo& info = glfwWindowAllocator.Get(id.id24); + ResizeInfo& info = glfwWindowAllocator.Get(id.id); if (!info.done) { info.done = true; - CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id24); + CoreGraphics::DisplayMode& mode = glfwWindowAllocator.Get(id.id); mode.SetWidth(info.newWidth); mode.SetHeight(info.newHeight); mode.SetAspectRatio(info.newWidth / float(info.newHeight)); @@ -637,7 +635,7 @@ WindowPollEvents() const CoreGraphics::DisplayMode WindowGetDisplayMode(const WindowId id) { - return glfwWindowAllocator.Get(id.id24); + return glfwWindowAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -646,7 +644,7 @@ WindowGetDisplayMode(const WindowId id) const CoreGraphics::AntiAliasQuality::Code WindowGetAAQuality(const WindowId id) { - return glfwWindowAllocator.Get(id.id24).aa; + return glfwWindowAllocator.Get(id.id).aa; } //------------------------------------------------------------------------------ @@ -655,7 +653,7 @@ WindowGetAAQuality(const WindowId id) const bool WindowIsFullscreen(const WindowId id) { - return glfwWindowAllocator.Get(id.id24).fullscreen; + return glfwWindowAllocator.Get(id.id).fullscreen; } //------------------------------------------------------------------------------ @@ -664,7 +662,7 @@ WindowIsFullscreen(const WindowId id) const bool WindowIsDecorated(const WindowId id) { - return glfwWindowAllocator.Get(id.id24).decorated; + return glfwWindowAllocator.Get(id.id).decorated; } //------------------------------------------------------------------------------ @@ -673,7 +671,7 @@ WindowIsDecorated(const WindowId id) const bool WindowIsResizable(const WindowId id) { - return glfwWindowAllocator.Get(id.id24).resizable; + return glfwWindowAllocator.Get(id.id).resizable; } //------------------------------------------------------------------------------ @@ -682,7 +680,7 @@ WindowIsResizable(const WindowId id) const Util::StringAtom& WindowGetTitle(const WindowId id) { - return glfwWindowAllocator.Get(id.id24).title; + return glfwWindowAllocator.Get(id.id).title; } //------------------------------------------------------------------------------ @@ -691,7 +689,7 @@ WindowGetTitle(const WindowId id) const Util::StringAtom& WindowGetIcon(const WindowId id) { - return glfwWindowAllocator.Get(id.id24).icon; + return glfwWindowAllocator.Get(id.id).icon; } //------------------------------------------------------------------------------ @@ -700,7 +698,7 @@ WindowGetIcon(const WindowId id) const CoreGraphics::TextureId& WindowGetTexture(const WindowId id) { - return glfwWindowAllocator.Get(id.id24); + return glfwWindowAllocator.Get(id.id); } } // namespace CoreGraphics @@ -715,7 +713,7 @@ namespace Vulkan const VkSurfaceKHR& GetSurface(const CoreGraphics::WindowId& id) { - const VkSwapchainInfo& swapInfo = glfwWindowAllocator.Get(id.id24); + const VkSwapchainInfo& swapInfo = glfwWindowAllocator.Get(id.id); return swapInfo.surface; } @@ -725,9 +723,9 @@ GetSurface(const CoreGraphics::WindowId& id) void SetupVulkanSwapchain(const CoreGraphics::WindowId& id, const CoreGraphics::DisplayMode& mode, bool vsync, const Util::StringAtom& title) { - VkWindowSwapInfo& windowInfo = glfwWindowAllocator.Get(id.id24); - VkSwapchainInfo& swapInfo = glfwWindowAllocator.Get(id.id24); - VkBackbufferInfo& backbufferInfo = glfwWindowAllocator.Get(id.id24); + VkWindowSwapInfo& windowInfo = glfwWindowAllocator.Get(id.id); + VkSwapchainInfo& swapInfo = glfwWindowAllocator.Get(id.id); + VkBackbufferInfo& backbufferInfo = glfwWindowAllocator.Get(id.id); VkPhysicalDevice physicalDev = Vulkan::GetCurrentPhysicalDevice(); VkDevice dev = Vulkan::GetCurrentDevice(); @@ -902,10 +900,10 @@ SetupVulkanSwapchain(const CoreGraphics::WindowId& id, const CoreGraphics::Displ rtinfo.height = (float)swapchainExtent.height; rtinfo.windowTexture = true; rtinfo.defaultLayout = CoreGraphics::ImageLayout::TransferSource; - glfwWindowAllocator.Get(id.id24) = CreateTexture(rtinfo); + glfwWindowAllocator.Get(id.id) = CreateTexture(rtinfo); // add to graphics device for swapbuffers - CoreGraphics::AddBackBufferTexture(glfwWindowAllocator.Get(id.id24)); + CoreGraphics::AddBackBufferTexture(glfwWindowAllocator.Get(id.id)); windowInfo.dev = dev; } @@ -916,8 +914,8 @@ SetupVulkanSwapchain(const CoreGraphics::WindowId& id, const CoreGraphics::Displ void DiscardVulkanSwapchain(const CoreGraphics::WindowId& id) { - VkWindowSwapInfo& wndInfo = glfwWindowAllocator.Get(id.id24); - VkBackbufferInfo& backbufferInfo = glfwWindowAllocator.Get(id.id24); + VkWindowSwapInfo& wndInfo = glfwWindowAllocator.Get(id.id); + VkBackbufferInfo& backbufferInfo = glfwWindowAllocator.Get(id.id); uint32_t i; for (i = 0; i < backbufferInfo.numBackbuffers; i++) @@ -928,10 +926,10 @@ DiscardVulkanSwapchain(const CoreGraphics::WindowId& id) // destroy swapchain last vkDestroySwapchainKHR(wndInfo.dev, wndInfo.swapchain, nullptr); - CoreGraphics::RemoveBackBufferTexture(glfwWindowAllocator.Get(id.id24)); + CoreGraphics::RemoveBackBufferTexture(glfwWindowAllocator.Get(id.id)); // destroy __WINDOW__ render texture - DestroyTexture(glfwWindowAllocator.Get(id.id24)); + DestroyTexture(glfwWindowAllocator.Get(id.id)); } //------------------------------------------------------------------------------ @@ -955,7 +953,7 @@ RecreateVulkanSwapchain(const CoreGraphics::WindowId& id, const CoreGraphics::Di void Present(const CoreGraphics::WindowId& id) { - const VkWindowSwapInfo& wndInfo = glfwWindowAllocator.Get(id.id24); + const VkWindowSwapInfo& wndInfo = glfwWindowAllocator.Get(id.id); VkSemaphore semaphores[] = { diff --git a/code/render/coregraphics/image.cc b/code/render/coregraphics/image.cc index 8717e27e7..871dc0272 100644 --- a/code/render/coregraphics/image.cc +++ b/code/render/coregraphics/image.cc @@ -423,9 +423,7 @@ ImageId CreateImage(const ImageCreateInfoFile& info) stream->Unmap(); stream->Close(); - ImageId ret; - ret.id24 = id; - ret.id8 = ImageIdType; + ImageId ret = id; return ret; } #endif @@ -445,7 +443,7 @@ ImageId CreateImage(const ImageCreateInfoData& info) */ void DestroyImage(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); Memory::Free(Memory::ResourceHeap, loadInfo.buffer); } @@ -454,7 +452,7 @@ void DestroyImage(const ImageId id) */ ImageDimensions ImageGetDimensions(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return ImageDimensions{ loadInfo.width, loadInfo.height, loadInfo.depth }; } @@ -464,7 +462,7 @@ ImageDimensions ImageGetDimensions(const ImageId id) const byte* ImageGetBuffer(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return loadInfo.buffer; } @@ -474,7 +472,7 @@ ImageGetBuffer(const ImageId id) const byte* ImageGetRedPtr(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return &loadInfo.buffer[loadInfo.redOffset]; } @@ -484,7 +482,7 @@ ImageGetRedPtr(const ImageId id) const byte* ImageGetGreenPtr(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return &loadInfo.buffer[loadInfo.greenOffset]; } @@ -494,7 +492,7 @@ ImageGetGreenPtr(const ImageId id) const byte* ImageGetBluePtr(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return &loadInfo.buffer[loadInfo.blueOffset]; } @@ -504,7 +502,7 @@ ImageGetBluePtr(const ImageId id) const byte* ImageGetAlphaPtr(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return &loadInfo.buffer[loadInfo.alphaOffset]; } @@ -514,7 +512,7 @@ ImageGetAlphaPtr(const ImageId id) const SizeT ImageGetPixelStride(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return CoreGraphics::PixelFormat::ToSize(loadInfo.format); } @@ -524,7 +522,7 @@ ImageGetPixelStride(const ImageId id) ImageChannelPrimitive ImageGetChannelPrimitive(const ImageId id) { - ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id24); + ImageLoadInfo& loadInfo = imageAllocator.Get<0>(id.id); return loadInfo.primitive; } diff --git a/code/render/coregraphics/mesh.cc b/code/render/coregraphics/mesh.cc index ce72229dc..c5cad3c9e 100644 --- a/code/render/coregraphics/mesh.cc +++ b/code/render/coregraphics/mesh.cc @@ -40,9 +40,7 @@ CreateMesh(const MeshCreateInfo& info) meshAllocator.Set(id, internals); meshAllocator.Release(id); - MeshId ret; - ret.id24 = id; - ret.id8 = MeshIdType; + MeshId ret = id; return ret; } @@ -52,12 +50,12 @@ CreateMesh(const MeshCreateInfo& info) void DestroyMesh(const MeshId id) { - const CoreGraphics::VertexAlloc& vertices = meshAllocator.ConstGet(id.id24).vertexAllocation; - const CoreGraphics::VertexAlloc& indices = meshAllocator.ConstGet(id.id24).indexAllocation; + const CoreGraphics::VertexAlloc& vertices = meshAllocator.ConstGet(id.id).vertexAllocation; + const CoreGraphics::VertexAlloc& indices = meshAllocator.ConstGet(id.id).indexAllocation; CoreGraphics::DeallocateVertices(vertices); CoreGraphics::DeallocateIndices(indices); - meshAllocator.Dealloc(id.id24); + meshAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -66,7 +64,7 @@ DestroyMesh(const MeshId id) const Util::Array& MeshGetPrimitiveGroups(const MeshId id) { - return meshAllocator.ConstGet(id.id24).primitiveGroups; + return meshAllocator.ConstGet(id.id).primitiveGroups; } //------------------------------------------------------------------------------ @@ -75,7 +73,7 @@ MeshGetPrimitiveGroups(const MeshId id) const CoreGraphics::PrimitiveGroup MeshGetPrimitiveGroup(const MeshId id, const IndexT group) { - return meshAllocator.ConstGet(id.id24).primitiveGroups[group]; + return meshAllocator.ConstGet(id.id).primitiveGroups[group]; } //------------------------------------------------------------------------------ @@ -84,7 +82,7 @@ MeshGetPrimitiveGroup(const MeshId id, const IndexT group) const BufferId MeshGetVertexBuffer(const MeshId id, const IndexT stream) { - return meshAllocator.ConstGet(id.id24).streams[stream].vertexBuffer; + return meshAllocator.ConstGet(id.id).streams[stream].vertexBuffer; } //------------------------------------------------------------------------------ @@ -93,7 +91,7 @@ MeshGetVertexBuffer(const MeshId id, const IndexT stream) const void MeshSetVertexBuffer(const MeshId id, const BufferId buffer, const IndexT stream) { - meshAllocator.ConstGet(id.id24).streams[stream].vertexBuffer = buffer; + meshAllocator.ConstGet(id.id).streams[stream].vertexBuffer = buffer; } //------------------------------------------------------------------------------ @@ -102,7 +100,7 @@ MeshSetVertexBuffer(const MeshId id, const BufferId buffer, const IndexT stream) const uint MeshGetVertexOffset(const MeshId id, const IndexT stream) { - return meshAllocator.ConstGet(id.id24).streams[stream].offset; + return meshAllocator.ConstGet(id.id).streams[stream].offset; } //------------------------------------------------------------------------------ @@ -111,7 +109,7 @@ MeshGetVertexOffset(const MeshId id, const IndexT stream) const BufferId MeshGetIndexBuffer(const MeshId id) { - return meshAllocator.ConstGet(id.id24).indexBuffer; + return meshAllocator.ConstGet(id.id).indexBuffer; } //------------------------------------------------------------------------------ @@ -120,7 +118,7 @@ MeshGetIndexBuffer(const MeshId id) const uint MeshGetIndexOffset(const MeshId id) { - return meshAllocator.ConstGet(id.id24).indexBufferOffset; + return meshAllocator.ConstGet(id.id).indexBufferOffset; } //------------------------------------------------------------------------------ @@ -129,7 +127,7 @@ MeshGetIndexOffset(const MeshId id) const IndexType::Code MeshGetIndexType(const MeshId id) { - return meshAllocator.ConstGet(id.id24).indexType; + return meshAllocator.ConstGet(id.id).indexType; } //------------------------------------------------------------------------------ @@ -138,7 +136,7 @@ MeshGetIndexType(const MeshId id) const CoreGraphics::PrimitiveTopology::Code MeshGetTopology(const MeshId id) { - return meshAllocator.ConstGet(id.id24).primitiveTopology; + return meshAllocator.ConstGet(id.id).primitiveTopology; } //------------------------------------------------------------------------------ @@ -147,7 +145,7 @@ MeshGetTopology(const MeshId id) const CoreGraphics::VertexLayoutId MeshGetVertexLayout(const MeshId id) { - return meshAllocator.ConstGet(id.id24).vertexLayout; + return meshAllocator.ConstGet(id.id).vertexLayout; } //------------------------------------------------------------------------------ @@ -156,7 +154,7 @@ MeshGetVertexLayout(const MeshId id) const void MeshBind(const MeshId id, const CoreGraphics::CmdBufferId cmd) { - const auto& internals = meshAllocator.ConstGet(id.id24); + const auto& internals = meshAllocator.ConstGet(id.id); CoreGraphics::CmdSetPrimitiveTopology(cmd, internals.primitiveTopology); CoreGraphics::CmdSetVertexLayout(cmd, internals.vertexLayout); diff --git a/code/render/coregraphics/meshloader.cc b/code/render/coregraphics/meshloader.cc index 5b6d06756..1366c7b9f 100644 --- a/code/render/coregraphics/meshloader.cc +++ b/code/render/coregraphics/meshloader.cc @@ -94,7 +94,7 @@ MeshLoader::InitializeResource(Ids::Id32 entry, const Util::StringAtom& tag, con n_assert(stream.isvalid()); String resIdExt = this->names[entry].AsString().GetFileExtension(); - MeshResourceId ret = { meshResourceAllocator.Alloc(), MeshIdType }; + MeshResourceId ret = meshResourceAllocator.Alloc(); if (resIdExt == "nvx") { @@ -304,7 +304,7 @@ MeshLoader::SetupMeshFromNvx(const Ptr& stream, const Ids::Id32 entr } // Update mesh allocator - meshResourceAllocator.Set<0>(meshResource.resourceId, meshes); + meshResourceAllocator.Set<0>(meshResource.id, meshes); } } // namespace CoreGraphics diff --git a/code/render/coregraphics/meshresource.cc b/code/render/coregraphics/meshresource.cc index 553db3067..8fcd62187 100644 --- a/code/render/coregraphics/meshresource.cc +++ b/code/render/coregraphics/meshresource.cc @@ -14,7 +14,7 @@ MeshResourceAllocator meshResourceAllocator; const MeshId MeshResourceGetMesh(const MeshResourceId id, const IndexT index) { - return meshResourceAllocator.Get<0>(id.resourceId)[index]; + return meshResourceAllocator.Get<0>(id.id)[index]; } //------------------------------------------------------------------------------ @@ -23,7 +23,7 @@ MeshResourceGetMesh(const MeshResourceId id, const IndexT index) const SizeT MeshResourceGetNumMeshes(const MeshResourceId id) { - return meshResourceAllocator.Get<0>(id.resourceId).Size(); + return meshResourceAllocator.Get<0>(id.id).Size(); } //------------------------------------------------------------------------------ @@ -31,12 +31,12 @@ MeshResourceGetNumMeshes(const MeshResourceId id) */ void DestroyMeshResource(const MeshResourceId id) { - auto meshes = meshResourceAllocator.Get<0>(id.resourceId); + auto meshes = meshResourceAllocator.Get<0>(id.id); for (IndexT i = 0; i < meshes.Size(); i++) { DestroyMesh(meshes[i]); } - meshResourceAllocator.Dealloc(id.resourceId); + meshResourceAllocator.Dealloc(id.id); } } // namespace CoreGraphics diff --git a/code/render/coregraphics/shader.h b/code/render/coregraphics/shader.h index cc460f786..92fe067ed 100644 --- a/code/render/coregraphics/shader.h +++ b/code/render/coregraphics/shader.h @@ -49,7 +49,7 @@ struct ResourcePipelineId; struct ResourceTableSet; RESOURCE_ID_TYPE(ShaderId); -ID_24_8_24_8_NAMED_TYPE(ShaderProgramId, programId, programType, shaderId, shaderType); // 32 bits shader, 24 bits program, 8 bits type +ID_24_8_24_8_NAMED_TYPE(ShaderProgramId, programId, programGeneration, shaderId, shaderGeneration, program, shader); // 32 bits shader, 24 bits program, 8 bits type ID_32_TYPE(DerivativeStateId); // 32 bits derivative state (already created from an ordinary state) diff --git a/code/render/coregraphics/shaderloader.cc b/code/render/coregraphics/shaderloader.cc index da173bc2f..396c45fe3 100644 --- a/code/render/coregraphics/shaderloader.cc +++ b/code/render/coregraphics/shaderloader.cc @@ -77,9 +77,7 @@ ShaderLoader::ReloadFromStream(const Resources::ResourceId id, const Ptrstreams[id.loaderInstanceId].stream->MemoryUnmap(); Memory::Free(Memory::ScratchHeap, this->streams[id.loaderInstanceId].data); - TextureId tex; - tex.resourceId = id.resourceId; - tex.resourceType = id.resourceType; + TextureId tex = id.resource; CoreGraphics::DestroyTexture(tex); } diff --git a/code/render/coregraphics/vk/vkaccelerationstructure.cc b/code/render/coregraphics/vk/vkaccelerationstructure.cc index 05b553647..584615ace 100644 --- a/code/render/coregraphics/vk/vkaccelerationstructure.cc +++ b/code/render/coregraphics/vk/vkaccelerationstructure.cc @@ -24,7 +24,7 @@ VkTlasAllocator tlasAllocator; const VkDevice BlasGetVkDevice(const CoreGraphics::BlasId id) { - return blasAllocator.ConstGet(id.id24); + return blasAllocator.ConstGet(id.id); } //------------------------------------------------------------------------------ @@ -33,7 +33,7 @@ BlasGetVkDevice(const CoreGraphics::BlasId id) const VkBuffer BlasGetVkBuffer(const CoreGraphics::BlasId id) { - return BufferGetVk(blasAllocator.ConstGet(id.id24)); + return BufferGetVk(blasAllocator.ConstGet(id.id)); } //------------------------------------------------------------------------------ @@ -42,7 +42,7 @@ BlasGetVkBuffer(const CoreGraphics::BlasId id) const VkAccelerationStructureKHR BlasGetVk(const CoreGraphics::BlasId id) { - return blasAllocator.ConstGet(id.id24); + return blasAllocator.ConstGet(id.id); } //------------------------------------------------------------------------------ @@ -51,7 +51,7 @@ BlasGetVk(const CoreGraphics::BlasId id) const VkAccelerationStructureBuildGeometryInfoKHR& BlasGetVkBuild(const CoreGraphics::BlasId id) { - return blasAllocator.ConstGet(id.id24).buildGeometryInfo; + return blasAllocator.ConstGet(id.id).buildGeometryInfo; } //------------------------------------------------------------------------------ @@ -60,7 +60,7 @@ BlasGetVkBuild(const CoreGraphics::BlasId id) const Util::Array& BlasGetVkRanges(const CoreGraphics::BlasId id) { - return blasAllocator.ConstGet(id.id24).rangeInfos; + return blasAllocator.ConstGet(id.id).rangeInfos; } //------------------------------------------------------------------------------ @@ -69,7 +69,7 @@ BlasGetVkRanges(const CoreGraphics::BlasId id) const VkDevice TlasGetVkDevice(const CoreGraphics::TlasId id) { - return tlasAllocator.ConstGet(id.id24); + return tlasAllocator.ConstGet(id.id); } //------------------------------------------------------------------------------ @@ -78,7 +78,7 @@ TlasGetVkDevice(const CoreGraphics::TlasId id) const VkBuffer TlasGetVkBuffer(const CoreGraphics::TlasId id) { - return BufferGetVk(tlasAllocator.ConstGet(id.id24)); + return BufferGetVk(tlasAllocator.ConstGet(id.id)); } //------------------------------------------------------------------------------ @@ -87,7 +87,7 @@ TlasGetVkBuffer(const CoreGraphics::TlasId id) const VkAccelerationStructureKHR TlasGetVk(const CoreGraphics::TlasId id) { - return tlasAllocator.ConstGet(id.id24); + return tlasAllocator.ConstGet(id.id); } //------------------------------------------------------------------------------ @@ -96,7 +96,7 @@ TlasGetVk(const CoreGraphics::TlasId id) const VkAccelerationStructureBuildGeometryInfoKHR& TlasGetVkBuild(const CoreGraphics::TlasId id) { - return tlasAllocator.ConstGet(id.id24).geometryInfo; + return tlasAllocator.ConstGet(id.id).geometryInfo; } //------------------------------------------------------------------------------ @@ -105,7 +105,7 @@ TlasGetVkBuild(const CoreGraphics::TlasId id) const Util::Array& TlasGetVkRanges(const CoreGraphics::TlasId id) { - return tlasAllocator.ConstGet(id.id24).rangeInfos; + return tlasAllocator.ConstGet(id.id).rangeInfos; } } // namespace Vulkan @@ -260,9 +260,7 @@ CreateBlas(const BlasCreateInfo& info) blasAllocator.Set(id, as); setup.buildGeometryInfo.dstAccelerationStructure = as; - BlasId ret; - ret.id24 = id; - ret.id8 = BlasIdType; + BlasId ret = id; return ret; } @@ -272,10 +270,10 @@ CreateBlas(const BlasCreateInfo& info) void DestroyBlas(const BlasId blas) { - blasAllocator.Dealloc(blas.id24); CoreGraphics::DelayedDeleteBlas(blas); - CoreGraphics::DestroyBuffer(blasAllocator.Get(blas.id24)); - CoreGraphics::DestroyBuffer(blasAllocator.Get(blas.id24)); + CoreGraphics::DestroyBuffer(blasAllocator.Get(blas.id)); + CoreGraphics::DestroyBuffer(blasAllocator.Get(blas.id)); + blasAllocator.Dealloc(blas.id); } //------------------------------------------------------------------------------ @@ -319,10 +317,7 @@ CreateBlasInstance(const BlasInstanceCreateInfo& info) blasInstanceAllocator.Set(id, info.transform); - BlasInstanceId ret; - ret.id24 = id; - ret.id8 = BlasInstanceIdType; - + BlasInstanceId ret = id; BlasInstanceIdRelease(ret); return ret; } @@ -333,9 +328,9 @@ CreateBlasInstance(const BlasInstanceCreateInfo& info) void DestroyBlasInstance(const BlasInstanceId id) { - VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id24); + VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id); setup.mask = 0x0; // Disable instance such that TLAS building will ignore it - blasInstanceAllocator.Dealloc(id.id24); + blasInstanceAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -344,7 +339,7 @@ DestroyBlasInstance(const BlasInstanceId id) void BlasInstanceUpdate(const BlasInstanceId id, const Math::mat4& transform, CoreGraphics::BufferId buf, uint offset) { - VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id24); + VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id); Math::mat4 trans = Math::transpose(transform); trans.store3(&setup.transform.matrix[0][0]); @@ -358,7 +353,7 @@ BlasInstanceUpdate(const BlasInstanceId id, const Math::mat4& transform, CoreGra void BlasInstanceUpdate(const BlasInstanceId id, CoreGraphics::BufferId buf, uint offset) { - VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id24); + VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id); char* ptr = (char*)CoreGraphics::BufferMap(buf) + offset; memcpy(ptr, &setup, sizeof(setup)); } @@ -369,7 +364,7 @@ BlasInstanceUpdate(const BlasInstanceId id, CoreGraphics::BufferId buf, uint off void BlasInstanceSetMask(const BlasInstanceId id, uint mask) { - VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id24); + VkAccelerationStructureInstanceKHR& setup = blasInstanceAllocator.Get(id.id); setup.mask = mask; } @@ -526,9 +521,7 @@ CreateTlas(const TlasCreateInfo& info) tlasAllocator.Set(id, as); scene.geometryInfo.dstAccelerationStructure = as; - TlasId ret; - ret.id24 = id; - ret.id8 = TlasIdType; + TlasId ret = id; return ret; } @@ -539,10 +532,10 @@ void DestroyTlas(const TlasId tlas) { CoreGraphics::DelayedDeleteTlas(tlas); - CoreGraphics::DestroyBuffer(tlasAllocator.Get(tlas.id24)); - CoreGraphics::DestroyBuffer(tlasAllocator.Get(tlas.id24)); - CoreGraphics::DestroyBuffer(tlasAllocator.Get(tlas.id24)); - tlasAllocator.Dealloc(tlas.id24); + CoreGraphics::DestroyBuffer(tlasAllocator.Get(tlas.id)); + CoreGraphics::DestroyBuffer(tlasAllocator.Get(tlas.id)); + CoreGraphics::DestroyBuffer(tlasAllocator.Get(tlas.id)); + tlasAllocator.Dealloc(tlas.id); } //------------------------------------------------------------------------------ @@ -551,9 +544,9 @@ DestroyTlas(const TlasId tlas) void TlasInitBuild(const TlasId tlas) { - SceneSetup& scene = tlasAllocator.Get(tlas.id24); + SceneSetup& scene = tlasAllocator.Get(tlas.id); scene.geometryInfo.mode = VkBuildAccelerationStructureModeKHR::VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR; - scene.geometryInfo.scratchData = VkDeviceOrHostAddressKHR{ .deviceAddress = tlasAllocator.Get(tlas.id24) }; + scene.geometryInfo.scratchData = VkDeviceOrHostAddressKHR{ .deviceAddress = tlasAllocator.Get(tlas.id) }; } //------------------------------------------------------------------------------ @@ -562,9 +555,9 @@ TlasInitBuild(const TlasId tlas) void TlasInitUpdate(const TlasId tlas) { - SceneSetup& scene = tlasAllocator.Get(tlas.id24); + SceneSetup& scene = tlasAllocator.Get(tlas.id); scene.geometryInfo.mode = VkBuildAccelerationStructureModeKHR::VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR; - scene.geometryInfo.scratchData = VkDeviceOrHostAddressKHR{ .deviceAddress = tlasAllocator.Get(tlas.id24) }; + scene.geometryInfo.scratchData = VkDeviceOrHostAddressKHR{ .deviceAddress = tlasAllocator.Get(tlas.id) }; } } // namespace CoreGraphics diff --git a/code/render/coregraphics/vk/vkbarrier.cc b/code/render/coregraphics/vk/vkbarrier.cc index 49fa7e143..2606705e8 100644 --- a/code/render/coregraphics/vk/vkbarrier.cc +++ b/code/render/coregraphics/vk/vkbarrier.cc @@ -24,7 +24,7 @@ VkBarrierAllocator barrierAllocator(0x00FFFFFF); const VkBarrierInfo& BarrierGetVk(const CoreGraphics::BarrierId id) { - return barrierAllocator.Get(id.id24); + return barrierAllocator.Get(id.id); } } @@ -126,9 +126,7 @@ CreateBarrier(const BarrierCreateInfo& info) vkInfo.numMemoryBarriers = 1; } - BarrierId eventId; - eventId.id24 = id; - eventId.id8 = BarrierIdType; + BarrierId eventId = id; return eventId; } @@ -138,7 +136,7 @@ CreateBarrier(const BarrierCreateInfo& info) void DestroyBarrier(const BarrierId id) { - barrierAllocator.Dealloc(id.id24); + barrierAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -147,8 +145,8 @@ DestroyBarrier(const BarrierId id) void BarrierReset(const BarrierId id) { - VkBarrierInfo& vkInfo = barrierAllocator.Get(id.id24); - Util::Array& rts = barrierAllocator.Get(id.id24); + VkBarrierInfo& vkInfo = barrierAllocator.Get(id.id); + Util::Array& rts = barrierAllocator.Get(id.id); IndexT i; for (i = 0; i < rts.Size(); i++) diff --git a/code/render/coregraphics/vk/vkbuffer.cc b/code/render/coregraphics/vk/vkbuffer.cc index 8216bf64a..249d9e669 100644 --- a/code/render/coregraphics/vk/vkbuffer.cc +++ b/code/render/coregraphics/vk/vkbuffer.cc @@ -17,7 +17,7 @@ VkBufferSparseExtensionAllocator bufferSparseExtensionAllocator; VkBuffer BufferGetVk(const CoreGraphics::BufferId id) { - return bufferAllocator.ConstGet(id.id24).buf; + return bufferAllocator.ConstGet(id.id).buf; } //------------------------------------------------------------------------------ @@ -26,7 +26,7 @@ BufferGetVk(const CoreGraphics::BufferId id) VkDeviceMemory BufferGetVkMemory(const CoreGraphics::BufferId id) { - return bufferAllocator.ConstGet(id.id24).mem.mem; + return bufferAllocator.ConstGet(id.id).mem.mem; } //------------------------------------------------------------------------------ @@ -35,7 +35,7 @@ BufferGetVkMemory(const CoreGraphics::BufferId id) VkDevice BufferGetVkDevice(const CoreGraphics::BufferId id) { - return bufferAllocator.ConstGet(id.id24).dev; + return bufferAllocator.ConstGet(id.id).dev; } } // namespace Vulkan @@ -267,9 +267,7 @@ CreateBuffer(const BufferCreateInfo& info) loadInfo.byteSize = size; loadInfo.elementSize = info.elementSize; - BufferId ret; - ret.id8 = BufferIdType; - ret.id24 = id; + BufferId ret = id; #if NEBULA_GRAPHICS_DEBUG ObjectSetName(ret, info.name.Value()); @@ -286,14 +284,14 @@ CreateBuffer(const BufferCreateInfo& info) void DestroyBuffer(const BufferId id) { - bufferAllocator.Acquire(id.id24); - VkBufferLoadInfo& loadInfo = bufferAllocator.Get(id.id24); + bufferAllocator.Acquire(id.id); + VkBufferLoadInfo& loadInfo = bufferAllocator.Get(id.id); CoreGraphics::DelayedDeleteBuffer(id); CoreGraphics::DelayedFreeMemory(loadInfo.mem); loadInfo.mem = CoreGraphics::Alloc{}; - bufferAllocator.Dealloc(id.id24); - bufferAllocator.Release(id.id24); + bufferAllocator.Dealloc(id.id); + bufferAllocator.Release(id.id); } //------------------------------------------------------------------------------ @@ -302,7 +300,7 @@ DestroyBuffer(const BufferId id) const BufferUsageFlags BufferGetType(const BufferId id) { - return bufferAllocator.ConstGet(id.id24).usageFlags; + return bufferAllocator.ConstGet(id.id).usageFlags; } //------------------------------------------------------------------------------ @@ -311,7 +309,7 @@ BufferGetType(const BufferId id) const SizeT BufferGetSize(const BufferId id) { - return bufferAllocator.ConstGet(id.id24).size; + return bufferAllocator.ConstGet(id.id).size; } //------------------------------------------------------------------------------ @@ -320,7 +318,7 @@ BufferGetSize(const BufferId id) const SizeT BufferGetElementSize(const BufferId id) { - return bufferAllocator.ConstGet(id.id24).elementSize; + return bufferAllocator.ConstGet(id.id).elementSize; } //------------------------------------------------------------------------------ @@ -329,7 +327,7 @@ BufferGetElementSize(const BufferId id) const SizeT BufferGetByteSize(const BufferId id) { - return bufferAllocator.ConstGet(id.id24).byteSize; + return bufferAllocator.ConstGet(id.id).byteSize; } //------------------------------------------------------------------------------ @@ -347,7 +345,7 @@ BufferGetUploadMaxSize() void* BufferMap(const BufferId id) { - const VkBufferMapInfo& mapInfo = bufferAllocator.ConstGet(id.id24); + const VkBufferMapInfo& mapInfo = bufferAllocator.ConstGet(id.id); n_assert2(mapInfo.mappedMemory != nullptr, "Buffer must be created as dynamic or mapped to support mapping"); return mapInfo.mappedMemory; } @@ -367,10 +365,10 @@ BufferUnmap(const BufferId id) void BufferUpdate(const BufferId id, const void* data, const uint size, const uint offset) { - const VkBufferMapInfo& map = bufferAllocator.ConstGet(id.id24); + const VkBufferMapInfo& map = bufferAllocator.ConstGet(id.id); #if NEBULA_DEBUG - const VkBufferLoadInfo& setup = bufferAllocator.ConstGet(id.id24); + const VkBufferLoadInfo& setup = bufferAllocator.ConstGet(id.id); n_assert(size + offset <= (uint)setup.byteSize); #endif byte* buf = (byte*)map.mappedMemory + offset; @@ -393,7 +391,7 @@ BufferUpload(const CoreGraphics::CmdBufferId cmdBuf, const BufferId id, const vo void BufferFill(const CoreGraphics::CmdBufferId cmdBuf, const BufferId id, char pattern) { - const VkBufferLoadInfo& setup = bufferAllocator.ConstGet(id.id24); + const VkBufferLoadInfo& setup = bufferAllocator.ConstGet(id.id); int remainingBytes = setup.byteSize; uint numChunks = Math::divandroundup(setup.byteSize, BufferGetUploadMaxSize()); @@ -416,7 +414,7 @@ BufferFill(const CoreGraphics::CmdBufferId cmdBuf, const BufferId id, char patte void BufferFlush(const BufferId id, IndexT offset, SizeT size) { - const VkBufferLoadInfo& loadInfo = bufferAllocator.ConstGet(id.id24); + const VkBufferLoadInfo& loadInfo = bufferAllocator.ConstGet(id.id); n_assert(size == NEBULA_WHOLE_BUFFER_SIZE ? true : (uint)offset + size <= loadInfo.byteSize); Flush(loadInfo.dev, loadInfo.mem, offset, size); } @@ -427,7 +425,7 @@ BufferFlush(const BufferId id, IndexT offset, SizeT size) void BufferInvalidate(const BufferId id, IndexT offset, SizeT size) { - const VkBufferLoadInfo& loadInfo = bufferAllocator.ConstGet(id.id24); + const VkBufferLoadInfo& loadInfo = bufferAllocator.ConstGet(id.id); n_assert(size == NEBULA_WHOLE_BUFFER_SIZE ? true : (uint)offset + size <= loadInfo.byteSize); Invalidate(loadInfo.dev, loadInfo.mem, offset, size); } @@ -438,8 +436,8 @@ BufferInvalidate(const BufferId id, IndexT offset, SizeT size) void BufferSparseEvict(const BufferId id, IndexT pageIndex) { - __Lock(bufferAllocator, id.id24); - Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id24).sparseExtension; + __Lock(bufferAllocator, id.id); + Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != 0xFFFFFFFF); const BufferSparsePageTable& table = bufferSparseExtensionAllocator.ConstGet(sparseExtension); @@ -471,8 +469,8 @@ BufferSparseEvict(const BufferId id, IndexT pageIndex) void BufferSparseMakeResident(const BufferId id, IndexT pageIndex) { - __Lock(bufferAllocator, id.id24); - Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id24).sparseExtension; + __Lock(bufferAllocator, id.id); + Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != 0xFFFFFFFF); const BufferSparsePageTable& table = bufferSparseExtensionAllocator.ConstGet(sparseExtension); @@ -501,8 +499,8 @@ BufferSparseMakeResident(const BufferId id, IndexT pageIndex) IndexT BufferSparseGetPageIndex(const BufferId id, SizeT offset) { - __Lock(bufferAllocator, id.id24); - Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id24).sparseExtension; + __Lock(bufferAllocator, id.id); + Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != 0xFFFFFFFF); const BufferSparsePageTable& table = bufferSparseExtensionAllocator.ConstGet(sparseExtension); @@ -516,8 +514,8 @@ BufferSparseGetPageIndex(const BufferId id, SizeT offset) SizeT BufferSparseGetPageSize(const BufferId id) { - __Lock(bufferAllocator, id.id24); - Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id24).sparseExtension; + __Lock(bufferAllocator, id.id); + Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != 0xFFFFFFFF); const BufferSparsePageTable& table = bufferSparseExtensionAllocator.ConstGet(sparseExtension); return table.memoryReqs.alignment; @@ -529,9 +527,9 @@ BufferSparseGetPageSize(const BufferId id) void BufferSparseCommitChanges(const BufferId id) { - __Lock(bufferAllocator, id.id24); - VkBuffer buf = bufferAllocator.ConstGet(id.id24).buf; - Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id24).sparseExtension; + __Lock(bufferAllocator, id.id); + VkBuffer buf = bufferAllocator.ConstGet(id.id).buf; + Ids::Id32 sparseExtension = bufferAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != 0xFFFFFFFF); const BufferSparsePageTable& table = bufferSparseExtensionAllocator.ConstGet(sparseExtension); diff --git a/code/render/coregraphics/vk/vkcommandbuffer.cc b/code/render/coregraphics/vk/vkcommandbuffer.cc index 6d0255cb6..cf75a68a8 100644 --- a/code/render/coregraphics/vk/vkcommandbuffer.cc +++ b/code/render/coregraphics/vk/vkcommandbuffer.cc @@ -36,7 +36,7 @@ Threading::CriticalSection commandBufferCritSect; const VkCommandPool CmdBufferPoolGetVk(const CoreGraphics::CmdBufferPoolId id) { - return commandBufferPools.Get(id.id24); + return commandBufferPools.Get(id.id); } //------------------------------------------------------------------------------ @@ -45,7 +45,7 @@ CmdBufferPoolGetVk(const CoreGraphics::CmdBufferPoolId id) const VkDevice CmdBufferPoolGetVkDevice(const CoreGraphics::CmdBufferPoolId id) { - return commandBufferPools.Get(id.id24); + return commandBufferPools.Get(id.id); } //------------------------------------------------------------------------------ @@ -54,11 +54,8 @@ CmdBufferPoolGetVkDevice(const CoreGraphics::CmdBufferPoolId id) const VkCommandBuffer CmdBufferGetVk(const CoreGraphics::CmdBufferId id) { -#if NEBULA_DEBUG - n_assert(id.id8 == CoreGraphics::IdType::CommandBufferIdType); -#endif if (id == CoreGraphics::InvalidCmdBufferId) return VK_NULL_HANDLE; - else return commandBuffers.Get(id.id24); + else return commandBuffers.Get(id.id); } //------------------------------------------------------------------------------ @@ -67,7 +64,7 @@ CmdBufferGetVk(const CoreGraphics::CmdBufferId id) const VkCommandPool CmdBufferGetVkPool(const CoreGraphics::CmdBufferId id) { - return commandBuffers.Get(id.id24);; + return commandBuffers.Get(id.id); } //------------------------------------------------------------------------------ @@ -76,7 +73,7 @@ CmdBufferGetVkPool(const CoreGraphics::CmdBufferId id) const VkDevice CmdBufferGetVkDevice(const CoreGraphics::CmdBufferId id) { - return commandBuffers.Get(id.id24);; + return commandBuffers.Get(id.id); } } // Vulkan @@ -114,9 +111,7 @@ CreateCmdBufferPool(const CmdBufferPoolCreateInfo& info) commandBufferPools.Set(id, dev); n_assert(res == VK_SUCCESS); - CmdBufferPoolId ret; - ret.id24 = id; - ret.id8 = CommandBufferPoolIdType; + CmdBufferPoolId ret = id; return ret; } @@ -126,7 +121,7 @@ CreateCmdBufferPool(const CmdBufferPoolCreateInfo& info) void DestroyCmdBufferPool(const CmdBufferPoolId pool) { - vkDestroyCommandPool(commandBufferPools.Get(pool.id24), commandBufferPools.Get(pool.id24), nullptr); + vkDestroyCommandPool(commandBufferPools.Get(pool.id), commandBufferPools.Get(pool.id), nullptr); } //------------------------------------------------------------------------------ @@ -213,9 +208,7 @@ CreateCmdBuffer(const CmdBufferCreateInfo& info) ScissorBundle& scissors = commandBuffers.Get(id); scissors.scissors.Resize(8); - CmdBufferId ret; - ret.id24 = id; - ret.id8 = CommandBufferIdType; + CmdBufferId ret = id; return ret; } @@ -225,25 +218,21 @@ CreateCmdBuffer(const CmdBufferCreateInfo& info) void DestroyCmdBuffer(const CmdBufferId id) { -#if _DEBUG - n_assert(id.id8 == CommandBufferIdType); -#endif - - __Lock(commandBuffers, id.id24); + __Lock(commandBuffers, id.id); #if NEBULA_ENABLE_PROFILING - QueryBundle& queryBundles = commandBuffers.Get(id.id24); + QueryBundle& queryBundles = commandBuffers.Get(id.id); queryBundles.chunks[0].Clear(); queryBundles.chunks[1].Clear(); queryBundles.chunks[2].Clear(); - CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id24); + CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id); markers.markerStack.Clear(); markers.finishedMarkers.Clear(); #endif CoreGraphics::DelayedDeleteCommandBuffer(id); - commandBuffers.Dealloc(id.id24); + commandBuffers.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -252,9 +241,6 @@ DestroyCmdBuffer(const CmdBufferId id) void CmdBeginRecord(const CmdBufferId id, const CmdBufferBeginInfo& info) { -#if _DEBUG - n_assert(id.id8 == CommandBufferIdType); -#endif VkCommandBufferUsageFlags flags = 0; flags |= info.submitOnce ? VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT : 0; flags |= info.submitDuringPass ? VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT : 0; @@ -266,18 +252,18 @@ CmdBeginRecord(const CmdBufferId id, const CmdBufferBeginInfo& info) flags, nullptr // fixme, this part can optimize if used properly! }; - VkResult res = vkBeginCommandBuffer(commandBuffers.Get(id.id24), &begin); + VkResult res = vkBeginCommandBuffer(commandBuffers.Get(id.id), &begin); n_assert(res == VK_SUCCESS); // Also write first timestamp - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + QueryBundle& queryBundle = commandBuffers.Get(id.id); queryBundle.states[CoreGraphics::TimestampsQueryType].currentChunk = 0; VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::TimestampsQueryType); if (queryBundle.enabled[CoreGraphics::TimestampsQueryType]) { QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::TimestampsQueryType); - vkCmdWriteTimestamp(commandBuffers.Get(id.id24), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool, chunk.offset + chunk.queryCount++); + vkCmdWriteTimestamp(commandBuffers.Get(id.id), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool, chunk.offset + chunk.queryCount++); } } @@ -287,11 +273,7 @@ CmdBeginRecord(const CmdBufferId id, const CmdBufferBeginInfo& info) void CmdEndRecord(const CmdBufferId id) { -#if _DEBUG - n_assert(id.id8 == CommandBufferIdType); -#endif - - VkResult res = vkEndCommandBuffer(commandBuffers.Get(id.id24)); + VkResult res = vkEndCommandBuffer(commandBuffers.Get(id.id)); n_assert(res == VK_SUCCESS); } @@ -301,12 +283,9 @@ CmdEndRecord(const CmdBufferId id) void CmdReset(const CmdBufferId id, const CmdBufferClearInfo& info) { -#if _DEBUG - n_assert(id.id8 == CommandBufferIdType); -#endif VkCommandBufferResetFlags flags = 0; flags |= info.allowRelease ? VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT : 0; - VkResult res = vkResetCommandBuffer(commandBuffers.Get(id.id24), flags); + VkResult res = vkResetCommandBuffer(commandBuffers.Get(id.id), flags); n_assert(res == VK_SUCCESS); } @@ -317,10 +296,10 @@ void CmdSetVertexBuffer(const CmdBufferId id, IndexT streamIndex, const CoreGraphics::BufferId& buffer, SizeT bufferOffset) { #if _DEBUG - CoreGraphics::QueueType usage = commandBuffers.Get(id.id24); + CoreGraphics::QueueType usage = commandBuffers.Get(id.id); n_assert(usage == QueueType::GraphicsQueueType); #endif - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkBuffer buf = Vulkan::BufferGetVk(buffer); VkDeviceSize offset = bufferOffset; vkCmdBindVertexBuffers(cmdBuf, streamIndex, 1, &buf, &offset); @@ -333,11 +312,11 @@ void CmdSetVertexLayout(const CmdBufferId id, const CoreGraphics::VertexLayoutId& vl) { #if _DEBUG - CoreGraphics::QueueType usage = commandBuffers.Get(id.id24); + CoreGraphics::QueueType usage = commandBuffers.Get(id.id); n_assert(usage == QueueType::GraphicsQueueType); #endif - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - //VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + //VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); const VertexLayoutVkBindInfo& bindInfo = VertexLayoutGetVkBindInfo(vl); vkCmdSetVertexInputEXT(cmdBuf, bindInfo.binds.Size(), bindInfo.binds.Begin(), bindInfo.attrs.Size(), bindInfo.attrs.Begin()); @@ -351,10 +330,10 @@ void CmdSetIndexBuffer(const CmdBufferId id, const IndexType::Code indexType, const CoreGraphics::BufferId& buffer, SizeT bufferOffset) { #if _DEBUG - CoreGraphics::QueueType usage = commandBuffers.Get(id.id24); + CoreGraphics::QueueType usage = commandBuffers.Get(id.id); n_assert(usage == QueueType::GraphicsQueueType); #endif - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkBuffer buf = Vulkan::BufferGetVk(buffer); VkDeviceSize offset = bufferOffset; VkIndexType vkIdxType = indexType == IndexType::Index16 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32; @@ -368,10 +347,10 @@ void CmdSetIndexBuffer(const CmdBufferId id, const CoreGraphics::BufferId& buffer, CoreGraphics::IndexType::Code indexSize, SizeT bufferOffset) { #if _DEBUG - CoreGraphics::QueueType usage = commandBuffers.Get(id.id24); + CoreGraphics::QueueType usage = commandBuffers.Get(id.id); n_assert(usage == QueueType::GraphicsQueueType); #endif - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkBuffer buf = Vulkan::BufferGetVk(buffer); VkDeviceSize offset = bufferOffset; VkIndexType vkIdxType = indexSize == IndexType::Index16 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32; @@ -385,12 +364,12 @@ void CmdSetPrimitiveTopology(const CmdBufferId id, const CoreGraphics::PrimitiveTopology::Code topo) { #if _DEBUG - CoreGraphics::QueueType usage = commandBuffers.Get(id.id24); + CoreGraphics::QueueType usage = commandBuffers.Get(id.id); n_assert(usage == QueueType::GraphicsQueueType); #endif - VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkPrimitiveTopology comp = VkTypes::AsVkPrimitiveType(topo); pipelineBundle.inputAssembly.topo = comp; pipelineBundle.inputAssembly.primRestart = false; @@ -404,8 +383,8 @@ CmdSetPrimitiveTopology(const CmdBufferId id, const CoreGraphics::PrimitiveTopol void CmdSetShaderProgram(const CmdBufferId id, const CoreGraphics::ShaderProgramId pro, bool bindGlobals) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); VkShaderProgramRuntimeInfo& info = shaderProgramAlloc.Get(pro.programId); IndexT buffer = CoreGraphics::GetBufferedFrameIndex(); @@ -434,7 +413,7 @@ CmdSetShaderProgram(const CmdBufferId id, const CoreGraphics::ShaderProgramId pr } else { - CmdPipelineBuildBits& bits = commandBuffers.Get(id.id24); + CmdPipelineBuildBits& bits = commandBuffers.Get(id.id); bits |= CoreGraphics::CmdPipelineBuildBits::ShaderInfoSet; bits &= ~CoreGraphics::CmdPipelineBuildBits::PipelineBuilt; @@ -493,9 +472,9 @@ CmdSetResourceTable(const CmdBufferId id, const CoreGraphics::ResourceTableId ta void CmdSetResourceTable(const CmdBufferId id, const CoreGraphics::ResourceTableId table, const IndexT slot, CoreGraphics::ShaderPipeline pipeline, uint32 numOffsets, uint32* offsets) { - const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); VkDescriptorSet set = Vulkan::ResourceTableGetVkDescriptorSet(table); - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); switch (pipeline) { case ShaderPipeline::GraphicsPipeline: @@ -517,8 +496,8 @@ CmdSetResourceTable(const CmdBufferId id, const CoreGraphics::ResourceTableId ta void CmdPushConstants(const CmdBufferId id, ShaderPipeline pipeline, uint offset, uint size, const void* data) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); switch (pipeline) { case ShaderPipeline::GraphicsPipeline: @@ -540,8 +519,8 @@ CmdPushConstants(const CmdBufferId id, ShaderPipeline pipeline, uint offset, uin void CmdPushGraphicsConstants(const CmdBufferId id, uint offset, uint size, const void* data) { - const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdPushConstants(cmdBuf, pipelineBundle.graphicsLayout, VK_SHADER_STAGE_ALL_GRAPHICS, offset, size, data); } @@ -551,8 +530,8 @@ CmdPushGraphicsConstants(const CmdBufferId id, uint offset, uint size, const voi void CmdPushComputeConstants(const CmdBufferId id, uint offset, uint size, const void* data) { - const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdPushConstants(cmdBuf, pipelineBundle.computeLayout, VK_SHADER_STAGE_COMPUTE_BIT, offset, size, data); } @@ -562,26 +541,26 @@ CmdPushComputeConstants(const CmdBufferId id, uint offset, uint size, const void void CmdSetGraphicsPipeline(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); - CmdPipelineBuildBits& bits = commandBuffers.Get(id.id24); + CmdPipelineBuildBits& bits = commandBuffers.Get(id.id); n_assert((bits & CmdPipelineBuildBits::AllInfoSet) != 0); if (!AllBits(bits, CmdPipelineBuildBits::PipelineBuilt)) { - const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + const VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); VkPipeline pipeline = CoreGraphics::GetOrCreatePipeline(pipelineBundle.pass, pipelineBundle.pipelineInfo.subpass, pipelineBundle.program, pipelineBundle.inputAssembly, pipelineBundle.pipelineInfo); bits |= CmdPipelineBuildBits::PipelineBuilt; vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); } // Set viewport and scissors since Vulkan requires them to be set after the pipeline - ViewportBundle& viewports = commandBuffers.Get(id.id24); + ViewportBundle& viewports = commandBuffers.Get(id.id); if (viewports.numPending > 0) { vkCmdSetViewport(cmdBuf, 0, viewports.numPending, viewports.viewports.Begin()); viewports.numPending = 0; } - ScissorBundle& rects = commandBuffers.Get(id.id24); + ScissorBundle& rects = commandBuffers.Get(id.id); if (rects.numPending > 0) { vkCmdSetScissor(cmdBuf, 0, rects.numPending, rects.scissors.Begin()); @@ -595,10 +574,10 @@ CmdSetGraphicsPipeline(const CmdBufferId id) void CmdSetGraphicsPipeline(const CmdBufferId buf, const PipelineId pipeline) { - VkCommandBuffer cmdBuf = commandBuffers.Get(buf.id24); - Pipeline& pipelineObj = pipelineAllocator.Get(pipeline.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(buf.id); + Pipeline& pipelineObj = pipelineAllocator.Get(pipeline.id); vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineObj.pipeline); - VkPipelineBundle& pipelineBundle = commandBuffers.Get(buf.id24); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(buf.id); bool pipelineChange = pipelineBundle.graphicsLayout != pipelineObj.layout; pipelineBundle.graphicsLayout = pipelineObj.layout; @@ -611,13 +590,13 @@ CmdSetGraphicsPipeline(const CmdBufferId buf, const PipelineId pipeline) } // Set viewport and scissors since Vulkan requires them to be set after the pipeline - ViewportBundle& viewports = commandBuffers.Get(buf.id24); + ViewportBundle& viewports = commandBuffers.Get(buf.id); if (viewports.numPending > 0) { vkCmdSetViewport(cmdBuf, 0, viewports.numPending, viewports.viewports.Begin()); viewports.numPending = 0; } - ScissorBundle& rects = commandBuffers.Get(buf.id24); + ScissorBundle& rects = commandBuffers.Get(buf.id); if (rects.numPending > 0) { vkCmdSetScissor(cmdBuf, 0, rects.numPending, rects.scissors.Begin()); @@ -631,9 +610,9 @@ CmdSetGraphicsPipeline(const CmdBufferId buf, const PipelineId pipeline) void CmdSetRayTracingPipeline(const CmdBufferId buf, const PipelineId pipeline) { - VkCommandBuffer cmdBuf = commandBuffers.Get(buf.id24); - VkPipelineBundle& pipelineBundle = commandBuffers.Get(buf.id24); - Pipeline& pipelineObj = pipelineAllocator.Get(pipeline.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(buf.id); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(buf.id); + Pipeline& pipelineObj = pipelineAllocator.Get(pipeline.id); pipelineBundle.raytracingLayout = pipelineObj.layout; bool pipelineChange = pipelineBundle.graphicsLayout != pipelineObj.layout; @@ -904,7 +883,7 @@ CmdHandover( void CmdBarrier(const CmdBufferId id, const CoreGraphics::BarrierId barrier) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkBarrierInfo& info = BarrierGetVk(barrier); vkCmdPipelineBarrier(cmdBuf, info.srcFlags, @@ -921,7 +900,7 @@ CmdBarrier(const CmdBufferId id, const CoreGraphics::BarrierId barrier) void CmdSignalEvent(const CmdBufferId id, const CoreGraphics::EventId ev, const CoreGraphics::PipelineStage stage) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkEventInfo& info = EventGetVk(ev); vkCmdSetEvent(cmdBuf, info.event, VkTypes::AsVkPipelineStage(stage)); } @@ -932,7 +911,7 @@ CmdSignalEvent(const CmdBufferId id, const CoreGraphics::EventId ev, const CoreG void CmdWaitEvent(const CmdBufferId id, const EventId ev, const CoreGraphics::PipelineStage waitStage, const CoreGraphics::PipelineStage signalStage) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkEventInfo& info = EventGetVk(ev); vkCmdWaitEvents( cmdBuf @@ -955,7 +934,7 @@ CmdWaitEvent(const CmdBufferId id, const EventId ev, const CoreGraphics::Pipelin void CmdResetEvent(const CmdBufferId id, const CoreGraphics::EventId ev, const CoreGraphics::PipelineStage stage) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkEventInfo& info = EventGetVk(ev); vkCmdResetEvent(cmdBuf, info.event, VkTypes::AsVkPipelineStage(stage)); } @@ -966,12 +945,12 @@ CmdResetEvent(const CmdBufferId id, const CoreGraphics::EventId ev, const CoreGr void CmdBeginPass(const CmdBufferId id, const PassId pass) { - VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkRenderPassBeginInfo& info = PassGetVkRenderPassBeginInfo(pass); const VkGraphicsPipelineCreateInfo& framebufferInfo = PassGetVkFramebufferInfo(pass); - CmdPipelineBuildBits& bits = commandBuffers.Get(id.id24); + CmdPipelineBuildBits& bits = commandBuffers.Get(id.id); bits |= CoreGraphics::CmdPipelineBuildBits::FramebufferLayoutInfoSet; bits &= ~CoreGraphics::CmdPipelineBuildBits::PipelineBuilt; @@ -995,9 +974,9 @@ CmdBeginPass(const CmdBufferId id, const PassId pass) void CmdNextSubpass(const CmdBufferId id) { - VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); pipelineBundle.pipelineInfo.subpass++; - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdNextSubpass(cmdBuf, VK_SUBPASS_CONTENTS_INLINE); } @@ -1007,7 +986,7 @@ CmdNextSubpass(const CmdBufferId id) void CmdEndPass(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdEndRenderPass(cmdBuf); } @@ -1017,7 +996,7 @@ CmdEndPass(const CmdBufferId id) void CmdResetClipToPass(const CmdBufferId id) { - VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id24); + VkPipelineBundle& pipelineBundle = commandBuffers.Get(id.id); // Set viewports and scissors auto viewports = PassGetViewports(pipelineBundle.pass); @@ -1032,7 +1011,7 @@ CmdResetClipToPass(const CmdBufferId id) void CmdDraw(const CmdBufferId id, const CoreGraphics::PrimitiveGroup& pg) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); if (pg.GetNumIndices() > 0) vkCmdDrawIndexed(cmdBuf, pg.GetNumIndices(), 1, pg.GetBaseIndex(), pg.GetBaseVertex(), 0); else @@ -1045,7 +1024,7 @@ CmdDraw(const CmdBufferId id, const CoreGraphics::PrimitiveGroup& pg) void CmdDraw(const CmdBufferId id, SizeT numInstances, const CoreGraphics::PrimitiveGroup& pg) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); if (pg.GetNumIndices() > 0) vkCmdDrawIndexed(cmdBuf, pg.GetNumIndices(), numInstances, pg.GetBaseIndex(), pg.GetBaseVertex(), 0); else @@ -1058,7 +1037,7 @@ CmdDraw(const CmdBufferId id, SizeT numInstances, const CoreGraphics::PrimitiveG void CmdDraw(const CmdBufferId id, SizeT numInstances, IndexT baseInstance, const CoreGraphics::PrimitiveGroup& pg) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); if (pg.GetNumIndices() > 0) vkCmdDrawIndexed(cmdBuf, pg.GetNumIndices(), numInstances, pg.GetBaseIndex(), pg.GetBaseVertex(), baseInstance); else @@ -1071,7 +1050,7 @@ CmdDraw(const CmdBufferId id, SizeT numInstances, IndexT baseInstance, const Cor void CmdDrawIndirect(const CmdBufferId id, const CoreGraphics::BufferId buffer, IndexT bufferOffset, SizeT numDraws, SizeT stride) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdDrawIndirect(cmdBuf, BufferGetVk(buffer), bufferOffset, numDraws, stride); } @@ -1081,7 +1060,7 @@ CmdDrawIndirect(const CmdBufferId id, const CoreGraphics::BufferId buffer, Index void CmdDrawIndirectIndexed(const CmdBufferId id, const CoreGraphics::BufferId buffer, IndexT bufferOffset, SizeT numDraws, SizeT stride) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdDrawIndexedIndirect(cmdBuf, BufferGetVk(buffer), bufferOffset, numDraws, stride); } @@ -1091,7 +1070,7 @@ CmdDrawIndirectIndexed(const CmdBufferId id, const CoreGraphics::BufferId buffer void CmdDispatch(const CmdBufferId id, int dimX, int dimY, int dimZ) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdDispatch(cmdBuf, dimX, dimY, dimZ); } @@ -1101,7 +1080,7 @@ CmdDispatch(const CmdBufferId id, int dimX, int dimY, int dimZ) void CmdResolve(const CmdBufferId id, const CoreGraphics::TextureId source, const CoreGraphics::TextureCopy sourceCopy, const CoreGraphics::TextureId dest, const CoreGraphics::TextureCopy destCopy) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkImage vkSrc = TextureGetVkImage(source); VkImage vkDst = TextureGetVkImage(dest); @@ -1131,7 +1110,7 @@ CmdResolve(const CmdBufferId id, const CoreGraphics::TextureId source, const Cor void CmdBuildBlas(const CmdBufferId id, const CoreGraphics::BlasId blas) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkAccelerationStructureBuildGeometryInfoKHR& buildInfo = Vulkan::BlasGetVkBuild(blas); const Util::Array& rangeInfo = Vulkan::BlasGetVkRanges(blas); const VkAccelerationStructureBuildRangeInfoKHR* ranges[] = { rangeInfo.ConstBegin() }; @@ -1144,7 +1123,7 @@ CmdBuildBlas(const CmdBufferId id, const CoreGraphics::BlasId blas) void CmdBuildTlas(const CmdBufferId id, const CoreGraphics::TlasId tlas) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); const VkAccelerationStructureBuildGeometryInfoKHR& buildInfo = Vulkan::TlasGetVkBuild(tlas); const Util::Array& rangeInfo = Vulkan::TlasGetVkRanges(tlas); const VkAccelerationStructureBuildRangeInfoKHR* ranges[] = { rangeInfo.ConstBegin() }; @@ -1183,7 +1162,7 @@ CmdRaysDispatch(const CmdBufferId id, const RayDispatchTable& table, int dimX, i RegionSetup(hitRegion, table.hitEntry); RegionSetup(callableRegion, table.callableEntry); - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdTraceRaysKHR(cmdBuf, &genRegion, &missRegion, &hitRegion, &callableRegion, dimX, dimY, dimZ); } @@ -1193,7 +1172,7 @@ CmdRaysDispatch(const CmdBufferId id, const RayDispatchTable& table, int dimX, i void CmdDrawMeshlets(const CmdBufferId id, int dimX, int dimY, int dimZ) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdDrawMeshTasksEXT(cmdBuf, dimX, dimY, dimZ); } @@ -1224,7 +1203,7 @@ CmdCopy( copy.extent = { (uint32_t)to[i].region.width(), (uint32_t)to[i].region.height(), 1 }; } - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdCopyImage(cmdBuf, TextureGetVkImage(fromTexture), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, TextureGetVkImage(toTexture), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, copies.Size(), copies.Begin()); } @@ -1255,7 +1234,7 @@ CmdCopy( copy.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, (uint32_t)from[i].mip, (uint32_t)from[i].layer, 1 }; } - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdCopyImageToBuffer( cmdBuf , TextureGetVkImage(fromTexture) @@ -1290,7 +1269,7 @@ CmdCopy( copy.size = size; } - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdCopyBuffer(cmdBuf, BufferGetVk(fromBuffer), BufferGetVk(toBuffer), copies.Size(), copies.Begin()); } @@ -1321,7 +1300,7 @@ CmdCopy( copy.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, (uint32_t)to[i].mip, (uint32_t)to[i].layer, 1 }; } - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdCopyBufferToImage( cmdBuf , BufferGetVk(fromBuffer) @@ -1360,7 +1339,7 @@ CmdBlit( blit.dstOffsets[1] = { toRegion.right, toRegion.bottom, 1 }; blit.dstSubresource = { VkTypes::AsVkImageAspectFlags(toBits), (uint32_t)toMip, (uint32_t)toLayer, 1 }; - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdBlitImage( cmdBuf , TextureGetVkImage(from) @@ -1378,7 +1357,7 @@ CmdBlit( void CmdSetViewports(const CmdBufferId id, Util::FixedArray> viewports) { - ViewportBundle& pending = commandBuffers.Get(id.id24); + ViewportBundle& pending = commandBuffers.Get(id.id); pending.numPending = 0; for (Math::rectangle viewport : viewports) { @@ -1399,7 +1378,7 @@ CmdSetViewports(const CmdBufferId id, Util::FixedArray> vie void CmdSetScissors(const CmdBufferId id, Util::FixedArray> rects) { - ScissorBundle& pending = commandBuffers.Get(id.id24); + ScissorBundle& pending = commandBuffers.Get(id.id); pending.numPending = 0; for (Math::rectangle rect : rects) { @@ -1418,7 +1397,7 @@ CmdSetScissors(const CmdBufferId id, Util::FixedArray> rect void CmdSetViewport(const CmdBufferId id, const Math::rectangle& rect, int index) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkViewport vp; vp.width = (float)rect.width(); vp.height = (float)rect.height(); @@ -1435,7 +1414,7 @@ CmdSetViewport(const CmdBufferId id, const Math::rectangle& rect, int index void CmdSetScissorRect(const CmdBufferId id, const Math::rectangle& rect, int index) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); VkRect2D sc; sc.extent.width = rect.width(); sc.extent.height = rect.height(); @@ -1450,7 +1429,7 @@ CmdSetScissorRect(const CmdBufferId id, const Math::rectangle& rect, int in void CmdSetStencilRef(const CmdBufferId id, const uint frontRef, const uint backRef) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); if (frontRef == backRef) { vkCmdSetStencilReference(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, frontRef); @@ -1468,7 +1447,7 @@ CmdSetStencilRef(const CmdBufferId id, const uint frontRef, const uint backRef) void CmdSetStencilReadMask(const CmdBufferId id, const uint readMask) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdSetStencilCompareMask(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, readMask); } @@ -1478,7 +1457,7 @@ CmdSetStencilReadMask(const CmdBufferId id, const uint readMask) void CmdSetStencilWriteMask(const CmdBufferId id, const uint writeMask) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdSetStencilWriteMask(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, writeMask); } @@ -1488,7 +1467,7 @@ CmdSetStencilWriteMask(const CmdBufferId id, const uint writeMask) void CmdUpdateBuffer(const CmdBufferId id, const CoreGraphics::BufferId buffer, uint offset, uint size, const void* data) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); vkCmdUpdateBuffer(cmdBuf, Vulkan::BufferGetVk(buffer), offset, size, data); } @@ -1498,8 +1477,8 @@ CmdUpdateBuffer(const CmdBufferId id, const CoreGraphics::BufferId buffer, uint void CmdStartOcclusionQueries(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + QueryBundle& queryBundle = commandBuffers.Get(id.id); VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::OcclusionQueryType); n_assert(queryBundle.enabled[CoreGraphics::OcclusionQueryType]); QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::OcclusionQueryType); @@ -1512,8 +1491,8 @@ CmdStartOcclusionQueries(const CmdBufferId id) void CmdEndOcclusionQueries(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + QueryBundle& queryBundle = commandBuffers.Get(id.id); VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::OcclusionQueryType); n_assert(queryBundle.enabled[CoreGraphics::OcclusionQueryType]); QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::OcclusionQueryType); @@ -1526,8 +1505,8 @@ CmdEndOcclusionQueries(const CmdBufferId id) void CmdStartPipelineQueries(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + QueryBundle& queryBundle = commandBuffers.Get(id.id); VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::StatisticsQueryType); n_assert(queryBundle.enabled[CoreGraphics::StatisticsQueryType]); QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::StatisticsQueryType); @@ -1540,8 +1519,8 @@ CmdStartPipelineQueries(const CmdBufferId id) void CmdEndPipelineQueries(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); + QueryBundle& queryBundle = commandBuffers.Get(id.id); VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::StatisticsQueryType); n_assert(queryBundle.enabled[CoreGraphics::StatisticsQueryType]); QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::StatisticsQueryType); @@ -1555,16 +1534,16 @@ CmdEndPipelineQueries(const CmdBufferId id) void CmdBeginMarker(const CmdBufferId id, const Math::vec4& color, const char* name) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); #if NEBULA_ENABLE_PROFILING - CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id24); - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id); + QueryBundle& queryBundle = commandBuffers.Get(id.id); VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::TimestampsQueryType); if (queryBundle.enabled[CoreGraphics::TimestampsQueryType]) { QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::TimestampsQueryType); - CoreGraphics::QueueType usage = commandBuffers.Get(id.id24); + CoreGraphics::QueueType usage = commandBuffers.Get(id.id); FrameProfilingMarker marker; marker.color = color; marker.name = name; @@ -1593,15 +1572,15 @@ CmdBeginMarker(const CmdBufferId id, const Math::vec4& color, const char* name) void CmdEndMarker(const CmdBufferId id) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); #if NEBULA_ENABLE_PROFILING - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + QueryBundle& queryBundle = commandBuffers.Get(id.id); VkQueryPool pool = Vulkan::GetQueryPool(CoreGraphics::TimestampsQueryType); if (queryBundle.enabled[CoreGraphics::TimestampsQueryType]) { QueryBundle::QueryChunk& chunk = queryBundle.GetChunk(CoreGraphics::TimestampsQueryType); - CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id24); + CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id); n_assert(!markers.markerStack.IsEmpty()); FrameProfilingMarker marker = markers.markerStack.Pop(); marker.gpuEnd = chunk.offset + chunk.queryCount++; @@ -1623,7 +1602,7 @@ CmdEndMarker(const CmdBufferId id) void CmdInsertMarker(const CmdBufferId id, const Math::vec4& color, const char* name) { - VkCommandBuffer cmdBuf = commandBuffers.Get(id.id24); + VkCommandBuffer cmdBuf = commandBuffers.Get(id.id); alignas(16) float col[4]; color.store(col); @@ -1643,7 +1622,7 @@ CmdInsertMarker(const CmdBufferId id, const Math::vec4& color, const char* name) void CmdFinishQueries(const CmdBufferId id) { - QueryBundle& queryBundle = commandBuffers.Get(id.id24); + QueryBundle& queryBundle = commandBuffers.Get(id.id); for (IndexT i = 0; i < CoreGraphics::QueryType::NumQueryTypes; i++) { // Grab all chunk offsets and counts @@ -1672,7 +1651,7 @@ CmdFinishQueries(const CmdBufferId id) Util::Array CmdCopyProfilingMarkers(const CmdBufferId id) { - CoreGraphics::CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id24); + CoreGraphics::CmdBufferMarkerBundle& markers = commandBuffers.Get(id.id); return markers.finishedMarkers; } @@ -1682,7 +1661,7 @@ CmdCopyProfilingMarkers(const CmdBufferId id) uint CmdGetMarkerOffset(const CmdBufferId id) { - CoreGraphics::QueryBundle& queries = commandBuffers.Get(id.id24); + CoreGraphics::QueryBundle& queries = commandBuffers.Get(id.id); n_assert(queries.enabled[CoreGraphics::QueryType::TimestampsQueryType]); return queries.chunks[CoreGraphics::TimestampsQueryType][0].offset; } diff --git a/code/render/coregraphics/vk/vkevent.cc b/code/render/coregraphics/vk/vkevent.cc index 8d7b359e7..a16f2e98a 100644 --- a/code/render/coregraphics/vk/vkevent.cc +++ b/code/render/coregraphics/vk/vkevent.cc @@ -27,7 +27,7 @@ VkEventAllocator eventAllocator(0x00FFFFFF); const VkEventInfo& EventGetVk(const CoreGraphics::EventId id) { - return eventAllocator.Get(id.id24); + return eventAllocator.Get(id.id); } } @@ -123,9 +123,7 @@ CreateEvent(const EventCreateInfo& info) vkInfo.numMemoryBarriers = 1; } - EventId eventId; - eventId.id24 = id; - eventId.id8 = EventIdType; + EventId eventId = id; return eventId; } @@ -135,10 +133,10 @@ CreateEvent(const EventCreateInfo& info) void DestroyEvent(const EventId id) { - VkEventInfo& vkInfo = eventAllocator.Get(id.id24); - const VkDevice& dev = eventAllocator.Get(id.id24); + VkEventInfo& vkInfo = eventAllocator.Get(id.id); + const VkDevice& dev = eventAllocator.Get(id.id); vkDestroyEvent(dev, vkInfo.event, nullptr); - eventAllocator.Dealloc(id.id24); + eventAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -147,7 +145,7 @@ DestroyEvent(const EventId id) void EventSignal(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGraphics::PipelineStage stage) { - VkEventInfo& info = eventAllocator.Get(id.id24); + VkEventInfo& info = eventAllocator.Get(id.id); vkCmdSetEvent(CmdBufferGetVk(buf), info.event, VkTypes::AsVkPipelineStage(stage)); } @@ -157,7 +155,7 @@ EventSignal(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGra void EventWait(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGraphics::PipelineStage waitStage, const CoreGraphics::PipelineStage signalStage) { - VkEventInfo& info = eventAllocator.Get(id.id24); + VkEventInfo& info = eventAllocator.Get(id.id); vkCmdWaitEvents(CmdBufferGetVk(buf), 1, &info.event, VkTypes::AsVkPipelineStage(waitStage), VkTypes::AsVkPipelineStage(signalStage), @@ -175,7 +173,7 @@ EventWait(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGraph void EventReset(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGraphics::PipelineStage stage) { - VkEventInfo& info = eventAllocator.Get(id.id24); + VkEventInfo& info = eventAllocator.Get(id.id); vkCmdResetEvent(CmdBufferGetVk(buf), info.event, VkTypes::AsVkPipelineStage(stage)); } @@ -185,7 +183,7 @@ EventReset(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGrap void EventWaitAndReset(const EventId id, const CoreGraphics::CmdBufferId buf, const CoreGraphics::PipelineStage waitStage, const CoreGraphics::PipelineStage signalStage) { - VkEventInfo& info = eventAllocator.Get(id.id24); + VkEventInfo& info = eventAllocator.Get(id.id); vkCmdWaitEvents(CmdBufferGetVk(buf), 1, &info.event, VkTypes::AsVkPipelineStage(waitStage), VkTypes::AsVkPipelineStage(signalStage), @@ -204,8 +202,8 @@ EventWaitAndReset(const EventId id, const CoreGraphics::CmdBufferId buf, const C bool EventPoll(const EventId id) { - const VkEventInfo& info = eventAllocator.Get(id.id24); - VkDevice dev = eventAllocator.Get(id.id24); + const VkEventInfo& info = eventAllocator.Get(id.id); + VkDevice dev = eventAllocator.Get(id.id); VkResult res = vkGetEventStatus(dev, info.event); return res == VK_EVENT_SET; } @@ -216,8 +214,8 @@ EventPoll(const EventId id) void EventHostReset(const EventId id) { - const VkEventInfo& info = eventAllocator.Get(id.id24); - VkDevice dev = eventAllocator.Get(id.id24); + const VkEventInfo& info = eventAllocator.Get(id.id); + VkDevice dev = eventAllocator.Get(id.id); vkResetEvent(dev, info.event); } @@ -227,8 +225,8 @@ EventHostReset(const EventId id) void EventHostSignal(const EventId id) { - const VkEventInfo& info = eventAllocator.Get(id.id24); - VkDevice dev = eventAllocator.Get(id.id24); + const VkEventInfo& info = eventAllocator.Get(id.id); + VkDevice dev = eventAllocator.Get(id.id); vkSetEvent(dev, info.event); } @@ -238,8 +236,8 @@ EventHostSignal(const EventId id) void EventHostWait(const EventId id) { - const VkEventInfo& info = eventAllocator.Get(id.id24); - VkDevice dev = eventAllocator.Get(id.id24); + const VkEventInfo& info = eventAllocator.Get(id.id); + VkDevice dev = eventAllocator.Get(id.id); VkResult res; while (true) { diff --git a/code/render/coregraphics/vk/vkfence.cc b/code/render/coregraphics/vk/vkfence.cc index 2f7a0586e..26a2e36c7 100644 --- a/code/render/coregraphics/vk/vkfence.cc +++ b/code/render/coregraphics/vk/vkfence.cc @@ -19,7 +19,7 @@ VkFence FenceGetVk(const CoreGraphics::FenceId id) { if (id == CoreGraphics::FenceId::Invalid()) return VK_NULL_HANDLE; - else return fenceAllocator.Get<1>(id.id24).fence; + else return fenceAllocator.Get<1>(id.id).fence; } } @@ -51,9 +51,7 @@ CreateFence(const FenceCreateInfo& info) fenceAllocator.Get<0>(id) = dev; fenceAllocator.Get<1>(id).fence = fence; - FenceId ret; - ret.id24 = id; - ret.id8 = FenceIdType; + FenceId ret = id; return ret; } @@ -63,10 +61,10 @@ CreateFence(const FenceCreateInfo& info) void DestroyFence(const FenceId id) { - VkFenceInfo& vkInfo = fenceAllocator.Get<1>(id.id24); - const VkDevice& dev = fenceAllocator.Get<0>(id.id24); + VkFenceInfo& vkInfo = fenceAllocator.Get<1>(id.id); + const VkDevice& dev = fenceAllocator.Get<0>(id.id); vkDestroyFence(dev, vkInfo.fence, nullptr); - fenceAllocator.Dealloc(id.id24); + fenceAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -75,7 +73,7 @@ DestroyFence(const FenceId id) bool FencePeek(const FenceId id) { - return vkGetFenceStatus(fenceAllocator.Get<0>(id.id24), fenceAllocator.Get<1>(id.id24).fence) == VK_SUCCESS; + return vkGetFenceStatus(fenceAllocator.Get<0>(id.id), fenceAllocator.Get<1>(id.id).fence) == VK_SUCCESS; } //------------------------------------------------------------------------------ @@ -84,7 +82,7 @@ FencePeek(const FenceId id) bool FenceReset(const FenceId id) { - return vkResetFences(fenceAllocator.Get<0>(id.id24), 1, &fenceAllocator.Get<1>(id.id24).fence) == VK_SUCCESS; + return vkResetFences(fenceAllocator.Get<0>(id.id), 1, &fenceAllocator.Get<1>(id.id).fence) == VK_SUCCESS; } //------------------------------------------------------------------------------ @@ -93,8 +91,8 @@ FenceReset(const FenceId id) bool FenceWait(const FenceId id, const uint64 time) { - VkFence fence = fenceAllocator.Get<1>(id.id24).fence; - VkDevice dev = fenceAllocator.Get<0>(id.id24); + VkFence fence = fenceAllocator.Get<1>(id.id).fence; + VkDevice dev = fenceAllocator.Get<0>(id.id); VkResult res = vkWaitForFences(dev, 1, &fence, false, time); return res == VK_SUCCESS || res == VK_TIMEOUT; } @@ -105,8 +103,8 @@ FenceWait(const FenceId id, const uint64 time) bool FenceWaitAndReset(const FenceId id, const uint64 time) { - VkFence fence = fenceAllocator.Get<1>(id.id24).fence; - VkDevice dev = fenceAllocator.Get<0>(id.id24); + VkFence fence = fenceAllocator.Get<1>(id.id).fence; + VkDevice dev = fenceAllocator.Get<0>(id.id); VkResult res = vkWaitForFences(dev, 1, &fence, false, time); if (res == VK_SUCCESS) { diff --git a/code/render/coregraphics/vk/vkgraphicsdevice.cc b/code/render/coregraphics/vk/vkgraphicsdevice.cc index c5d208e51..249b15e28 100644 --- a/code/render/coregraphics/vk/vkgraphicsdevice.cc +++ b/code/render/coregraphics/vk/vkgraphicsdevice.cc @@ -2567,7 +2567,7 @@ ObjectSetName(const SemaphoreId id, const char* name) VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, nullptr, VK_OBJECT_TYPE_SEMAPHORE, - (uint64_t)SemaphoreGetVk(id.id24), + (uint64_t)SemaphoreGetVk(id.id), name }; VkDevice dev = GetCurrentDevice(); diff --git a/code/render/coregraphics/vk/vkpass.cc b/code/render/coregraphics/vk/vkpass.cc index b1f5215f7..d032018b2 100644 --- a/code/render/coregraphics/vk/vkpass.cc +++ b/code/render/coregraphics/vk/vkpass.cc @@ -23,7 +23,7 @@ VkPassAllocator passAllocator(0x00FFFFFF); const VkRenderPassBeginInfo& PassGetVkRenderPassBeginInfo(const CoreGraphics::PassId& id) { - return passAllocator.Get(id.id24); + return passAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -32,7 +32,7 @@ PassGetVkRenderPassBeginInfo(const CoreGraphics::PassId& id) const VkGraphicsPipelineCreateInfo& PassGetVkFramebufferInfo(const CoreGraphics::PassId& id) { - return passAllocator.Get(id.id24).framebufferPipelineInfo; + return passAllocator.Get(id.id).framebufferPipelineInfo; } //------------------------------------------------------------------------------ @@ -41,7 +41,7 @@ PassGetVkFramebufferInfo(const CoreGraphics::PassId& id) const SizeT PassGetVkNumAttachments(const CoreGraphics::PassId& id) { - return passAllocator.Get(id.id24).attachments.Size(); + return passAllocator.Get(id.id).attachments.Size(); } //------------------------------------------------------------------------------ @@ -50,7 +50,7 @@ PassGetVkNumAttachments(const CoreGraphics::PassId& id) const VkDevice PassGetVkDevice(const CoreGraphics::PassId& id) { - return passAllocator.Get(id.id24).dev; + return passAllocator.Get(id.id).dev; } //------------------------------------------------------------------------------ @@ -59,7 +59,7 @@ PassGetVkDevice(const CoreGraphics::PassId& id) const VkFramebuffer PassGetVkFramebuffer(const CoreGraphics::PassId& id) { - return passAllocator.Get(id.id24).framebuffer; + return passAllocator.Get(id.id).framebuffer; } //------------------------------------------------------------------------------ @@ -68,7 +68,7 @@ PassGetVkFramebuffer(const CoreGraphics::PassId& id) const VkRenderPass PassGetVkRenderPass(const CoreGraphics::PassId& id) { - return passAllocator.Get(id.id24).pass; + return passAllocator.Get(id.id).pass; } } // namespace Vulkan @@ -473,7 +473,7 @@ GetSubpassInfo( void SetupPass(const PassId pid) { - Ids::Id32 id = pid.id24; + Ids::Id32 id = pid.id; VkPassLoadInfo& loadInfo = passAllocator.Get(id); VkPassRuntimeInfo& runtimeInfo = passAllocator.Get(id); VkRenderPassBeginInfo& beginInfo = passAllocator.Get(id); @@ -705,10 +705,7 @@ CreatePass(const PassCreateInfo& info) } } - PassId ret; - ret.id24 = id; - ret.id8 = PassIdType; - + PassId ret = id; SetupPass(ret); return ret; @@ -720,8 +717,8 @@ CreatePass(const PassCreateInfo& info) void DestroyPass(const PassId id) { - VkPassLoadInfo& loadInfo = passAllocator.Get(id.id24); - VkPassRuntimeInfo& runtimeInfo = passAllocator.Get(id.id24); + VkPassLoadInfo& loadInfo = passAllocator.Get(id.id); + VkPassRuntimeInfo& runtimeInfo = passAllocator.Get(id.id); for (IndexT i = 0; i < loadInfo.attachments.Size(); i++) CoreGraphics::DestroyTextureView(loadInfo.attachments[i]); @@ -741,7 +738,7 @@ DestroyPass(const PassId id) void PassWindowResizeCallback(const PassId id) { - VkPassLoadInfo& loadInfo = passAllocator.Get(id.id24); + VkPassLoadInfo& loadInfo = passAllocator.Get(id.id); // destroy pass and our descriptor set vkDestroyRenderPass(loadInfo.dev, loadInfo.pass, nullptr); @@ -761,7 +758,7 @@ PassWindowResizeCallback(const PassId id) const Util::Array& PassGetAttachments(const CoreGraphics::PassId id) { - return passAllocator.Get(id.id24).attachments; + return passAllocator.Get(id.id).attachments; } //------------------------------------------------------------------------------ @@ -770,7 +767,7 @@ PassGetAttachments(const CoreGraphics::PassId id) const uint32_t PassGetNumSubpassAttachments(const CoreGraphics::PassId id, const IndexT subpass) { - return passAllocator.Get(id.id24)[subpass]; + return passAllocator.Get(id.id)[subpass]; } //------------------------------------------------------------------------------ @@ -779,7 +776,7 @@ PassGetNumSubpassAttachments(const CoreGraphics::PassId id, const IndexT subpass const CoreGraphics::ResourceTableId PassGetResourceTable(const CoreGraphics::PassId id) { - VkPassRuntimeInfo& runtimeInfo = passAllocator.Get(id.id24); + VkPassRuntimeInfo& runtimeInfo = passAllocator.Get(id.id); return runtimeInfo.passDescriptorSet; } @@ -789,7 +786,7 @@ PassGetResourceTable(const CoreGraphics::PassId id) const Util::StringAtom PassGetName(const CoreGraphics::PassId id) { - return passAllocator.Get(id.id24).name; + return passAllocator.Get(id.id).name; } //------------------------------------------------------------------------------ @@ -798,7 +795,7 @@ PassGetName(const CoreGraphics::PassId id) const Util::FixedArray>& PassGetRects(const CoreGraphics::PassId& id) { - const VkPassRuntimeInfo& info = passAllocator.Get(id.id24); + const VkPassRuntimeInfo& info = passAllocator.Get(id.id); return info.subpassRects[info.currentSubpassIndex]; } @@ -808,7 +805,7 @@ PassGetRects(const CoreGraphics::PassId& id) const Util::FixedArray>& PassGetViewports(const CoreGraphics::PassId& id) { - const VkPassRuntimeInfo& info = passAllocator.Get(id.id24); + const VkPassRuntimeInfo& info = passAllocator.Get(id.id); return info.subpassViewports[info.currentSubpassIndex]; } diff --git a/code/render/coregraphics/vk/vkpipeline.cc b/code/render/coregraphics/vk/vkpipeline.cc index 305ce1853..fd65712d8 100644 --- a/code/render/coregraphics/vk/vkpipeline.cc +++ b/code/render/coregraphics/vk/vkpipeline.cc @@ -72,7 +72,7 @@ CreateGraphicsPipeline(const PipelineCreateInfo& info) obj.pipeline = pipeline; obj.layout = programInfo.layout; obj.pass = info.pass; - return PipelineId{ ret, PipelineIdType }; + return PipelineId{ ret }; } //------------------------------------------------------------------------------ @@ -81,9 +81,9 @@ CreateGraphicsPipeline(const PipelineCreateInfo& info) void DestroyGraphicsPipeline(const PipelineId pipeline) { - Pipeline& obj = pipelineAllocator.Get<0>(pipeline.id24); + Pipeline& obj = pipelineAllocator.Get<0>(pipeline.id); vkDestroyPipeline(Vulkan::GetCurrentDevice(), obj.pipeline, nullptr); - pipelineAllocator.Dealloc(pipeline.id24); + pipelineAllocator.Dealloc(pipeline.id); } //------------------------------------------------------------------------------ @@ -388,9 +388,7 @@ CreateRaytracingPipeline(const Util::Array progra Ids::Id32 id = pipelineAllocator.Alloc(); pipelineAllocator.Set(id, { .pipeline = pipeline, .layout = createInfo.layout, .pass = InvalidPassId }); - PipelineId pipeId; - pipeId.id24 = id; - pipeId.id8 = PipelineIdType; + PipelineId pipeId = id; ret.pipeline = pipeId; return ret; @@ -406,9 +404,9 @@ DestroyRaytracingPipeline(const PipelineRayTracingTable& table) CoreGraphics::DestroyBuffer(table.missBindingBuffer); CoreGraphics::DestroyBuffer(table.hitBindingBuffer); CoreGraphics::DestroyBuffer(table.callableBindingBuffer); - Pipeline& obj = pipelineAllocator.Get<0>(table.pipeline.id24); + Pipeline& obj = pipelineAllocator.Get<0>(table.pipeline.id); vkDestroyPipeline(Vulkan::GetCurrentDevice(), obj.pipeline, nullptr); - pipelineAllocator.Dealloc(table.pipeline.id24); + pipelineAllocator.Dealloc(table.pipeline.id); } } // namespace CoreGraphics diff --git a/code/render/coregraphics/vk/vkresourcetable.cc b/code/render/coregraphics/vk/vkresourcetable.cc index ae8abb820..1d5fb20ad 100644 --- a/code/render/coregraphics/vk/vkresourcetable.cc +++ b/code/render/coregraphics/vk/vkresourcetable.cc @@ -29,7 +29,7 @@ VkDescriptorSetLayout EmptySetLayout; const VkDescriptorSet& ResourceTableGetVkDescriptorSet(CoreGraphics::ResourceTableId id) { - return resourceTableAllocator.Get(id.id24); + return resourceTableAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -38,7 +38,7 @@ ResourceTableGetVkDescriptorSet(CoreGraphics::ResourceTableId id) const IndexT ResourceTableGetVkPoolIndex(CoreGraphics::ResourceTableId id) { - return resourceTableAllocator.Get(id.id24); + return resourceTableAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -47,7 +47,7 @@ ResourceTableGetVkPoolIndex(CoreGraphics::ResourceTableId id) const VkDevice& ResourceTableGetVkDevice(CoreGraphics::ResourceTableId id) { - return resourceTableAllocator.Get(id.id24); + return resourceTableAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -88,7 +88,7 @@ SetupEmptyDescriptorSetLayout() const VkDescriptorSetLayout& ResourceTableLayoutGetVk(const CoreGraphics::ResourceTableLayoutId& id) { - return resourceTableLayoutAllocator.Get(id.id24); + return resourceTableLayoutAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -97,14 +97,14 @@ ResourceTableLayoutGetVk(const CoreGraphics::ResourceTableLayoutId& id) void ResourceTableLayoutAllocTable(const CoreGraphics::ResourceTableLayoutId& id, const VkDevice dev, uint overallocationSize, IndexT& outIndex, VkDescriptorSet& outSet) { - Util::Array& freeItems = resourceTableLayoutAllocator.Get(id.id24); + Util::Array& freeItems = resourceTableLayoutAllocator.Get(id.id); VkDescriptorPool pool = VK_NULL_HANDLE; for (IndexT i = 0; i < freeItems.Size(); i++) { // if free, return if (freeItems[i] > 0) { - pool = resourceTableLayoutAllocator.Get(id.id24)[i]; + pool = resourceTableLayoutAllocator.Get(id.id)[i]; outIndex = i; break; } @@ -113,7 +113,7 @@ ResourceTableLayoutAllocTable(const CoreGraphics::ResourceTableLayoutId& id, con // no pool found, allocate new pool if (pool == VK_NULL_HANDLE) { - Util::Array poolSizes = resourceTableLayoutAllocator.Get(id.id24); + Util::Array poolSizes = resourceTableLayoutAllocator.Get(id.id); for (IndexT i = 0; i < poolSizes.Size(); i++) { poolSizes[i].descriptorCount *= overallocationSize; @@ -134,9 +134,9 @@ ResourceTableLayoutAllocTable(const CoreGraphics::ResourceTableLayoutId& id, con n_assert(res == VK_SUCCESS); // add to list of pools, and set new pointer to the new pool - resourceTableLayoutAllocator.Get(id.id24).Append(pool); + resourceTableLayoutAllocator.Get(id.id).Append(pool); freeItems.Append(overallocationSize); - outIndex = resourceTableLayoutAllocator.Get(id.id24).Size() - 1; + outIndex = resourceTableLayoutAllocator.Get(id.id).Size() - 1; } VkDescriptorSetAllocateInfo dsetAlloc = @@ -161,10 +161,10 @@ ResourceTableLayoutAllocTable(const CoreGraphics::ResourceTableLayoutId& id, con void ResourceTableLayoutDeallocTable(const CoreGraphics::ResourceTableLayoutId& id, const VkDevice dev, const VkDescriptorSet& set, const IndexT index) { - VkDescriptorPool& pool = resourceTableLayoutAllocator.Get(id.id24)[index]; + VkDescriptorPool& pool = resourceTableLayoutAllocator.Get(id.id)[index]; VkResult res = vkFreeDescriptorSets(dev, pool, 1, &set); n_assert(res == VK_SUCCESS); - resourceTableLayoutAllocator.Get(id.id24)[index]++; + resourceTableLayoutAllocator.Get(id.id)[index]++; } //------------------------------------------------------------------------------ @@ -173,7 +173,7 @@ ResourceTableLayoutDeallocTable(const CoreGraphics::ResourceTableLayoutId& id, c const VkDescriptorPool& ResourceTableLayoutGetVkDescriptorPool(const CoreGraphics::ResourceTableLayoutId& id, const IndexT index) { - return resourceTableLayoutAllocator.Get(id.id24)[index]; + return resourceTableLayoutAllocator.Get(id.id)[index]; } //------------------------------------------------------------------------------ @@ -182,7 +182,7 @@ ResourceTableLayoutGetVkDescriptorPool(const CoreGraphics::ResourceTableLayoutId uint* ResourceTableLayoutGetFreeItemsCounter(const CoreGraphics::ResourceTableLayoutId& id, const IndexT index) { - Util::Array& freeItems = resourceTableLayoutAllocator.Get(id.id24); + Util::Array& freeItems = resourceTableLayoutAllocator.Get(id.id); return &freeItems[index]; } @@ -192,7 +192,7 @@ ResourceTableLayoutGetFreeItemsCounter(const CoreGraphics::ResourceTableLayoutId const VkPipelineLayout& ResourcePipelineGetVk(const CoreGraphics::ResourcePipelineId& id) { - return resourcePipelineAllocator.Get<1>(id.id24); + return resourcePipelineAllocator.Get<1>(id.id); } } // namespace Vulkan @@ -223,9 +223,7 @@ CreateResourceTable(const ResourceTableCreateInfo& info) layout = info.layout; ResourceTableLayoutAllocTable(layout, dev, info.overallocationSize, poolIndex, set); - ResourceTableId ret; - ret.id24 = id; - ret.id8 = ResourceTableIdType; + ResourceTableId ret = id; return ret; } @@ -238,7 +236,7 @@ DestroyResourceTable(const ResourceTableId id) n_assert(id != InvalidResourceTableId); CoreGraphics::DelayedDeleteDescriptorSet(id); - resourceTableAllocator.Dealloc(id.id24); + resourceTableAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -247,7 +245,7 @@ DestroyResourceTable(const ResourceTableId id) const ResourceTableLayoutId& ResourceTableGetLayout(ResourceTableId id) { - return resourceTableAllocator.Get(id.id24); + return resourceTableAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -256,12 +254,12 @@ ResourceTableGetLayout(ResourceTableId id) void ResourceTableCopy(const ResourceTableId from, IndexT fromSlot, IndexT fromIndex, const ResourceTableId to, IndexT toSlot, IndexT toIndex, const SizeT numResources) { - VkDescriptorSet& fromSet = resourceTableAllocator.Get(from.id24); - VkDescriptorSet& toSet = resourceTableAllocator.Get(to.id24); + VkDescriptorSet& fromSet = resourceTableAllocator.Get(from.id); + VkDescriptorSet& toSet = resourceTableAllocator.Get(to.id); - Threading::SpinlockScope scope1(&resourceTableAllocator.Get(from.id24)); - Threading::SpinlockScope scope2(&resourceTableAllocator.Get(to.id24)); - Util::Array& copies = resourceTableAllocator.Get(to.id24); + Threading::SpinlockScope scope1(&resourceTableAllocator.Get(from.id)); + Threading::SpinlockScope scope2(&resourceTableAllocator.Get(to.id)); + Util::Array& copies = resourceTableAllocator.Get(to.id); VkCopyDescriptorSet copy = { @@ -284,10 +282,10 @@ ResourceTableCopy(const ResourceTableId from, IndexT fromSlot, IndexT fromIndex, void ResourceTableSetTexture(const ResourceTableId id, const ResourceTableTexture& tex) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(tex.slot != InvalidIndex); @@ -295,8 +293,8 @@ ResourceTableSetTexture(const ResourceTableId id, const ResourceTableTexture& te write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; write.pNext = nullptr; - const CoreGraphics::ResourceTableLayoutId& layout = resourceTableAllocator.Get(id.id24); - const Util::HashTable& immutable = resourceTableLayoutAllocator.Get(layout.id24); + const CoreGraphics::ResourceTableLayoutId& layout = resourceTableAllocator.Get(id.id); + const Util::HashTable& immutable = resourceTableLayoutAllocator.Get(layout.id); VkDescriptorImageInfo img; if (immutable[tex.slot]) @@ -341,10 +339,10 @@ ResourceTableSetTexture(const ResourceTableId id, const ResourceTableTexture& te void ResourceTableSetTexture(const ResourceTableId id, const ResourceTableTextureView& tex) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(tex.slot != InvalidIndex); @@ -352,8 +350,8 @@ ResourceTableSetTexture(const ResourceTableId id, const ResourceTableTextureView write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; write.pNext = nullptr; - const CoreGraphics::ResourceTableLayoutId& layout = resourceTableAllocator.Get(id.id24); - const Util::HashTable& immutable = resourceTableLayoutAllocator.Get(layout.id24); + const CoreGraphics::ResourceTableLayoutId& layout = resourceTableAllocator.Get(id.id); + const Util::HashTable& immutable = resourceTableLayoutAllocator.Get(layout.id); VkDescriptorImageInfo img; if (immutable[tex.slot]) @@ -396,10 +394,10 @@ ResourceTableSetTexture(const ResourceTableId id, const ResourceTableTextureView void ResourceTableSetInputAttachment(const ResourceTableId id, const ResourceTableInputAttachment& tex) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(tex.slot != InvalidIndex); @@ -436,10 +434,10 @@ ResourceTableSetInputAttachment(const ResourceTableId id, const ResourceTableInp void ResourceTableSetRWTexture(const ResourceTableId id, const ResourceTableTexture& tex) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(tex.slot != InvalidIndex); @@ -476,10 +474,10 @@ ResourceTableSetRWTexture(const ResourceTableId id, const ResourceTableTexture& void ResourceTableSetRWTexture(const ResourceTableId id, const ResourceTableTextureView& tex) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(tex.slot != InvalidIndex); @@ -517,10 +515,10 @@ void ResourceTableSetConstantBuffer(const ResourceTableId id, const ResourceTableBuffer& buf) { n_assert(!buf.texelBuffer); - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(buf.slot != InvalidIndex); @@ -564,10 +562,10 @@ ResourceTableSetConstantBuffer(const ResourceTableId id, const ResourceTableBuff void ResourceTableSetRWBuffer(const ResourceTableId id, const ResourceTableBuffer& buf) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(buf.slot != InvalidIndex); @@ -610,10 +608,10 @@ ResourceTableSetRWBuffer(const ResourceTableId id, const ResourceTableBuffer& bu void ResourceTableSetSampler(const ResourceTableId id, const ResourceTableSampler& samp) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(samp.slot != InvalidIndex); @@ -650,10 +648,10 @@ ResourceTableSetSampler(const ResourceTableId id, const ResourceTableSampler& sa void ResourceTableSetAccelerationStructure(const ResourceTableId id, const ResourceTableTlas& tlas) { - VkDescriptorSet& set = resourceTableAllocator.Get(id.id24); + VkDescriptorSet& set = resourceTableAllocator.Get(id.id); - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); n_assert(tlas.slot != InvalidIndex); @@ -694,10 +692,10 @@ ResourceTableCommitChanges(const ResourceTableId id) n_assert(!ResourceTableBlocked); // resource tables are blocked, add to pending write queue - Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id24)); - Util::Array& infoList = resourceTableAllocator.Get(id.id24); - Util::Array& copies = resourceTableAllocator.Get(id.id24); - VkDevice& dev = resourceTableAllocator.Get(id.id24); + Threading::SpinlockScope scope(&resourceTableAllocator.Get(id.id)); + Util::Array& infoList = resourceTableAllocator.Get(id.id); + Util::Array& copies = resourceTableAllocator.Get(id.id); + VkDevice& dev = resourceTableAllocator.Get(id.id); // because we store the write-infos in the other list, and the VkWriteDescriptorSet wants a pointer to the structure // we need to re-assign the pointers, but thankfully they have values from before @@ -1075,10 +1073,7 @@ CreateResourceTableLayout(const ResourceTableLayoutCreateInfo& info) n_assert(res == VK_SUCCESS); } - ResourceTableLayoutId ret; - ret.id24 = id; - ret.id8 = ResourceTableLayoutIdType; - + ResourceTableLayoutId ret = id; return ret; } @@ -1088,18 +1083,18 @@ CreateResourceTableLayout(const ResourceTableLayoutCreateInfo& info) void DestroyResourceTableLayout(const ResourceTableLayoutId& id) { - VkDevice& dev = resourceTableLayoutAllocator.Get(id.id24); - VkDescriptorSetLayout& layout = resourceTableLayoutAllocator.Get(id.id24); + VkDevice& dev = resourceTableLayoutAllocator.Get(id.id); + VkDescriptorSetLayout& layout = resourceTableLayoutAllocator.Get(id.id); vkDestroyDescriptorSetLayout(dev, layout, nullptr); // destroy all pools - Util::Array& pools = resourceTableLayoutAllocator.Get(id.id24); + Util::Array& pools = resourceTableLayoutAllocator.Get(id.id); for (IndexT i = 0; i < pools.Size(); i++) vkDestroyDescriptorPool(dev, pools[i], nullptr); pools.Clear(); - resourceTableLayoutAllocator.Dealloc(id.id24); + resourceTableLayoutAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -1123,7 +1118,7 @@ CreateResourcePipeline(const ResourcePipelineCreateInfo& info) { layouts.Append(EmptySetLayout); } - layouts.Append(resourceTableLayoutAllocator.Get(info.tables[i].id24)); + layouts.Append(resourceTableLayoutAllocator.Get(info.tables[i].id)); } VkPushConstantRange push; @@ -1144,9 +1139,7 @@ CreateResourcePipeline(const ResourcePipelineCreateInfo& info) VkResult res = vkCreatePipelineLayout(dev, &crInfo, nullptr, &layout); n_assert(res == VK_SUCCESS); - ResourcePipelineId ret; - ret.id24 = id; - ret.id8 = ResourcePipelineIdType; + ResourcePipelineId ret = id; return ret; } @@ -1156,11 +1149,11 @@ CreateResourcePipeline(const ResourcePipelineCreateInfo& info) void DestroyResourcePipeline(const ResourcePipelineId& id) { - VkDevice& dev = resourcePipelineAllocator.Get<0>(id.id24); - VkPipelineLayout& layout = resourcePipelineAllocator.Get<1>(id.id24); + VkDevice& dev = resourcePipelineAllocator.Get<0>(id.id); + VkPipelineLayout& layout = resourcePipelineAllocator.Get<1>(id.id); vkDestroyPipelineLayout(dev, layout, nullptr); - resourcePipelineAllocator.Dealloc(id.id24); + resourcePipelineAllocator.Dealloc(id.id); } } // namespace CoreGraphics diff --git a/code/render/coregraphics/vk/vksampler.cc b/code/render/coregraphics/vk/vksampler.cc index 587208d38..b3a2d23b7 100644 --- a/code/render/coregraphics/vk/vksampler.cc +++ b/code/render/coregraphics/vk/vksampler.cc @@ -17,7 +17,7 @@ VkSamplerAllocator samplerAllocator; const VkSampler& SamplerGetVk(const CoreGraphics::SamplerId& id) { - return samplerAllocator.Get<1>(id.id24); + return samplerAllocator.Get<1>(id.id); } } // namespace Vulkan @@ -262,16 +262,12 @@ CreateSampler(const SamplerCreateInfo& info) UniqueSamplerHashes.Add(hash, id); - SamplerId ret; - ret.id24 = id; - ret.id8 = SamplerIdType; + SamplerId ret = id; return ret; } else { - SamplerId ret; - ret.id24 = UniqueSamplerHashes.ValueAtIndex(i); - ret.id8 = SamplerIdType; + SamplerId ret = UniqueSamplerHashes.ValueAtIndex(i); return ret; } } @@ -282,12 +278,12 @@ CreateSampler(const SamplerCreateInfo& info) void DestroySampler(const SamplerId& id) { - UniqueSamplerHashes.Erase(samplerAllocator.Get<2>(id.id24)); - VkDevice& dev = samplerAllocator.Get<0>(id.id24); - VkSampler& sampler = samplerAllocator.Get<1>(id.id24); + UniqueSamplerHashes.Erase(samplerAllocator.Get<2>(id.id)); + VkDevice& dev = samplerAllocator.Get<0>(id.id); + VkSampler& sampler = samplerAllocator.Get<1>(id.id); vkDestroySampler(dev, sampler, nullptr); - samplerAllocator.Dealloc(id.id24); + samplerAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ diff --git a/code/render/coregraphics/vk/vksemaphore.cc b/code/render/coregraphics/vk/vksemaphore.cc index 706c1f742..2603d059a 100644 --- a/code/render/coregraphics/vk/vksemaphore.cc +++ b/code/render/coregraphics/vk/vksemaphore.cc @@ -22,7 +22,7 @@ VkSemaphore SemaphoreGetVk(const CoreGraphics::SemaphoreId& id) { if (id == CoreGraphics::SemaphoreId::Invalid()) return VK_NULL_HANDLE; - else return semaphoreAllocator.Get(id.id24); + else return semaphoreAllocator.Get(id.id); } } @@ -58,9 +58,7 @@ CreateSemaphore(const SemaphoreCreateInfo& info) VkResult res = vkCreateSemaphore(dev, &cinfo, nullptr, &semaphoreAllocator.Get(id)); n_assert(res == VK_SUCCESS); - SemaphoreId ret; - ret.id24 = id; - ret.id8 = SemaphoreIdType; + SemaphoreId ret = id; return ret; } @@ -70,8 +68,8 @@ CreateSemaphore(const SemaphoreCreateInfo& info) void DestroySemaphore(const SemaphoreId& semaphore) { - vkDestroySemaphore(semaphoreAllocator.Get(semaphore.id24), semaphoreAllocator.Get(semaphore.id24), nullptr); - semaphoreAllocator.Dealloc(semaphore.id24); + vkDestroySemaphore(semaphoreAllocator.Get(semaphore.id), semaphoreAllocator.Get(semaphore.id), nullptr); + semaphoreAllocator.Dealloc(semaphore.id); } //------------------------------------------------------------------------------ @@ -80,7 +78,7 @@ DestroySemaphore(const SemaphoreId& semaphore) uint64 SemaphoreGetValue(const SemaphoreId& semaphore) { - return semaphoreAllocator.Get(semaphore.id24); + return semaphoreAllocator.Get(semaphore.id); } //------------------------------------------------------------------------------ @@ -89,13 +87,13 @@ SemaphoreGetValue(const SemaphoreId& semaphore) void SemaphoreSignal(const SemaphoreId& semaphore) { - switch (semaphoreAllocator.Get(semaphore.id24)) + switch (semaphoreAllocator.Get(semaphore.id)) { case SemaphoreType::Binary: - semaphoreAllocator.Get(semaphore.id24) = 1; + semaphoreAllocator.Get(semaphore.id) = 1; break; case SemaphoreType::Timeline: - semaphoreAllocator.Get(semaphore.id24)++; + semaphoreAllocator.Get(semaphore.id)++; break; } } @@ -106,10 +104,10 @@ SemaphoreSignal(const SemaphoreId& semaphore) void SemaphoreReset(const SemaphoreId& semaphore) { - switch (semaphoreAllocator.Get(semaphore.id24)) + switch (semaphoreAllocator.Get(semaphore.id)) { case SemaphoreType::Binary: - semaphoreAllocator.Get(semaphore.id24) = 0; + semaphoreAllocator.Get(semaphore.id) = 0; break; default: n_error("unhandled enum"); break; } @@ -117,4 +115,4 @@ SemaphoreReset(const SemaphoreId& semaphore) } // namespace Vulkan -#pragma pop_macro("CreateSemaphore") \ No newline at end of file +#pragma pop_macro("CreateSemaphore") diff --git a/code/render/coregraphics/vk/vkshader.cc b/code/render/coregraphics/vk/vkshader.cc index 08715396e..d77710e4b 100644 --- a/code/render/coregraphics/vk/vkshader.cc +++ b/code/render/coregraphics/vk/vkshader.cc @@ -521,14 +521,12 @@ CreateShader(const ShaderCreateInfo& info) // load effect from memory AnyFX::ShaderEffect* effect = info.effect; - uint32_t id = shaderAlloc.Alloc(); + Ids::Id32 id = shaderAlloc.Alloc(); VkReflectionInfo& reflectionInfo = shaderAlloc.Get(id); VkShaderSetupInfo& setupInfo = shaderAlloc.Get(id); VkShaderRuntimeInfo& runtimeInfo = shaderAlloc.Get(id); - ShaderId ret; - ret.resourceId = id; - ret.resourceType = CoreGraphics::ShaderIdType; + ShaderId ret = id; setupInfo.id = ShaderIdentifier::FromName(info.name); setupInfo.name = info.name; @@ -620,9 +618,8 @@ CreateShader(const ShaderCreateInfo& info) // make an ID which is the shader id and program id ShaderProgramId shaderProgramId; + shaderProgramId.shader = ret.id; shaderProgramId.programId = programId; - shaderProgramId.shaderId = ret.resourceId; - shaderProgramId.shaderType = ret.resourceType; runtimeInfo.programMap.Add(shaderProgramAlloc.Get(programId).mask, shaderProgramId); } @@ -646,8 +643,8 @@ CreateShader(const ShaderCreateInfo& info) void DeleteShader(const ShaderId id) { - VkShaderSetupInfo& setup = shaderAlloc.Get(id.resourceId); - VkShaderRuntimeInfo& runtime = shaderAlloc.Get(id.resourceId); + VkShaderSetupInfo& setup = shaderAlloc.Get(id.id); + VkShaderRuntimeInfo& runtime = shaderAlloc.Get(id.id); ShaderCleanup(setup.dev, setup.immutableSamplers, setup.descriptorSetLayouts, setup.uniformBufferMap, setup.pipelineLayout); for (IndexT i = 0; i < runtime.programMap.Size(); i++) @@ -666,7 +663,7 @@ void DestroyShader(const ShaderId id) { DeleteShader(id); - shaderAlloc.Dealloc(id.resourceId); + shaderAlloc.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -676,9 +673,9 @@ void ReloadShader(const ShaderId id, const AnyFX::ShaderEffect* effect) { DeleteShader(id); - VkReflectionInfo& reflectionInfo = shaderAlloc.Get(id.resourceId); - VkShaderSetupInfo& setupInfo = shaderAlloc.Get(id.resourceId); - VkShaderRuntimeInfo& runtimeInfo = shaderAlloc.Get(id.resourceId); + VkReflectionInfo& reflectionInfo = shaderAlloc.Get(id.id); + VkShaderSetupInfo& setupInfo = shaderAlloc.Get(id.id); + VkShaderRuntimeInfo& runtimeInfo = shaderAlloc.Get(id.id); reflectionInfo.uniformBuffers.Clear(); reflectionInfo.uniformBuffersByName.Clear(); @@ -755,7 +752,7 @@ ReloadShader(const ShaderId id, const AnyFX::ShaderEffect* effect) CoreGraphics::ShaderProgramId ShaderGetShaderProgram(const CoreGraphics::ShaderId shaderId, const CoreGraphics::ShaderFeature::Mask mask) { - VkShaderRuntimeInfo& runtime = shaderAlloc.Get(shaderId.resourceId); + VkShaderRuntimeInfo& runtime = shaderAlloc.Get(shaderId.id); IndexT i = runtime.programMap.FindIndex(mask); if (i == InvalidIndex) return CoreGraphics::InvalidShaderProgramId; else return runtime.programMap.ValueAtIndex(i); @@ -767,7 +764,7 @@ ShaderGetShaderProgram(const CoreGraphics::ShaderId shaderId, const CoreGraphics const CoreGraphics::ResourceTableId ShaderCreateResourceTable(const CoreGraphics::ShaderId id, const IndexT group, const uint overallocationSize) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); IndexT idx = info.descriptorSetLayoutMap.FindIndex(group); if (idx == InvalidIndex) return CoreGraphics::InvalidResourceTableId; else @@ -787,7 +784,7 @@ ShaderCreateResourceTable(const CoreGraphics::ShaderId id, const IndexT group, c ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); IndexT idx = info.descriptorSetLayoutMap.FindIndex(group); if (idx == InvalidIndex) return CoreGraphics::ResourceTableSet(); else @@ -807,7 +804,7 @@ ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint o const bool ShaderHasResourceTable(const ShaderId id, const IndexT group) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); return info.descriptorSetLayoutMap.FindIndex(group) != InvalidIndex; } @@ -817,7 +814,7 @@ ShaderHasResourceTable(const ShaderId id, const IndexT group) const CoreGraphics::BufferId ShaderCreateConstantBuffer(const CoreGraphics::ShaderId id, const Util::StringAtom& name, CoreGraphics::BufferAccessMode mode) { - const auto& uniformBuffers = shaderAlloc.Get(id.resourceId).uniformBuffersByName; + const auto& uniformBuffers = shaderAlloc.Get(id.id).uniformBuffersByName; IndexT i = uniformBuffers.FindIndex(name); if (i != InvalidIndex) { @@ -849,7 +846,7 @@ ShaderCreateConstantBuffer(const CoreGraphics::ShaderId id, const Util::StringAt const CoreGraphics::BufferId ShaderCreateConstantBuffer(const CoreGraphics::ShaderId id, const IndexT cbIndex, CoreGraphics::BufferAccessMode mode) { - const auto& uniformBuffers = shaderAlloc.Get(id.resourceId).uniformBuffers; + const auto& uniformBuffers = shaderAlloc.Get(id.id).uniformBuffers; const VkReflectionInfo::UniformBuffer& buffer = uniformBuffers[cbIndex]; if (buffer.byteSize > 0) { @@ -875,7 +872,7 @@ ShaderCreateConstantBuffer(const CoreGraphics::ShaderId id, const IndexT cbIndex const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT group, const IndexT cbIndex, BufferAccessMode mode) { - const auto& uniformBuffers = shaderAlloc.Get(id.resourceId).uniformBuffersPerSet; + const auto& uniformBuffers = shaderAlloc.Get(id.id).uniformBuffersPerSet; const auto& buffer = uniformBuffers[group][cbIndex]; if (buffer.byteSize > 0) { @@ -913,7 +910,7 @@ ShaderCalculateConstantBufferIndex(const uint64 bindingMask, const IndexT slot) const IndexT ShaderGetConstantBinding(const CoreGraphics::ShaderId id, const Util::StringAtom& name) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); IndexT index = info.constantBindings.FindIndex(name.Value()); if (index == InvalidIndex) return INT32_MAX; // invalid binding else return info.constantBindings.ValueAtIndex(index); @@ -925,7 +922,7 @@ ShaderGetConstantBinding(const CoreGraphics::ShaderId id, const Util::StringAtom const IndexT ShaderGetConstantBinding(const CoreGraphics::ShaderId id, const IndexT cIndex) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); return info.constantBindings.ValueAtIndex(cIndex); } @@ -935,7 +932,7 @@ ShaderGetConstantBinding(const CoreGraphics::ShaderId id, const IndexT cIndex) const SizeT ShaderGetConstantBindingsCount(const CoreGraphics::ShaderId id) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); return info.constantBindings.Size(); } @@ -945,7 +942,7 @@ ShaderGetConstantBindingsCount(const CoreGraphics::ShaderId id) CoreGraphics::ResourceTableLayoutId ShaderGetResourceTableLayout(const CoreGraphics::ShaderId id, const IndexT group) { - const VkShaderSetupInfo& setupInfo = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& setupInfo = shaderAlloc.Get(id.id); uint layout = setupInfo.descriptorSetLayoutMap[group]; return Util::Get<1>(setupInfo.descriptorSetLayouts[layout]); } @@ -956,7 +953,7 @@ ShaderGetResourceTableLayout(const CoreGraphics::ShaderId id, const IndexT group CoreGraphics::ResourcePipelineId ShaderGetResourcePipeline(const CoreGraphics::ShaderId id) { - return shaderAlloc.Get(id.resourceId).pipelineLayout; + return shaderAlloc.Get(id.id).pipelineLayout; } //------------------------------------------------------------------------------ @@ -965,7 +962,7 @@ ShaderGetResourcePipeline(const CoreGraphics::ShaderId id) const Resources::ResourceName ShaderGetName(const ShaderId id) { - return shaderAlloc.Get(id.resourceId).name; + return shaderAlloc.Get(id.id).name; } //------------------------------------------------------------------------------ @@ -974,7 +971,7 @@ ShaderGetName(const ShaderId id) const SizeT ShaderGetConstantCount(const CoreGraphics::ShaderId id) { - return shaderAlloc.Get(id.resourceId).variables.Size(); + return shaderAlloc.Get(id.id).variables.Size(); } //------------------------------------------------------------------------------ @@ -983,7 +980,7 @@ ShaderGetConstantCount(const CoreGraphics::ShaderId id) const CoreGraphics::ShaderConstantType ShaderGetConstantType(const CoreGraphics::ShaderId id, const IndexT i) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variables[i]; + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variables[i]; switch (var.type) { case AnyFX::Double: @@ -1074,7 +1071,7 @@ ShaderGetConstantType(const CoreGraphics::ShaderId id, const IndexT i) const CoreGraphics::ShaderConstantType ShaderGetConstantType(const CoreGraphics::ShaderId id, const Util::StringAtom& name) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variablesByName[name]; + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variablesByName[name]; switch (var.type) { case AnyFX::Double: @@ -1165,7 +1162,7 @@ ShaderGetConstantType(const CoreGraphics::ShaderId id, const Util::StringAtom& n const Util::StringAtom ShaderGetConstantBlockName(const CoreGraphics::ShaderId id, const Util::StringAtom& name) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variablesByName[name]; + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variablesByName[name]; return var.blockName; } @@ -1175,7 +1172,7 @@ ShaderGetConstantBlockName(const CoreGraphics::ShaderId id, const Util::StringAt const Util::StringAtom ShaderGetConstantBlockName(const CoreGraphics::ShaderId id, const IndexT cIndex) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variables[cIndex]; + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variables[cIndex]; return var.blockName; } @@ -1185,7 +1182,7 @@ ShaderGetConstantBlockName(const CoreGraphics::ShaderId id, const IndexT cIndex) const Util::StringAtom ShaderGetConstantName(const CoreGraphics::ShaderId id, const IndexT i) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variables[i]; + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variables[i]; return var.name; } @@ -1195,10 +1192,10 @@ ShaderGetConstantName(const CoreGraphics::ShaderId id, const IndexT i) const IndexT ShaderGetConstantGroup(const CoreGraphics::ShaderId id, const Util::StringAtom& name) { - IndexT idx = shaderAlloc.Get(id.resourceId).variablesByName.FindIndex(name); + IndexT idx = shaderAlloc.Get(id.id).variablesByName.FindIndex(name); if (idx != InvalidIndex) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variablesByName.ValueAtIndex(idx); + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variablesByName.ValueAtIndex(idx); return var.blockSet; } else @@ -1211,10 +1208,10 @@ ShaderGetConstantGroup(const CoreGraphics::ShaderId id, const Util::StringAtom& const IndexT ShaderGetConstantSlot(const CoreGraphics::ShaderId id, const Util::StringAtom& name) { - IndexT idx = shaderAlloc.Get(id.resourceId).variablesByName.FindIndex(name); + IndexT idx = shaderAlloc.Get(id.id).variablesByName.FindIndex(name); if (idx != InvalidIndex) { - const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.resourceId).variablesByName.ValueAtIndex(idx); + const VkReflectionInfo::Variable& var = shaderAlloc.Get(id.id).variablesByName.ValueAtIndex(idx); return var.blockBinding; } else @@ -1227,7 +1224,7 @@ ShaderGetConstantSlot(const CoreGraphics::ShaderId id, const Util::StringAtom& n const SizeT ShaderGetConstantBufferCount(const CoreGraphics::ShaderId id) { - return shaderAlloc.Get(id.resourceId).uniformBuffers.Size(); + return shaderAlloc.Get(id.id).uniformBuffers.Size(); } //------------------------------------------------------------------------------ @@ -1236,7 +1233,7 @@ ShaderGetConstantBufferCount(const CoreGraphics::ShaderId id) const SizeT ShaderGetConstantBufferSize(const CoreGraphics::ShaderId id, const IndexT i) { - const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.resourceId).uniformBuffers[i]; + const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.id).uniformBuffers[i]; return var.byteSize; } @@ -1246,7 +1243,7 @@ ShaderGetConstantBufferSize(const CoreGraphics::ShaderId id, const IndexT i) const Util::StringAtom ShaderGetConstantBufferName(const CoreGraphics::ShaderId id, const IndexT i) { - const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.resourceId).uniformBuffers[i]; + const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.id).uniformBuffers[i]; return var.name; } @@ -1256,7 +1253,7 @@ ShaderGetConstantBufferName(const CoreGraphics::ShaderId id, const IndexT i) const IndexT ShaderGetConstantBufferResourceSlot(const CoreGraphics::ShaderId id, const IndexT i) { - const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.resourceId).uniformBuffers[i]; + const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.id).uniformBuffers[i]; return var.binding; } @@ -1266,7 +1263,7 @@ ShaderGetConstantBufferResourceSlot(const CoreGraphics::ShaderId id, const Index const IndexT ShaderGetConstantBufferResourceGroup(const CoreGraphics::ShaderId id, const IndexT i) { - const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.resourceId).uniformBuffers[i]; + const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.id).uniformBuffers[i]; return var.set; } @@ -1276,7 +1273,7 @@ ShaderGetConstantBufferResourceGroup(const CoreGraphics::ShaderId id, const Inde const uint64 ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group) { - const auto& masks = shaderAlloc.Get(id.resourceId).uniformBuffersMask; + const auto& masks = shaderAlloc.Get(id.id).uniformBuffersMask; if (masks.Size() > group) return masks[group]; else @@ -1289,7 +1286,7 @@ ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group) const uint64 ShaderGetConstantBufferSize(const ShaderId id, const IndexT group, const IndexT i) { - const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.resourceId).uniformBuffersPerSet[group][i]; + const VkReflectionInfo::UniformBuffer& var = shaderAlloc.Get(id.id).uniformBuffersPerSet[group][i]; return var.byteSize; } @@ -1299,7 +1296,7 @@ ShaderGetConstantBufferSize(const ShaderId id, const IndexT group, const IndexT const IndexT ShaderGetResourceSlot(const CoreGraphics::ShaderId id, const Util::StringAtom& name) { - const VkShaderSetupInfo& info = shaderAlloc.Get(id.resourceId); + const VkShaderSetupInfo& info = shaderAlloc.Get(id.id); IndexT index = info.resourceIndexMap.FindIndex(name); if (index == InvalidIndex) return index; else return info.resourceIndexMap.ValueAtIndex(index); @@ -1311,7 +1308,7 @@ ShaderGetResourceSlot(const CoreGraphics::ShaderId id, const Util::StringAtom& n const Util::Dictionary& ShaderGetPrograms(const CoreGraphics::ShaderId id) { - return shaderAlloc.Get(id.resourceId).programMap; + return shaderAlloc.Get(id.id).programMap; } //------------------------------------------------------------------------------ @@ -1329,7 +1326,7 @@ ShaderGetProgramName(CoreGraphics::ShaderProgramId id) const CoreGraphics::ShaderProgramId ShaderGetProgram(const ShaderId id, const CoreGraphics::ShaderFeature::Mask mask) { - VkShaderRuntimeInfo& runtime = shaderAlloc.Get(id.resourceId); + VkShaderRuntimeInfo& runtime = shaderAlloc.Get(id.id); IndexT i = runtime.programMap.FindIndex(mask); if (i == InvalidIndex) return CoreGraphics::InvalidShaderProgramId; else return runtime.programMap.ValueAtIndex(i); diff --git a/code/render/coregraphics/vk/vkshaderserver.cc b/code/render/coregraphics/vk/vkshaderserver.cc index 70b7a71ed..2f37c054b 100644 --- a/code/render/coregraphics/vk/vkshaderserver.cc +++ b/code/render/coregraphics/vk/vkshaderserver.cc @@ -98,7 +98,7 @@ VkShaderServer::UpdateResources() const _PendingView& pend = pendingViewsThisFrame[i]; TextureIdLock _0(pend.tex); - VkTextureRuntimeInfo& info = textureAllocator.Get(pend.tex.resourceId); + VkTextureRuntimeInfo& info = textureAllocator.Get(pend.tex.id); VkImageView oldView = info.view; VkResult res = vkCreateImageView(GetCurrentDevice(), &pend.createInfo, nullptr, &info.view); n_assert(res == VK_SUCCESS); diff --git a/code/render/coregraphics/vk/vktexture.cc b/code/render/coregraphics/vk/vktexture.cc index 34e8cf44d..520d58bba 100644 --- a/code/render/coregraphics/vk/vktexture.cc +++ b/code/render/coregraphics/vk/vktexture.cc @@ -29,7 +29,7 @@ VkTextureSparseExtensionAllocator textureSparseExtensionAllocator; const VkImage TextureGetVkImage(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).img; + return textureAllocator.ConstGet(id.id).img; } //------------------------------------------------------------------------------ @@ -38,7 +38,7 @@ TextureGetVkImage(const CoreGraphics::TextureId id) const VkImageView TextureGetVkImageView(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).view; + return textureAllocator.ConstGet(id.id).view; } //------------------------------------------------------------------------------ @@ -47,7 +47,7 @@ TextureGetVkImageView(const CoreGraphics::TextureId id) const VkImageView TextureGetVkStencilImageView(const CoreGraphics::TextureId id) { - Ids::Id32 stencil = textureAllocator.ConstGet(id.resourceId).stencilExtension; + Ids::Id32 stencil = textureAllocator.ConstGet(id.id).stencilExtension; n_assert(stencil != Ids::InvalidId32); return TextureViewGetVk(textureStencilExtensionAllocator.Get(stencil)); } @@ -58,7 +58,7 @@ TextureGetVkStencilImageView(const CoreGraphics::TextureId id) const VkDevice TextureGetVkDevice(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).dev; + return textureAllocator.ConstGet(id.id).dev; } //------------------------------------------------------------------------------ @@ -226,7 +226,7 @@ namespace CoreGraphics { using namespace Vulkan; -_IMPL_ACQUIRE_RELEASE_RESOURCE(TextureId, textureAllocator); +_IMPL_ACQUIRE_RELEASE(TextureId, textureAllocator); //------------------------------------------------------------------------------ /** @@ -234,10 +234,10 @@ _IMPL_ACQUIRE_RELEASE_RESOURCE(TextureId, textureAllocator); void SetupTexture(const TextureId id) { - __Lock(textureAllocator, id.resourceId); - Vulkan::VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.resourceId); - Vulkan::VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.resourceId); - Vulkan::VkTextureWindowInfo& windowInfo = textureAllocator.Get(id.resourceId); + __Lock(textureAllocator, id.id); + Vulkan::VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.id); + Vulkan::VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.id); + Vulkan::VkTextureWindowInfo& windowInfo = textureAllocator.Get(id.id); VkFormat vkformat = VkTypes::AsVkFormat(loadInfo.format); @@ -344,7 +344,7 @@ SetupTexture(const TextureId id) else { // otherwise use other image memory to create alias - CoreGraphics::Alloc mem = textureAllocator.Get(loadInfo.alias.resourceId).mem; + CoreGraphics::Alloc mem = textureAllocator.Get(loadInfo.alias.id).mem; loadInfo.mem = mem; VkResult res = vkBindImageMemory(loadInfo.dev, loadInfo.img, loadInfo.mem.mem, loadInfo.mem.offset); n_assert(res == VK_SUCCESS); @@ -571,7 +571,7 @@ SetupTexture(const TextureId id) loadInfo.swapExtension = textureSwapExtensionAllocator.Alloc(); VkTextureSwapInfo& swapInfo = textureSwapExtensionAllocator.Get(loadInfo.swapExtension); - VkBackbufferInfo& backbufferInfo = CoreGraphics::glfwWindowAllocator.Get(windowInfo.window.id24); + VkBackbufferInfo& backbufferInfo = CoreGraphics::glfwWindowAllocator.Get(windowInfo.window.id); swapInfo.swapimages = backbufferInfo.backbuffers; swapInfo.swapviews = backbufferInfo.backbufferViews; VkClearColorValue clear = { { 0, 0, 0, 0 } }; @@ -645,11 +645,9 @@ const TextureId CreateTexture(const TextureCreateInfo& info) { /// during the load-phase, we can safetly get the structs - uint32_t id = textureAllocator.Alloc(); + Ids::Id32 id = textureAllocator.Alloc(); - TextureId ret; - ret.resourceId = id; - ret.resourceType = CoreGraphics::TextureIdType; + TextureId ret = id; Vulkan::VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id); Vulkan::VkTextureLoadInfo& loadInfo = textureAllocator.Get(id); @@ -717,9 +715,9 @@ CreateTexture(const TextureCreateInfo& info) void DeleteTexture(const TextureId id) { - __Lock(textureAllocator, id.resourceId); - VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.resourceId); - VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.resourceId); + __Lock(textureAllocator, id.id); + VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.id); + VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.id); if (loadInfo.stencilExtension != Ids::InvalidId32) { @@ -795,7 +793,7 @@ void DestroyTexture(const TextureId id) { DeleteTexture(id); - textureAllocator.Dealloc(id.resourceId); + textureAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -804,7 +802,7 @@ DestroyTexture(const TextureId id) CoreGraphics::TextureDimensions TextureGetDimensions(const CoreGraphics::TextureId id) { - const VkTextureLoadInfo& loadInfo = textureAllocator.ConstGet(id.resourceId); + const VkTextureLoadInfo& loadInfo = textureAllocator.ConstGet(id.id); return CoreGraphics::TextureDimensions { .width = (SizeT)loadInfo.width, .height = (SizeT)loadInfo.height, .depth = (SizeT)loadInfo.depth }; } @@ -814,7 +812,7 @@ TextureGetDimensions(const CoreGraphics::TextureId id) CoreGraphics::TextureRelativeDimensions TextureGetRelativeDimensions(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).relativeDims; + return textureAllocator.ConstGet(id.id).relativeDims; } //------------------------------------------------------------------------------ @@ -823,7 +821,7 @@ TextureGetRelativeDimensions(const CoreGraphics::TextureId id) CoreGraphics::PixelFormat::Code TextureGetPixelFormat(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).format; + return textureAllocator.ConstGet(id.id).format; } //------------------------------------------------------------------------------ @@ -832,7 +830,7 @@ TextureGetPixelFormat(const CoreGraphics::TextureId id) CoreGraphics::TextureType TextureGetType(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).type; + return textureAllocator.ConstGet(id.id).type; } //------------------------------------------------------------------------------ @@ -841,7 +839,7 @@ TextureGetType(const CoreGraphics::TextureId id) SizeT TextureGetNumMips(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).mips; + return textureAllocator.ConstGet(id.id).mips; } //------------------------------------------------------------------------------ @@ -850,7 +848,7 @@ TextureGetNumMips(const CoreGraphics::TextureId id) SizeT TextureGetNumLayers(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).layers; + return textureAllocator.ConstGet(id.id).layers; } //------------------------------------------------------------------------------ @@ -859,7 +857,7 @@ TextureGetNumLayers(const CoreGraphics::TextureId id) SizeT TextureGetNumSamples(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).samples; + return textureAllocator.ConstGet(id.id).samples; } //------------------------------------------------------------------------------ @@ -868,7 +866,7 @@ TextureGetNumSamples(const CoreGraphics::TextureId id) const CoreGraphics::TextureId TextureGetAlias(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).alias; + return textureAllocator.ConstGet(id.id).alias; } //------------------------------------------------------------------------------ @@ -877,7 +875,7 @@ TextureGetAlias(const CoreGraphics::TextureId id) const CoreGraphics::TextureUsage TextureGetUsage(const TextureId id) { - return textureAllocator.ConstGet(id.resourceId).usage; + return textureAllocator.ConstGet(id.id).usage; } //------------------------------------------------------------------------------ @@ -886,7 +884,7 @@ TextureGetUsage(const TextureId id) const CoreGraphics::ImageLayout TextureGetDefaultLayout(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).defaultLayout; + return textureAllocator.ConstGet(id.id).defaultLayout; } //------------------------------------------------------------------------------ @@ -895,7 +893,7 @@ TextureGetDefaultLayout(const CoreGraphics::TextureId id) uint TextureGetBindlessHandle(const CoreGraphics::TextureId id) { - return textureAllocator.ConstGet(id.resourceId).bind; + return textureAllocator.ConstGet(id.id).bind; } //------------------------------------------------------------------------------ @@ -904,7 +902,7 @@ TextureGetBindlessHandle(const CoreGraphics::TextureId id) uint TextureGetStencilBindlessHandle(const CoreGraphics::TextureId id) { - Ids::Id32 stencil = textureAllocator.ConstGet(id.resourceId).stencilExtension; + Ids::Id32 stencil = textureAllocator.ConstGet(id.id).stencilExtension; n_assert(stencil != Ids::InvalidId32); return textureStencilExtensionAllocator.ConstGet(stencil); } @@ -915,15 +913,15 @@ TextureGetStencilBindlessHandle(const CoreGraphics::TextureId id) IndexT TextureSwapBuffers(const CoreGraphics::TextureId id) { - textureAllocator.Acquire(id.resourceId); - VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.resourceId); + textureAllocator.Acquire(id.id); + VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.id); textureSwapExtensionAllocator.Acquire(loadInfo.swapExtension); - VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.resourceId); - const VkTextureWindowInfo& wnd = textureAllocator.ConstGet(id.resourceId); + VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.id); + const VkTextureWindowInfo& wnd = textureAllocator.ConstGet(id.id); const VkTextureSwapInfo& swap = textureSwapExtensionAllocator.ConstGet(loadInfo.swapExtension); n_assert(wnd.window != CoreGraphics::InvalidWindowId); - VkWindowSwapInfo& swapInfo = CoreGraphics::glfwWindowAllocator.Get(wnd.window.id24); + VkWindowSwapInfo& swapInfo = CoreGraphics::glfwWindowAllocator.Get(wnd.window.id); // get present fence and be sure it is finished before getting the next image VkDevice dev = Vulkan::GetCurrentDevice(); @@ -951,7 +949,7 @@ TextureSwapBuffers(const CoreGraphics::TextureId id) runtimeInfo.view = swap.swapviews[swapBufferIndex]; textureSwapExtensionAllocator.Release(loadInfo.swapExtension); - textureAllocator.Release(id.resourceId); + textureAllocator.Release(id.id); return swapBufferIndex; } @@ -961,10 +959,10 @@ TextureSwapBuffers(const CoreGraphics::TextureId id) void TextureWindowResized(const TextureId id) { - __Lock(textureAllocator, id.resourceId); - VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.resourceId); - VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.resourceId); - const VkTextureWindowInfo& windowInfo = textureAllocator.ConstGet(id.resourceId); + __Lock(textureAllocator, id.id); + VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.id); + VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.id); + const VkTextureWindowInfo& windowInfo = textureAllocator.ConstGet(id.id); if (loadInfo.windowTexture || loadInfo.windowRelative) { @@ -989,7 +987,7 @@ TextureWindowResized(const TextureId id) CoreGraphics::TextureSparsePageSize TextureSparseGetPageSize(const CoreGraphics::TextureId id) { - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const VkSparseImageMemoryRequirements& reqs = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1007,8 +1005,8 @@ TextureSparseGetPageSize(const CoreGraphics::TextureId id) IndexT TextureSparseGetPageIndex(const CoreGraphics::TextureId id, IndexT layer, IndexT mip, IndexT x, IndexT y, IndexT z) { - __Lock(textureAllocator, id.resourceId); - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + __Lock(textureAllocator, id.id); + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const VkSparseImageMemoryRequirements& reqs = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1030,7 +1028,7 @@ TextureSparseGetPageIndex(const CoreGraphics::TextureId id, IndexT layer, IndexT const CoreGraphics::TextureSparsePage& TextureSparseGetPage(const CoreGraphics::TextureId id, IndexT layer, IndexT mip, IndexT pageIndex) { - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const TextureSparsePageTable& table = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1043,7 +1041,7 @@ TextureSparseGetPage(const CoreGraphics::TextureId id, IndexT layer, IndexT mip, SizeT TextureSparseGetNumPages(const CoreGraphics::TextureId id, IndexT layer, IndexT mip) { - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const TextureSparsePageTable& table = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1060,7 +1058,7 @@ TextureSparseGetNumPages(const CoreGraphics::TextureId id, IndexT layer, IndexT IndexT TextureSparseGetMaxMip(const CoreGraphics::TextureId id) { - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const VkSparseImageMemoryRequirements& reqs = textureSparseExtensionAllocator.ConstGet(sparseExtension); return reqs.imageMipTailFirstLod; @@ -1072,8 +1070,8 @@ TextureSparseGetMaxMip(const CoreGraphics::TextureId id) void TextureSparseEvict(const CoreGraphics::TextureId id, IndexT layer, IndexT mip, IndexT pageIndex) { - __Lock(textureAllocator, id.resourceId); - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + __Lock(textureAllocator, id.id); + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const TextureSparsePageTable& table = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1112,8 +1110,8 @@ TextureSparseEvict(const CoreGraphics::TextureId id, IndexT layer, IndexT mip, I void TextureSparseMakeResident(const CoreGraphics::TextureId id, IndexT layer, IndexT mip, IndexT pageIndex) { - __Lock(textureAllocator, id.resourceId); - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + __Lock(textureAllocator, id.id); + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const TextureSparsePageTable& table = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1151,8 +1149,8 @@ TextureSparseMakeResident(const CoreGraphics::TextureId id, IndexT layer, IndexT void TextureSparseEvictMip(const CoreGraphics::TextureId id, IndexT layer, IndexT mip) { - __Lock(textureAllocator, id.resourceId); - Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.resourceId).sparseExtension; + __Lock(textureAllocator, id.id); + Ids::Id32 sparseExtension = textureAllocator.ConstGet(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const TextureSparsePageTable& table = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1192,8 +1190,8 @@ TextureSparseEvictMip(const CoreGraphics::TextureId id, IndexT layer, IndexT mip void TextureSparseMakeMipResident(const CoreGraphics::TextureId id, IndexT layer, IndexT mip) { - __Lock(textureAllocator, id.resourceId); - Ids::Id32 sparseExtension = textureAllocator.Get(id.resourceId).sparseExtension; + __Lock(textureAllocator, id.id); + Ids::Id32 sparseExtension = textureAllocator.Get(id.id).sparseExtension; n_assert(sparseExtension != Ids::InvalidId32); const TextureSparsePageTable& table = textureSparseExtensionAllocator.ConstGet(sparseExtension); @@ -1233,9 +1231,9 @@ TextureSparseMakeMipResident(const CoreGraphics::TextureId id, IndexT layer, Ind void TextureSparseCommitChanges(const CoreGraphics::TextureId id) { - __Lock(textureAllocator, id.resourceId); - Ids::Id32 sparseExtension = textureAllocator.Get(id.resourceId).sparseExtension; - VkImage img = textureAllocator.Get(id.resourceId).img; + __Lock(textureAllocator, id.id); + Ids::Id32 sparseExtension = textureAllocator.Get(id.id).sparseExtension; + VkImage img = textureAllocator.Get(id.id).img; n_assert(sparseExtension != Ids::InvalidId32); Util::Array& opaqueBinds = textureSparseExtensionAllocator.Get(sparseExtension); @@ -1285,8 +1283,8 @@ TextureSparseCommitChanges(const CoreGraphics::TextureId id) void TextureSparseUpdate(const CoreGraphics::CmdBufferId cmdBuf, const CoreGraphics::TextureId id, const Math::rectangle& region, IndexT mip, IndexT layer, const CoreGraphics::TextureId source) { - __Lock(textureAllocator, id.resourceId); - const VkTextureLoadInfo& loadInfo = textureAllocator.Get(source.resourceId); + __Lock(textureAllocator, id.id); + const VkTextureLoadInfo& loadInfo = textureAllocator.Get(source.id); VkImageBlit blit; blit.srcOffsets[0] = { 0, 0, 0 }; @@ -1311,7 +1309,7 @@ TextureSparseUpdate(const CoreGraphics::CmdBufferId cmdBuf, const CoreGraphics:: void TextureSparseUpdate(const CoreGraphics::CmdBufferId cmdBuf, const CoreGraphics::TextureId id, const Math::rectangle& region, IndexT mip, IndexT layer, char* buf) { - __Lock(textureAllocator, id.resourceId); + __Lock(textureAllocator, id.id); // allocate intermediate buffer and copy row-wise CoreGraphics::PixelFormat::Code fmt = TextureGetPixelFormat(id); TextureDimensions dims = TextureGetDimensions(id); @@ -1510,9 +1508,9 @@ TextureClearDepthStencil(const CoreGraphics::CmdBufferId cmd, const CoreGraphics void TextureSetHighestLod(const CoreGraphics::TextureId id, uint lod) { - __Lock(textureAllocator, id.resourceId); - const VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.resourceId); - VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.resourceId); + __Lock(textureAllocator, id.id); + const VkTextureLoadInfo& loadInfo = textureAllocator.Get(id.id); + VkTextureRuntimeInfo& runtimeInfo = textureAllocator.Get(id.id); // create image view VkImageSubresourceRange viewSubres; diff --git a/code/render/coregraphics/vk/vktextureview.cc b/code/render/coregraphics/vk/vktextureview.cc index fc4123d0a..a2b114f94 100644 --- a/code/render/coregraphics/vk/vktextureview.cc +++ b/code/render/coregraphics/vk/vktextureview.cc @@ -22,7 +22,7 @@ VkTextureViewAllocator textureViewAllocator(0x00FFFFFF); const VkImageView TextureViewGetVk(const TextureViewId id) { - return textureViewAllocator.Get(id.id24).view; + return textureViewAllocator.Get(id.id).view; } //------------------------------------------------------------------------------ @@ -31,7 +31,7 @@ TextureViewGetVk(const TextureViewId id) const VkDevice TextureViewGetVkDevice(const CoreGraphics::TextureViewId id) { - return textureViewAllocator.Get(id.id24).dev; + return textureViewAllocator.Get(id.id).dev; } } // namespace Vulkan @@ -92,9 +92,7 @@ CreateTextureView(const TextureViewCreateInfo& info) VkResult stat = vkCreateImageView(loadInfo.dev, &viewCreate, nullptr, &runtimeInfo.view); n_assert(stat == VK_SUCCESS); - TextureViewId ret; - ret.id24 = id; - ret.id8 = TextureViewIdType; + TextureViewId ret = id; #if NEBULA_GRAPHICS_DEBUG ObjectSetName(ret, info.name.Value()); @@ -109,10 +107,10 @@ CreateTextureView(const TextureViewCreateInfo& info) void DestroyTextureView(const TextureViewId id) { - //VkTextureViewLoadInfo& loadInfo = textureViewAllocator.Get(id.id24); - //VkTextureViewRuntimeInfo& runtimeInfo = textureViewAllocator.Get(id.id24); + //VkTextureViewLoadInfo& loadInfo = textureViewAllocator.Get(id.id); + //VkTextureViewRuntimeInfo& runtimeInfo = textureViewAllocator.Get(id.id); CoreGraphics::DelayedDeleteTextureView(id); - textureViewAllocator.Dealloc(id.id24); + textureViewAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -121,8 +119,8 @@ DestroyTextureView(const TextureViewId id) void TextureViewReload(const TextureViewId id) { - VkTextureViewRuntimeInfo& runtimeInfo = textureViewAllocator.Get(id.id24); - VkTextureViewLoadInfo& loadInfo = textureViewAllocator.Get(id.id24); + VkTextureViewRuntimeInfo& runtimeInfo = textureViewAllocator.Get(id.id); + VkTextureViewLoadInfo& loadInfo = textureViewAllocator.Get(id.id); // First destroy the old view CoreGraphics::DelayedDeleteTextureView(id); @@ -166,7 +164,7 @@ TextureViewReload(const TextureViewId id) TextureId TextureViewGetTexture(const TextureViewId id) { - VkTextureViewLoadInfo& loadInfo = textureViewAllocator.Get(id.id24); + VkTextureViewLoadInfo& loadInfo = textureViewAllocator.Get(id.id); return loadInfo.tex; } diff --git a/code/render/coregraphics/vk/vkvertexlayout.cc b/code/render/coregraphics/vk/vkvertexlayout.cc index c86ea72a1..02f42608a 100644 --- a/code/render/coregraphics/vk/vkvertexlayout.cc +++ b/code/render/coregraphics/vk/vkvertexlayout.cc @@ -20,7 +20,7 @@ VkPipelineVertexInputStateCreateInfo* VertexLayoutGetDerivative(const CoreGraphics::VertexLayoutId layout, const CoreGraphics::ShaderProgramId shader) { Threading::CriticalScope scope(&vertexSignatureMutex); - Util::HashTable& hashTable = vertexLayoutAllocator.Get(layout.resourceId); + Util::HashTable& hashTable = vertexLayoutAllocator.Get(layout.id); const Ids::Id64 shaderHash = shader.HashCode64(); IndexT i = hashTable.FindIndex(shaderHash); @@ -31,8 +31,8 @@ VertexLayoutGetDerivative(const CoreGraphics::VertexLayoutId layout, const CoreG else { const VkProgramReflectionInfo& program = ShaderGetProgramReflection(shader); - const BindInfo& bindInfo = vertexLayoutAllocator.Get(layout.resourceId); - const VkPipelineVertexInputStateCreateInfo& baseInfo = vertexLayoutAllocator.Get(layout.resourceId); + const BindInfo& bindInfo = vertexLayoutAllocator.Get(layout.id); + const VkPipelineVertexInputStateCreateInfo& baseInfo = vertexLayoutAllocator.Get(layout.id); IndexT index = hashTable.Add(shaderHash, {}); DerivativeLayout& layout = hashTable.ValueAtIndex(shaderHash, index); @@ -70,7 +70,7 @@ const VertexLayoutVkBindInfo& VertexLayoutGetVkBindInfo(const CoreGraphics::VertexLayoutId layout) { Threading::CriticalScope scope(&vertexSignatureMutex); - return vertexLayoutAllocator.Get(layout.resourceId); + return vertexLayoutAllocator.Get(layout.id); } } // namespace Vulkan @@ -193,9 +193,7 @@ CreateVertexLayout(const VertexLayoutCreateInfo& info) .pVertexAttributeDescriptions = bindInfo.attrs.Begin() }; - VertexLayoutId ret; - ret.resourceId = id; - ret.resourceType = VertexLayoutIdType; + VertexLayoutId ret = id; return ret; } @@ -205,7 +203,7 @@ CreateVertexLayout(const VertexLayoutCreateInfo& info) void DestroyVertexLayout(const VertexLayoutId id) { - vertexLayoutAllocator.Dealloc(id.resourceId); + vertexLayoutAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -214,7 +212,7 @@ DestroyVertexLayout(const VertexLayoutId id) const SizeT VertexLayoutGetSize(const VertexLayoutId id) { - return vertexLayoutAllocator.Get(id.resourceId).vertexByteSize; + return vertexLayoutAllocator.Get(id.id).vertexByteSize; } //------------------------------------------------------------------------------ @@ -223,7 +221,7 @@ VertexLayoutGetSize(const VertexLayoutId id) const SizeT VertexLayoutGetStreamSize(const VertexLayoutId id, IndexT stream) { - return vertexLayoutAllocator.Get(id.resourceId)[stream]; + return vertexLayoutAllocator.Get(id.id)[stream]; } //------------------------------------------------------------------------------ @@ -232,7 +230,7 @@ VertexLayoutGetStreamSize(const VertexLayoutId id, IndexT stream) const Util::Array& VertexLayoutGetComponents(const VertexLayoutId id) { - return vertexLayoutAllocator.Get(id.resourceId).comps; + return vertexLayoutAllocator.Get(id.id).comps; } } // namespace Vulkan diff --git a/code/render/frame/framescript.cc b/code/render/frame/framescript.cc index 031f69229..54631b494 100644 --- a/code/render/frame/framescript.cc +++ b/code/render/frame/framescript.cc @@ -274,7 +274,7 @@ FrameScript::Build() { CoreGraphics::BarrierCreateInfo inf = { - Util::String::Sprintf("End of Frame Texture Reset Transition %d", tex.resourceId), + Util::String::Sprintf("End of Frame Texture Reset Transition %d", tex.id), CoreGraphics::BarrierDomain::Global, fromStage, toStage, diff --git a/code/render/graphics/graphicscontext.h b/code/render/graphics/graphicscontext.h index e43c4db0a..7a0321afa 100644 --- a/code/render/graphics/graphicscontext.h +++ b/code/render/graphics/graphicscontext.h @@ -186,16 +186,15 @@ inline void GraphicsContext::InternalDefragment(ID_ALLOCATOR& allocator, Graphics::GraphicsContextState&& state) { auto& freeIds = allocator.FreeIds(); - uint32_t index; - uint32_t oldIndex; + Ids::Id32 index; + Ids::Id32 oldIndex; Graphics::GraphicsEntityId lastId; IndexT mapIndex; uint32_t dataSize; SizeT size = freeIds.Size(); for (SizeT i = size - 1; i >= 0; --i) { - index = freeIds.Back(); - freeIds.EraseBack(); + index = freeIds.Dequeue(); dataSize = (uint32_t)allocator.Size(); if (index >= dataSize) { @@ -214,7 +213,7 @@ GraphicsContext::InternalDefragment(ID_ALLOCATOR& allocator, Graphics::GraphicsC } else { - freeIds.Append(index); + freeIds.Enqueue(index); i++; } } diff --git a/code/render/graphics/graphicsserver.cc b/code/render/graphics/graphicsserver.cc index 660729900..a15bd563d 100644 --- a/code/render/graphics/graphicsserver.cc +++ b/code/render/graphics/graphicsserver.cc @@ -287,7 +287,7 @@ GraphicsServer::OnWindowResized(CoreGraphics::WindowId wndId) { if (this->contexts[i]->OnWindowResized != nullptr) { - this->contexts[i]->OnWindowResized(wndId.id24, mode.GetWidth(), mode.GetHeight()); + this->contexts[i]->OnWindowResized(wndId.id, mode.GetWidth(), mode.GetHeight()); } } } diff --git a/code/render/materials/material.cc b/code/render/materials/material.cc index 7a7f0aef7..d402da892 100644 --- a/code/render/materials/material.cc +++ b/code/render/materials/material.cc @@ -148,9 +148,7 @@ CreateMaterial(const MaterialTemplates::Entry* entry) CoreGraphics::ResourceTableCommitChanges(table); } - MaterialId ret; - ret.resourceId = id; - ret.resourceType = CoreGraphics::MaterialIdType; + MaterialId ret = id; return ret; } @@ -160,7 +158,7 @@ CreateMaterial(const MaterialTemplates::Entry* entry) void DestroyMaterial(const MaterialId id) { - materialAllocator.Dealloc(id.resourceId); + materialAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -169,8 +167,8 @@ DestroyMaterial(const MaterialId id) void MaterialSetConstant(const MaterialId mat, const ShaderConfigBatchConstant* bind, const MaterialVariant& value) { - const MaterialTemplates::Entry* temp = materialAllocator.Get(mat.resourceId); - const auto& buffersPerPass = materialAllocator.Get(mat.resourceId); + const MaterialTemplates::Entry* temp = materialAllocator.Get(mat.id); + const auto& buffersPerPass = materialAllocator.Get(mat.id); for (const auto& pass : temp->passes) { @@ -190,10 +188,10 @@ MaterialSetConstant(const MaterialId mat, const ShaderConfigBatchConstant* bind, void MaterialSetTexture(const MaterialId mat, const ShaderConfigBatchTexture* bind, const CoreGraphics::TextureId tex) { - const MaterialTemplates::Entry* temp = materialAllocator.Get(mat.resourceId); + const MaterialTemplates::Entry* temp = materialAllocator.Get(mat.id); for (const auto& pass : temp->passes) { - CoreGraphics::ResourceTableId table = materialAllocator.Get(mat.resourceId)[pass.Value()->index]; + CoreGraphics::ResourceTableId table = materialAllocator.Get(mat.id)[pass.Value()->index]; CoreGraphics::ResourceTableSetTexture(table, { tex, bind->slot, 0, CoreGraphics::InvalidSamplerId, false }); } } @@ -204,7 +202,7 @@ MaterialSetTexture(const MaterialId mat, const ShaderConfigBatchTexture* bind, c void MaterialSetBufferBinding(const MaterialId id, IndexT index) { - materialAllocator.Set(id.resourceId, index); + materialAllocator.Set(id.id, index); } //------------------------------------------------------------------------------ @@ -213,7 +211,7 @@ MaterialSetBufferBinding(const MaterialId id, IndexT index) IndexT MaterialGetBufferBinding(const MaterialId id) { - return Ids::Index(materialAllocator.Get(id.resourceId)); + return Ids::Index(materialAllocator.Get(id.id)); } //------------------------------------------------------------------------------ @@ -223,10 +221,10 @@ void MaterialAddLODTexture(const MaterialId mat, const Resources::ResourceId tex) { Threading::CriticalScope scope(&materialTextureLoadSection); - materialAllocator.Get(mat.resourceId).Append(tex); + materialAllocator.Get(mat.id).Append(tex); // When a new texture is added, make sure to update it's LOD as well - Resources::SetMinLod(tex, materialAllocator.Get(mat.resourceId), false); + Resources::SetMinLod(tex, materialAllocator.Get(mat.id), false); } //------------------------------------------------------------------------------ @@ -236,8 +234,8 @@ void MaterialSetLowestLod(const MaterialId mat, float lod) { Threading::CriticalScope scope(&materialTextureLoadSection); - Util::Array& textures = materialAllocator.Get(mat.resourceId); - float& minLod = materialAllocator.Get(mat.resourceId); + Util::Array& textures = materialAllocator.Get(mat.id); + float& minLod = materialAllocator.Get(mat.id); if (minLod <= lod) return; minLod = lod; @@ -254,7 +252,7 @@ MaterialSetLowestLod(const MaterialId mat, float lod) const MaterialTemplates::Entry* MaterialGetTemplate(const MaterialId mat) { - return materialAllocator.Get(mat.resourceId); + return materialAllocator.Get(mat.id); } //------------------------------------------------------------------------------ @@ -263,7 +261,7 @@ MaterialGetTemplate(const MaterialId mat) const Materials::BatchIndex MaterialGetBatchIndex(const MaterialId mat, const CoreGraphics::BatchGroup::Code code) { - return materialAllocator.Get(mat.resourceId)->passes[code]->index; + return materialAllocator.Get(mat.id)->passes[code]->index; } //------------------------------------------------------------------------------ @@ -272,7 +270,7 @@ MaterialGetBatchIndex(const MaterialId mat, const CoreGraphics::BatchGroup::Code uint64_t MaterialGetSortCode(const MaterialId mat) { - return materialAllocator.Get(mat.resourceId)->uniqueId; + return materialAllocator.Get(mat.id)->uniqueId; } //------------------------------------------------------------------------------ @@ -281,7 +279,7 @@ MaterialGetSortCode(const MaterialId mat) void MaterialApply(const MaterialId id, const CoreGraphics::CmdBufferId buf, IndexT index) { - CoreGraphics::CmdSetResourceTable(buf, materialAllocator.Get(id.resourceId)[index], NEBULA_BATCH_GROUP, CoreGraphics::GraphicsPipeline, nullptr); + CoreGraphics::CmdSetResourceTable(buf, materialAllocator.Get(id.id)[index], NEBULA_BATCH_GROUP, CoreGraphics::GraphicsPipeline, nullptr); } //------------------------------------------------------------------------------ @@ -295,8 +293,7 @@ CreateMaterialInstance(const MaterialId material) // create id MaterialInstanceId ret; ret.instance = inst; - ret.materialId = material.resourceId; - ret.materialType = material.resourceType; + ret.material = material.id; return ret; } diff --git a/code/render/materials/material.h b/code/render/materials/material.h index 019ec05d5..4ed9f2c61 100644 --- a/code/render/materials/material.h +++ b/code/render/materials/material.h @@ -31,7 +31,7 @@ struct ShaderConfigBatchConstant; struct ShaderConfigBatchTexture; RESOURCE_ID_TYPE(MaterialId); -ID_32_24_8_NAMED_TYPE(MaterialInstanceId, instance, materialId, materialType); // 32 bits instance, 24 bits material, 8 bits type +ID_32_24_8_NAMED_TYPE(MaterialInstanceId, instance, materialId, materialGeneration, material); // 32 bits instance, 24 bits material, 8 bits type typedef IndexT BatchIndex; diff --git a/code/render/materials/materialloader.cc b/code/render/materials/materialloader.cc index ebe5a8685..b92b23136 100644 --- a/code/render/materials/materialloader.cc +++ b/code/render/materials/materialloader.cc @@ -649,9 +649,7 @@ MaterialLoader::RegisterTerrainMaterial(const MaterialInterface::TerrainMaterial void MaterialLoader::Unload(const Resources::ResourceId id) { - MaterialId material; - material.resourceId = id.resourceId; - material.resourceType = id.resourceType; + MaterialId material = id.resource; DestroyMaterial(material); } diff --git a/code/render/models/model.cc b/code/render/models/model.cc index 5e6d3e39a..d2e388500 100644 --- a/code/render/models/model.cc +++ b/code/render/models/model.cc @@ -20,9 +20,7 @@ CreateModel(const ModelCreateInfo& info) modelAllocator.Set(id, info.boundingBox); modelAllocator.Set(id, info.nodes); - ModelId ret; - ret.resourceId = id; - ret.resourceType = CoreGraphics::ModelIdType; + ModelId ret = id; return ret; } @@ -32,8 +30,8 @@ CreateModel(const ModelCreateInfo& info) void DestroyModel(const ModelId id) { - modelAllocator.Get(id.resourceId).Clear(); - modelAllocator.Dealloc(id.resourceId); + modelAllocator.Get(id.id).Clear(); + modelAllocator.Dealloc(id.id); } //------------------------------------------------------------------------------ @@ -42,7 +40,7 @@ DestroyModel(const ModelId id) const Util::Array& ModelGetNodes(const ModelId id) { - return modelAllocator.Get(id.resourceId); + return modelAllocator.Get(id.id); } //------------------------------------------------------------------------------ @@ -51,7 +49,7 @@ ModelGetNodes(const ModelId id) const Math::bbox& ModelGetBoundingBox(const ModelId id) { - return modelAllocator.Get(id.resourceId); + return modelAllocator.Get(id.id); } } // namespace Models diff --git a/code/render/models/modelloader.cc b/code/render/models/modelloader.cc index f8d6881d3..e2875d878 100644 --- a/code/render/models/modelloader.cc +++ b/code/render/models/modelloader.cc @@ -178,9 +178,7 @@ ModelLoader::InitializeResource(Ids::Id32 entry, const Util::StringAtom& tag, co void ModelLoader::Unload(const Resources::ResourceId id) { - ModelId model; - model.resourceId = id.resourceId; - model.resourceType = id.resourceType; + ModelId model = id.resource; const Util::Array& nodes = ModelGetNodes(model); // unload nodes diff --git a/code/resource/resources/resourceid.h b/code/resource/resources/resourceid.h index 457093e60..8a4a35d4d 100644 --- a/code/resource/resources/resourceid.h +++ b/code/resource/resources/resourceid.h @@ -27,20 +27,22 @@ #include "util/stringatom.h" #include "ids/id.h" #include "core/debug.h" +#include "ids/idgenerationpool.h" namespace Resources { typedef Util::StringAtom ResourceName; -ID_24_8_24_8_NAMED_TYPE(ResourceId, loaderInstanceId, loaderIndex, resourceId, resourceType); // 24 bits: loader resource id, 8 bits: loader index, 24 bits: unique resource id, 8 bits: resource type +ID_24_8_24_8_NAMED_TYPE(ResourceId, loaderInstanceId, loaderIndex, resourceId, generation, loader, resource); // 24 bits: loader resource id, 8 bits: loader index, 24 bits: unique resource id, 8 bits: generation // define a generic typed ResourceId, this is so we can have specialized allocators, but have a common pool implementation... -ID_24_8_NAMED_TYPE(ResourceUnknownId, resourceId, resourceType); +ID_24_8_NAMED_TYPE(ResourceUnknownId, resourceId, generation, id); } // namespace Resource #define RESOURCE_ID_TYPE(type) struct type : public Resources::ResourceUnknownId { \ constexpr type() {};\ constexpr type(const Resources::ResourceUnknownId& res) : Resources::ResourceUnknownId(res) {};\ - constexpr type(const Resources::ResourceId& res) : Resources::ResourceUnknownId(res.resourceId, res.resourceType) {};\ - constexpr type(const Ids::Id24 id, const Ids::Id8 type) : Resources::ResourceUnknownId(id, type) {};\ + constexpr type(const Resources::ResourceId& res) : Resources::ResourceUnknownId(res.resourceId, res.generation) {};\ + constexpr type(const Ids::Id24 id, const Ids::Id8 generation) : Resources::ResourceUnknownId(id, generation) {};\ + constexpr type(const Ids::Id32 id) : Resources::ResourceUnknownId(Ids::Index(id), Ids::Generation(id)) {};\ }; \ static constexpr type Invalid##type = Resources::InvalidResourceUnknownId; diff --git a/code/resource/resources/resourceloader.cc b/code/resource/resources/resourceloader.cc index fa261926a..388f54d8c 100644 --- a/code/resource/resources/resourceloader.cc +++ b/code/resource/resources/resourceloader.cc @@ -216,16 +216,16 @@ ResourceLoader::SetupIdFromEntry(const Ids::Id32 entry, ResourceId& cacheEntry) { case Resource::State::Loaded: cacheEntry.resourceId = this->resources[entry].resourceId; - cacheEntry.resourceType = this->resources[entry].resourceType; + cacheEntry.generation = this->resources[entry].generation; break; case Resource::State::Failed: cacheEntry.resourceId = this->failResourceId.resourceId; - cacheEntry.resourceType = this->failResourceId.resourceType; + cacheEntry.generation = this->failResourceId.generation; break; case Resource::State::Pending: case Resource::State::Unloaded: cacheEntry.resourceId = this->placeholderResourceId.resourceId; - cacheEntry.resourceType = this->placeholderResourceId.resourceType; + cacheEntry.generation = this->placeholderResourceId.generation; break; } } @@ -291,7 +291,7 @@ _LoadInternal(ResourceLoader* loader, const ResourceLoader::_PendingResourceLoad // If new resource, initialize it ResourceUnknownId internalResource = loader->InitializeResource(res.entry, res.tag, stream, res.immediate); resource.resourceId = internalResource.resourceId; - resource.resourceType = internalResource.resourceType; + resource.generation = internalResource.generation; requestedBits = loader->LodMask(res.entry, res.lod, !res.immediate); if (res.immediate) @@ -314,7 +314,7 @@ _LoadInternal(ResourceLoader* loader, const ResourceLoader::_PendingResourceLoad // If the initialize failed, it means the file is invalid or can't be found state = Resource::Failed; resource.resourceId = loader->failResourceId.resourceId; - resource.resourceType = loader->failResourceId.resourceType; + resource.generation = loader->failResourceId.generation; n_printf("[RESOURCE LOADER] Failed to load resource %s\n", loader->names[res.entry].Value()); goto skip_stream; } @@ -322,7 +322,7 @@ _LoadInternal(ResourceLoader* loader, const ResourceLoader::_PendingResourceLoad else { resource.resourceId = loader->failResourceId.resourceId; - resource.resourceType = loader->failResourceId.resourceType; + resource.generation = loader->failResourceId.generation; n_printf("[RESOURCE LOADER] Failed to open resource %s\n", loader->names[res.entry].Value()); state = Resource::Failed; goto skip_stream;