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:
parent
dd237d866d
commit
746c90e860
32
src/dxvk/dxvk_event.cpp
Normal file
32
src/dxvk/dxvk_event.cpp
Normal 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
57
src/dxvk/dxvk_event.h
Normal 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;
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user