Invalid VkDisplayKHR object with vkGetDisplayModeProperties2KHR

I’m having a little trouble navigating correct API usage between vkGetPhysicalDeviceDisplayPlaneProperties2KHR and vkGetDisplayModeProperties2KHR

Specifically, I’m using the former to establish the collection of available display planes, which returns a set of properties… those properties include a VkDisplayKHR object.

My intention is to then query that VkDisplayKHR object to determine the available mode properties, however I’m hitting the following validation layer error in the first call to vkGetDisplayModeProperties2KHR

validation layer: (Validation) Validation Error: [ VUID-vkGetDisplayModeProperties2KHR-display-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xa377861e | Invalid VkDisplayKHR Object 0x30000000003. The Vulkan spec states: display must be a valid VkDisplayKHR handle (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkGetDisplayModeProperties2KHR-display-parameter)
validation layer: (Validation) Validation Error: [ UNASSIGNED-Threading-Info ] Object 0: handle = 0x30000000003, type = VK_OBJECT_TYPE_DISPLAY_KHR; | MessageID = 0x5d6b67e2 | Couldn't find VkDisplayKHR Object 0x30000000003. This should not happen and may indicate a bug in the application.
validation layer: (Validation) Validation Error: [ UNASSIGNED-Threading-Info ] Object 0: handle = 0x30000000003, type = VK_OBJECT_TYPE_DISPLAY_KHR; | MessageID = 0x5d6b67e2 | Couldn't find VkDisplayKHR Object 0x30000000003. This should not happen and may indicate a bug in the application.

which is followed by an immediate seg fault…

Here’s the code driving that… fairly straight foward:

// Experiment with DisplayPlaneSurface

uint32_t propertyCount = 0;
vkGetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice, &propertyCount, nullptr);

VkDisplayPlaneProperties2KHR* preferredDisplayPlaneProperty = nullptr;

std::vector<VkDisplayPlaneProperties2KHR> displayPlaneProperties(propertyCount);
for (auto& planeProperty : displayPlaneProperties) {
	planeProperty = {};
	planeProperty.sType = STRUCTURE_TYPE_DISPLAY_PLANE_PROPERTIES_2_KHR;
}

VkResult ret = vkGetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice, &propertyCount, displayPlaneProperties.data());
// Returns success, with 4 properties populated

VkDisplayModePropertiesKHR* preferredDisplayModeProperties = nullptr;


for (auto& planeProperty : displayPlaneProperties) {
	preferredDisplayPlaneProperty = &planeProperty;

	VkDisplayKHR display = planeProperty.displayPlaneProperties.currentDisplay;
	uint32_t displayPropertyCount = 0;

	ret = vkGetDisplayModeProperties2KHR(physicalDevice, display, &displayPropertyCount, nullptr);
	// ^^^ produces validation layer warnings, then seg faults.
				
	std::vector<VkDisplayModeProperties2KHR> displayModeProperties(displayPropertyCount);
	for (auto& displayProperty : displayModeProperties) {
		displayProperty = {};
		displayProperty.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR;
	}

	vkGetDisplayModeProperties2KHR(physicalDevice, display, &displayPropertyCount, displayModeProperties.data());


	for (auto& displayProperty : displayModeProperties) {
		debug_printf(LOGLEVEL_VULKAN, "display mode: refresh rate: %d, region: %d x %d",
			displayProperty.displayModeProperties.parameters.refreshRate,
			displayProperty.displayModeProperties.parameters.visibleRegion.width,
			displayProperty.displayModeProperties.parameters.visibleRegion.height
		);

		preferredDisplayModeProperties = &displayProperty.displayModeProperties;
	}

}

I guess I would expect that any VkDisplayKHR handle returned by the API would be a valid one… but I’m not in a position right now to test with other devices/drivers… perhaps I overlooked something in how this API is intended to operate?

Platform: Linux (Fedora 38)
Vulkan Instance Version: 1.2.135
driverID = DRIVER_ID_NVIDIA_PROPRIETARY
driverName = NVIDIA

Pretty old instance version…

What’s the version of your SDK?

Did you enable all the relevant extensions?

Thanks @krOoze

Serves me right for resurrecting an old project and forgetting to update the SDK (I did so on the other platforms I’m testing, but they don’t utilise this extension… and I guess I just blanked on this one target).

That has done the trick, latest SDK proceeds beyond this issue.
Now I have a different issue :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.