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 133 // Batched descriptor set update 134 static const char kVulkanBatchedDescriptorSetUpdate[] = "ANDROID_EMU_vulkan_batched_descriptor_set_update"; 135 136 // DMA for readback 137 static const char kReadColorBufferDma[] = "ANDROID_EMU_read_color_buffer_dma"; 138 139 // Struct describing available emulator features 140 struct EmulatorFeatureInfo { 141 EmulatorFeatureInfoEmulatorFeatureInfo142 EmulatorFeatureInfo() : 143 syncImpl(SYNC_IMPL_NONE), 144 dmaImpl(DMA_IMPL_NONE), 145 hostComposition(HOST_COMPOSITION_NONE), 146 glesMaxVersion(GLES_MAX_VERSION_2), 147 hasDirectMem(false), 148 hasVulkan(false), 149 hasDeferredVulkanCommands(false), 150 hasVulkanNullOptionalStrings(false), 151 hasVulkanCreateResourcesWithRequirements(false), 152 hasVulkanIgnoredHandles(false), 153 hasYUVCache (false), 154 hasAsyncUnmapBuffer (false), 155 hasVirtioGpuNext (false), 156 hasSharedSlotsHostMemoryAllocator(false), 157 hasVulkanFreeMemorySync(false), 158 hasVirtioGpuNativeSync(false), 159 hasVulkanShaderFloat16Int8(false), 160 hasVulkanAsyncQueueSubmit(false), 161 hasHostSideTracing(false), 162 hasAsyncFrameCommands(false), 163 hasVulkanQueueSubmitWithCommands(false), 164 hasVulkanBatchedDescriptorSetUpdate(false), 165 hasSyncBufferData(false), 166 hasReadColorBufferDma(false) 167 { } 168 169 SyncImpl syncImpl; 170 DmaImpl dmaImpl; 171 HostComposition hostComposition; 172 GLESMaxVersion glesMaxVersion; 173 bool hasDirectMem; 174 bool hasVulkan; 175 bool hasDeferredVulkanCommands; 176 bool hasVulkanNullOptionalStrings; 177 bool hasVulkanCreateResourcesWithRequirements; 178 bool hasVulkanIgnoredHandles; 179 bool hasYUVCache; 180 bool hasAsyncUnmapBuffer; 181 bool hasVirtioGpuNext; 182 bool hasSharedSlotsHostMemoryAllocator; 183 bool hasVulkanFreeMemorySync; 184 bool hasVirtioGpuNativeSync; 185 bool hasVulkanShaderFloat16Int8; 186 bool hasVulkanAsyncQueueSubmit; 187 bool hasHostSideTracing; 188 bool hasAsyncFrameCommands; 189 bool hasVulkanQueueSubmitWithCommands; 190 bool hasVulkanBatchedDescriptorSetUpdate; 191 bool hasSyncBufferData; 192 bool hasReadColorBufferDma; 193 }; 194 195 enum HostConnectionType { 196 HOST_CONNECTION_TCP = 0, 197 HOST_CONNECTION_QEMU_PIPE = 1, 198 HOST_CONNECTION_VIRTIO_GPU = 2, 199 HOST_CONNECTION_ADDRESS_SPACE = 3, 200 HOST_CONNECTION_VIRTIO_GPU_PIPE = 4, 201 HOST_CONNECTION_VIRTIO_GPU_ADDRESS_SPACE = 5, 202 }; 203 204 enum GrallocType { 205 GRALLOC_TYPE_RANCHU = 0, 206 GRALLOC_TYPE_MINIGBM = 1, 207 GRALLOC_TYPE_DYN_ALLOC_MINIGBM = 2, 208 }; 209 210 #endif // __COMMON_EMULATOR_FEATURE_INFO_H 211