Debian Codegraph @

Source/Core/VideoBackends/Metal/MTLUtil.h

raw symbols SCIP
1 // Copyright 2022 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <AppKit/NSScreen.h>
7 #include <Metal/Metal.h>
8
9 #include <vector>
10
11 #include "VideoCommon/AbstractShader.h"
12 #include "VideoCommon/TextureConfig.h"
13 #include "VideoCommon/VideoConfig.h"
14
15 #include "VideoBackends/Metal/MRCHelpers.h"
16
17 namespace Metal
18 {
19 struct DeviceFeatures
20 {
21 /// Manually copy buffer data to the GPU (instead of letting the GPU read from system memory)
22 /// On discrete GPUs, this tends to be faster if the copy is able to operate in parallel with a
23 /// previous render. This is the case unless a game uses features like bbox or texture downloads.
24 bool manual_buffer_upload;
25 bool subgroup_ops;
26 };
27
28 extern DeviceFeatures g_features;
29
30 namespace Util
31 {
32 struct Viewport
33 {
34 float x;
35 float y;
36 float width;
37 float height;
38 float near_depth;
39 float far_depth;
40 };
41
42 /// Gets the list of Metal devices, ordered so the system default device is first
43 std::vector<MRCOwned<id<MTLDevice>>> GetAdapterList();
44 void PopulateBackendInfo(BackendInfo* backend_info);
45 void PopulateBackendInfoAdapters(BackendInfo* backend_info,
46 const std::vector<MRCOwned<id<MTLDevice>>>& adapters);
47 void PopulateBackendInfoFeatures(const VideoConfig& config, BackendInfo* backend_info,
48 id<MTLDevice> device);
49
50 AbstractTextureFormat ToAbstract(MTLPixelFormat format);
51 MTLPixelFormat FromAbstract(AbstractTextureFormat format);
52 static inline bool HasStencil(AbstractTextureFormat format)
53 {
54 return format == AbstractTextureFormat::D24_S8 || format == AbstractTextureFormat::D32F_S8;
55 }
56
57 std::optional<std::string> TranslateShaderToMSL(ShaderStage stage, std::string_view source,
58 VideoCommon::ShaderIncluder* shader_includer);
59
60 } // namespace Util
61 } // namespace Metal