2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2011 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2016-02-16 02:29:24 +00:00
|
|
|
#include <memory>
|
2019-07-20 22:57:50 +00:00
|
|
|
#include <optional>
|
2011-01-31 01:28:32 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2018-10-03 13:03:22 +00:00
|
|
|
#include "Common/WindowSystemInfo.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-02-02 13:16:43 +00:00
|
|
|
namespace MMIO
|
|
|
|
{
|
|
|
|
class Mapping;
|
|
|
|
}
|
2016-01-17 21:54:31 +00:00
|
|
|
class PointerWrap;
|
2011-03-16 22:48:17 +00:00
|
|
|
|
2023-01-28 01:53:19 +00:00
|
|
|
class AbstractGfx;
|
|
|
|
class BoundingBox;
|
|
|
|
class Renderer;
|
|
|
|
class TextureCacheBase;
|
|
|
|
class VertexManagerBase;
|
|
|
|
|
2017-01-23 08:27:13 +00:00
|
|
|
enum class FieldType
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
2017-01-23 08:27:13 +00:00
|
|
|
Odd,
|
|
|
|
Even,
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
2017-01-23 07:51:46 +00:00
|
|
|
enum class EFBAccessType
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
2017-01-23 07:51:46 +00:00
|
|
|
PeekZ,
|
|
|
|
PokeZ,
|
|
|
|
PeekColor,
|
|
|
|
PokeColor
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
class VideoBackendBase
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-01-12 08:35:24 +00:00
|
|
|
virtual ~VideoBackendBase() {}
|
2018-10-03 13:03:22 +00:00
|
|
|
virtual bool Initialize(const WindowSystemInfo& wsi) = 0;
|
2014-03-11 05:55:00 +00:00
|
|
|
virtual void Shutdown() = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-11 05:55:00 +00:00
|
|
|
virtual std::string GetName() const = 0;
|
|
|
|
virtual std::string GetDisplayName() const { return GetName(); }
|
2023-03-26 00:16:53 +00:00
|
|
|
virtual void InitBackendInfo(const WindowSystemInfo& wsi) = 0;
|
2019-07-20 22:57:50 +00:00
|
|
|
virtual std::optional<std::string> GetWarningMessage() const { return {}; }
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2018-11-07 13:10:51 +00:00
|
|
|
// Prepares a native window for rendering. This is called on the main thread, or the
|
|
|
|
// thread which owns the window.
|
2020-03-11 13:10:28 +00:00
|
|
|
virtual void PrepareWindow(WindowSystemInfo& wsi) {}
|
2018-11-07 13:10:51 +00:00
|
|
|
|
2020-01-24 08:29:38 +00:00
|
|
|
static std::string BadShaderFilename(const char* shader_stage, int counter);
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
void Video_ExitLoop();
|
2017-09-14 04:46:30 +00:00
|
|
|
|
2021-08-03 22:55:38 +00:00
|
|
|
void Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks);
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2018-05-20 20:20:21 +00:00
|
|
|
u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 data);
|
2016-01-12 08:35:24 +00:00
|
|
|
u32 Video_GetQueryResult(PerfQueryType type);
|
|
|
|
u16 Video_GetBoundingBox(int index);
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2024-11-03 19:33:51 +00:00
|
|
|
static std::string GetDefaultBackendConfigName();
|
2024-11-03 19:35:47 +00:00
|
|
|
static std::string GetDefaultBackendDisplayName();
|
2020-10-21 19:34:38 +00:00
|
|
|
static const std::vector<std::unique_ptr<VideoBackendBase>>& GetAvailableBackends();
|
2011-01-31 01:28:32 +00:00
|
|
|
static void ActivateBackend(const std::string& name);
|
2011-12-31 04:16:12 +00:00
|
|
|
|
2018-09-28 04:22:18 +00:00
|
|
|
// Fills the backend_info fields with the capabilities of the selected backend/device.
|
2023-03-26 00:16:53 +00:00
|
|
|
static void PopulateBackendInfo(const WindowSystemInfo& wsi);
|
2018-09-28 04:22:18 +00:00
|
|
|
|
2019-06-29 08:35:12 +00:00
|
|
|
// Wrapper function which pushes the event to the GPU thread.
|
2016-01-12 08:35:24 +00:00
|
|
|
void DoState(PointerWrap& p);
|
2013-09-22 16:09:39 +00:00
|
|
|
|
2016-01-02 20:01:12 +00:00
|
|
|
protected:
|
2023-01-28 01:53:19 +00:00
|
|
|
// For hardware backends
|
|
|
|
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
|
|
|
std::unique_ptr<VertexManagerBase> vertex_manager,
|
|
|
|
std::unique_ptr<PerfQueryBase> perf_query,
|
|
|
|
std::unique_ptr<BoundingBox> bounding_box);
|
|
|
|
|
|
|
|
// For software and null backends. Allows overriding the default Renderer and Texture Cache
|
|
|
|
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
|
|
|
std::unique_ptr<VertexManagerBase> vertex_manager,
|
|
|
|
std::unique_ptr<PerfQueryBase> perf_query,
|
|
|
|
std::unique_ptr<BoundingBox> bounding_box,
|
|
|
|
std::unique_ptr<Renderer> renderer,
|
|
|
|
std::unique_ptr<TextureCacheBase> texture_cache);
|
2016-01-13 20:14:20 +00:00
|
|
|
void ShutdownShared();
|
2016-01-12 08:35:24 +00:00
|
|
|
|
2016-01-02 20:01:12 +00:00
|
|
|
bool m_initialized = false;
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
extern VideoBackendBase* g_video_backend;
|