dolphin/Source/Core/VideoCommon/BoundingBox.h
Scott Mansell 8a23629345 Split AbstractGfx out of Renderer
Almost all the virtual functions in Renderer are part of dolphin's
"graphics api abstraction layer", which has slowly formed over the
last decade or two.

Most of the work was done previously with the introduction of the
various "AbstractX" classes, associated with texture cache cleanups
and implementation of newer graphics APIs (Direct3D 12, Vulkan, Metal).
We are simply taking the last step and yeeting these functions out
of Renderer.

This "AbstractGfx" class is now completely agnostic of any details
from the flipper/hollywood GPU we are emulating, though somewhat
specialized.

(Will not build, this commit only contains changes outside VideoBackends)
2023-01-31 18:46:02 +13:00

55 lines
1.3 KiB
C++

// Copyright 2014 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <memory>
#include <vector>
#include "Common/CommonTypes.h"
class PixelShaderManager;
class PointerWrap;
using BBoxType = s32;
constexpr u32 NUM_BBOX_VALUES = 4;
class BoundingBox
{
public:
explicit BoundingBox() = default;
virtual ~BoundingBox() = default;
bool IsEnabled() const { return m_is_active; }
void Enable(PixelShaderManager& pixel_shader_manager);
void Disable(PixelShaderManager& pixel_shader_manager);
void Flush();
u16 Get(u32 index);
void Set(u32 index, u16 value);
void DoState(PointerWrap& p);
// Initialize, Read, and Write are only safe to call if the backend supports bounding box,
// otherwise unexpected exceptions can occur
virtual bool Initialize() = 0;
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;
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;
};
extern std::unique_ptr<BoundingBox> g_bounding_box;