2017-10-10 23:32:13 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-20 02:45:57 +01:00
|
|
|
#include <vector>
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
#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
|
|
|
|
*/
|
2019-09-19 19:35:52 +02:00
|
|
|
template<DxvkAccess Access>
|
2018-09-17 20:42:08 +02:00
|
|
|
void trackResource(Rc<DxvkResource>&& rc) {
|
2019-09-19 19:35:52 +02:00
|
|
|
rc->acquire(Access);
|
|
|
|
m_resources.emplace_back(std::move(rc), Access);
|
2017-12-20 02:45:57 +01:00
|
|
|
}
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Resets the command list
|
|
|
|
*
|
|
|
|
* Called automatically by the device when
|
|
|
|
* the command list has completed execution.
|
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2019-09-19 19:35:52 +02:00
|
|
|
std::vector<std::pair<Rc<DxvkResource>, DxvkAccess>> m_resources;
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|