aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorspencer-lunarg <spencer@lunarg.com>2023-10-07 08:21:33 +0900
committerSpencer Fricke <115671160+spencer-lunarg@users.noreply.github.com>2023-10-07 15:32:36 +0900
commit730234d8e46f6eea3622a4a90a1f4ce537cf2321 (patch)
tree753ab382955d155dc089957114b006b40acffda1 /scripts
parent96bad23002d40ad7e7eba3743ff22af1cd24d8f4 (diff)
downloadusermoji-730234d8e46f6eea3622a4a90a1f4ce537cf2321.tar.xz
icd: Add support to mock AHB commands
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mock_icd_generator.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py
index 3de3e540..6b800922 100644
--- a/scripts/mock_icd_generator.py
+++ b/scripts/mock_icd_generator.py
@@ -454,6 +454,14 @@ CUSTOM_C_INTERCEPTS = {
return VK_SUCCESS;
''',
'vkGetPhysicalDeviceImageFormatProperties2KHR': '''
+ auto *external_image_prop = lvl_find_mod_in_chain<VkExternalImageFormatProperties>(pImageFormatProperties->pNext);
+ auto *external_image_format = lvl_find_in_chain<VkPhysicalDeviceExternalImageFormatInfo>(pImageFormatInfo->pNext);
+ if (external_image_prop && external_image_format && external_image_format->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
+ external_image_prop->externalMemoryProperties.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
+ external_image_prop->externalMemoryProperties.compatibleHandleTypes = external_image_format->handleType;
+ external_image_prop->externalMemoryProperties.compatibleHandleTypes = external_image_format->handleType;
+ }
+
GetPhysicalDeviceImageFormatProperties(physicalDevice, pImageFormatInfo->format, pImageFormatInfo->type, pImageFormatInfo->tiling, pImageFormatInfo->usage, pImageFormatInfo->flags, &pImageFormatProperties->imageFormatProperties);
return VK_SUCCESS;
''',
@@ -651,7 +659,12 @@ CUSTOM_C_INTERCEPTS = {
''',
'vkGetPhysicalDeviceExternalBufferProperties':'''
constexpr VkExternalMemoryHandleTypeFlags supported_flags = 0x1FF;
- if (pExternalBufferInfo->handleType & supported_flags) {
+ if (pExternalBufferInfo->handleType & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
+ // Can't have dedicated memory with AHB
+ pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
+ pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = pExternalBufferInfo->handleType;
+ pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = pExternalBufferInfo->handleType;
+ } else if (pExternalBufferInfo->handleType & supported_flags) {
pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0x7;
pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = supported_flags;
pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = supported_flags;
@@ -1043,6 +1056,18 @@ CUSTOM_C_INTERCEPTS = {
pGranularity->width = 1;
pGranularity->height = 1;
''',
+'vkGetAndroidHardwareBufferPropertiesANDROID': '''
+ pProperties->allocationSize = 65536;
+ pProperties->memoryTypeBits = 1 << 5; // DEVICE_LOCAL only type
+
+ auto *format_prop = lvl_find_mod_in_chain<VkAndroidHardwareBufferFormatPropertiesANDROID>(pProperties->pNext);
+ if (format_prop) {
+ // Likley using this format
+ format_prop->format = VK_FORMAT_R8G8B8A8_UNORM;
+ format_prop->externalFormat = 37;
+ }
+ return VK_SUCCESS;
+''',
}
# MockICDGeneratorOptions - subclass of GeneratorOptions.