Skip to content

Commit 65c2047

Browse files
author
devsh
committed
fix bad (reverse) implementation of checking validity of SDataView
Also set content hashes on Geometry Creator made ICPUBuffers
1 parent 8ed377a commit 65c2047

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

include/nbl/asset/ICPUPolygonGeometry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class NBL_API2 ICPUPolygonGeometry final : public IPolygonGeometry<ICPUBuffer>
122122
}
123123

124124
//
125+
inline const core::vector<SJointWeight>& getJointWeightViews() const {return base_t::getJointWeightViews();}
125126
inline core::vector<SJointWeight>* getJointWeightViews()
126127
{
127128
if (isMutable())

include/nbl/asset/IGeometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class IGeometryBase : public virtual core::IReferenceCounted
6666
struct SDataViewBase
6767
{
6868
// mostly checking validity of the format
69-
inline operator bool() const {return format==EF_UNKNOWN || isBlockCompressionFormat(format) && isDepthOrStencilFormat(format);}
69+
inline operator bool() const {return format==EF_UNKNOWN || !isBlockCompressionFormat(format) && !isDepthOrStencilFormat(format);}
7070

7171
//
7272
inline bool isFormatted() const {return format!=EF_UNKNOWN && bool(*this);}

include/nbl/asset/utils/CPolygonGeometryManipulator.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,47 @@
1313

1414
namespace nbl::asset
1515
{
16+
17+
// TODO: move to its own header!
18+
class NBL_API2 CGeometryManipulator
19+
{
20+
public:
21+
static inline void recomputeContentHash(const IGeometry<ICPUBuffer>::SDataView& view)
22+
{
23+
if (!view)
24+
return;
25+
view.src.buffer->setContentHash(view.src.buffer->computeContentHash());
26+
}
27+
28+
// TODO: static inline IGeometryBase::SDataViewBase::SAABBStorage computeRange(const IGeometry<ICPUBuffer>::SDataView& view)
29+
30+
// TODO: static inline void recomputeRange(IGeometry<ICPUBuffer>::SDataView& view)
31+
};
32+
1633
//! An interface for easy manipulation of polygon geometries.
1734
class NBL_API2 CPolygonGeometryManipulator
1835
{
1936
public:
37+
static inline void recomputeContentHashes(ICPUPolygonGeometry* geo)
38+
{
39+
if (!geo)
40+
return;
41+
CGeometryManipulator::recomputeContentHash(geo->getPositionView());
42+
CGeometryManipulator::recomputeContentHash(geo->getIndexView());
43+
CGeometryManipulator::recomputeContentHash(geo->getNormalView());
44+
for (const auto& view : *geo->getJointWeightViews())
45+
{
46+
CGeometryManipulator::recomputeContentHash(view.indices);
47+
CGeometryManipulator::recomputeContentHash(view.weights);
48+
}
49+
if (auto pView=geo->getJointOBBView(); pView)
50+
CGeometryManipulator::recomputeContentHash(*pView);
51+
for (const auto& view : *geo->getAuxAttributeViews())
52+
CGeometryManipulator::recomputeContentHash(view);
53+
}
54+
55+
// TODO: recomputeRanges
56+
2057
//! Comparison methods
2158
enum E_ERROR_METRIC
2259
{

src/nbl/asset/utils/CGeometryCreator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createCube(const h
182182
}
183183
}
184184

185+
CPolygonGeometryManipulator::recomputeContentHashes(retval.get());
185186
return retval;
186187
}
187188

@@ -751,6 +752,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createRectangle(co
751752
}
752753
}
753754

755+
CPolygonGeometryManipulator::recomputeContentHashes(retval.get());
754756
return retval;
755757
}
756758

@@ -847,6 +849,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createDisk(const f
847849
}
848850
std::fill_n(normals,vertexCount,hlsl::vector<int8_t,4>(0,0,127,0));
849851

852+
CPolygonGeometryManipulator::recomputeContentHashes(retval.get());
850853
return retval;
851854
}
852855

0 commit comments

Comments
 (0)