gfxstream: guest: make sure signalSemaphoreValueCount is correct

From the Vulkan 1.3.204 spec:

VUID-VkSubmitInfo-pNext-03240

"If the pNext chain of this structure includes a
 VkTimelineSemaphoreSubmitInfo structure and any element of
 pSignalSemaphores was created with a VkSemaphoreType of
 VK_SEMAPHORE_TYPE_TIMELINE, then its signalSemaphoreValueCount
 member must equal signalSemaphoreCount"

Internally, Mesa WSI creates placeholder semaphores/fences (see
transformVkSemaphore functions in in gfxstream_vk_private.cpp).
We don't want to forward that to the host, since there is no host
side Vulkan object associated with the placeholder sync objects.

The way to test this behavior is Zink + glxgears, on Linux hosts.
It should fail without this check.

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Gurchetan Singh 2024-07-12 10:27:57 -07:00 committed by Marge Bot
parent 97304dffdf
commit 96cceac511
2 changed files with 32 additions and 0 deletions

View file

@ -5982,6 +5982,35 @@ VkResult ResourceTracker::on_vkQueueSubmit(void* context, VkResult input_result,
uint32_t submitCount, const VkSubmitInfo* pSubmits,
VkFence fence) {
AEMU_SCOPED_TRACE("on_vkQueueSubmit");
/* From the Vulkan 1.3.204 spec:
*
* VUID-VkSubmitInfo-pNext-03240
*
* "If the pNext chain of this structure includes a VkTimelineSemaphoreSubmitInfo structure
* and any element of pSignalSemaphores was created with a VkSemaphoreType of
* VK_SEMAPHORE_TYPE_TIMELINE, then its signalSemaphoreValueCount member must equal
* signalSemaphoreCount"
*
* Internally, Mesa WSI creates placeholder semaphores/fences (see transformVkSemaphore functions
* in in gfxstream_vk_private.cpp). We don't want to forward that to the host, since there is
* no host side Vulkan object associated with the placeholder sync objects.
*
* The way to test this behavior is Zink + glxgears, on Linux hosts. It should fail without
* this check.
*/
for (uint32_t i = 0; i < submitCount; i++) {
VkTimelineSemaphoreSubmitInfo* tssi = const_cast<VkTimelineSemaphoreSubmitInfo*>(
vk_find_struct<VkTimelineSemaphoreSubmitInfo>(&pSubmits[i]));
if (tssi) {
uint32_t count = getSignalSemaphoreCount(pSubmits[i]);
if (count != tssi->signalSemaphoreValueCount) {
tssi->signalSemaphoreValueCount = count;
}
}
}
return on_vkQueueSubmitTemplate<VkSubmitInfo>(context, input_result, queue, submitCount,
pSubmits, fence);
}

View file

@ -129,6 +129,9 @@ REGISTER_VK_STRUCT_ID(VkDeviceCreateInfo, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceGroupProperties,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES);
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT);
REGISTER_VK_STRUCT_ID(VkSubmitInfo, VK_STRUCTURE_TYPE_SUBMIT_INFO);
REGISTER_VK_STRUCT_ID(VkTimelineSemaphoreSubmitInfo,
VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO);
#if defined(LINUX_GUEST_BUILD)
REGISTER_VK_STRUCT_ID(wsi_image_create_info, VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA);
#endif