VideoCommon: Abstract bounding box

This moves much of the duplicated bounding box code into VideoCommon,
leaving only the specific buffer implementations in each backend.
This commit is contained in:
Techjar
2021-06-09 07:42:21 -04:00
parent 7ec02ee4d3
commit 1161af8059
41 changed files with 617 additions and 708 deletions

View File

@ -8,41 +8,35 @@
#include <string>
#include "Common/CommonTypes.h"
#include "VideoBackends/Vulkan/VulkanLoader.h"
#include "VideoCommon/BoundingBox.h"
namespace Vulkan
{
class StagingBuffer;
class BoundingBox
class VKBoundingBox final : public BoundingBox
{
public:
BoundingBox();
~BoundingBox();
~VKBoundingBox() override;
bool Initialize();
bool Initialize() override;
s32 Get(size_t index);
void Set(size_t index, s32 value);
void Invalidate();
void Flush();
protected:
std::vector<BBoxType> Read(u32 index, u32 length) override;
void Write(u32 index, const std::vector<BBoxType>& values) override;
private:
bool CreateGPUBuffer();
bool CreateReadbackBuffer();
void Readback();
VkBuffer m_gpu_buffer = VK_NULL_HANDLE;
VkDeviceMemory m_gpu_memory = VK_NULL_HANDLE;
static const size_t NUM_VALUES = 4;
static const size_t BUFFER_SIZE = sizeof(u32) * NUM_VALUES;
static constexpr size_t BUFFER_SIZE = sizeof(BBoxType) * NUM_BBOX_VALUES;
std::unique_ptr<StagingBuffer> m_readback_buffer;
std::array<bool, NUM_VALUES> m_values_dirty = {};
bool m_valid = true;
};
} // namespace Vulkan