mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[dxvk] Implement staging buffer statistics
This commit is contained in:
parent
e137f049ee
commit
d330718353
@ -15,7 +15,6 @@
|
||||
#include "dxvk_presenter.h"
|
||||
#include "dxvk_signal.h"
|
||||
#include "dxvk_sparse.h"
|
||||
#include "dxvk_staging.h"
|
||||
#include "dxvk_stats.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
@ -29,6 +29,7 @@ namespace dxvk {
|
||||
| VK_ACCESS_SHADER_READ_BIT;
|
||||
|
||||
VkDeviceSize alignedSize = dxvk::align(size, 256u);
|
||||
m_allocationCounter += alignedSize;
|
||||
|
||||
if (2 * alignedSize > m_size) {
|
||||
return DxvkBufferSlice(m_device->createBuffer(info,
|
||||
@ -55,6 +56,8 @@ namespace dxvk {
|
||||
void DxvkStagingBuffer::reset() {
|
||||
m_buffer = nullptr;
|
||||
m_offset = 0;
|
||||
|
||||
m_allocationCounterValueOnReset = m_allocationCounter;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,23 @@
|
||||
#include <queue>
|
||||
|
||||
#include "dxvk_buffer.h"
|
||||
#include "dxvk_device.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class DxvkDevice;
|
||||
|
||||
/**
|
||||
* \brief Staging buffer statistics
|
||||
*
|
||||
* Can optionally be used to throttle resource
|
||||
* uploads through the staging buffer.
|
||||
*/
|
||||
struct DxvkStagingBufferStats {
|
||||
/// Total amount allocated since the buffer was created
|
||||
VkDeviceSize allocatedTotal = 0u;
|
||||
/// Amount allocated since the last time the buffer was reset
|
||||
VkDeviceSize allocatedSinceLastReset = 0u;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Staging buffer
|
||||
@ -48,12 +61,26 @@ namespace dxvk {
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* \brief Retrieves allocation statistics
|
||||
* \returns Current allocation statistics
|
||||
*/
|
||||
DxvkStagingBufferStats getStatistics() const {
|
||||
DxvkStagingBufferStats result = { };
|
||||
result.allocatedTotal = m_allocationCounter;
|
||||
result.allocatedSinceLastReset = m_allocationCounter - m_allocationCounterValueOnReset;
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Rc<DxvkDevice> m_device;
|
||||
Rc<DxvkBuffer> m_buffer;
|
||||
VkDeviceSize m_offset;
|
||||
VkDeviceSize m_size;
|
||||
Rc<DxvkDevice> m_device = nullptr;
|
||||
Rc<DxvkBuffer> m_buffer = nullptr;
|
||||
VkDeviceSize m_offset = 0u;
|
||||
VkDeviceSize m_size = 0u;
|
||||
|
||||
VkDeviceSize m_allocationCounter = 0u;
|
||||
VkDeviceSize m_allocationCounterValueOnReset = 0u;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user