// OS specific macros for the example main entry points // Most of the code base is shared for the different supported operating systems, but stuff like message handling differs
// Windows entry point VulkanExample* vulkanExample; LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (vulkanExample != NULL) { vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam); } return (DefWindowProc(hWnd, uMsg, wParam, lParam)); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) { for (size_t i = 0; i < __argc; i++) { VulkanExample::args.push_back(__argv[i]); }; vulkanExample = newVulkanExample(); vulkanExample->initVulkan(); vulkanExample->setupWindow(hInstance, WndProc); vulkanExample->prepare(); vulkanExample->renderLoop(); delete(vulkanExample); return0; }
* Default constructor * * @param physicalDevice Physical device that is to be used */ VulkanDevice::VulkanDevice(VkPhysicalDevice physicalDevice) { assert(physicalDevice); this->physicalDevice = physicalDevice;
// Store Properties features, limits and properties of the physical device for later use // Device properties also contain limits and sparse properties vkGetPhysicalDeviceProperties(physicalDevice, &properties); // Features should be checked by the examples before using them vkGetPhysicalDeviceFeatures(physicalDevice, &features); // Memory properties are used regularly for creating all kinds of buffers vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memoryProperties); // Queue family properties, used for setting up requested queues upon device creation uint32_t queueFamilyCount; vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, nullptr); assert(queueFamilyCount > 0); queueFamilyProperties.resize(queueFamilyCount); vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueFamilyProperties.data());
// Get list of supported extensions uint32_t extCount = 0; vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extCount, nullptr); if (extCount > 0) { std::vector<VkExtensionProperties> extensions(extCount); if (vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extCount, &extensions.front()) == VK_SUCCESS) { for (auto ext : extensions) { supportedExtensions.push_back(ext.extensionName); } } } }