renderdoc icon indicating copy to clipboard operation
renderdoc copied to clipboard

Vulkan application crash during `vkEnumeratePhysicalDeviceGroups` capture

Open KacperZielinski-Intel opened this issue 1 year ago • 0 comments

Description

RenderDoc's vkEnumeratePhysicalDeviceGroups implementation is non-compliant with Vulkan specification.

See: vkEnumeratePhysicalDeviceGroups documentation

When vkEnumeratePhysicalDeviceGroups is called to query less than the total number of available device groups, then pPhysicalDeviceGroupCount parameter would be overridden with the total amount of available device groups. However, Vulkan specification says that the amount of device groups written to pPhysicalDeviceGroupProperties should be returned instead.

Attempt to record such case in RenderDoc, will cause Vulkan loader (vulkan-1.dll) to crash on preparing vkEnumeratePhysicalDeviceGroups trampoline.

I have prepared fix for this issue.

Steps to reproduce

uint32_t pPhysicalDeviceGroupCount{};

// Request number of total available physical device groups.
vkEnumeratePhysicalDeviceGroups(instance, &pPhysicalDeviceGroupCount, NULL);

assert(pPhysicalDeviceGroupCount > 2);
--pPhysicalDeviceGroupCount;

// Array of empty physical device group properties.
VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties = new VkPhysicalDeviceGroupProperties[pPhysicalDeviceGroupCount];

for (uint32_t i = 0; i < pPhysicalDeviceGroupCount; ++i)
{
    pPhysicalDeviceGroupProperties[i].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES;
    pPhysicalDeviceGroupProperties[i].pNext = NULL;
    pPhysicalDeviceGroupProperties[i].physicalDeviceCount = 0;
    pPhysicalDeviceGroupProperties[i].physicalDevices = NULL;
    pPhysicalDeviceGroupProperties[i].subsetAllocation = 0;
}

// Query less than total number of available physical device groups.
vkEnumeratePhysicalDeviceGroups(instance, &pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
// < crash in vulkan-1.dll >

Environment

  • RenderDoc version: 1.31
  • Operating System: Windows 11
  • Graphics API: Vulkan 1.3
  • GPU: Intel Arc

KacperZielinski-Intel avatar Feb 28 '24 10:02 KacperZielinski-Intel