1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2025-01-20 12:52:15 +01:00
rpi-vk-driver/test/mintest/mintest.cpp
2020-05-18 21:58:34 +01:00

42 lines
1.5 KiB
C++

#include <stdlib.h>
#include <vulkan/vulkan.h>
int main() {
VkInstance instance;
VkSurfaceKHR windowSurface;
VkPhysicalDevice physicalDevice;
const char* enabledExtensions[] = {
"VK_KHR_surface",
"VK_KHR_display",
};
VkInstanceCreateInfo createInfo = {};
createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*);
createInfo.ppEnabledExtensionNames = enabledExtensions;
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
vkCreateInstance(&createInfo, nullptr, &instance);
uint32_t deviceCount = 1;
vkEnumeratePhysicalDevices(instance, &deviceCount, &physicalDevice);
uint32_t displayCount;
vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayCount, 0);
VkDisplayPropertiesKHR* displayProperties = (VkDisplayPropertiesKHR*)malloc(sizeof(VkDisplayPropertiesKHR)*displayCount);
vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayCount, displayProperties);
uint32_t modeCount;
vkGetDisplayModePropertiesKHR(physicalDevice, displayProperties[0].display, &modeCount, 0);
VkDisplayModePropertiesKHR* displayModeProperties = (VkDisplayModePropertiesKHR*)malloc(sizeof(VkDisplayModePropertiesKHR)*modeCount);
vkGetDisplayModePropertiesKHR(physicalDevice, displayProperties[0].display, &modeCount, displayModeProperties);
VkDisplaySurfaceCreateInfoKHR dsci = {};
dsci.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
vkCreateDisplayPlaneSurfaceKHR(instance, &dsci, 0, &windowSurface);
return 0;
}