Skip to content

Commit

Permalink
adjust syntax for creating semaphore_value_info
Browse files Browse the repository at this point in the history
achieved by adding operator,() overload
allow creation of semaphore_signal_info via semaphore_value_info
new semaphore_signal_info / semaphore_wait_info syntax:
pipelineStageFlags >> (signalSemaphore, newValue)
(waitSemaphore, waitValue) >> pipelineStageFlags
  • Loading branch information
MoritzRoth committed Oct 8, 2023
1 parent a5c9355 commit 2d1439f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
35 changes: 16 additions & 19 deletions include/avk/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,18 @@ namespace avk
#endif
}

/** Helper struct to specify a semaphore and a signal value for it.
* This is used for timeline semaphores.
*/
struct semaphore_value_info
{
avk::resource_argument<avk::semaphore_t> mSemaphore;
uint64_t mValue;
};
inline semaphore_value_info operator,(avk::resource_argument<avk::semaphore_t> aSemaphore, uint64_t aValue) {
return semaphore_value_info{std::move(aSemaphore), aValue};
}

struct semaphore_wait_info
{
avk::resource_argument<avk::semaphore_t> mWaitSemaphore;
Expand All @@ -1124,14 +1136,10 @@ namespace avk
return semaphore_wait_info{ std::move(aSemaphore), aStageFlags, 0 };
}

/** Helper struct to specify a semaphore and a signal value for it.
* This is used for timeline semaphores.
*/
struct semaphore_value_info
inline semaphore_wait_info operator>> (semaphore_value_info aSemaphoreValueInfo, avk::stage::pipeline_stage_flags aStageFlags)
{
avk::resource_argument<avk::semaphore_t> mSignalSemaphore;
uint64_t mValue;
};
return semaphore_wait_info{ std::move(aSemaphoreValueInfo.mSemaphore), aStageFlags, aSemaphoreValueInfo.mValue };
}

struct semaphore_signal_info
{
Expand All @@ -1144,21 +1152,10 @@ namespace avk
{
return semaphore_signal_info{ aStageFlags, std::move(aSemaphore), 0 };
}

inline semaphore_value_info operator>> (avk::resource_argument<avk::semaphore_t> aSemaphore, uint64_t aSemaphoreValue)
{
return semaphore_value_info{ std::move(aSemaphore), aSemaphoreValue };
}

inline semaphore_signal_info operator>> (avk::stage::pipeline_stage_flags aStageFlags, semaphore_value_info aSemaphoreValueInfo)
{
return semaphore_signal_info{ aStageFlags, std::move(aSemaphoreValueInfo.mSignalSemaphore), aSemaphoreValueInfo.mValue };
}

inline semaphore_signal_info operator>> (avk::semaphore_signal_info aSemaphoreSignalInfo, uint64_t aSemaphoreValue)
{
aSemaphoreSignalInfo.mValue = aSemaphoreValue;
return aSemaphoreSignalInfo;
return semaphore_signal_info{ aStageFlags, std::move(aSemaphoreValueInfo.mSemaphore), aSemaphoreValueInfo.mValue };
}

class recorded_command_buffer;
Expand Down
6 changes: 3 additions & 3 deletions src/avk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7149,12 +7149,12 @@ namespace avk
return vk::Result::eSuccess;
}

const vk::Device& device = aSemaphoreValueInfos.front().mSignalSemaphore->mSemaphore.getOwner();
const vk::Device& device = aSemaphoreValueInfos.front().mSemaphore->mSemaphore.getOwner();
std::vector<vk::Semaphore> semHandles;
std::vector<uint64_t> timestampValues;
for (const auto& svi : aSemaphoreValueInfos) {
assert(device == svi.mSignalSemaphore->mSemaphore.getOwner());
semHandles.push_back(svi.mSignalSemaphore->handle());
assert(device == svi.mSemaphore->mSemaphore.getOwner());
semHandles.push_back(svi.mSemaphore->handle());
timestampValues.push_back(svi.mValue);
}

Expand Down

0 comments on commit 2d1439f

Please sign in to comment.