Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions icd/generated-vksc/function_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1579,26 +1579,38 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPh
*pPropertyCount = 1;
} else {
unique_lock_t lock(global_lock);
*pPropertyCount = 1;
pProperties[0].display = (VkDisplayKHR)global_unique_handle++;
pProperties[0].displayName = "Vulkan Mock Display";
display_map[physicalDevice].insert(pProperties[0].display);
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
VkDisplayPlanePropertiesKHR* pProperties) {
// Not a CREATE or DESTROY function
*pPropertyCount = 1;
if (pProperties) {
pProperties[0].currentDisplay = VK_NULL_HANDLE;
pProperties[0].currentStackIndex = 0;
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
uint32_t* pDisplayCount, VkDisplayKHR* pDisplays) {
// Not a CREATE or DESTROY function
*pDisplayCount = 1;
if (pDisplays) {
pDisplays[0] = {};
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
uint32_t* pPropertyCount,
VkDisplayModePropertiesKHR* pProperties) {
// Not a CREATE or DESTROY function
*pPropertyCount = 1;
if (pProperties) {
pProperties[0] = {};
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
Expand Down Expand Up @@ -1728,12 +1740,17 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormats2KHR(VkPhys
pSurfaceFormats[1].surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
if (*pSurfaceFormatCount >= 1) {
pSurfaceFormats[1].pNext = nullptr;
pSurfaceFormats[0].pNext = nullptr;
pSurfaceFormats[0].surfaceFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
pSurfaceFormats[0].surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
}
return VK_SUCCESS;
if (*pSurfaceFormatCount >= 2) {
*pSurfaceFormatCount = 2;
return VK_SUCCESS;
} else {
return VK_INCOMPLETE;
}
}
static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
Expand Down
27 changes: 22 additions & 5 deletions icd/generated/function_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1549,26 +1549,38 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPh
*pPropertyCount = 1;
} else {
unique_lock_t lock(global_lock);
*pPropertyCount = 1;
pProperties[0].display = (VkDisplayKHR)global_unique_handle++;
pProperties[0].displayName = "Vulkan Mock Display";
display_map[physicalDevice].insert(pProperties[0].display);
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
VkDisplayPlanePropertiesKHR* pProperties) {
// Not a CREATE or DESTROY function
*pPropertyCount = 1;
if (pProperties) {
pProperties[0].currentDisplay = VK_NULL_HANDLE;
pProperties[0].currentStackIndex = 0;
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
uint32_t* pDisplayCount, VkDisplayKHR* pDisplays) {
// Not a CREATE or DESTROY function
*pDisplayCount = 1;
if (pDisplays) {
pDisplays[0] = {};
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
uint32_t* pPropertyCount,
VkDisplayModePropertiesKHR* pProperties) {
// Not a CREATE or DESTROY function
*pPropertyCount = 1;
if (pProperties) {
pProperties[0] = {};
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
Expand Down Expand Up @@ -2282,12 +2294,17 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormats2KHR(VkPhys
pSurfaceFormats[1].surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
if (*pSurfaceFormatCount >= 1) {
pSurfaceFormats[1].pNext = nullptr;
pSurfaceFormats[0].pNext = nullptr;
pSurfaceFormats[0].surfaceFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
pSurfaceFormats[0].surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
}
return VK_SUCCESS;
if (*pSurfaceFormatCount >= 2) {
*pSurfaceFormatCount = 2;
return VK_SUCCESS;
} else {
return VK_INCOMPLETE;
}
}
static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
Expand Down
33 changes: 31 additions & 2 deletions scripts/generators/mock_icd_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,17 @@
pSurfaceFormats[1].surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
if (*pSurfaceFormatCount >= 1) {
pSurfaceFormats[1].pNext = nullptr;
pSurfaceFormats[0].pNext = nullptr;
pSurfaceFormats[0].surfaceFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
pSurfaceFormats[0].surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
}
return VK_SUCCESS;
if (*pSurfaceFormatCount >= 2) {
*pSurfaceFormatCount = 2;
return VK_SUCCESS;
} else {
return VK_INCOMPLETE;
}
''',
'vkGetPhysicalDeviceSurfaceSupportKHR': '''
// Currently say that all surface/queue combos are supported
Expand Down Expand Up @@ -1162,11 +1167,35 @@
*pPropertyCount = 1;
} else {
unique_lock_t lock(global_lock);
*pPropertyCount = 1;
pProperties[0].display = (VkDisplayKHR)global_unique_handle++;
pProperties[0].displayName = "Vulkan Mock Display";
display_map[physicalDevice].insert(pProperties[0].display);
}
return VK_SUCCESS;
''',
'vkGetPhysicalDeviceDisplayPlanePropertiesKHR': '''
*pPropertyCount = 1;
if (pProperties) {
pProperties[0].currentDisplay = VK_NULL_HANDLE;
pProperties[0].currentStackIndex = 0;
}
return VK_SUCCESS;
''',
'vkGetDisplayPlaneSupportedDisplaysKHR': '''
*pDisplayCount = 1;
if (pDisplays) {
pDisplays[0] = {};
}
return VK_SUCCESS;
''',
'vkGetDisplayModePropertiesKHR': '''
*pPropertyCount = 1;
if (pProperties) {
pProperties[0] = {};
}
return VK_SUCCESS;
''',
'vkRegisterDisplayEventEXT': '''
unique_lock_t lock(global_lock);
*pFence = (VkFence)global_unique_handle++;
Expand Down
2 changes: 1 addition & 1 deletion vulkaninfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ target_include_directories(vulkaninfo PRIVATE
)

target_compile_definitions(vulkaninfo PRIVATE VK_ENABLE_BETA_EXTENSIONS VK_NO_PROTOTYPES)
target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_DISPLAY_KHR)

if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU|QNX")
if(VULKANSC)
Expand Down Expand Up @@ -109,7 +110,6 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU|QNX")
if(BUILD_WSI_SCI_SUPPORT)
target_compile_definitions(vulkaninfo INTERFACE VK_USE_PLATFORM_SCI)
endif()
target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_DISPLAY)
endif()

if(APPLE)
Expand Down
64 changes: 55 additions & 9 deletions vulkaninfo/vulkaninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ AppDisplayMode::AppDisplayMode(AppGpu &gpu, const VkDisplayModePropertiesKHR &in

static std::string MakeName(uint32_t index, const VkDisplayPropertiesKHR &prop) {
std::stringstream name;
name << "Display id : " << index << " (" << prop.displayName << ")";
name << "Display id : " << index << " (" << (prop.displayName ? prop.displayName : "<null>") << ")";
return name.str();
}

Expand Down Expand Up @@ -1550,23 +1550,58 @@ int main(int argc, char **argv) {

#if defined(VULKANINFO_WSI_ENABLED)
for (auto &surface_extension : instance.surface_extensions) {
surface_extension.create_window(instance);
surface_extension.surface = surface_extension.create_surface(instance);
// If the surface extension has a create_window function then call it to create the single shared window
if (surface_extension.create_window) {
try {
surface_extension.create_window(instance);
} catch (std::exception &e) {
std::cerr << "ERROR while creating window for surface extension " << surface_extension.name << " : " << e.what()
<< "\n";
continue;
}
}

// If the surface extension has a create_surface function then call it to create the single shared surface
if (surface_extension.create_surface) {
try {
surface_extension.surface = surface_extension.create_surface(instance);
} catch (std::exception &e) {
std::cerr << "ERROR while creating surface for extension " << surface_extension.name << " : " << e.what()
<< "\n";
}
}
}
#endif // defined(VULKANINFO_WSI_ENABLED)

std::vector<std::unique_ptr<AppGpu>> gpus;

uint32_t gpu_counter = 0;
for (auto &phys_device : phys_devices) {
gpus.push_back(
std::unique_ptr<AppGpu>(new AppGpu(instance, gpu_counter++, phys_device, parse_data.show.promoted_structs)));
// Take a copy of the surface extensions list as some may be per physical device (e.g. VK_KHR_display)
auto surface_extensions = instance.surface_extensions;
#if defined(VULKANINFO_WSI_ENABLED)
for (auto &surface_extension : surface_extensions) {
// If the surface extension has a create_surface_for_physical_device function then call it to create
// the physical device specific surface
if (surface_extension.create_surface_for_physical_device) {
try {
surface_extension.surface = surface_extension.create_surface_for_physical_device(instance, phys_device);
} catch (std::exception &e) {
std::cerr << "ERROR while creating surface for extension " << surface_extension.name << " : " << e.what()
<< "\n";
}
}
}
#endif // defined(VULKANINFO_WSI_ENABLED)
gpus.push_back(std::unique_ptr<AppGpu>(
new AppGpu(instance, gpu_counter++, phys_device, parse_data.show.promoted_structs, std::move(surface_extensions))));
}

std::vector<std::unique_ptr<AppSurface>> surfaces;
#if defined(VULKANINFO_WSI_ENABLED)
for (auto &surface_extension : instance.surface_extensions) {
for (auto &gpu : gpus) {
for (auto &gpu : gpus) {
for (auto &surface_extension : gpu->surface_extensions) {
if (surface_extension.surface == VK_NULL_HANDLE) continue;
try {
// check if the surface is supported by the physical device before adding it to the list
VkBool32 supported = VK_FALSE;
Expand Down Expand Up @@ -1613,10 +1648,21 @@ int main(int argc, char **argv) {

// Call the printer's destructor before the file handle gets closed
printer.reset(nullptr);

// Clean up the AppSurface objects to destroy the underlying VkSurfaceKHR objects
surfaces.clear();

#if defined(VULKANINFO_WSI_ENABLED)
for (auto &surface_extension : instance.surface_extensions) {
AppDestroySurface(instance, surface_extension.surface);
surface_extension.destroy_window(instance);
// If the surface is shared across physical devices then we have to destroy it here as there's a single shared
// surface for the AppInstance object (contrarily to per physical device surfaces that are maintained by AppSurface)
if (surface_extension.create_surface) {
vkDestroySurfaceKHR(instance.instance, surface_extension.surface, nullptr);
}
// If the surface extension has a destroy_window function then call it to destroy the single shared window
if (surface_extension.destroy_window) {
surface_extension.destroy_window(instance);
}
}
#endif // defined(VULKANINFO_WSI_ENABLED)
} catch (std::exception &e) {
Expand Down
Loading
Loading