1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/dxvk/dxvk_lifetime.h
Philip Rebohle 63183141bc
[dxvk] Implement read/write tracking in lifetime tracker
This way we will be able to more accurately determine how a
resource is going to be used by the GPU, and we can also cut
unnecessary atomic operations for non-resource objects.
2019-09-20 01:44:01 +02:00

48 lines
1003 B
C++

#pragma once
#include <vector>
#include "dxvk_resource.h"
namespace dxvk {
/**
* \brief DXVK lifetime tracker
*
* Maintains references to a set of resources. This is
* used to guarantee that resources are not destroyed
* or otherwise accessed in an unsafe manner until the
* device has finished using them.
*/
class DxvkLifetimeTracker {
public:
DxvkLifetimeTracker();
~DxvkLifetimeTracker();
/**
* \brief Adds a resource to track
* \param [in] rc The resource to track
*/
template<DxvkAccess Access>
void trackResource(Rc<DxvkResource>&& rc) {
rc->acquire(Access);
m_resources.emplace_back(std::move(rc), Access);
}
/**
* \brief Resets the command list
*
* Called automatically by the device when
* the command list has completed execution.
*/
void reset();
private:
std::vector<std::pair<Rc<DxvkResource>, DxvkAccess>> m_resources;
};
}