Skip to content

Commit ab95861

Browse files
author
devsh
committed
just handling the vertex loading on PLY left
1 parent b1efc69 commit ab95861

File tree

6 files changed

+267
-433
lines changed

6 files changed

+267
-433
lines changed

examples_tests

include/nbl/asset/ICPUPolygonGeometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class NBL_API2 ICPUPolygonGeometry final : public IPolygonGeometry<ICPUBuffer>
116116
return nullptr;
117117
}
118118

119-
//
119+
// TODO: either SoA or AoS but add names
120120
inline const core::vector<SDataView>& getAuxAttributeViews() const {return base_t::getAuxAttributeViews();}
121121
inline core::vector<SDataView>* getAuxAttributeViews()
122122
{

include/nbl/asset/IGeometry.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "nbl/builtin/hlsl/shapes/aabb.hlsl"
99

1010
#include "nbl/asset/IAsset.h"
11+
#include "nbl/asset/format/EFormat.h"
1112

1213

1314
namespace nbl::asset
@@ -48,6 +49,57 @@ class IGeometryBase : public virtual core::IReferenceCounted
4849
S8_NORM,
4950
BitCount=4
5051
};
52+
//
53+
static inline EAABBFormat getMatchingAABBFormat(const E_FORMAT attributeFormat)
54+
{
55+
if (isBlockCompressionFormat(attributeFormat))
56+
return EAABBFormat::BitCount;
57+
if (isFloatingPointFormat(attributeFormat))
58+
{
59+
const auto maxVal = getFormatMaxValue<double>(attributeFormat,0);
60+
if (maxVal>hlsl::numeric_limits<hlsl::float32_t>::max)
61+
return EAABBFormat::F64;
62+
if (maxVal>hlsl::numeric_limits<hlsl::float16_t>::max)
63+
return EAABBFormat::F32;
64+
return EAABBFormat::F16;
65+
}
66+
else if (isNormalizedFormat(attributeFormat))
67+
{
68+
const auto precision = getFormatPrecision<float>(attributeFormat,0,0.f);
69+
const auto minVal = getFormatMinValue<float>(attributeFormat,0);
70+
if (minVal<-0.f)
71+
return precision<getFormatPrecision<float>(EF_R8_SNORM,0,0.f) ? EAABBFormat::S16_NORM:EAABBFormat::S8_NORM;
72+
else
73+
return precision<getFormatPrecision<float>(EF_R8_UNORM,0,0.f) ? EAABBFormat::U16_NORM:EAABBFormat::U8_NORM;
74+
}
75+
else if (isIntegerFormat(attributeFormat))
76+
{
77+
if (isSignedFormat(attributeFormat))
78+
{
79+
const auto maxVal = getFormatMaxValue<int64_t>(attributeFormat,0);
80+
if (maxVal>hlsl::numeric_limits<int32_t>::max)
81+
return EAABBFormat::S64;
82+
else if (maxVal>hlsl::numeric_limits<int16_t>::max)
83+
return EAABBFormat::S32;
84+
else if (maxVal>hlsl::numeric_limits<int8_t>::max)
85+
return EAABBFormat::S16;
86+
return EAABBFormat::S8;
87+
}
88+
else
89+
{
90+
const auto maxVal = getFormatMaxValue<uint64_t>(attributeFormat,0);
91+
if (maxVal>hlsl::numeric_limits<uint32_t>::max)
92+
return EAABBFormat::U64;
93+
else if (maxVal>hlsl::numeric_limits<uint16_t>::max)
94+
return EAABBFormat::U32;
95+
else if (maxVal>hlsl::numeric_limits<uint8_t>::max)
96+
return EAABBFormat::U16;
97+
return EAABBFormat::U8;
98+
99+
}
100+
}
101+
return EAABBFormat::BitCount;
102+
}
51103
// using `nbl::hlsl::` concepts instead of `std::` so that `nbl::hlsl::float16_t` can be used
52104
union SAABBStorage
53105
{

src/nbl/asset/IAssetManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void IAssetManager::addLoadersAndWriters()
124124
addAssetLoader(core::make_smart_refctd_ptr<asset::CSTLMeshFileLoader>(this));
125125
#endif
126126
#ifdef _NBL_COMPILE_WITH_PLY_LOADER_
127-
addAssetLoader(core::make_smart_refctd_ptr<asset::CPLYMeshFileLoader>(this));
127+
addAssetLoader(core::make_smart_refctd_ptr<asset::CPLYMeshFileLoader>());
128128
#endif
129129
#ifdef _NBL_COMPILE_WITH_MTL_LOADER_
130130
addAssetLoader(core::make_smart_refctd_ptr<asset::CGraphicsPipelineLoaderMTL>(this, core::smart_refctd_ptr<system::ISystem>(m_system)));

0 commit comments

Comments
 (0)