Debian Codegraph @

Source/Core/VideoCommon/VideoBackendBase.h

raw symbols SCIP
1 // Copyright 2011 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <memory>
7 #include <optional>
8 #include <string>
9 #include <vector>
10
11 #include "Common/CommonTypes.h"
12 #include "Common/WindowSystemInfo.h"
13 #include "VideoCommon/PerfQueryBase.h"
14
15 namespace MMIO
16 {
17 class Mapping;
18 }
19 class PointerWrap;
20
21 class AbstractGfx;
22 class BoundingBox;
23 class TextureCacheBase;
24 class VertexManagerBase;
25 class EFBInterfaceBase;
26
27 enum class FieldType
28 {
29 Odd,
30 Even,
31 };
32
33 class VideoBackendBase
34 {
35 public:
36 virtual ~VideoBackendBase() {}
37 virtual bool Initialize(const WindowSystemInfo& wsi) = 0;
38 virtual void Shutdown() = 0;
39
40 virtual std::string GetConfigName() const = 0;
41 virtual std::string GetDisplayName() const { return GetConfigName(); }
42 virtual void InitBackendInfo(const WindowSystemInfo& wsi) = 0;
43 virtual std::optional<std::string> GetWarningMessage() const { return {}; }
44
45 // Prepares a native window for rendering. This is called on the main thread, or the
46 // thread which owns the window.
47 virtual void PrepareWindow(WindowSystemInfo& wsi) {}
48
49 static std::string BadShaderFilename(const char* shader_stage, int counter);
50
51 void Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks);
52
53 u32 Video_GetQueryResult(PerfQueryType type);
54 u16 Video_GetBoundingBox(int index);
55
56 static std::string GetDefaultBackendConfigName();
57 static std::string GetDefaultBackendDisplayName();
58 static const std::vector<std::unique_ptr<VideoBackendBase>>& GetAvailableBackends();
59 static void ActivateBackend(const std::string& name);
60
61 // Fills the backend_info fields with the capabilities of the selected backend/device.
62 static void PopulateBackendInfo(const WindowSystemInfo& wsi);
63
64 // Wrapper function which pushes the event to the GPU thread.
65 void DoState(PointerWrap& p);
66
67 protected:
68 // For hardware backends
69 bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
70 std::unique_ptr<VertexManagerBase> vertex_manager,
71 std::unique_ptr<PerfQueryBase> perf_query,
72 std::unique_ptr<BoundingBox> bounding_box);
73
74 // For software and null backends. Allows overriding the default EFBInterface and TextureCache
75 bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
76 std::unique_ptr<VertexManagerBase> vertex_manager,
77 std::unique_ptr<PerfQueryBase> perf_query,
78 std::unique_ptr<BoundingBox> bounding_box,
79 std::unique_ptr<EFBInterfaceBase> efb_interface,
80 std::unique_ptr<TextureCacheBase> texture_cache);
81 void ShutdownShared();
82
83 bool m_initialized = false;
84 };
85
86 extern VideoBackendBase* g_video_backend;