| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <array> |
| 7 |
#include <memory> |
| 8 |
#include <span> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#include "Common/CommonTypes.h" |
| 12 |
|
| 13 |
class PixelShaderManager; |
| 14 |
class PointerWrap; |
| 15 |
|
| 16 |
using BBoxType = s32; |
| 17 |
constexpr u32 NUM_BBOX_VALUES = 4; |
| 18 |
|
| 19 |
class BoundingBox |
| 20 |
{ |
| 21 |
public: |
| 22 |
explicit BoundingBox() = default; |
| 23 |
virtual ~BoundingBox() = default; |
| 24 |
|
| 25 |
bool IsEnabled() const { return m_is_active; } |
| 26 |
void Enable(PixelShaderManager& pixel_shader_manager); |
| 27 |
void Disable(PixelShaderManager& pixel_shader_manager); |
| 28 |
|
| 29 |
void Flush(); |
| 30 |
|
| 31 |
u16 Get(u32 index); |
| 32 |
void Set(u32 index, u16 value); |
| 33 |
|
| 34 |
void DoState(PointerWrap& p); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
virtual bool Initialize() = 0; |
| 39 |
|
| 40 |
protected: |
| 41 |
virtual std::vector<BBoxType> Read(u32 index, u32 length) = 0; |
| 42 |
virtual void Write(u32 index, std::span<const BBoxType> values) = 0; |
| 43 |
|
| 44 |
private: |
| 45 |
void Readback(); |
| 46 |
|
| 47 |
bool m_is_active = false; |
| 48 |
|
| 49 |
std::array<BBoxType, NUM_BBOX_VALUES> m_values = {}; |
| 50 |
std::array<bool, NUM_BBOX_VALUES> m_dirty = {}; |
| 51 |
bool m_is_valid = true; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
std::array<u16, 4> m_bounding_box_fallback = {}; |
| 64 |
}; |
| 65 |
|
| 66 |
extern std::unique_ptr<BoundingBox> g_bounding_box; |