2014-09-14 10:52:51 -06:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-09-14 10:52:51 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-06-09 05:42:21 -06:00
|
|
|
#include <array>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-09-14 10:52:51 -06:00
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
class PointerWrap;
|
2014-09-14 10:52:51 -06:00
|
|
|
|
2021-06-09 05:42:21 -06:00
|
|
|
using BBoxType = s32;
|
|
|
|
constexpr u32 NUM_BBOX_VALUES = 4;
|
|
|
|
|
|
|
|
class BoundingBox
|
2014-09-14 10:52:51 -06:00
|
|
|
{
|
2021-06-09 05:42:21 -06:00
|
|
|
public:
|
|
|
|
explicit BoundingBox() = default;
|
|
|
|
virtual ~BoundingBox() = default;
|
2014-09-14 10:52:51 -06:00
|
|
|
|
2021-06-09 05:42:21 -06:00
|
|
|
bool IsEnabled() const { return m_is_active; }
|
|
|
|
void Enable();
|
|
|
|
void Disable();
|
2019-12-05 08:58:03 -07:00
|
|
|
|
2021-06-09 05:42:21 -06:00
|
|
|
void Flush();
|
2019-12-05 08:58:03 -07:00
|
|
|
|
2021-06-09 05:42:21 -06:00
|
|
|
u16 Get(u32 index);
|
|
|
|
void Set(u32 index, u16 value);
|
2019-12-05 08:58:03 -07:00
|
|
|
|
2021-06-09 05:42:21 -06:00
|
|
|
void DoState(PointerWrap& p);
|
2019-12-05 08:58:03 -07:00
|
|
|
|
2021-06-09 05:42:21 -06: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 08:58:03 -07:00
|
|
|
|
2021-06-09 05:42:21 -06: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 08:58:03 -07:00
|
|
|
|
2021-06-09 05:42:21 -06: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;
|
|
|
|
};
|