2014-09-14 16:52:51 +00:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-09-14 16:52:51 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
#include <array>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-09-14 16:52:51 +00:00
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
class PointerWrap;
|
2014-09-14 16:52:51 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
using BBoxType = s32;
|
|
|
|
constexpr u32 NUM_BBOX_VALUES = 4;
|
|
|
|
|
|
|
|
class BoundingBox
|
2014-09-14 16:52:51 +00:00
|
|
|
{
|
2021-06-09 11:42:21 +00:00
|
|
|
public:
|
|
|
|
explicit BoundingBox() = default;
|
|
|
|
virtual ~BoundingBox() = default;
|
2014-09-14 16:52:51 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
bool IsEnabled() const { return m_is_active; }
|
|
|
|
void Enable();
|
|
|
|
void Disable();
|
2019-12-05 15:58:03 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
void Flush();
|
2019-12-05 15:58:03 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
u16 Get(u32 index);
|
|
|
|
void Set(u32 index, u16 value);
|
2019-12-05 15:58:03 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
void DoState(PointerWrap& p);
|
2019-12-05 15:58:03 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
// Initialize, Read, and Write are only safe to call if the backend supports bounding box,
|
|
|
|
// otherwise unexpected exceptions can occur
|
|
|
|
virtual bool Initialize() = 0;
|
2019-12-05 15:58:03 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
protected:
|
|
|
|
virtual std::vector<BBoxType> Read(u32 index, u32 length) = 0;
|
|
|
|
// TODO: This can likely use std::span once we're on C++20
|
|
|
|
virtual void Write(u32 index, const std::vector<BBoxType>& values) = 0;
|
2019-12-05 15:58:03 +00:00
|
|
|
|
2021-06-09 11:42:21 +00:00
|
|
|
private:
|
|
|
|
void Readback();
|
|
|
|
|
|
|
|
bool m_is_active = false;
|
|
|
|
|
|
|
|
std::array<BBoxType, NUM_BBOX_VALUES> m_values = {};
|
|
|
|
std::array<bool, NUM_BBOX_VALUES> m_dirty = {};
|
|
|
|
bool m_is_valid = true;
|
|
|
|
};
|