1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 22:24:15 +01:00

[dxvk] Add DxvkEvent class

Will be used to back D3D11 event queries.
This commit is contained in:
Philip Rebohle 2018-02-15 13:26:05 +01:00
parent dd237d866d
commit 746c90e860
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 89 additions and 0 deletions

32
src/dxvk/dxvk_event.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "dxvk_event.h"
namespace dxvk {
DxvkEvent:: DxvkEvent() { }
DxvkEvent::~DxvkEvent() { }
uint32_t DxvkEvent::reset() {
std::unique_lock<std::mutex> lock(m_mutex);
m_status = DxvkEventStatus::Reset;
return ++m_revision;
}
void DxvkEvent::signalEvent(uint32_t revision) {
std::unique_lock<std::mutex> lock(m_mutex);
if (m_revision == revision) {
m_status = DxvkEventStatus::Signaled;
m_signal.notify_one();
}
}
DxvkEventStatus DxvkEvent::getStatus() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_status;
}
}

57
src/dxvk/dxvk_event.h Normal file
View File

@ -0,0 +1,57 @@
#pragma once
#include <condition_variable>
#include <mutex>
#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;
};
}