mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[d3d11] Remove old UAV counter buffer implementation
This commit is contained in:
parent
5c45a50daf
commit
66d1bed083
@ -7,7 +7,6 @@
|
||||
#include "d3d11_annotation.h"
|
||||
#include "d3d11_context_state.h"
|
||||
#include "d3d11_device_child.h"
|
||||
#include "d3d11_uav_counter.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "d3d11_options.h"
|
||||
#include "d3d11_shader.h"
|
||||
#include "d3d11_state.h"
|
||||
#include "d3d11_uav_counter.h"
|
||||
#include "d3d11_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
@ -1,67 +0,0 @@
|
||||
#include "d3d11_device.h"
|
||||
#include "d3d11_uav_counter.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
constexpr VkDeviceSize D3D11UavCounterAllocator::SlicesPerBuffer;
|
||||
|
||||
|
||||
D3D11UavCounterAllocator::D3D11UavCounterAllocator(D3D11Device* pDevice)
|
||||
: m_device (pDevice),
|
||||
m_alignment (GetOffsetAlignment()) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
D3D11UavCounterAllocator::~D3D11UavCounterAllocator() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
DxvkBufferSlice D3D11UavCounterAllocator::AllocSlice() {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_freeSlices.size() == 0)
|
||||
CreateBuffer(SlicesPerBuffer);
|
||||
|
||||
DxvkBufferSlice slice = m_freeSlices.back();
|
||||
m_freeSlices.pop_back();
|
||||
return slice;
|
||||
}
|
||||
|
||||
|
||||
void D3D11UavCounterAllocator::FreeSlice(const DxvkBufferSlice& Slice) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_freeSlices.push_back(Slice);
|
||||
}
|
||||
|
||||
|
||||
void D3D11UavCounterAllocator::CreateBuffer(VkDeviceSize SliceCount) {
|
||||
DxvkBufferCreateInfo info;
|
||||
info.size = SliceCount * m_alignment;
|
||||
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
|
||||
| VK_BUFFER_USAGE_TRANSFER_SRC_BIT
|
||||
| VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
|
||||
info.stages = VK_PIPELINE_STAGE_TRANSFER_BIT
|
||||
| m_device->GetEnabledShaderStages();
|
||||
info.access = VK_ACCESS_TRANSFER_READ_BIT
|
||||
| VK_ACCESS_TRANSFER_WRITE_BIT
|
||||
| VK_ACCESS_SHADER_READ_BIT
|
||||
| VK_ACCESS_SHADER_WRITE_BIT;
|
||||
|
||||
Rc<DxvkBuffer> buffer = m_device->GetDXVKDevice()->createBuffer(
|
||||
info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
for (uint32_t i = 0; i < SliceCount; i++) {
|
||||
m_freeSlices.push_back(DxvkBufferSlice(
|
||||
buffer, m_alignment * i, m_alignment));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VkDeviceSize D3D11UavCounterAllocator::GetOffsetAlignment() const {
|
||||
const auto& devInfo = m_device->GetDXVKDevice()->adapter()->deviceProperties();
|
||||
return align(sizeof(D3D11UavCounter), devInfo.limits.minStorageBufferOffsetAlignment);
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d11_include.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D11Device;
|
||||
|
||||
/**
|
||||
* \brief UAV counter structure
|
||||
*
|
||||
* Data structure passed to shaders that use
|
||||
* append/consume buffer functionality.
|
||||
*/
|
||||
struct D3D11UavCounter {
|
||||
uint32_t atomicCtr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief D3D11 UAV counter slice allocator
|
||||
*
|
||||
* Thread-safe allocator for UAV counter slices.
|
||||
* The resulting slices are aligned to the device's
|
||||
* \c minStorageBufferOffsetAlignment.
|
||||
*/
|
||||
class D3D11UavCounterAllocator {
|
||||
constexpr static VkDeviceSize SlicesPerBuffer = 16384;
|
||||
public:
|
||||
|
||||
D3D11UavCounterAllocator(
|
||||
D3D11Device* pDevice);
|
||||
|
||||
~D3D11UavCounterAllocator();
|
||||
|
||||
/**
|
||||
* \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:
|
||||
|
||||
D3D11Device* m_device;
|
||||
VkDeviceSize m_alignment;
|
||||
|
||||
std::mutex m_mutex;
|
||||
std::vector<DxvkBufferSlice> m_freeSlices;
|
||||
|
||||
void CreateBuffer(VkDeviceSize SliceCount);
|
||||
|
||||
VkDeviceSize GetOffsetAlignment() const;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -8,6 +8,17 @@ namespace dxvk {
|
||||
|
||||
class D3D11Device;
|
||||
|
||||
/**
|
||||
* \brief UAV counter structure
|
||||
*
|
||||
* Data structure passed to shaders that use
|
||||
* append/consume buffer functionality.
|
||||
*/
|
||||
struct D3D11UavCounter {
|
||||
uint32_t atomicCtr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Unordered access view
|
||||
*
|
||||
|
@ -40,7 +40,6 @@ d3d11_src = [
|
||||
'd3d11_shader.cpp',
|
||||
'd3d11_state.cpp',
|
||||
'd3d11_texture.cpp',
|
||||
'd3d11_uav_counter.cpp',
|
||||
'd3d11_util.cpp',
|
||||
'd3d11_view_dsv.cpp',
|
||||
'd3d11_view_rtv.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user