Skip to content

Commit 300078b

Browse files
fixes for const correctness, Example 2 works
1 parent 38b8a81 commit 300078b

File tree

9 files changed

+12
-15
lines changed

9 files changed

+12
-15
lines changed

examples_tests/common/CommonAPI.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,8 @@ class CommonAPI
388388
{
389389
using namespace nbl;
390390
using namespace system;
391-
nbl::core::smart_refctd_ptr<nbl::system::ISystemCaller> caller = nullptr;
392391
#ifdef _NBL_PLATFORM_WINDOWS_
393-
caller = nbl::core::make_smart_refctd_ptr<nbl::system::CSystemCallerWin32>();
394-
#endif
395-
#ifdef _NBL_PLATFORM_WINDOWS_
396-
return nbl::core::make_smart_refctd_ptr<nbl::system::CSystemWin32>(std::move(caller));
392+
return nbl::core::make_smart_refctd_ptr<nbl::system::CSystemWin32>();
397393
#elif defined(_NBL_PLATFORM_ANDROID_)
398394
#if 0
399395
return nbl::core::make_smart_refctd_ptr<nbl::system::CSystemAndroid>(std::move(caller));

include/nbl/system/IFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class IFile : public IFileBase, private ISystem::IFutureManipulator
1212
//
1313
inline void read(ISystem::future_t<size_t>& fut, void* buffer, size_t offset, size_t sizeToRead)
1414
{
15-
const auto* ptr = reinterpret_cast<const std::byte*>(getMappedPointer());
15+
const IFileBase* constThis = this;
16+
const auto* ptr = reinterpret_cast<const std::byte*>(constThis->getMappedPointer());
1617
if (ptr)
1718
{
1819
const size_t size = getSize();

include/nbl/system/ISystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ISystem : public core::IReferenceCounted
113113

114114
//! Compile time resource ID
115115
template<typename StringUniqueType>
116-
inline core::smart_refctd_ptr<IFile> loadBuiltinData() const
116+
inline core::smart_refctd_ptr<const IFile> loadBuiltinData() const
117117
{
118118
#ifdef _NBL_EMBED_BUILTIN_RESOURCES_
119119
return impl_loadEmbeddedBuiltinData(StringUniqueType::value,nbl::builtin::get_resource<StringUniqueType>());
@@ -260,7 +260,7 @@ class ISystem : public core::IReferenceCounted
260260
virtual ~ISystem() {}
261261

262262
//
263-
core::smart_refctd_ptr<IFile> impl_loadEmbeddedBuiltinData(const std::string& builtinPath, const std::pair<const uint8_t*,size_t>& found) const;
263+
core::smart_refctd_ptr<const IFile> impl_loadEmbeddedBuiltinData(const std::string& builtinPath, const std::pair<const uint8_t*,size_t>& found) const;
264264

265265
// given an `absolutePath` find the archive it belongs to
266266
struct FoundArchiveFile

src/nbl/asset/IAssetManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void IAssetManager::insertBuiltinAssets()
220220
// materials
221221
{
222222
//
223-
auto buildInGLSLShader = [&]( core::smart_refctd_ptr<system::IFile>&& data,
223+
auto buildInGLSLShader = [&]( core::smart_refctd_ptr<const system::IFile>&& data,
224224
asset::IShader::E_SHADER_STAGE type,
225225
std::initializer_list<const char*> paths) -> void
226226
{

src/nbl/asset/interchange/CGLTFLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ using namespace nbl::asset;
4545
{
4646
auto registerShader = [&](auto constexprStringType, IShader::E_SHADER_STAGE stage, const char* extraDefine=nullptr) -> void
4747
{
48-
auto glslFile = assetManager->getSystem()->loadBuiltinData<decltype(constexprStringType)>();
48+
core::smart_refctd_ptr<const system::IFile> glslFile = assetManager->getSystem()->loadBuiltinData<decltype(constexprStringType)>();
4949
auto glsl = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glslFile->getSize());
5050
memcpy(glsl->getPointer(),glslFile->getMappedPointer(),glsl->getSize());
5151

src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CGraphicsPipelineLoaderMTL::CGraphicsPipelineLoaderMTL(IAssetManager* _am, core:
3131
//create vertex shaders and insert them into cache
3232
auto registerShader = [&](auto constexprStringType, ICPUShader::E_SHADER_STAGE stage) -> void
3333
{
34-
auto data = m_assetMgr->getSystem()->loadBuiltinData<decltype(constexprStringType)>();
34+
core::smart_refctd_ptr<const system::IFile> data = m_assetMgr->getSystem()->loadBuiltinData<decltype(constexprStringType)>();
3535
auto buffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(data->getSize());
3636
memcpy(buffer->getPointer(), data->getMappedPointer(), data->getSize());
3737
auto unspecializedShader = core::make_smart_refctd_ptr<asset::ICPUShader>(

src/nbl/asset/utils/IGLSLEmbeddedIncludeLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class IGLSLEmbeddedIncludeLoader : public IBuiltinIncludeLoader
5353
system::ISystem::future_t<core::smart_refctd_ptr<system::IFile>> future;
5454
auto path = "nbl/builtin/" + _name;
5555
s->createFile(future,path,core::bitflag(system::IFileBase::ECF_READ)|system::IFileBase::ECF_MAPPABLE);
56-
auto data = future.get();
56+
core::smart_refctd_ptr<const system::IFile> data = future.get();
5757
if (!data)
5858
return "";
5959
auto begin = reinterpret_cast<const char*>(data->getMappedPointer());

src/nbl/system/ISystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ISystem::ISystem(core::smart_refctd_ptr<ISystem::ICaller>&& caller) : m_dispatch
1616
addArchiveLoader(core::make_smart_refctd_ptr<CArchiveLoaderTar>(nullptr));
1717
}
1818

19-
core::smart_refctd_ptr<IFile> ISystem::impl_loadEmbeddedBuiltinData(const std::string& builtinPath, const std::pair<const uint8_t*,size_t>& found) const
19+
core::smart_refctd_ptr<const IFile> ISystem::impl_loadEmbeddedBuiltinData(const std::string& builtinPath, const std::pair<const uint8_t*,size_t>& found) const
2020
{
2121
#ifdef _NBL_EMBED_BUILTIN_RESOURCES_
2222
if (found.first && found.second)
@@ -215,7 +215,7 @@ void ISystem::createFile(future_t<core::smart_refctd_ptr<IFile>>& future, std::f
215215
auto file = impl_loadEmbeddedBuiltinData(filename.string(),nbl::builtin::get_resource_runtime(filename.string()));
216216
if (file)
217217
{
218-
future.notify(std::move(file));
218+
future.notify(core::smart_refctd_ptr<IFile>(const_cast<IFile*>(file.get())));
219219
return;
220220
}
221221
#else

src/nbl/video/utilities/CScanner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using namespace video;
66
core::smart_refctd_ptr<asset::ICPUShader> CScanner::createShader(const bool indirect, const E_SCAN_TYPE scanType, const E_DATA_TYPE dataType, const E_OPERATOR op) const
77
{
88
auto system = m_device->getPhysicalDevice()->getSystem();
9-
core::smart_refctd_ptr<nbl::system::IFile> glsl;
9+
core::smart_refctd_ptr<const system::IFile> glsl;
1010
{
1111
if(indirect)
1212
glsl = system->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/scan/indirect.comp")>();

0 commit comments

Comments
 (0)