Skip to content

Commit 5400d27

Browse files
author
devsh
committed
IImage isn't an IDescriptor, only views can be bound, also fix a nasty static_cast bug
1 parent c9847c9 commit 5400d27

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

include/nbl/asset/IDescriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class IDescriptor : public virtual core::IReferenceCounted
4242
{
4343
EC_BUFFER = 0,
4444
EC_SAMPLER,
45-
EC_IMAGE,
45+
EC_IMAGE, // TODO: rename to IMAGE_VIEW
4646
EC_BUFFER_VIEW,
4747
EC_ACCELERATION_STRUCTURE,
4848
EC_COUNT

include/nbl/asset/IImage.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ inline bool operator==(const VkExtent3D& v1, const VkExtent3D& v2)
5858
}
5959

6060

61-
class IImage : public IDescriptor
61+
class IImage : public virtual core::IReferenceCounted
6262
{
6363
public:
6464
enum E_ASPECT_FLAGS : uint16_t
@@ -583,10 +583,6 @@ class IImage : public IDescriptor
583583
}
584584

585585

586-
//!
587-
E_CATEGORY getTypeCategory() const override { return EC_IMAGE; }
588-
589-
590586
inline const auto& getTexelBlockInfo() const
591587
{
592588
return info;

include/nbl/type_traits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ struct pointer_to_nonconst_object
254254
template<typename T>
255255
using pointer_to_nonconst_object_t = typename pointer_to_nonconst_object<T>::type;
256256

257+
258+
template<typename T, typename U>
259+
constexpr bool are_related_v = std::is_base_of_v<T,U> || std::is_base_of_v<U,T>;
260+
257261
}
258262

259263
#endif

include/nbl/video/IDescriptorPool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,15 @@ class NBL_API2 IDescriptorPool : public IBackendObject
100100
virtual bool reset_impl() = 0;
101101

102102
private:
103+
// unfortunately according to the C++ spec this is a pile of UB that will never pass strict aliasing
103104
inline core::smart_refctd_ptr<asset::IDescriptor>* getDescriptorStorage(const asset::IDescriptor::E_TYPE type) const
104105
{
105106
core::smart_refctd_ptr<asset::IDescriptor>* baseAddress;
107+
// static_assert(reintepret_castable_pointers_v<asset::IDescriptor,IGPUSampler>);
108+
// static_assert(reintepret_castable_pointers_v<asset::IDescriptor,IGPUImageView>);
109+
// static_assert(reintepret_castable_pointers_v<asset::IDescriptor,IGPUBufferView>);
110+
// static_assert(reintepret_castable_pointers_v<asset::IDescriptor,IGPUBuffer>);
111+
// static_assert(reintepret_castable_pointers_v<asset::IDescriptor,IGPUTopLevelAccelerationStructure>);
106112
switch (type)
107113
{
108114
case asset::IDescriptor::E_TYPE::ET_SAMPLER:

src/nbl/asset/ICPUDescriptorSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ IAsset* ICPUDescriptorSet::getDependant_impl(size_t ix)
125125
case IDescriptor::EC_SAMPLER:
126126
return static_cast<ICPUSampler*>(desc);
127127
case IDescriptor::EC_IMAGE:
128-
return static_cast<ICPUImage*>(desc);
128+
return static_cast<ICPUImageView*>(desc);
129129
case IDescriptor::EC_BUFFER_VIEW:
130130
return static_cast<ICPUBufferView*>(desc);
131131
case IDescriptor::EC_ACCELERATION_STRUCTURE:

0 commit comments

Comments
 (0)