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 // Vulkan auxiliary command memory 145 static const char kVulkanAuxCommandMemory[] = "ANDROID_EMU_vulkan_aux_command_memory"; 146 147 // Struct describing available emulator features 148 struct EmulatorFeatureInfo { 149 EmulatorFeatureInfoEmulatorFeatureInfo150 EmulatorFeatureInfo() : 151 syncImpl(SYNC_IMPL_NONE), 152 dmaImpl(DMA_IMPL_NONE), 153 hostComposition(HOST_COMPOSITION_NONE), 154 glesMaxVersion(GLES_MAX_VERSION_2), 155 hasDirectMem(false), 156 hasVulkan(false), 157 hasDeferredVulkanCommands(false), 158 hasVulkanNullOptionalStrings(false), 159 hasVulkanCreateResourcesWithRequirements(false), 160 hasVulkanIgnoredHandles(false), 161 hasYUVCache (false), 162 hasAsyncUnmapBuffer (false), 163 hasVirtioGpuNext (false), 164 hasSharedSlotsHostMemoryAllocator(false), 165 hasVulkanFreeMemorySync(false), 166 hasVirtioGpuNativeSync(false), 167 hasVulkanShaderFloat16Int8(false), 168 hasVulkanAsyncQueueSubmit(false), 169 hasHostSideTracing(false), 170 hasAsyncFrameCommands(false), 171 hasVulkanQueueSubmitWithCommands(false), 172 hasVulkanBatchedDescriptorSetUpdate(false), 173 hasSyncBufferData(false), 174 hasVulkanAsyncQsri(false), 175 hasReadColorBufferDma(false), 176 hasHWCMultiConfigs(false), 177 hasVulkanAuxCommandMemory(false) 178 { } 179 180 SyncImpl syncImpl; 181 DmaImpl dmaImpl; 182 HostComposition hostComposition; 183 GLESMaxVersion glesMaxVersion; 184 bool hasDirectMem; 185 bool hasVulkan; 186 bool hasDeferredVulkanCommands; 187 bool hasVulkanNullOptionalStrings; 188 bool hasVulkanCreateResourcesWithRequirements; 189 bool hasVulkanIgnoredHandles; 190 bool hasYUVCache; 191 bool hasAsyncUnmapBuffer; 192 bool hasVirtioGpuNext; 193 bool hasSharedSlotsHostMemoryAllocator; 194 bool hasVulkanFreeMemorySync; 195 bool hasVirtioGpuNativeSync; 196 bool hasVulkanShaderFloat16Int8; 197 bool hasVulkanAsyncQueueSubmit; 198 bool hasHostSideTracing; 199 bool hasAsyncFrameCommands; 200 bool hasVulkanQueueSubmitWithCommands; 201 bool hasVulkanBatchedDescriptorSetUpdate; 202 bool hasSyncBufferData; 203 bool hasVulkanAsyncQsri; 204 bool hasReadColorBufferDma; 205 bool hasHWCMultiConfigs; 206 bool hasVulkanAuxCommandMemory; // This feature tracks if vulkan command buffers should be stored in an auxiliary shared memory 207 }; 208 209 enum HostConnectionType { 210 HOST_CONNECTION_QEMU_PIPE = 1, 211 HOST_CONNECTION_ADDRESS_SPACE = 2, 212 HOST_CONNECTION_VIRTIO_GPU_PIPE = 3, 213 HOST_CONNECTION_VIRTIO_GPU_ADDRESS_SPACE = 4, 214 }; 215 216 enum GrallocType { 217 GRALLOC_TYPE_RANCHU = 0, 218 GRALLOC_TYPE_MINIGBM = 1, 219 GRALLOC_TYPE_DYN_ALLOC_MINIGBM = 2, 220 }; 221 222 #endif // __COMMON_EMULATOR_FEATURE_INFO_H 223