mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 22:24:15 +01:00
[dxvk] Implement backend part for event queries
This commit is contained in:
parent
5334ff57bf
commit
5fea615ed7
@ -141,8 +141,13 @@ namespace dxvk {
|
||||
|
||||
void D3D11Query::Signal(DxvkContext* ctx, uint32_t revision) {
|
||||
switch (m_desc.Query) {
|
||||
case D3D11_QUERY_EVENT: {
|
||||
DxvkEventRevision rev = { m_event, revision };
|
||||
ctx->signalEvent(rev);
|
||||
} break;
|
||||
|
||||
case D3D11_QUERY_TIMESTAMP: {
|
||||
DxvkQueryRevision rev = { m_query, m_revision };
|
||||
DxvkQueryRevision rev = { m_query, revision };
|
||||
ctx->writeTimestamp(rev);
|
||||
} break;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "dxvk_binding.h"
|
||||
#include "dxvk_descriptor.h"
|
||||
#include "dxvk_event_tracker.h"
|
||||
#include "dxvk_lifetime.h"
|
||||
#include "dxvk_limits.h"
|
||||
#include "dxvk_pipelayout.h"
|
||||
@ -85,12 +86,32 @@ namespace dxvk {
|
||||
m_queryTracker.trackQueryRange(std::move(queries));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Adds an event revision to track
|
||||
*
|
||||
* The event will be signaled after the command
|
||||
* buffer has finished executing on the GPU.
|
||||
*/
|
||||
void trackEvent(const DxvkEventRevision& event) {
|
||||
m_eventTracker.trackEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Signals tracked events
|
||||
*
|
||||
* Marks all tracked events as signaled. Call this after
|
||||
* synchronizing with a fence for this command list.
|
||||
*/
|
||||
void signalEvents() {
|
||||
m_eventTracker.signalEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Writes back query results
|
||||
*
|
||||
* Uses the query range to write back query data
|
||||
* after the command list has finished executing
|
||||
* on the GPU.
|
||||
* Writes back query data to all queries tracked by the
|
||||
* query range tracker. Call this after synchronizing
|
||||
* with a fence for this command list.
|
||||
*/
|
||||
void writeQueryData() {
|
||||
m_queryTracker.writeQueryData();
|
||||
@ -486,6 +507,7 @@ namespace dxvk {
|
||||
DxvkDescriptorAlloc m_descAlloc;
|
||||
DxvkStagingAlloc m_stagingAlloc;
|
||||
DxvkQueryTracker m_queryTracker;
|
||||
DxvkEventTracker m_eventTracker;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1201,6 +1201,11 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::signalEvent(const DxvkEventRevision& event) {
|
||||
m_cmd->trackEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::writeTimestamp(const DxvkQueryRevision& query) {
|
||||
DxvkQueryHandle handle = this->allocQuery(query);
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "dxvk_cmdlist.h"
|
||||
#include "dxvk_context_state.h"
|
||||
#include "dxvk_data.h"
|
||||
#include "dxvk_event.h"
|
||||
#include "dxvk_query.h"
|
||||
#include "dxvk_query_pool.h"
|
||||
#include "dxvk_util.h"
|
||||
|
||||
@ -542,6 +544,13 @@ namespace dxvk {
|
||||
uint32_t attachment,
|
||||
const DxvkBlendMode& blendMode);
|
||||
|
||||
/**
|
||||
* \brief Signals an event
|
||||
* \param [in] event The event
|
||||
*/
|
||||
void signalEvent(
|
||||
const DxvkEventRevision& event);
|
||||
|
||||
/**
|
||||
* \brief Writes to a timestamp query
|
||||
* \param [in] query The timestamp query
|
||||
|
@ -14,7 +14,7 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkEvent::signalEvent(uint32_t revision) {
|
||||
void DxvkEvent::signal(uint32_t revision) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_revision == revision) {
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Event status
|
||||
*/
|
||||
enum class DxvkEventStatus {
|
||||
Reset = 0,
|
||||
Signaled = 1,
|
||||
@ -36,7 +39,7 @@ namespace dxvk {
|
||||
* \brief Signals the event
|
||||
* \param [in] revision The revision ID
|
||||
*/
|
||||
void signalEvent(uint32_t revision);
|
||||
void signal(uint32_t revision);
|
||||
|
||||
/**
|
||||
* \brief Queries event status
|
||||
@ -54,4 +57,15 @@ namespace dxvk {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Event revision
|
||||
*
|
||||
* Stores the event object and the
|
||||
* version ID for event operations.
|
||||
*/
|
||||
struct DxvkEventRevision {
|
||||
Rc<DxvkEvent> event;
|
||||
uint32_t revision;
|
||||
};
|
||||
|
||||
}
|
30
src/dxvk/dxvk_event_tracker.cpp
Normal file
30
src/dxvk/dxvk_event_tracker.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "dxvk_event_tracker.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkEventTracker::DxvkEventTracker() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
DxvkEventTracker::~DxvkEventTracker() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DxvkEventTracker::trackEvent(const DxvkEventRevision& event) {
|
||||
m_events.push_back(event);
|
||||
}
|
||||
|
||||
|
||||
void DxvkEventTracker::signalEvents() {
|
||||
for (const DxvkEventRevision& event : m_events)
|
||||
event.event->signal(event.revision);
|
||||
}
|
||||
|
||||
|
||||
void DxvkEventTracker::reset() {
|
||||
m_events.clear();
|
||||
}
|
||||
|
||||
}
|
45
src/dxvk/dxvk_event_tracker.h
Normal file
45
src/dxvk/dxvk_event_tracker.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "dxvk_event.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Event tracker
|
||||
*/
|
||||
class DxvkEventTracker {
|
||||
|
||||
public:
|
||||
|
||||
DxvkEventTracker();
|
||||
~DxvkEventTracker();
|
||||
|
||||
/**
|
||||
* \brief Adds an event to track
|
||||
* \param [in] event The event revision
|
||||
*/
|
||||
void trackEvent(const DxvkEventRevision& event);
|
||||
|
||||
/**
|
||||
* \brief Signals tracked events
|
||||
*
|
||||
* Retrieves query data from the query pools
|
||||
* and writes it back to the query objects.
|
||||
*/
|
||||
void signalEvents();
|
||||
|
||||
/**
|
||||
* \brief Resets event tracker
|
||||
*
|
||||
* Releases all events from the tracker.
|
||||
* Call this after signaling the events.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
private:
|
||||
|
||||
std::vector<DxvkEventRevision> m_events;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -58,7 +58,9 @@ namespace dxvk {
|
||||
entry.fence->wait(std::numeric_limits<uint64_t>::max());
|
||||
|
||||
entry.cmdList->writeQueryData();
|
||||
entry.cmdList->signalEvents();
|
||||
entry.cmdList->reset();
|
||||
|
||||
m_device->recycleCommandList(entry.cmdList);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ dxvk_src = files([
|
||||
'dxvk_device.cpp',
|
||||
'dxvk_extensions.cpp',
|
||||
'dxvk_event.cpp',
|
||||
'dxvk_event_tracker.cpp',
|
||||
'dxvk_format.cpp',
|
||||
'dxvk_framebuffer.cpp',
|
||||
'dxvk_graphics.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user