2019-03-28 10:35:46 +00:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-03-28 10:35:46 +00:00
|
|
|
|
|
|
|
#pragma once
|
2021-06-09 11:42:21 +00:00
|
|
|
|
2019-03-28 10:35:46 +00:00
|
|
|
#include <memory>
|
|
|
|
#include "VideoBackends/D3D12/Common.h"
|
2020-09-15 13:01:29 +00:00
|
|
|
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
|
2019-03-28 10:35:46 +00:00
|
|
|
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
|
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
|
|
|
|
2019-03-28 10:35:46 +00:00
|
|
|
namespace DX12
|
|
|
|
{
|
2021-06-09 11:42:21 +00:00
|
|
|
class D3D12BoundingBox final : public BoundingBox
|
2019-03-28 10:35:46 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-06-09 11:42:21 +00:00
|
|
|
~D3D12BoundingBox() override;
|
2019-03-28 10:35:46 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
bool Initialize() override;
|
2019-03-28 10:35:46 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
protected:
|
|
|
|
std::vector<BBoxType> Read(u32 index, u32 length) override;
|
2023-12-09 19:54:17 +00:00
|
|
|
void Write(u32 index, std::span<const BBoxType> values) override;
|
2019-03-28 10:35:46 +00:00
|
|
|
|
|
|
|
private:
|
2021-06-09 11:42:21 +00: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 10:35:46 +00: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 04:43:19 +00:00
|
|
|
DescriptorHandle m_gpu_descriptor{};
|
2019-03-28 10:35:46 +00:00
|
|
|
};
|
2021-06-09 11:42:21 +00:00
|
|
|
|
|
|
|
} // namespace DX12
|