Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ option(NBL_BUILD_DPL "Enable DPL (Dynamic Parallelism Library)" OFF)
option(NBL_PCH "Enable pre-compiled header" ON)
option(NBL_FAST_MATH "Enable fast low-precision math" OFF) # the reason OFF is by default now is the var controling it at build time was set AFTER BuildConfigOptions was generated - resulting in the feature being always OFF regardless the value xD - so just for sanity, keeping the same behaviour by default
option(NBL_BUILD_EXAMPLES "Enable building examples" ON)
option(NBL_BUILD_MITSUBA_LOADER "Enable nbl::ext::MitsubaLoader?" OFF) # TODO: once it compies turn this ON by default!
option(NBL_BUILD_MITSUBA_LOADER "Enable nbl::ext::MitsubaLoader?" ON)
option(NBL_BUILD_IMGUI "Enable nbl::ext::ImGui?" ON)

option(NBL_BUILD_OPTIX "Enable nbl::ext::OptiX?" OFF)
Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"NBL_UPDATE_GIT_SUBMODULE": "OFF",
"NBL_COMPILE_WITH_CUDA": "OFF",
"NBL_BUILD_OPTIX": "OFF",
"NBL_BUILD_MITSUBA_LOADER": "OFF",
"NBL_BUILD_MITSUBA_LOADER": "ON",
"NBL_BUILD_RADEON_RAYS": "OFF",
"_NBL_COMPILE_WITH_OPEN_EXR_": "ON",
"NBL_EXPLICIT_MODULE_LOAD_LOG": "ON",
Expand Down
36 changes: 18 additions & 18 deletions include/nbl/asset/IAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,24 @@ class IAsset : virtual public core::IReferenceCounted
//!
inline bool isMutable() const {return m_mutable;}

inline void visitDependents(std::function<bool(const IAsset*)> visit) const
{
visitDependents_impl([&visit](const IAsset* dep)->bool
{
if (dep)
return visit(dep);
return true;
});
}

inline void visitDependents(std::function<bool(IAsset*)> visit)
{
assert(isMutable());
visitDependents([&](const IAsset* dependent) -> bool
{
return visit(const_cast<IAsset*>(dependent));
});
}
inline void visitDependents(std::function<bool(const IAsset*)> visit) const
{
visitDependents_impl([&visit](const IAsset* dep)->bool
{
if (dep)
return visit(dep);
return true;
});
}

inline void visitDependents(std::function<bool(IAsset*)> visit)
{
assert(isMutable());
visitDependents([&](const IAsset* dependent) -> bool
{
return visit(const_cast<IAsset*>(dependent));
});
}

virtual bool valid() const = 0;

Expand Down
4 changes: 2 additions & 2 deletions include/nbl/asset/ICPUMorphTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NBL_API2 ICPUMorphTargets : public IAsset, public IMorphTargets<ICPUGeomet
inline E_TYPE getAssetType() const override {return AssetType;}

//
inline bool valid() const //override
inline bool valid() const override
{
for (const auto& target : m_targets)
if (!target || !target.geoCollection->valid())
Expand Down Expand Up @@ -55,7 +55,7 @@ class NBL_API2 ICPUMorphTargets : public IAsset, public IMorphTargets<ICPUGeomet

protected:
//
inline void visitDependents_impl(std::function<bool(const IAsset*)> visit) const //override
inline void visitDependents_impl(std::function<bool(const IAsset*)> visit) const override
{
auto nonNullOnly = [&visit](const IAsset* dep)->bool
{
Expand Down
54 changes: 54 additions & 0 deletions include/nbl/asset/ICPUScene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (C) 2025-2025 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_ASSET_I_CPU_SCENE_H_INCLUDED_
#define _NBL_ASSET_I_CPU_SCENE_H_INCLUDED_


#include "nbl/asset/IScene.h"
// TODO: change to true IR later
#include "nbl/asset/material_compiler3/CFrontendIR.h"


namespace nbl::asset
{
//
class NBL_API2 ICPUScene : public IAsset, public IScene
{
using base_t = IScene;

public:
inline ICPUScene() = default;

constexpr static inline auto AssetType = ET_SCENE;
inline E_TYPE getAssetType() const override { return AssetType; }

inline bool valid() const override
{
return true;
}

inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth=~0u) const
{
const auto nextDepth = _depth ? (_depth-1):0;
auto retval = core::smart_refctd_ptr<ICPUScene>();
return retval;
}

protected:
//
inline void visitDependents_impl(std::function<bool(const IAsset*)> visit) const override
{
}


// suggested contents:
// - morph target list
// - material table
// - instance list (morph target, keyframed transforms, material table indexings, FUTURE: reference skeleton)
// - area light list (OBB decompositions, material table indexings)
// - envlight data
};
}

#endif
23 changes: 23 additions & 0 deletions include/nbl/asset/IScene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2025-2025 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_ASSET_I_SCENE_H_INCLUDED_
#define _NBL_ASSET_I_SCENE_H_INCLUDED_


#include "nbl/asset/IMorphTargets.h"


namespace nbl::asset
{
// This is incredibly temporary, lots of things are going to change
class NBL_API2 IScene : public virtual core::IReferenceCounted
{
public:

protected:
virtual ~IScene() = default;
};
}

#endif
1 change: 1 addition & 0 deletions include/nbl/asset/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "nbl/asset/interchange/IAssetLoader.h"
#include "nbl/asset/interchange/IImageLoader.h"
#include "nbl/asset/interchange/IGeometryLoader.h"
#include "nbl/asset/interchange/ISceneLoader.h"
#include "nbl/asset/interchange/IAssetWriter.h"
#include "nbl/asset/interchange/IImageWriter.h"
#include "nbl/asset/metadata/COpenEXRMetadata.h"
Expand Down
4 changes: 2 additions & 2 deletions include/nbl/asset/interchange/IAssetLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class NBL_API2 IAssetLoader : public virtual core::IReferenceCounted
enum E_LOADER_PARAMETER_FLAGS : uint64_t
{
ELPF_NONE = 0, //!< default value, it doesn't do anything
ELPF_RIGHT_HANDED_MESHES = 0x1, //!< specifies that a mesh will be flipped in such a way that it'll look correctly in right-handed camera system
ELPF_DONT_COMPILE_GLSL = 0x2, //!< it states that GLSL won't be compiled to SPIR-V if it is loaded or generated
/*deprecated*/ELPF_RIGHT_HANDED_MESHES = 0x1, //!< specifies that a mesh will be flipped in such a way that it'll look correctly in right-handed camera system
/*deprecated*/ELPF_DONT_COMPILE_GLSL = 0x2, //!< it states that GLSL won't be compiled to SPIR-V if it is loaded or generated
ELPF_LOAD_METADATA_ONLY = 0x4 //!< it forces the loader to not load the entire scene for performance in special cases to fetch metadata.
};

Expand Down
5 changes: 2 additions & 3 deletions include/nbl/asset/interchange/IImageLoader.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#ifndef __NBL_ASSET_I_IMAGE_LOADER_H_INCLUDED__
#define __NBL_ASSET_I_IMAGE_LOADER_H_INCLUDED__
#ifndef _NBL_ASSET_I_IMAGE_LOADER_H_INCLUDED_
#define _NBL_ASSET_I_IMAGE_LOADER_H_INCLUDED_

#include "nbl/core/declarations.h"

Expand Down
30 changes: 30 additions & 0 deletions include/nbl/asset/interchange/ISceneLoader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2025-2025 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_ASSET_I_SCENE_LOADER_H_INCLUDED_
#define _NBL_ASSET_I_SCENE_LOADER_H_INCLUDED_


#include "nbl/core/declarations.h"

#include "nbl/asset/ICPUScene.h"
#include "nbl/asset/interchange/IAssetLoader.h"


namespace nbl::asset
{

class ISceneLoader : public IAssetLoader
{
public:
virtual inline uint64_t getSupportedAssetTypesBitfield() const override {return IAsset::ET_SCENE;}

protected:
inline ISceneLoader() {}

private:
};

}

#endif
56 changes: 20 additions & 36 deletions include/nbl/ext/MitsubaLoader/CMitsubaLoader.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_EXT_MISTUBA_LOADER_C_MITSUBA_LOADER_H_INCLUDED_
#define _NBL_EXT_MISTUBA_LOADER_C_MITSUBA_LOADER_H_INCLUDED_

#ifndef __C_MITSUBA_LOADER_H_INCLUDED__
#define __C_MITSUBA_LOADER_H_INCLUDED__

#include "nbl/asset/asset.h"

#include "IFileSystem.h"
#include "nbl/asset/utils/ICPUVirtualTexture.h"

#include "nbl/ext/MitsubaLoader/CSerializedLoader.h"
#include "nbl/ext/MitsubaLoader/CMitsubaMetadata.h"
#include "nbl/ext/MitsubaLoader/CElementShape.h"
//#include "nbl/ext/MitsubaLoader/CMitsubaMetadata.h"
//#include "nbl/ext/MitsubaLoader/CElementShape.h"
#include "nbl/ext/MitsubaLoader/SContext.h"


Expand All @@ -23,8 +20,7 @@ namespace nbl::ext::MitsubaLoader
class CElementBSDF;
class CMitsubaMaterialCompilerFrontend;


// TODO: we need a GLSL to C++ compatibility wrapper
#if 0 // TODO
//#include "nbl/builtin/glsl/ext/MitsubaLoader/instance_data_struct.glsl"
#define uint uint32_t
#define uvec2 uint64_t
Expand All @@ -50,25 +46,16 @@ struct nbl_glsl_ext_Mitsuba_Loader_instance_data_t
#undef mat4x3
#undef nbl_glsl_MC_material_data_t
using instance_data_t = nbl_glsl_ext_Mitsuba_Loader_instance_data_t;
#endif


class CMitsubaLoader : public asset::IRenderpassIndependentPipelineLoader
class CMitsubaLoader final : public asset::ISceneLoader
{
friend class CMitsubaMaterialCompilerFrontend;
public:
//! Constructor
CMitsubaLoader(asset::IAssetManager* _manager, io::IFileSystem* _fs);

void initialize() override;

protected:
io::IFileSystem* m_filesystem;
// friend class CMitsubaMaterialCompilerFrontend;
core::smart_refctd_ptr<system::ISystem> m_system;

//! Destructor
virtual ~CMitsubaLoader() = default;

static core::smart_refctd_ptr<asset::ICPUPipelineLayout> createPipelineLayout(asset::IAssetManager* _manager, const asset::ICPUVirtualTexture* _vt);

#if 0
//
core::vector<SContext::shape_ass_type> getMesh(SContext& ctx, uint32_t hierarchyLevel, CElementShape* shape);
core::vector<SContext::shape_ass_type> loadShapeGroup(SContext& ctx, uint32_t hierarchyLevel, const CElementShape::ShapeGroup* shapegroup, const core::matrix3x4SIMD& relTform);
Expand All @@ -82,24 +69,21 @@ class CMitsubaLoader : public asset::IRenderpassIndependentPipelineLoader

template <typename Iter>
core::smart_refctd_ptr<asset::ICPUDescriptorSet> createDS0(const SContext& _ctx, asset::ICPUPipelineLayout* _layout, const asset::material_compiler::CMaterialCompilerGLSLBackendCommon::result_t& _compResult, Iter meshBegin, Iter meshEnd);

#endif
public:
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
bool isALoadableFileFormat(io::IReadFile* _file) const override;
//! Constructor
inline CMitsubaLoader(core::smart_refctd_ptr<system::ISystem>&& _system) : m_system(std::move(_system)) {}

//! Returns an array of string literals terminated by nullptr
const char** getAssociatedFileExtensions() const override;
bool isALoadableFileFormat(system::IFile* _file, const system::logger_opt_ptr logger=nullptr) const override;

//! Returns the assets loaded by the loader
/** Bits of the returned value correspond to each IAsset::E_TYPE
enumeration member, and the return value cannot be 0. */
uint64_t getSupportedAssetTypesBitfield() const override { return asset::IAsset::ET_MESH/*|asset::IAsset::ET_SCENE|asset::IAsset::ET_IMPLEMENTATION_SPECIFIC_METADATA*/; }
inline const char** getAssociatedFileExtensions() const override
{
static const char* ext[]{ "xml", nullptr };
return ext;
}

//! Loads an asset from an opened file, returns nullptr in case of failure.
asset::SAssetBundle loadAsset(io::IReadFile* _file, const asset::IAssetLoader::SAssetLoadParams& _params, asset::IAssetLoader::IAssetLoaderOverride* _override = nullptr, uint32_t _hierarchyLevel = 0u) override;
asset::SAssetBundle loadAsset(system::IFile* _file, const asset::IAssetLoader::SAssetLoadParams& _params, asset::IAssetLoader::IAssetLoaderOverride* _override=nullptr, uint32_t _hierarchyLevel=0u) override;
};

}
Expand Down
11 changes: 5 additions & 6 deletions include/nbl/ext/MitsubaLoader/CMitsubaMaterialCompilerFrontend.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _C_MITSUBA_MATERIAL_COMPILER_FRONTEND_H_INCLUDED_
#define _C_MITSUBA_MATERIAL_COMPILER_FRONTEND_H_INCLUDED_

#ifndef __C_MITSUBA_MATERIAL_COMPILER_FRONTEND_H_INCLUDED__
#define __C_MITSUBA_MATERIAL_COMPILER_FRONTEND_H_INCLUDED__

#include "nbl/core/Types.h"

#include "nbl/asset/material_compiler/IR.h"
//#include "nbl/asset/material_compiler/IR.h"

#include "nbl/ext/MitsubaLoader/CElementBSDF.h"
#include "nbl/ext/MitsubaLoader/CElementEmitter.h"
Expand All @@ -23,6 +21,7 @@ struct SContext;
class CMitsubaMaterialCompilerFrontend
{
public:
#ifdef 0
using IRNode = asset::material_compiler::IR::INode;
using EmitterNode = asset::material_compiler::IR::CEmitterNode;
enum E_IMAGE_VIEW_SEMANTIC : uint8_t
Expand Down Expand Up @@ -60,8 +59,8 @@ class CMitsubaMaterialCompilerFrontend
tex_ass_type getErrorTexture(const E_IMAGE_VIEW_SEMANTIC semantic) const;

IRNode* createIRNode(asset::material_compiler::IR* ir, const CElementBSDF* _bsdf);
#endif
};

}

#endif
Loading
Loading