mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-21 22:54:16 +01:00
[dxvk] Remove old lifetime tracking code
This commit is contained in:
parent
cc22ccfc5c
commit
3a587c5116
@ -1,17 +0,0 @@
|
|||||||
#include "dxvk_lifetime.h"
|
|
||||||
|
|
||||||
namespace dxvk {
|
|
||||||
|
|
||||||
DxvkLifetimeTracker:: DxvkLifetimeTracker() { }
|
|
||||||
DxvkLifetimeTracker::~DxvkLifetimeTracker() { }
|
|
||||||
|
|
||||||
|
|
||||||
void DxvkLifetimeTracker::reset() {
|
|
||||||
m_resources.clear();
|
|
||||||
m_allocations.clear();
|
|
||||||
m_samplers.clear();
|
|
||||||
m_events.clear();
|
|
||||||
m_queries.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dxvk_gpu_event.h"
|
|
||||||
#include "dxvk_gpu_query.h"
|
|
||||||
#include "dxvk_resource.h"
|
|
||||||
#include "dxvk_sampler.h"
|
|
||||||
|
|
||||||
namespace dxvk {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Resource pointer
|
|
||||||
*
|
|
||||||
* Keeps a resource alive and stores access information.
|
|
||||||
*/
|
|
||||||
template<typename T>
|
|
||||||
class DxvkLifetime {
|
|
||||||
static constexpr uintptr_t AccessMask = 0x3u;
|
|
||||||
static constexpr uintptr_t PointerMask = ~AccessMask;
|
|
||||||
|
|
||||||
static_assert(alignof(T) > AccessMask);
|
|
||||||
public:
|
|
||||||
|
|
||||||
DxvkLifetime() = default;
|
|
||||||
|
|
||||||
template<typename Tx>
|
|
||||||
DxvkLifetime(
|
|
||||||
Rc<Tx>&& resource,
|
|
||||||
DxvkAccess access)
|
|
||||||
: m_ptr(reinterpret_cast<uintptr_t>(static_cast<DxvkResource*>(resource.ptr())) | uintptr_t(access)) {
|
|
||||||
resource.unsafeExtract()->convertRef(DxvkAccess::None, access);
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkLifetime(
|
|
||||||
const T* resource,
|
|
||||||
DxvkAccess access)
|
|
||||||
: m_ptr(reinterpret_cast<uintptr_t>(static_cast<const DxvkResource*>(resource)) | uintptr_t(access)) {
|
|
||||||
acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkLifetime(DxvkLifetime&& other)
|
|
||||||
: m_ptr(other.m_ptr) {
|
|
||||||
other.m_ptr = 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkLifetime(const DxvkLifetime& other)
|
|
||||||
: m_ptr(other.m_ptr) {
|
|
||||||
acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkLifetime& operator = (DxvkLifetime&& other) {
|
|
||||||
release();
|
|
||||||
|
|
||||||
m_ptr = other.m_ptr;
|
|
||||||
other.m_ptr = 0u;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkLifetime& operator = (const DxvkLifetime& other) {
|
|
||||||
other.acquire();
|
|
||||||
release();
|
|
||||||
|
|
||||||
m_ptr = other.m_ptr;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
~DxvkLifetime() {
|
|
||||||
release();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
uintptr_t m_ptr = 0u;
|
|
||||||
|
|
||||||
T* ptr() const {
|
|
||||||
return reinterpret_cast<T*>(m_ptr & PointerMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkAccess access() const {
|
|
||||||
return DxvkAccess(m_ptr & AccessMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void acquire() const {
|
|
||||||
if (m_ptr)
|
|
||||||
ptr()->acquire(access());
|
|
||||||
}
|
|
||||||
|
|
||||||
void release() const {
|
|
||||||
if (m_ptr)
|
|
||||||
ptr()->release(access());
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief 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 sampler to track
|
|
||||||
* \param [in] res The sampler to track
|
|
||||||
*/
|
|
||||||
void trackSampler(const Rc<DxvkSampler>& res) {
|
|
||||||
m_samplers.push_back(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Adds an event to track
|
|
||||||
* \param [in] res The event to track
|
|
||||||
*/
|
|
||||||
void trackEvent(Rc<DxvkGpuEvent>&& event) {
|
|
||||||
m_events.push_back(std::move(event));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Adds a query to track
|
|
||||||
* \param [in] query The query to track
|
|
||||||
*/
|
|
||||||
void trackQuery(Rc<DxvkGpuQuery>&& query) {
|
|
||||||
m_queries.push_back(std::move(query));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Adds a resource to track
|
|
||||||
* \param [in] res The resource to track
|
|
||||||
*/
|
|
||||||
void trackResource(DxvkLifetime<DxvkResource>&& res) {
|
|
||||||
m_resources.push_back(std::move(res));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Adds a resource allocation to track
|
|
||||||
* \param [in] res The allocation to track
|
|
||||||
*/
|
|
||||||
void trackResource(Rc<DxvkResourceAllocation>&& res) {
|
|
||||||
m_allocations.push_back(std::move(res));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Resets the command list
|
|
||||||
*
|
|
||||||
* Called automatically by the device when
|
|
||||||
* the command list has completed execution.
|
|
||||||
*/
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::vector<Rc<DxvkSampler>> m_samplers;
|
|
||||||
std::vector<Rc<DxvkGpuEvent>> m_events;
|
|
||||||
std::vector<Rc<DxvkGpuQuery>> m_queries;
|
|
||||||
|
|
||||||
std::vector<DxvkLifetime<DxvkResource>> m_resources;
|
|
||||||
std::vector<Rc<DxvkResourceAllocation>> m_allocations;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -87,7 +87,6 @@ dxvk_src = [
|
|||||||
'dxvk_graphics.cpp',
|
'dxvk_graphics.cpp',
|
||||||
'dxvk_image.cpp',
|
'dxvk_image.cpp',
|
||||||
'dxvk_instance.cpp',
|
'dxvk_instance.cpp',
|
||||||
'dxvk_lifetime.cpp',
|
|
||||||
'dxvk_memory.cpp',
|
'dxvk_memory.cpp',
|
||||||
'dxvk_meta_blit.cpp',
|
'dxvk_meta_blit.cpp',
|
||||||
'dxvk_meta_clear.cpp',
|
'dxvk_meta_clear.cpp',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user