1
0
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:
Philip Rebohle 2024-10-07 14:15:07 +02:00 committed by Philip Rebohle
parent e137f049ee
commit d330718353
3 changed files with 36 additions and 7 deletions

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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;
};