Skip to content

Commit ba669f7

Browse files
committed
address all ISystem comments - nuke some stuff, make it compile but encounter issues at runtime
1 parent 0433827 commit ba669f7

File tree

14 files changed

+110
-130
lines changed

14 files changed

+110
-130
lines changed

examples_tests

include/nbl/builtin/common.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

include/nbl/scene/ICullingLoDSelectionSystem.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,17 @@ class ICullingLoDSelectionSystem : public virtual core::IReferenceCounted
490490
auto getShader = [device]<core::StringLiteral Path>() -> shader_source_and_path
491491
{
492492
auto system = device->getPhysicalDevice()->getSystem();
493-
auto glslFile = system->loadBuiltinData<Path>();
493+
494+
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
495+
{
496+
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
497+
system->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
498+
if (future.wait())
499+
return future.copy();
500+
return nullptr;
501+
};
502+
503+
auto glslFile = loadBuiltinData(Path.value);
494504
core::smart_refctd_ptr<asset::ICPUBuffer> glsl;
495505
{
496506
glsl = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glslFile->getSize());

include/nbl/scene/ISkinInstanceCacheManager.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ class ISkinInstanceCacheManager : public virtual core::IReferenceCounted
2626
auto system = device->getPhysicalDevice()->getSystem();
2727
auto createShader = [&system,&device](auto uniqueString, asset::IShader::E_SHADER_STAGE type=asset::IShader::ESS_COMPUTE) -> core::smart_refctd_ptr<video::IGPUSpecializedShader>
2828
{
29-
auto glslFile = system->loadBuiltinData<decltype(uniqueString)>();
29+
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
30+
{
31+
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
32+
system->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
33+
if (future.wait())
34+
return future.copy();
35+
return nullptr;
36+
};
37+
38+
auto glslFile = loadBuiltinData(uniqueString);
3039
core::smart_refctd_ptr<asset::ICPUBuffer> glsl;
3140
{
3241
glsl = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glslFile->getSize());
@@ -36,9 +45,9 @@ class ISkinInstanceCacheManager : public virtual core::IReferenceCounted
3645
return device->createSpecializedShader(shader.get(),{nullptr,nullptr,"main"});
3746
};
3847

39-
auto updateSpec = createShader(NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/skinning/cache_update.comp")());
40-
auto debugDrawVertexSpec = createShader(NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/skinning/debug.vert")(),asset::IShader::ESS_VERTEX);
41-
auto debugDrawFragmentSpec = createShader(NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag")(),asset::IShader::ESS_FRAGMENT);
48+
auto updateSpec = createShader("nbl/builtin/glsl/skinning/cache_update.comp");
49+
auto debugDrawVertexSpec = createShader("nbl/builtin/glsl/skinning/debug.vert",asset::IShader::ESS_VERTEX);
50+
auto debugDrawFragmentSpec = createShader("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag",asset::IShader::ESS_FRAGMENT);
4251
if (!updateSpec || !debugDrawVertexSpec || !debugDrawFragmentSpec)
4352
return nullptr;
4453

include/nbl/scene/ITransformTreeManager.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,16 @@ class ITransformTreeManager : public virtual core::IReferenceCounted
108108
auto system = device->getPhysicalDevice()->getSystem();
109109
auto createShader = [&system,&device]<core::StringLiteral Path>(asset::IShader::E_SHADER_STAGE type=asset::IShader::ESS_COMPUTE) -> core::smart_refctd_ptr<video::IGPUSpecializedShader>
110110
{
111-
auto glslFile = system->loadBuiltinData<Path>();
111+
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
112+
{
113+
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
114+
system->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
115+
if (future.wait())
116+
return future.copy();
117+
return nullptr;
118+
};
119+
120+
auto glslFile = loadBuiltinData(Path.value);
112121
core::smart_refctd_ptr<asset::ICPUBuffer> glsl;
113122
{
114123
glsl = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glslFile->getSize());

include/nbl/system/ISystem.h

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
#include "nbl/core/declarations.h"
66
#include "nbl/core/util/bitflag.h"
77

8-
//#include "nbl/system/ICancellableAsyncQueueDispatcher.h"
9-
//#include "nbl/system/IFileArchive.h"
10-
11-
#include "nbl/builtin/common.h"
12-
138
#include <variant>
149

1510
#include "nbl/system/IFileArchive.h"
1611
#include "nbl/system/IAsyncQueueDispatcher.h"
1712

13+
#ifdef _NBL_EMBED_BUILTIN_RESOURCES_
14+
#include "nbl/builtin/builtinResources.h"
15+
#endif
16+
1817
namespace nbl::system
1918
{
2019

@@ -61,21 +60,6 @@ class NBL_API2 ISystem : public core::IReferenceCounted
6160
}
6261
#endif
6362

64-
//! Compile time resource ID
65-
template<nbl::core::StringLiteral Path>
66-
inline core::smart_refctd_ptr<const IFile> loadBuiltinData()
67-
{
68-
#ifdef _NBL_EMBED_BUILTIN_RESOURCES_
69-
return impl_loadEmbeddedBuiltinData(Path.value,nbl::builtin::get_resource<Path>());
70-
#else
71-
future_t<core::smart_refctd_ptr<IFile>> future;
72-
createFile(future,system::path(Path.value),core::bitflag(IFileBase::ECF_READ)|IFileBase::ECF_MAPPABLE);
73-
if (future.wait())
74-
return future.copy();
75-
return nullptr;
76-
#endif
77-
}
78-
7963
//
8064
inline void addArchiveLoader(core::smart_refctd_ptr<IArchiveLoader>&& loader)
8165
{
@@ -209,9 +193,6 @@ class NBL_API2 ISystem : public core::IReferenceCounted
209193
explicit ISystem(core::smart_refctd_ptr<ICaller>&& caller);
210194
virtual ~ISystem() {}
211195

212-
//
213-
core::smart_refctd_ptr<const IFile> impl_loadEmbeddedBuiltinData(const std::string& builtinPath, const std::pair<const uint8_t*,size_t>& found) const;
214-
215196
// given an `absolutePath` find the archive it belongs to
216197
struct FoundArchiveFile
217198
{

src/nbl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ nbl_get_conf_dir(NABLA_CONF_DIR_DEBUG Debug)
116116
nbl_get_conf_dir(NABLA_CONF_DIR_RELEASE Release)
117117
if(NBL_EMBED_BUILTIN_RESOURCES)
118118
add_subdirectory(builtin)
119-
NBL_ADD_BUILTIN_RESOURCES(nblBuiltinResourceData)
119+
NBL_ADD_BUILTIN_RESOURCES(nblBuiltinResourceData) # internal, must be added with the macro to properly propagate scope
120120
endif()
121121
nbl_get_conf_dir(NABLA_CONF_DIR_RELWITHDEBINFO RelWithDebInfo)
122122

src/nbl/asset/IAssetManager.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,38 +242,47 @@ void IAssetManager::insertBuiltinAssets()
242242
};
243243
auto fileSystem = getSystem();
244244

245-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/specialized_shader/fullscreentriangle.vert")>(),
245+
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
246+
{
247+
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
248+
fileSystem->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
249+
if (future.wait())
250+
return future.copy();
251+
return nullptr;
252+
};
253+
254+
buildInGLSLShader(loadBuiltinData("nbl/builtin/specialized_shader/fullscreentriangle.vert"),
246255
asset::IShader::ESS_VERTEX,
247256
{
248257
"nbl/builtin/specialized_shader/fullscreentriangle.vert"
249258
});
250-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/lambertian/singletexture/specialized_shader.vert")>(),
259+
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/lambertian/singletexture/specialized_shader.vert"),
251260
asset::IShader::ESS_VERTEX,
252261
{
253262
"nbl/builtin/material/lambertian/singletexture/specialized_shader.vert",
254263
"nbl/builtin/material/debug/vertex_uv/specialized_shader.vert"
255264
});
256-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/lambertian/singletexture/specialized_shader.frag")>(), // it somehow adds an extra "tt" raw string to the end of the returned value, beware
265+
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/lambertian/singletexture/specialized_shader.frag"), // it somehow adds an extra "tt" raw string to the end of the returned value, beware
257266
asset::IShader::ESS_FRAGMENT,
258267
{
259268
"nbl/builtin/material/lambertian/singletexture/specialized_shader.frag"
260269
});
261270

262-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.vert")>(),
271+
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_normal/specialized_shader.vert"),
263272
asset::IShader::ESS_VERTEX,
264273
{
265274
"nbl/builtin/material/debug/vertex_normal/specialized_shader.vert"});
266-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_color/specialized_shader.vert")>(),
275+
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_color/specialized_shader.vert"),
267276
asset::IShader::ESS_VERTEX,
268277
{
269278
"nbl/builtin/material/debug/vertex_color/specialized_shader.vert"
270279
});
271-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_uv/specialized_shader.frag")>(),
280+
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_uv/specialized_shader.frag"),
272281
asset::IShader::ESS_FRAGMENT,
273282
{
274283
"nbl/builtin/material/debug/vertex_uv/specialized_shader.frag"
275284
});
276-
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag")>(),
285+
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag"),
277286
asset::IShader::ESS_FRAGMENT,
278287
{
279288
"nbl/builtin/material/debug/vertex_normal/specialized_shader.frag",

src/nbl/asset/interchange/CGLTFLoader.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,18 @@ using namespace nbl::asset;
4747
{
4848
auto registerShader = [&](auto constexprStringType, IShader::E_SHADER_STAGE stage, const char* extraDefine=nullptr) -> void
4949
{
50-
core::smart_refctd_ptr<const system::IFile> glslFile = assetManager->getSystem()->loadBuiltinData<decltype(constexprStringType)>();
50+
auto fileSystem = assetManager->getSystem();
51+
52+
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
53+
{
54+
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
55+
fileSystem->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
56+
if (future.wait())
57+
return future.copy();
58+
return nullptr;
59+
};
60+
61+
core::smart_refctd_ptr<const system::IFile> glslFile = loadBuiltinData(decltype(constexprStringType)::value);
5162
auto glsl = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glslFile->getSize());
5263
memcpy(glsl->getPointer(),glslFile->getMappedPointer(),glsl->getSize());
5364

src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@ CGraphicsPipelineLoaderMTL::CGraphicsPipelineLoaderMTL(IAssetManager* _am, core:
3030
//create vertex shaders and insert them into cache
3131
auto registerShader = [&]<core::StringLiteral Path>(ICPUShader::E_SHADER_STAGE stage) -> void
3232
{
33-
core::smart_refctd_ptr<const system::IFile> data = m_assetMgr->getSystem()->loadBuiltinData<Path>();
33+
auto fileSystem = m_assetMgr->getSystem();
34+
35+
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
36+
{
37+
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
38+
fileSystem->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
39+
if (future.wait())
40+
return future.copy();
41+
return nullptr;
42+
};
43+
44+
core::smart_refctd_ptr<const system::IFile> data = loadBuiltinData(Path.value);
3445
auto buffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(data->getSize()+1u);
3546
char* bufferPtr = reinterpret_cast<char*>(buffer->getPointer());
3647
memcpy(bufferPtr, data->getMappedPointer(), data->getSize());

0 commit comments

Comments
 (0)