1 // Copyright (C) 2018 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 #ifndef __COMMON_EMULATOR_FEATURE_INFO_H 15 #define __COMMON_EMULATOR_FEATURE_INFO_H 16 17 // SyncImpl determines the presence of host/guest OpenGL fence sync 18 // capabilities. It corresponds exactly to EGL_ANDROID_native_fence_sync 19 // capability, but for the emulator, we need to make sure that 20 // OpenGL pipe protocols match, so we use a special extension name 21 // here. 22 // SYNC_IMPL_NONE means that the native fence sync capability is 23 // not present, and we will end up using the equivalent of glFinish 24 // in order to preserve buffer swapping order. 25 // SYNC_IMPL_NATIVE_SYNC means that we do have native fence sync 26 // capability, and we will use a fence fd to synchronize buffer swaps. 27 enum SyncImpl { 28 SYNC_IMPL_NONE = 0, 29 SYNC_IMPL_NATIVE_SYNC_V2 = 1, // ANDROID_native_fence_sync 30 SYNC_IMPL_NATIVE_SYNC_V3 = 2, // KHR_wait_sync 31 SYNC_IMPL_NATIVE_SYNC_V4 = 3, // Correct eglGetSyncAttribKHR 32 }; 33 34 // Interface for native sync: 35 // Use the highest that shows up 36 static const char kRCNativeSyncV2[] = "ANDROID_EMU_native_sync_v2"; 37 static const char kRCNativeSyncV3[] = "ANDROID_EMU_native_sync_v3"; 38 static const char kRCNativeSyncV4[] = "ANDROID_EMU_native_sync_v4"; 39 40 // DMA for OpenGL 41 enum DmaImpl { 42 DMA_IMPL_NONE = 0, 43 DMA_IMPL_v1 = 1, 44 }; 45 46 static const char kDmaExtStr_v1[] = "ANDROID_EMU_dma_v1"; 47 48 // OpenGL ES max supported version 49 enum GLESMaxVersion { 50 GLES_MAX_VERSION_2 = 0, 51 GLES_MAX_VERSION_3_0 = 1, 52 GLES_MAX_VERSION_3_1 = 2, 53 GLES_MAX_VERSION_3_2 = 3, 54 }; 55 56 static const char kGLESMaxVersion_2[] = "ANDROID_EMU_gles_max_version_2"; 57 static const char kGLESMaxVersion_3_0[] = "ANDROID_EMU_gles_max_version_3_0"; 58 static const char kGLESMaxVersion_3_1[] = "ANDROID_EMU_gles_max_version_3_1"; 59 static const char kGLESMaxVersion_3_2[] = "ANDROID_EMU_gles_max_version_3_2"; 60 61 enum HostComposition { 62 HOST_COMPOSITION_NONE = 0, 63 HOST_COMPOSITION_V1, 64 HOST_COMPOSITION_V2, 65 }; 66 67 static const char kHostCompositionV1[] = "ANDROID_EMU_host_composition_v1"; 68 static const char kHostCompositionV2[] = "ANDROID_EMU_host_composition_v2"; 69 70 // No querying errors from host extension 71 static const char kGLESNoHostError[] = "ANDROID_EMU_gles_no_host_error"; 72 73 // Host to guest memory mapping 74 static const char kGLDirectMem[] = "ANDROID_EMU_direct_mem"; 75 76 // Vulkan host support 77 // To be delivered/enabled when at least the following is working/available: 78 // - HOST_COHERENT memory mapping 79 // - Full gralloc interop: External memory, AHB 80 static const char kVulkan[] = "ANDROID_EMU_vulkan"; 81 82 // Deferred Vulkan commands 83 static const char kDeferredVulkanCommands[] = "ANDROID_EMU_deferred_vulkan_commands"; 84 85 // Vulkan null optional strings 86 static const char kVulkanNullOptionalStrings[] = "ANDROID_EMU_vulkan_null_optional_strings"; 87 88 // Vulkan create resources with requirements 89 static const char kVulkanCreateResourcesWithRequirements[] = "ANDROID_EMU_vulkan_create_resources_with_requirements"; 90 91 // Vulkan ignored handles 92 static const char kVulkanIgnoredHandles[] = "ANDROID_EMU_vulkan_ignored_handles"; 93 94 // YUV host cache 95 static const char kYUVCache[] = "ANDROID_EMU_YUV_Cache"; 96 97 // GL protocol v2 98 static const char kAsyncUnmapBuffer[] = "ANDROID_EMU_async_unmap_buffer"; 99 100 // virtio-gpu-next 101 static const char kVirtioGpuNext[] = "ANDROID_EMU_virtio_gpu_next"; 102 103 static const char kHasSharedSlotsHostMemoryAllocator[] = "ANDROID_EMU_has_shared_slots_host_memory_allocator"; 104 105 // Vulkan free memory sync 106 static const char kVulkanFreeMemorySync[] = "ANDROID_EMU_vulkan_free_memory_sync"; 107 108 // virtio-gpu syncfd support 109 static const char kVirtioGpuNativeSync[] = "ANDROID_EMU_virtio_gpu_native_sync"; 110 111 // Vulkan extension that required a protocol update (new marshaling structs) 112 static const char kVulkanShaderFloat16Int8[] = "ANDROID_EMU_vulkan_shader_float16_int8"; 113 114 // Vulkan async queue submit 115 static const char kVulkanAsyncQueueSubmit[] = "ANDROID_EMU_vulkan_async_queue_submit"; 116 117 // A flag to _not_ ignore host opengl errors (now host opengl errors are ignored by default) 118 static const char kGLESUseHostError[] = "ANDROID_EMU_gles_use_host_error"; 119 120 // Host side tracing 121 static const char kHostSideTracing[] = "ANDROID_EMU_host_side_tracing"; 122 123 // Make current async 124 static const char kAsyncFrameCommands[] = "ANDROID_EMU_async_frame_commands"; 125 126 // Queue submit with commands 127 static const char kVulkanQueueSubmitWithCommands[] = "ANDROID_EMU_vulkan_queue_submit_with_commands"; 128 // 129 // Synchronized glBufferData call 130 static const char kSyncBufferData[] = "ANDROID_EMU_sync_buffer_data"; 131 132 // Batched descriptor set update 133 static const char kVulkanBatchedDescriptorSetUpdate[] = "ANDROID_EMU_vulkan_batched_descriptor_set_update"; 134 135 // Async QSRI 136 static const char kVulkanAsyncQsri[] = "ANDROID_EMU_vulkan_async_qsri"; 137 138 // DMA for readback 139 static const char kReadColorBufferDma[] = "ANDROID_EMU_read_color_buffer_dma"; 140 141 // HWC multiple display configs 142 static const char kHWCMultiConfigs[] = "ANDROID_EMU_hwc_multi_configs"; 143 144 // Struct describing available emulator features 145 struct EmulatorFeatureInfo { 146 EmulatorFeatureInfoEmulatorFeatureInfo147 EmulatorFeatureInfo() : 148 syncImpl(SYNC_IMPL_NONE), 149 dmaImpl(DMA_IMPL_NONE), 150 hostComposition(HOST_COMPOSITION_NONE), 151 glesMaxVersion(GLES_MAX_VERSION_2), 152 hasDirectMem(false), 153 hasVulkan(false), 154 hasDeferredVulkanCommands(false), 155 hasVulkanNullOptionalStrings(false), 156 hasVulkanCreateResourcesWithRequirements(false), 157 hasVulkanIgnoredHandles(false), 158 hasYUVCache (false), 159 hasAsyncUnmapBuffer (false), 160 hasVirtioGpuNext (false), 161 hasSharedSlotsHostMemoryAllocator(false), 162 hasVulkanFreeMemorySync(false), 163 hasVirtioGpuNativeSync(false), 164 hasVulkanShaderFloat16Int8(false), 165 hasVulkanAsyncQueueSubmit(false), 166 hasHostSideTracing(false), 167 hasAsyncFrameCommands(false), 168 hasVulkanQueueSubmitWithCommands(false), 169 hasVulkanBatchedDescriptorSetUpdate(false), 170 hasSyncBufferData(false), 171 hasVulkanAsyncQsri(false), 172 hasReadColorBufferDma(false), 173 hasHWCMultiConfigs(false) 174 { } 175 176 SyncImpl syncImpl; 177 DmaImpl dmaImpl; 178 HostComposition hostComposition; 179 GLESMaxVersion glesMaxVersion; 180 bool hasDirectMem; 181 bool hasVulkan; 182 bool hasDeferredVulkanCommands; 183 bool hasVulkanNullOptionalStrings; 184 bool hasVulkanCreateResourcesWithRequirements; 185 bool hasVulkanIgnoredHandles; 186 bool hasYUVCache; 187 bool hasAsyncUnmapBuffer; 188 bool hasVirtioGpuNext; 189 bool hasSharedSlotsHostMemoryAllocator; 190 bool hasVulkanFreeMemorySync; 191 bool hasVirtioGpuNativeSync; 192 bool hasVulkanShaderFloat16Int8; 193 bool hasVulkanAsyncQueueSubmit; 194 bool hasHostSideTracing; 195 bool hasAsyncFrameCommands; 196 bool hasVulkanQueueSubmitWithCommands; 197 bool hasVulkanBatchedDescriptorSetUpdate; 198 bool hasSyncBufferData; 199 bool hasVulkanAsyncQsri; 200 bool hasReadColorBufferDma; 201 bool hasHWCMultiConfigs; 202 }; 203 204 enum HostConnectionType { 205 HOST_CONNECTION_TCP = 0, 206 HOST_CONNECTION_QEMU_PIPE = 1, 207 HOST_CONNECTION_VIRTIO_GPU = 2, 208 HOST_CONNECTION_ADDRESS_SPACE = 3, 209 HOST_CONNECTION_VIRTIO_GPU_PIPE = 4, 210 HOST_CONNECTION_VIRTIO_GPU_ADDRESS_SPACE = 5, 211 }; 212 213 enum GrallocType { 214 GRALLOC_TYPE_RANCHU = 0, 215 GRALLOC_TYPE_MINIGBM = 1, 216 GRALLOC_TYPE_DYN_ALLOC_MINIGBM = 2, 217 }; 218 219 #endif // __COMMON_EMULATOR_FEATURE_INFO_H 220