Android-cuttlefish cvd tool
gpu_mode.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <string>
20#include <string_view>
21
22#include "absl/strings/string_view.h"
23
25
26namespace cuttlefish {
27
28enum class GpuMode {
29 Auto,
30 Custom,
35 Venus,
38 None,
39};
40
41inline constexpr absl::string_view kGpuModeAuto = "auto";
42inline constexpr absl::string_view kGpuModeCustom = "custom";
43inline constexpr absl::string_view kGpuModeGfxstream = "gfxstream";
44inline constexpr absl::string_view kGpuModeGfxstreamGuestAngle =
45 "gfxstream_guest_angle";
46inline constexpr absl::string_view kGpuModeGfxstreamGuestAngleHostLavapipe =
47 "gfxstream_guest_angle_host_lavapipe";
48inline constexpr absl::string_view kGpuModeGfxstreamGuestAngleHostSwiftshader =
49 "gfxstream_guest_angle_host_swiftshader";
50inline constexpr absl::string_view kGpuModeVenus = "venus";
51inline constexpr absl::string_view kGpuModeGuestLavapipe = "guest_lavapipe";
52inline constexpr absl::string_view kGpuModeGuestSwiftshader =
53 "guest_swiftshader";
54inline constexpr absl::string_view kGpuModeNone = "none";
55
56template <typename Sink>
57void AbslStringify(Sink& sink, GpuMode mode) {
58 switch (mode) {
59 case GpuMode::Auto:
60 sink.Append(kGpuModeAuto);
61 break;
62 case GpuMode::Custom:
63 sink.Append(kGpuModeCustom);
64 break;
66 sink.Append(kGpuModeGfxstream);
67 break;
69 sink.Append(kGpuModeGfxstreamGuestAngle);
70 break;
73 break;
76 break;
77 case GpuMode::Venus:
78 sink.Append(kGpuModeVenus);
79 break;
81 sink.Append(kGpuModeGuestLavapipe);
82 break;
84 sink.Append(kGpuModeGuestSwiftshader);
85 break;
86 case GpuMode::None:
87 sink.Append(kGpuModeNone);
88 break;
89 }
90}
91
92Result<GpuMode> GpuModeFromString(absl::string_view mode);
93std::string GpuModeString(GpuMode mode);
94std::string_view format_as(GpuMode mode); // For libfmt
95
96bool IsGfxstreamMode(GpuMode mode);
98
100
101} // namespace cuttlefish
Definition: alloc_driver.h:21
constexpr absl::string_view kGpuModeNone
Definition: gpu_mode.h:54
void AbslStringify(Sink &sink, DeviceType device_type)
Definition: device_type.h:44
constexpr absl::string_view kGpuModeAuto
Definition: gpu_mode.h:41
std::string GpuModeString(GpuMode mode)
Definition: gpu_mode.cc:55
constexpr absl::string_view kGpuModeVenus
Definition: gpu_mode.h:50
constexpr absl::string_view kGpuModeGfxstreamGuestAngle
Definition: gpu_mode.h:44
constexpr absl::string_view kGpuModeGuestSwiftshader
Definition: gpu_mode.h:52
constexpr absl::string_view kGpuModeGfxstreamGuestAngleHostLavapipe
Definition: gpu_mode.h:46
constexpr absl::string_view kGpuModeGfxstream
Definition: gpu_mode.h:43
bool IsGfxstreamGuestAngleMode(GpuMode mode)
Definition: gpu_mode.cc:96
constexpr absl::string_view kGpuModeGfxstreamGuestAngleHostSwiftshader
Definition: gpu_mode.h:48
constexpr absl::string_view kGpuModeGuestLavapipe
Definition: gpu_mode.h:51
Result< GpuMode > GpuModeFromString(absl::string_view mode)
Definition: gpu_mode.cc:29
bool IsGuestRenderingMode(GpuMode mode)
Definition: gpu_mode.cc:102
constexpr absl::string_view kGpuModeCustom
Definition: gpu_mode.h:42
bool IsGfxstreamMode(GpuMode mode)
Definition: gpu_mode.cc:90
std::string_view format_as(DeviceType device_type)
Definition: device_type.cpp:77
GpuMode
Definition: gpu_mode.h:28