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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix a few things here and there
devshgraphicsprogramming committed Mar 14, 2023
commit b535556a775c4e10522779734ba3959e6be648a6
33 changes: 27 additions & 6 deletions include/nbl/system/IAsyncQueueDispatcher.h
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ class IAsyncQueueDispatcherBase

protected:
// the base class is not directly usable
inline request_base_t() = default;
inline ~request_base_t()
{
// fully cleaned up
@@ -114,6 +115,7 @@ class IAsyncQueueDispatcherBase
}

// the base class is not directly usable
inline future_base_t() = default;
virtual inline ~future_base_t()
{
// non-cancellable future just need to get to this state, and cancellable will move here
@@ -127,7 +129,7 @@ class IAsyncQueueDispatcherBase

// this tells us whether an object with a lifetime has been constructed over the memory backing the future
// also acts as a lock
atomic_state_t<STATE,STATE::INITIAL> state= {};
atomic_state_t<STATE,STATE::INITIAL> state = {};
};

// not meant for direct usage
@@ -146,7 +148,7 @@ class IAsyncQueueDispatcherBase
}

public:
inline future_t() {}
inline future_t() : future_base_t() {}
inline ~future_t()
{
discard();
@@ -258,6 +260,8 @@ class IAsyncQueueDispatcherBase
}

protected:
// to get access to the below
friend class IAsyncQueueDispatcherBase;
// construct the retval element
template <typename... Args>
inline void construct(Args&&... args)
@@ -331,6 +335,21 @@ class IAsyncQueueDispatcherBase
return false;
}
};

protected:
template<typename T>
class future_constructor_t final
{
future_t<T>* pFuture;
public:
inline future_constructor_t(future_base_t* _future_base) : pFuture(static_cast<future_t<T>*>(_future_base)) {}

template<typename... Args>
inline void operator()(Args&&... args)
{
pFuture->construct(std::forward<Args>(args)...);
}
};
};

inline void IAsyncQueueDispatcherBase::request_base_t::finalize(future_base_t* fut)
@@ -388,7 +407,9 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro

struct request_t : public request_base_t
{
request_metadata_t m_metadata;
inline request_t() : request_base_t() {}

request_metadata_t m_metadata = {};
};

private:
@@ -410,7 +431,7 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro

public:
inline IAsyncQueueDispatcher() {}
inline IAsyncQueueDispatcher(base_t::start_on_construction_t) : base_t(base_t::start_on_construction_t) {}
inline IAsyncQueueDispatcher(base_t::start_on_construction_t) : base_t(base_t::start_on_construction) {}

using mutex_t = typename base_t::mutex_t;
using lock_t = typename base_t::lock_t;
@@ -454,7 +475,7 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
inline void background_work() {}

private:
template <typename... Args>
template<typename... Args>
void work(lock_t& lock, Args&&... optional_internal_state)
{
lock.unlock();
@@ -472,7 +493,7 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
if (req.wait())
{
// if the request supports cancelling and got cancelled, then `wait()` function may return false
static_cast<CRTP*>(this)->process_request(req.m_metadata,optional_internal_state...);
static_cast<CRTP*>(this)->process_request(nullptr/*TODO*/,req.m_metadata,optional_internal_state...);
req.notify();
}
// wake the waiter up
6 changes: 3 additions & 3 deletions include/nbl/system/atomic_state.h
Original file line number Diff line number Diff line change
@@ -51,11 +51,11 @@ class atomic_state_t
}
[[nodiscard]] inline bool waitAbortableTransition(const STATE to, const STATE from, const STATE abortState)
{
uint32_t expected = static_cast<uint32_t>(from);
STATE expected = from;
while (!tryTransition(to,expected))
{
state.wait(expected);
if (expected==static_cast<uint32_t>(abortState))
state.wait(static_cast<uint32_t>(expected));
if (expected==abortState)
return false;
expected = from;
}