From 66d1bed083c34e99658d0accbdbfa111492451cd Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 30 Aug 2018 15:32:46 +0200 Subject: [PATCH] [d3d11] Remove old UAV counter buffer implementation --- src/d3d11/d3d11_context.h | 1 - src/d3d11/d3d11_device.h | 1 - src/d3d11/d3d11_uav_counter.cpp | 67 -------------------------------- src/d3d11/d3d11_uav_counter.h | 69 --------------------------------- src/d3d11/d3d11_view_uav.h | 11 ++++++ src/d3d11/meson.build | 1 - 6 files changed, 11 insertions(+), 139 deletions(-) delete mode 100644 src/d3d11/d3d11_uav_counter.cpp delete mode 100644 src/d3d11/d3d11_uav_counter.h diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 484a72042..064b7d453 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -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 { diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index 817b3658d..9b2573251 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -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 { diff --git a/src/d3d11/d3d11_uav_counter.cpp b/src/d3d11/d3d11_uav_counter.cpp deleted file mode 100644 index ff976801a..000000000 --- a/src/d3d11/d3d11_uav_counter.cpp +++ /dev/null @@ -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 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 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 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); - } - -} \ No newline at end of file diff --git a/src/d3d11/d3d11_uav_counter.h b/src/d3d11/d3d11_uav_counter.h deleted file mode 100644 index 46859cb4f..000000000 --- a/src/d3d11/d3d11_uav_counter.h +++ /dev/null @@ -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 m_freeSlices; - - void CreateBuffer(VkDeviceSize SliceCount); - - VkDeviceSize GetOffsetAlignment() const; - - }; - -} \ No newline at end of file diff --git a/src/d3d11/d3d11_view_uav.h b/src/d3d11/d3d11_view_uav.h index bc133d09f..ac5c7c070 100644 --- a/src/d3d11/d3d11_view_uav.h +++ b/src/d3d11/d3d11_view_uav.h @@ -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 * diff --git a/src/d3d11/meson.build b/src/d3d11/meson.build index f70815b00..bf64de481 100644 --- a/src/d3d11/meson.build +++ b/src/d3d11/meson.build @@ -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',