Virtual function for enabling features for the logical device creation (called after physical device features have been read)

This commit is contained in:
saschawillems 2017-03-08 21:29:38 +01:00
parent ab95c2f29a
commit 83806a43c2
2 changed files with 16 additions and 8 deletions

View file

@ -830,6 +830,14 @@ void VulkanExampleBase::initVulkan()
physicalDevice = physicalDevices[selectedDevice]; physicalDevice = physicalDevices[selectedDevice];
// Store properties (including limits), features and memory properties of the phyiscal device (so that examples can check against them)
vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
vkGetPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
// Derived examples can override this to set actual features (based on above readings) to enable for logical device creation
getEnabledFeatures();
// Vulkan device creation // Vulkan device creation
// This is handled by a separate class that gets a logical device representation // This is handled by a separate class that gets a logical device representation
// and encapsulates functions related to a device // and encapsulates functions related to a device
@ -840,14 +848,6 @@ void VulkanExampleBase::initVulkan()
} }
device = vulkanDevice->logicalDevice; device = vulkanDevice->logicalDevice;
// todo: remove
// Store properties (including limits) and features of the phyiscal device
// So examples can check against them and see if a feature is actually supported
vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
vkGetPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
// Gather physical device memory properties
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
// Get a graphics queue from the device // Get a graphics queue from the device
vkGetDeviceQueue(device, vulkanDevice->queueFamilyIndices.graphics, 0, &queue); vkGetDeviceQueue(device, vulkanDevice->queueFamilyIndices.graphics, 0, &queue);
@ -2011,6 +2011,11 @@ void VulkanExampleBase::setupRenderPass()
VK_CHECK_RESULT(vkCreateRenderPass(device, &renderPassInfo, nullptr, &renderPass)); VK_CHECK_RESULT(vkCreateRenderPass(device, &renderPassInfo, nullptr, &renderPass));
} }
void VulkanExampleBase::getEnabledFeatures()
{
// Can be overriden in derived class
}
void VulkanExampleBase::windowResize() void VulkanExampleBase::windowResize()
{ {
if (!prepared) if (!prepared)

View file

@ -333,6 +333,9 @@ public:
// Can be overriden in derived class to setup a custom render pass (e.g. for MSAA) // Can be overriden in derived class to setup a custom render pass (e.g. for MSAA)
virtual void setupRenderPass(); virtual void setupRenderPass();
/** @brief (Virtual) called after the physical device features have been read, used to set features to enable on the device */
virtual void getEnabledFeatures();
// Connect and prepare the swap chain // Connect and prepare the swap chain
void initSwapchain(); void initSwapchain();
// Create swap chain images // Create swap chain images