diff --git a/src/dxvk/dxvk_event.cpp b/src/dxvk/dxvk_event.cpp new file mode 100644 index 000000000..1bf2099ce --- /dev/null +++ b/src/dxvk/dxvk_event.cpp @@ -0,0 +1,32 @@ +#include "dxvk_event.h" + +namespace dxvk { + + DxvkEvent:: DxvkEvent() { } + DxvkEvent::~DxvkEvent() { } + + + uint32_t DxvkEvent::reset() { + std::unique_lock lock(m_mutex); + + m_status = DxvkEventStatus::Reset; + return ++m_revision; + } + + + void DxvkEvent::signalEvent(uint32_t revision) { + std::unique_lock lock(m_mutex); + + if (m_revision == revision) { + m_status = DxvkEventStatus::Signaled; + m_signal.notify_one(); + } + } + + + DxvkEventStatus DxvkEvent::getStatus() { + std::unique_lock lock(m_mutex); + return m_status; + } + +} \ No newline at end of file diff --git a/src/dxvk/dxvk_event.h b/src/dxvk/dxvk_event.h new file mode 100644 index 000000000..d9df247c9 --- /dev/null +++ b/src/dxvk/dxvk_event.h @@ -0,0 +1,57 @@ +#pragma once + +#include +#include + +#include "dxvk_include.h" + +namespace dxvk { + + enum class DxvkEventStatus { + Reset = 0, + Signaled = 1, + }; + + /** + * \brief Event + * + * A CPU-side fence that will be signaled after + * all previous Vulkan commands recorded to a + * command buffer have finished executing. + */ + class DxvkEvent : public RcObject { + + public: + + DxvkEvent(); + ~DxvkEvent(); + + /** + * \brief Resets the event + * \returns New revision ID + */ + uint32_t reset(); + + /** + * \brief Signals the event + * \param [in] revision The revision ID + */ + void signalEvent(uint32_t revision); + + /** + * \brief Queries event status + * \returns Current event status + */ + DxvkEventStatus getStatus(); + + private: + + std::mutex m_mutex; + std::condition_variable m_signal; + + DxvkEventStatus m_status = DxvkEventStatus::Reset; + uint32_t m_revision = 0; + + }; + +} \ No newline at end of file