2019-03-28 11:35:46 +01:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-03-28 11:35:46 +01:00
|
|
|
|
|
|
|
#pragma once
|
2021-06-09 13:42:21 +02:00
|
|
|
|
2019-03-28 11:35:46 +01:00
|
|
|
#include <memory>
|
|
|
|
#include "VideoBackends/D3D12/Common.h"
|
2020-09-15 15:01:29 +02:00
|
|
|
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
|
2019-03-28 11:35:46 +01:00
|
|
|
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
|
|
|
|
|
2021-06-09 13:42:21 +02:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
|
|
|
|
2019-03-28 11:35:46 +01:00
|
|
|
namespace DX12
|
|
|
|
{
|
2021-06-09 13:42:21 +02:00
|
|
|
class D3D12BoundingBox final : public BoundingBox
|
2019-03-28 11:35:46 +01:00
|
|
|
{
|
|
|
|
public:
|
2021-06-09 13:42:21 +02:00
|
|
|
~D3D12BoundingBox() override;
|
2019-03-28 11:35:46 +01:00
|
|
|
|
2021-06-09 13:42:21 +02:00
|
|
|
bool Initialize() override;
|
2019-03-28 11:35:46 +01:00
|
|
|
|
2021-06-09 13:42:21 +02:00
|
|
|
protected:
|
|
|
|
std::vector<BBoxType> Read(u32 index, u32 length) override;
|
2023-12-09 20:54:17 +01:00
|
|
|
void Write(u32 index, std::span<const BBoxType> values) override;
|
2019-03-28 11:35:46 +01:00
|
|
|
|
|
|
|
private:
|
2021-06-09 13:42:21 +02:00
|
|
|
static constexpr u32 BUFFER_SIZE = sizeof(BBoxType) * NUM_BBOX_VALUES;
|
|
|
|
static constexpr u32 MAX_UPDATES_PER_FRAME = 128;
|
|
|
|
static constexpr u32 STREAM_BUFFER_SIZE = BUFFER_SIZE * MAX_UPDATES_PER_FRAME;
|
2019-03-28 11:35:46 +01:00
|
|
|
|
|
|
|
bool CreateBuffers();
|
|
|
|
|
|
|
|
// Three buffers: GPU for read/write, CPU for reading back, and CPU for staging changes.
|
|
|
|
ComPtr<ID3D12Resource> m_gpu_buffer;
|
|
|
|
ComPtr<ID3D12Resource> m_readback_buffer;
|
|
|
|
StreamBuffer m_upload_buffer;
|
2021-09-04 06:43:19 +02:00
|
|
|
DescriptorHandle m_gpu_descriptor{};
|
2019-03-28 11:35:46 +01:00
|
|
|
};
|
2021-06-09 13:42:21 +02:00
|
|
|
|
|
|
|
} // namespace DX12
|