Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Queue Refactor #476

Merged
merged 25 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ea3bc89
fix a bunch of docs
devshgraphicsprogramming Mar 2, 2023
de28767
ideas
devshgraphicsprogramming Mar 9, 2023
418db0d
better draft
devshgraphicsprogramming Mar 9, 2023
afa9dec
draft complete
devshgraphicsprogramming Mar 13, 2023
4a11105
the draft and the docs improve
devshgraphicsprogramming Mar 13, 2023
4273dfb
rework parts of `nbl::system` to work with the New API
devshgraphicsprogramming Mar 13, 2023
b535556
fix a few things here and there
devshgraphicsprogramming Mar 14, 2023
87eeacb
figure out how we're gonna construct the results over the future's st…
devshgraphicsprogramming Mar 14, 2023
2c46108
final missing piece
devshgraphicsprogramming Mar 14, 2023
1fa40e6
rework all loaders and a few other things to use new file API now
devshgraphicsprogramming Mar 14, 2023
8097e77
refactor a few windowing things
devshgraphicsprogramming Mar 17, 2023
8902116
boot the win32 implementations to `src/nbl/ui`
devshgraphicsprogramming Mar 17, 2023
a1b82a3
Everything makes far more sense after this refactor!
devshgraphicsprogramming Mar 17, 2023
a6ff1ae
try not to pollute with windows headers
devshgraphicsprogramming Mar 17, 2023
ca196a6
tiny bugs
devshgraphicsprogramming Mar 17, 2023
f8fb0fa
more funny bugs
devshgraphicsprogramming Mar 17, 2023
9b021a6
docs update
devshgraphicsprogramming Mar 18, 2023
33b9ec2
more docs
devshgraphicsprogramming Mar 18, 2023
c7a8f1e
Merge remote-tracking branch 'remotes/origin/master' into async_queues
devshgraphicsprogramming Mar 18, 2023
ebe1b01
resolve conflicts after merge
devshgraphicsprogramming Mar 18, 2023
94dbca2
fix weird build issues
devshgraphicsprogramming Mar 18, 2023
d00e5ce
more fix up for `ISystem::future_t`
devshgraphicsprogramming Mar 18, 2023
c6d7ea0
fix missing symbols for DLL builds
devshgraphicsprogramming Mar 21, 2023
73fcc8c
more DLL symbol fixes, also add some more logging
devshgraphicsprogramming Mar 21, 2023
1b91f2d
fix a typo in Descriptor Sets relating to Acceleration Structure
devshgraphicsprogramming Mar 22, 2023
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
23 changes: 8 additions & 15 deletions include/nbl/asset/IAssetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,12 @@ class NBL_API2 IAssetManager : public core::IReferenceCounted, public core::Quit
filePath = _params.workingDirectory/filePath;
_override->getLoadFilename(filePath, m_system.get(), ctx, _hierarchyLevel);
}

system::ISystem::future_t<core::smart_refctd_ptr<system::IFile>> future;
m_system->createFile(future, filePath, system::IFile::ECF_READ);
auto file = future.get();
if (!file)
return SAssetBundle(0);

return getAssetInHierarchy_impl<RestoreWholeBundle>(file.get(), filePath.string(), ctx.params, _hierarchyLevel, _override);
if (auto file=future.acquire())
return getAssetInHierarchy_impl<RestoreWholeBundle>(file->get(), filePath.string(), ctx.params, _hierarchyLevel, _override);
return SAssetBundle(0);
}

//TODO change name
Expand Down Expand Up @@ -652,15 +650,10 @@ class NBL_API2 IAssetManager : public core::IReferenceCounted, public core::Quit
_override = &defOverride;

system::ISystem::future_t<core::smart_refctd_ptr<system::IFile>> future;
m_system->createFile(future, (_params.workingDirectory.generic_string() + _filename).c_str(), system::IFile::ECF_WRITE);
auto file = future.get();
if (file) // could fail creating file (lack of permissions)
{
bool res = writeAsset(file.get(), _params, _override);
return res;
}
else
return false;
m_system->createFile(future, (_params.workingDirectory.generic_string()+_filename).c_str(), system::IFile::ECF_WRITE);
if (auto file=future.acquire())
return writeAsset(file->get(), _params, _override);
return false;
}
bool writeAsset(system::IFile* _file, const IAssetWriter::SAssetWriteParams& _params, IAssetWriter::IAssetWriterOverride* _override)
{
Expand Down
42 changes: 42 additions & 0 deletions include/nbl/core/StorageTrivializer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef __NBL_CORE_STORAGE_TRIVIALIZER_H_INCLUDED__
#define __NBL_CORE_STORAGE_TRIVIALIZER_H_INCLUDED__

namespace nbl::core
{

// This construct makes it so that we don't trigger T's constructors and destructors.
template<typename T>
struct StorageTrivializer;

template<>
struct NBL_FORCE_EBO StorageTrivializer<void>
{
void* getStorage() {return nullptr;}
const void* getStorage() const {return nullptr;}

void construct() {}
void destruct() {}
};

template<typename T>
struct alignas(T) StorageTrivializer
{
T* getStorage() {return reinterpret_cast<T*>(storage); }
const T* getStorage() const {return reinterpret_cast<const T*>(storage);}

template<typename... Args>
void construct(Args&&... args)
{
new (getStorage()) T(std::forward<Args>(args)...);
}
void destruct()
{
getStorage()->~T();
}

uint8_t* storage[sizeof(T)];
};

}

#endif
1 change: 1 addition & 0 deletions include/nbl/core/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "nbl/core/EventDeferredHandler.h"
#include "nbl/core/IBuffer.h"
#include "nbl/core/IReferenceCounted.h"
#include "nbl/core/StorageTrivializer.h"
#include "nbl/core/SRAIIBasedExiter.h"
#include "nbl/core/SRange.h"
#include "nbl/core/Byteswap.h"
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/system/CFileLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class CFileLogger : public IThreadsafeLogger
virtual void threadsafeLog_impl(const std::string_view& fmt, E_LOG_LEVEL logLevel, va_list args) override
{
const auto str = constructLogString(fmt, logLevel, args);
ISystem::future_t<size_t> future;
m_file->write(future,str.data(),m_pos,str.length());
m_pos += future.get(); // need to use the future to make sure op is actually executed :(
IFile::success_t succ;
m_file->write(succ,str.data(),m_pos,str.length());
m_pos += succ.getBytesProcessed();
}

core::smart_refctd_ptr<IFile> m_file;
Expand Down
Loading