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 // Struct describing available emulator features 109 struct EmulatorFeatureInfo { 110 EmulatorFeatureInfoEmulatorFeatureInfo111 EmulatorFeatureInfo() : 112 syncImpl(SYNC_IMPL_NONE), 113 dmaImpl(DMA_IMPL_NONE), 114 hostComposition(HOST_COMPOSITION_NONE), 115 glesMaxVersion(GLES_MAX_VERSION_2), 116 hasDirectMem(false), 117 hasVulkan(false), 118 hasDeferredVulkanCommands(false), 119 hasVulkanNullOptionalStrings(false), 120 hasVulkanCreateResourcesWithRequirements(false), 121 hasVulkanIgnoredHandles(false), 122 hasYUVCache (false), 123 hasAsyncUnmapBuffer (false), 124 hasVirtioGpuNext (false), 125 hasSharedSlotsHostMemoryAllocator(false), 126 hasVulkanFreeMemorySync(false) 127 { } 128 129 SyncImpl syncImpl; 130 DmaImpl dmaImpl; 131 HostComposition hostComposition; 132 GLESMaxVersion glesMaxVersion; 133 bool hasDirectMem; 134 bool hasVulkan; 135 bool hasDeferredVulkanCommands; 136 bool hasVulkanNullOptionalStrings; 137 bool hasVulkanCreateResourcesWithRequirements; 138 bool hasVulkanIgnoredHandles; 139 bool hasYUVCache; 140 bool hasAsyncUnmapBuffer; 141 bool hasVirtioGpuNext; 142 bool hasSharedSlotsHostMemoryAllocator; 143 bool hasVulkanFreeMemorySync; 144 }; 145 146 enum HostConnectionType { 147 HOST_CONNECTION_TCP = 0, 148 HOST_CONNECTION_QEMU_PIPE = 1, 149 HOST_CONNECTION_VIRTIO_GPU = 2, 150 HOST_CONNECTION_ADDRESS_SPACE = 3, 151 HOST_CONNECTION_VIRTIO_GPU_PIPE = 4, 152 }; 153 154 enum GrallocType { 155 GRALLOC_TYPE_RANCHU = 0, 156 GRALLOC_TYPE_MINIGBM = 1, 157 GRALLOC_TYPE_DYN_ALLOC_MINIGBM = 2, 158 }; 159 160 #endif // __COMMON_EMULATOR_FEATURE_INFO_H 161