1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-05 19:46:15 +01:00
dxvk/src/d3d11/d3d11_counter_buffer.h
Philip Rebohle 9992ba1a79
[d3d11] Add more general counter buffer allocator
We're going to need it for more than just UAV counters soon.
2018-08-30 15:24:38 +02:00

63 lines
1.3 KiB
C++

#pragma once
#include "d3d11_include.h"
#include "../dxvk/dxvk_buffer.h"
#include "../dxvk/dxvk_device.h"
namespace dxvk {
class D3D11Device;
/**
* \brief D3D11 UAV counter slice allocator
*
* Thread safe allocator for buffer slices of
* the same size, which are typically used to
* store counters (such as UAV counters).
*/
class D3D11CounterBuffer : public RcObject {
public:
D3D11CounterBuffer(
const Rc<DxvkDevice>& Device,
const DxvkBufferCreateInfo& BufferInfo,
VkDeviceSize SliceLength);
~D3D11CounterBuffer();
/**
* \brief Allocates a counter slice
*
* Picks a slice from the free list or
* creates a new buffer if necessary.
* \returns The counter slice
*/
DxvkBufferSlice AllocSlice();
/**
* \brief Frees a counter slice
*
* Adds the given slice back to the
* free list so that it can be reused.
* \param [in] Slice the slice to free
*/
void FreeSlice(
const DxvkBufferSlice& Slice);
private:
Rc<DxvkDevice> m_device;
DxvkBufferCreateInfo m_bufferInfo;
VkDeviceSize m_sliceLength;
std::mutex m_mutex;
std::vector<DxvkBufferSlice> m_freeSlices;
void CreateBuffer();
};
}