Skip to content

Commit 9b37004

Browse files
author
devsh
committed
sort out the serialized loader interface and metadata
temporarily disable other Mitsuba loader files
1 parent 43a1d17 commit 9b37004

File tree

3 files changed

+53
-84
lines changed

3 files changed

+53
-84
lines changed

include/nbl/ext/MitsubaLoader/CMitsubaSerializedMetadata.h

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,36 @@ namespace nbl::ext::MitsubaLoader
1515
class CMitsubaSerializedMetadata final : public asset::IAssetMetadata
1616
{
1717
public:
18-
class CRenderpassIndependentPipeline : public asset::IRenderpassIndependentPipelineMetadata
18+
class CPolygonGeometry : public asset::IPolygonGeometryMetadata
1919
{
2020
public:
21-
CRenderpassIndependentPipeline(CRenderpassIndependentPipeline&& _other) : CRenderpassIndependentPipeline()
22-
{
23-
CRenderpassIndependentPipeline::operator=(std::move(_other));
24-
}
25-
template<typename... Args>
26-
CRenderpassIndependentPipeline(Args&&... args) : IRenderpassIndependentPipelineMetadata(std::forward<Args>(args)...) {}
27-
28-
inline CRenderpassIndependentPipeline& operator=(CRenderpassIndependentPipeline&& other)
29-
{
30-
IRenderpassIndependentPipelineMetadata::operator=(std::move(other));
31-
return *this;
32-
}
33-
};
34-
class CMesh : public asset::IMeshMetadata
35-
{
36-
public:
37-
inline CMesh() : IMeshMetadata() {}
38-
template<typename... Args>
39-
inline CMesh(std::string&& _name, const uint32_t _id, Args&&... args) : m_name(std::move(_name)), m_id(_id), IMeshMetadata(std::forward<Args>(args)...) {}
21+
inline CPolygonGeometry() : IPolygonGeometryMetadata() {}
22+
inline CPolygonGeometry(std::string&& _name, const uint32_t _id) : m_name(std::move(_name)), m_id(_id) {}
4023

4124
std::string m_name;
4225
uint32_t m_id;
4326
};
4427

45-
CMitsubaSerializedMetadata(const uint32_t meshBound, core::smart_refctd_dynamic_array<asset::IRenderpassIndependentPipelineMetadata::ShaderInputSemantic>&& _semanticStorage) :
46-
m_pipelineStorage(asset::IAssetMetadata::createContainer<CRenderpassIndependentPipeline>(meshBound)), m_meshStorage(asset::IAssetMetadata::createContainer<CMesh>(meshBound)), m_semanticStorage(std::move(_semanticStorage))
47-
{
48-
}
28+
inline CMitsubaSerializedMetadata(const uint32_t meshBound) : m_polygonGeometryStorage(asset::IAssetMetadata::createContainer<CPolygonGeometry>(meshBound)) {}
4929

5030
_NBL_STATIC_INLINE_CONSTEXPR const char* LoaderName = "ext::MitsubaLoader::CSerializedLoader";
5131
const char* getLoaderName() const override { return LoaderName; }
5232

5333
//!
54-
inline const CRenderpassIndependentPipeline* getAssetSpecificMetadata(const asset::ICPURenderpassIndependentPipeline* asset) const
55-
{
56-
const auto found = IAssetMetadata::getAssetSpecificMetadata(asset);
57-
return static_cast<const CRenderpassIndependentPipeline*>(found);
58-
}
59-
inline const CMesh* getAssetSpecificMetadata(const asset::ICPUMesh* asset) const
34+
inline const CPolygonGeometry* getAssetSpecificMetadata(const asset::ICPUPolygonGeometry* asset) const
6035
{
6136
const auto found = IAssetMetadata::getAssetSpecificMetadata(asset);
62-
return static_cast<const CMesh*>(found);
37+
return static_cast<const CPolygonGeometry*>(found);
6338
}
6439

6540
private:
66-
meta_container_t<CRenderpassIndependentPipeline> m_pipelineStorage;
67-
meta_container_t<CMesh> m_meshStorage;
68-
core::smart_refctd_dynamic_array<asset::IRenderpassIndependentPipelineMetadata::ShaderInputSemantic> m_semanticStorage;
41+
meta_container_t<CPolygonGeometry> m_polygonGeometryStorage;
6942

7043
friend class CSerializedLoader;
71-
inline void placeMeta(uint32_t offset, const asset::ICPURenderpassIndependentPipeline* ppln, const asset::ICPUMesh* mesh, CMesh&& meshMeta)
44+
inline void placeMeta(uint32_t offset, const asset::ICPUPolygonGeometry* geo, CPolygonGeometry&& geoMeta)
7245
{
73-
auto& pplnMetaRef = m_pipelineStorage->operator[](offset) = CRenderpassIndependentPipeline(core::SRange<const asset::IRenderpassIndependentPipelineMetadata::ShaderInputSemantic>(m_semanticStorage->begin(),m_semanticStorage->end()));
74-
auto& meshMetaRef = m_meshStorage->operator[](offset) = std::move(meshMeta);
75-
IAssetMetadata::insertAssetSpecificMetadata(ppln,&pplnMetaRef);
76-
IAssetMetadata::insertAssetSpecificMetadata(mesh,&meshMetaRef);
46+
auto& geoMetaRef = m_polygonGeometryStorage->operator[](offset) = std::move(geoMeta);
47+
IAssetMetadata::insertAssetSpecificMetadata(geo,&geoMetaRef);
7748
}
7849
};
7950

include/nbl/ext/MitsubaLoader/CSerializedLoader.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,27 @@
88
#include "nbl/system/declarations.h"
99

1010
#include "nbl/asset/asset.h"
11+
#include "nbl/asset/interchange/IGeometryLoader.h"
1112

1213

1314
namespace nbl::ext::MitsubaLoader
1415
{
1516

17+
#ifdef _NBL_COMPILE_WITH_ZLIB_
1618
//! Meshloader capable of loading obj meshes.
1719
class CSerializedLoader final : public asset::IGeometryLoader
1820
{
19-
protected:
20-
//! Destructor
21-
inline ~CSerializedLoader() {}
22-
2321
public:
24-
//! Constructor
25-
CSerializedLoader(asset::IAssetManager* _manager) : IGeometryLoader() {}
22+
inline CSerializedLoader() = default;
2623

2724
inline bool isALoadableFileFormat(system::IFile* _file, const system::logger_opt_ptr logger = nullptr) const override
2825
{
2926
FileHeader header;
30-
31-
system::future<size_t> future;
32-
_file->read(future, &header, 0u, sizeof(header));
33-
future.get();
27+
28+
system::IFile::success_t success;
29+
_file->read(success,&header,0,sizeof(header));
30+
if (!success)
31+
return false;
3432

3533
return header==FileHeader();
3634
}
@@ -45,7 +43,6 @@ class CSerializedLoader final : public asset::IGeometryLoader
4543
asset::SAssetBundle loadAsset(system::IFile* _file, const asset::IAssetLoader::SAssetLoadParams& _params, asset::IAssetLoader::IAssetLoaderOverride* _override = nullptr, uint32_t _hierarchyLevel = 0u) override;
4644

4745
private:
48-
4946
struct FileHeader
5047
{
5148
uint16_t format = 0x041Cu;
@@ -57,14 +54,15 @@ class CSerializedLoader final : public asset::IGeometryLoader
5754
}
5855
inline bool operator==(const FileHeader& other) { return !operator!=(other); }
5956
};
60-
6157
struct SContext
6258
{
6359
IAssetLoader::SAssetLoadContext inner;
6460
uint32_t meshCount;
61+
// TODO : this should really be a two arrays, offsets then sizes
6562
core::smart_refctd_dynamic_array<uint64_t> meshOffsets;
6663
};
6764
};
65+
#endif
6866

6967

7068
}

src/nbl/ext/MitsubaLoader/CMakeLists.txt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@ set(NBL_EXT_INTERNAL_INCLUDE_DIR "${NBL_ROOT_PATH}/include/nbl/ext/MitsubaLoader
44

55

66
set(NBL_EXT_MITSUBA_LOADER_H
7-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/PropertyElement.h
8-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/IElement.h
9-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaMetadata.h
10-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementIntegrator.h
11-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementSensor.h
12-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementFilm.h
13-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementRFilter.h
14-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementSampler.h
15-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementTransform.h
16-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementShape.h
17-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementBSDF.h
18-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementTexture.h
19-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementEmitter.h
20-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementFactory.h
21-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaSerializedMetadata.h
22-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/ParserUtil.h
7+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/PropertyElement.h
8+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/IElement.h
9+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaMetadata.h
10+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementIntegrator.h
11+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementSensor.h
12+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementFilm.h
13+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementRFilter.h
14+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementSampler.h
15+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementTransform.h
16+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementShape.h
17+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementBSDF.h
18+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementTexture.h
19+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementEmitter.h
20+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CElementFactory.h
21+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaSerializedMetadata.h
22+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/ParserUtil.h
2323
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CSerializedLoader.h
24-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaLoader.h
25-
${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaMaterialCompilerFrontend.h
24+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaLoader.h
25+
# ${NBL_EXT_INTERNAL_INCLUDE_DIR}/CMitsubaMaterialCompilerFrontend.h
2626
)
2727

2828
set(NBL_EXT_MITSUBA_LOADER_SRC
29-
PropertyElement.cpp
30-
CElementIntegrator.cpp
31-
CElementSensor.cpp
32-
CElementFilm.cpp
33-
CElementRFilter.cpp
34-
CElementSampler.cpp
35-
CElementTransform.cpp
36-
CElementShape.cpp
37-
CElementBSDF.cpp
38-
CElementTexture.cpp
39-
CElementEmitter.cpp
40-
CElementFactory.cpp
41-
ParserUtil.cpp
29+
# PropertyElement.cpp
30+
# CElementIntegrator.cpp
31+
# CElementSensor.cpp
32+
# CElementFilm.cpp
33+
# CElementRFilter.cpp
34+
# CElementSampler.cpp
35+
# CElementTransform.cpp
36+
# CElementShape.cpp
37+
# CElementBSDF.cpp
38+
# CElementTexture.cpp
39+
# CElementEmitter.cpp
40+
# CElementFactory.cpp
41+
# ParserUtil.cpp
4242
CSerializedLoader.cpp
43-
CMitsubaLoader.cpp
44-
CMitsubaMaterialCompilerFrontend.cpp
43+
# CMitsubaLoader.cpp
44+
# CMitsubaMaterialCompilerFrontend.cpp
4545
)
4646

4747
set(NBL_EXT_MITSUBA_LOADER_EXTERNAL_INCLUDE

0 commit comments

Comments
 (0)