1 // Copyright 2024 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <string> 18 #include <map> 19 20 namespace gfxstream { 21 namespace host { 22 23 struct FeatureInfo; 24 25 using FeatureMap = std::map<std::string, FeatureInfo*>; 26 27 struct FeatureInfo { 28 FeatureInfo(const FeatureInfo& rhs) = default; 29 FeatureInfoFeatureInfo30 FeatureInfo(const char* name, 31 const char* description, 32 FeatureMap* map) : 33 name(name), 34 description(description), 35 enabled(false), 36 reason("Default value") { 37 if (map) { 38 (*map)[std::string(name)] = this; 39 } 40 } 41 42 ~FeatureInfo() = default; 43 44 std::string name; 45 std::string description; 46 bool enabled; 47 std::string reason; 48 }; 49 50 struct FeatureSet { 51 FeatureSet() = default; 52 53 FeatureSet(const FeatureSet& rhs); 54 FeatureSet& operator=(const FeatureSet& rhs); 55 56 FeatureMap map; 57 58 FeatureInfo AsyncComposeSupport = { 59 "AsyncComposeSupport", 60 "If enabled, allows the guest to use asynchronous render control commands " 61 "to compose and post frame buffers.", 62 &map, 63 }; 64 FeatureInfo ExternalBlob = { 65 "ExternalBlob", 66 "If enabled, virtio gpu blob resources will be allocated with external " 67 "memory and will be exportable via file descriptors.", 68 &map, 69 }; 70 FeatureInfo SystemBlob = { 71 "SystemBlob", 72 "If enabled, virtio gpu blob resources will be allocated with shmem and " 73 "will be exportable via file descriptors.", 74 &map, 75 }; 76 FeatureInfo GlAsyncSwap = { 77 "GlAsyncSwap", 78 "If enabled, uses the host GL driver's fence commands and fence file " 79 "descriptors in the guest to have explicit signals of buffer swap " 80 "completion.", 81 &map, 82 }; 83 FeatureInfo GlDirectMem = { 84 "GlDirectMem", 85 "If enabled, allows mapping the host address from glMapBufferRange() into " 86 "the guest.", 87 &map, 88 }; 89 FeatureInfo GlDma = { 90 "GlDma", 91 "Default description: consider contributing a description if you see this!", 92 &map, 93 }; 94 FeatureInfo GlDma2 = { 95 "GlDma2", 96 "Default description: consider contributing a description if you see this!", 97 &map, 98 }; 99 FeatureInfo GlPipeChecksum = { 100 "GlPipeChecksum", 101 "If enabled, the guest and host will use checksums to ensure consistency " 102 "for GL calls between the guest and host.", 103 &map, 104 }; 105 FeatureInfo GlesDynamicVersion = { 106 "GlesDynamicVersion", 107 "If enabled, attempts to detect and use the maximum supported GLES version " 108 "from the host.", 109 &map, 110 }; 111 FeatureInfo GrallocSync = { 112 "GrallocSync", 113 "If enabled, adds additional synchronization on the host for cases where " 114 "a guest app may directly writing to gralloc buffers and posting.", 115 &map, 116 }; 117 FeatureInfo GuestUsesAngle = { 118 "GuestUsesAngle", 119 "If enabled, indicates that the guest will not use GL and the host will not " 120 "enable the GL backend.", 121 &map, 122 }; 123 FeatureInfo HasSharedSlotsHostMemoryAllocator = { 124 "HasSharedSlotsHostMemoryAllocator", 125 "If enabled, the host supports " 126 "AddressSpaceSharedSlotsHostMemoryAllocatorContext.", 127 &map, 128 }; 129 FeatureInfo HostComposition = { 130 "HostComposition", 131 "If enabled, the host supports composition via render control commands.", 132 &map, 133 }; 134 FeatureInfo HwcMultiConfigs = { 135 "HwcMultiConfigs", 136 "If enabled, the host supports multiple HWComposer configs per display.", 137 &map, 138 }; 139 FeatureInfo Minigbm = { 140 "Minigbm", 141 "If enabled, the guest is known to be using Minigbm as its Gralloc " 142 "implementation.", 143 &map, 144 }; 145 FeatureInfo NativeTextureDecompression = { 146 "NativeTextureDecompression", 147 "If enabled, allows the host to use ASTC and ETC2 formats when supported by " 148 " the host GL driver.", 149 &map, 150 }; 151 FeatureInfo NoDelayCloseColorBuffer = { 152 "NoDelayCloseColorBuffer", 153 "If enabled, indicates that the guest properly associates resources with " 154 "guest OS handles and that the host resources can be immediately cleaned " 155 "upon receiving resource clean up commands.", 156 &map, 157 }; 158 FeatureInfo PlayStoreImage = { 159 "PlayStoreImage", 160 "If enabled, the guest image is using the play store image which has " 161 "additional requirements.", 162 &map, 163 }; 164 FeatureInfo RefCountPipe = { 165 "RefCountPipe", 166 "If enabled, resources are referenced counted via a specific pipe " 167 "implementation.", 168 &map, 169 }; 170 FeatureInfo VirtioGpuFenceContexts = { 171 "VirtioGpuFenceContexts", 172 "If enabled, the host will support multiple virtio gpu fence timelines.", 173 &map, 174 }; 175 FeatureInfo VirtioGpuNativeSync = { 176 "VirtioGpuNativeSync", 177 "If enabled, use virtio gpu instead of goldfish sync for sync fd support.", 178 &map, 179 }; 180 FeatureInfo VirtioGpuNext = { 181 "VirtioGpuNext", 182 "If enabled, virtio gpu supports blob resources (this was historically " 183 "called on a virtio-gpu-next branch in upstream kernel?).", 184 &map, 185 }; 186 FeatureInfo VulkanAllocateDeviceMemoryOnly = { 187 "VulkanAllocateDeviceMemoryOnly", 188 "If enabled, prevents the guest from allocating Vulkan memory that does " 189 "not have VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT.", 190 &map, 191 }; 192 FeatureInfo VulkanAllocateHostMemory = { 193 "VulkanAllocateHostMemory", 194 "If enabled, allocates host private memory and uses " 195 "VK_EXT_external_memory_host to handle Vulkan " 196 "VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT allocations.", 197 &map, 198 }; 199 FeatureInfo VulkanBatchedDescriptorSetUpdate = { 200 "VulkanBatchedDescriptorSetUpdate", 201 "If enabled, Vulkan descriptor set updates via vkUpdateDescriptorSets() are " 202 "not immediately sent to the host and are instead deferred until needed " 203 "in vkQueueSubmit() commands.", 204 &map, 205 }; 206 FeatureInfo VulkanIgnoredHandles = { 207 "VulkanIgnoredHandles", 208 "If enabled, the guest to host Vulkan protocol will ignore handles in some " 209 "cases such as VkWriteDescriptorSet().", 210 &map, 211 }; 212 FeatureInfo VulkanNativeSwapchain = { 213 "VulkanNativeSwapchain", 214 "If enabled, the host display implementation uses a native Vulkan swapchain.", 215 &map, 216 }; 217 FeatureInfo VulkanNullOptionalStrings = { 218 "VulkanNullOptionalStrings", 219 "If enabled, the guest to host Vulkan protocol will encode null optional " 220 "strings as actual null values instead of as empty strings.", 221 &map, 222 }; 223 FeatureInfo VulkanQueueSubmitWithCommands = { 224 "VulkanQueueSubmitWithCommands", 225 "If enabled, uses deferred command submission with global sequence number " 226 "synchronization for Vulkan queue submits.", 227 &map, 228 }; 229 FeatureInfo VulkanShaderFloat16Int8 = { 230 "VulkanShaderFloat16Int8", 231 "If enabled, enables the VK_KHR_shader_float16_int8 extension.", 232 &map, 233 }; 234 FeatureInfo VulkanSnapshots = { 235 "VulkanSnapshots", 236 "If enabled, supports snapshotting the guest and host Vulkan state.", 237 &map, 238 }; 239 FeatureInfo VulkanUseDedicatedAhbMemoryType = { 240 "VulkanUseDedicatedAhbMemoryType", 241 "If enabled, emulates an additional memory type for AHardwareBuffer allocations " 242 "that only has VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT for the purposes of preventing " 243 "the guest from trying to map AHardwareBuffer memory.", 244 &map, 245 }; 246 FeatureInfo Vulkan = { 247 "Vulkan", 248 "If enabled, allows the guest to use Vulkan and enables the Vulkan backend " 249 "on the host.", 250 &map, 251 }; 252 FeatureInfo Yuv420888ToNv21 = { 253 "Yuv420888ToNv21", 254 "If enabled, Androids HAL_PIXEL_FORMAT_YCbCr_420_888 format is treated as " 255 "NV21.", 256 &map, 257 }; 258 FeatureInfo YuvCache = { 259 "YuvCache", 260 "If enabled, the host will cache YUV frames.", 261 &map, 262 }; 263 }; 264 265 #define GFXSTREAM_SET_FEATURE_ON_CONDITION(set, feature, condition) \ 266 do \ 267 { \ 268 { \ 269 (set)->feature.enabled = condition; \ 270 (set)->feature.reason = #condition; \ 271 } \ 272 } while (0) 273 274 } // namespace host 275 } // namespace gfxstream 276