aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ruby <aruby@blackberry.com>2024-04-24 13:27:28 -0400
committerGurchetan Singh <gurchetansingh@google.com>2024-04-29 18:10:57 -0700
commit0059ccf51e5fb0bb8534b65fc4996ceb269a82d4 (patch)
treeb355d7861ec75ec20f8f3c56017e12b2976cca0f
parentcc1924d2b148a38927ebdcbb78d1611d80977320 (diff)
downloadgfxstream-0059ccf51e5fb0bb8534b65fc4996ceb269a82d4.tar.gz
gfxstream: translate physicalDevices list in VkPhysicalDeviceGroupProperties to their gfxstream objects
In preparation to fix some end2end tests. BUG=333133323 TEST=compile Change-Id: I0efeef4e3ace7a2ae38c1b8e16ebda5d546c6a7a
-rw-r--r--guest/vulkan/gfxstream_vk_device.cpp30
-rw-r--r--guest/vulkan_enc/vk_struct_id.h3
2 files changed, 33 insertions, 0 deletions
diff --git a/guest/vulkan/gfxstream_vk_device.cpp b/guest/vulkan/gfxstream_vk_device.cpp
index d6df9053..af26e638 100644
--- a/guest/vulkan/gfxstream_vk_device.cpp
+++ b/guest/vulkan/gfxstream_vk_device.cpp
@@ -457,6 +457,25 @@ VkResult gfxstream_vk_CreateDevice(VkPhysicalDevice physicalDevice,
mutableCreateInfo->enabledExtensionCount = static_cast<uint32_t>(filteredExts.size());
mutableCreateInfo->ppEnabledExtensionNames = filteredExts.data();
+ /* pNext = VkPhysicalDeviceGroupProperties */
+ std::vector<VkPhysicalDevice> initialPhysicalDeviceList;
+ VkPhysicalDeviceGroupProperties* mutablePhysicalDeviceGroupProperties =
+ (VkPhysicalDeviceGroupProperties*)vk_find_struct<VkPhysicalDeviceGroupProperties>(
+ pCreateInfo);
+ if (mutablePhysicalDeviceGroupProperties) {
+ // Temporarily modify the VkPhysicalDeviceGroupProperties structure to use translated
+ // VkPhysicalDevice references for the encoder call
+ for (int physDev = 0;
+ physDev < mutablePhysicalDeviceGroupProperties->physicalDeviceCount; physDev++) {
+ initialPhysicalDeviceList.push_back(
+ mutablePhysicalDeviceGroupProperties->physicalDevices[physDev]);
+ VK_FROM_HANDLE(gfxstream_vk_physical_device, gfxstream_physicalDevice,
+ mutablePhysicalDeviceGroupProperties->physicalDevices[physDev]);
+ mutablePhysicalDeviceGroupProperties->physicalDevices[physDev] =
+ gfxstream_physicalDevice->internal_object;
+ }
+ }
+
auto vkEnc = gfxstream::vk::ResourceTracker::getThreadLocalEncoder();
result = vkEnc->vkCreateDevice(gfxstream_physicalDevice->internal_object, pCreateInfo,
pAllocator, &gfxstream_device->internal_object,
@@ -464,6 +483,17 @@ VkResult gfxstream_vk_CreateDevice(VkPhysicalDevice physicalDevice,
// Revert the createInfo the user-set data
mutableCreateInfo->enabledExtensionCount = initialEnabledExtensionCount;
mutableCreateInfo->ppEnabledExtensionNames = initialPpEnabledExtensionNames;
+ if (mutablePhysicalDeviceGroupProperties) {
+ // Revert the physicalDevice list in VkPhysicalDeviceGroupProperties to the user-set
+ // data
+ for (int physDev = 0;
+ physDev < mutablePhysicalDeviceGroupProperties->physicalDeviceCount; physDev++) {
+ initialPhysicalDeviceList.push_back(
+ mutablePhysicalDeviceGroupProperties->physicalDevices[physDev]);
+ mutablePhysicalDeviceGroupProperties->physicalDevices[physDev] =
+ initialPhysicalDeviceList[physDev];
+ }
+ }
}
if (VK_SUCCESS == result) {
struct vk_device_dispatch_table dispatch_table;
diff --git a/guest/vulkan_enc/vk_struct_id.h b/guest/vulkan_enc/vk_struct_id.h
index 5c155658..99890a69 100644
--- a/guest/vulkan_enc/vk_struct_id.h
+++ b/guest/vulkan_enc/vk_struct_id.h
@@ -121,6 +121,9 @@ REGISTER_VK_STRUCT_ID(VkRenderPassAttachmentBeginInfo,
VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO);
REGISTER_VK_STRUCT_ID(VkImportMemoryHostPointerInfoEXT,
VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT);
+REGISTER_VK_STRUCT_ID(VkDeviceCreateInfo, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
+REGISTER_VK_STRUCT_ID(VkPhysicalDeviceGroupProperties,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES);
#undef REGISTER_VK_STRUCT_ID