summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Vulkan/VKBoundingBox.h
blob: 3520b8892c10261c07182692c01f9b7f12d888ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2016 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include <memory>
#include <string>

#include "Common/CommonTypes.h"
#include "VideoBackends/Vulkan/StagingBuffer.h"
#include "VideoBackends/Vulkan/VulkanLoader.h"

#include "VideoCommon/BoundingBox.h"

namespace Vulkan
{
class StagingBuffer;

class VKBoundingBox final : public BoundingBox
{
public:
  ~VKBoundingBox() override;

  bool Initialize() override;

protected:
  std::vector<BBoxType> Read(u32 index, u32 length) override;
  void Write(u32 index, std::span<const BBoxType> values) override;

private:
  bool CreateGPUBuffer();
  bool CreateReadbackBuffer();

  VkBuffer m_gpu_buffer = VK_NULL_HANDLE;
  VmaAllocation m_gpu_allocation = VK_NULL_HANDLE;

  static constexpr size_t BUFFER_SIZE = sizeof(BBoxType) * NUM_BBOX_VALUES;

  std::unique_ptr<StagingBuffer> m_readback_buffer;
};

}  // namespace Vulkan