Added function InitVulkanFeatures - better code for enabling Vulkan device features.
This commit is contained in:
parent
4b360aa9a8
commit
eaa10d11fa
1 changed files with 24 additions and 8 deletions
|
@ -328,6 +328,24 @@ static bool IsLayerSupported(const VkLayerProperties* pProps, size_t propCount,
|
||||||
|
|
||||||
static const size_t FIRST_PARAM_INDEX = 4;
|
static const size_t FIRST_PARAM_INDEX = 4;
|
||||||
|
|
||||||
|
static void InitVulkanFeatures(
|
||||||
|
VkPhysicalDeviceFeatures& outFeatures,
|
||||||
|
const VkPhysicalDeviceFeatures& supportedFeatures)
|
||||||
|
{
|
||||||
|
ZeroMemory(&outFeatures, sizeof(outFeatures));
|
||||||
|
|
||||||
|
// Enable something what may interact with memory/buffer/image support.
|
||||||
|
|
||||||
|
outFeatures.fullDrawIndexUint32 = supportedFeatures.fullDrawIndexUint32;
|
||||||
|
outFeatures.imageCubeArray = supportedFeatures.imageCubeArray;
|
||||||
|
outFeatures.geometryShader = supportedFeatures.geometryShader;
|
||||||
|
outFeatures.tessellationShader = supportedFeatures.tessellationShader;
|
||||||
|
outFeatures.multiDrawIndirect = supportedFeatures.multiDrawIndirect;
|
||||||
|
outFeatures.textureCompressionETC2 = supportedFeatures.textureCompressionETC2;
|
||||||
|
outFeatures.textureCompressionASTC_LDR = supportedFeatures.textureCompressionASTC_LDR;
|
||||||
|
outFeatures.textureCompressionBC = supportedFeatures.textureCompressionBC;
|
||||||
|
}
|
||||||
|
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -785,6 +803,9 @@ int Player::InitVulkan()
|
||||||
return RESULT_ERROR_VULKAN;
|
return RESULT_ERROR_VULKAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkPhysicalDeviceFeatures supportedFeatures;
|
||||||
|
vkGetPhysicalDeviceFeatures(m_PhysicalDevice, &supportedFeatures);
|
||||||
|
|
||||||
// Create logical device
|
// Create logical device
|
||||||
|
|
||||||
const float queuePriority = 1.f;
|
const float queuePriority = 1.f;
|
||||||
|
@ -795,13 +816,8 @@ int Player::InitVulkan()
|
||||||
deviceQueueCreateInfo.pQueuePriorities = &queuePriority;
|
deviceQueueCreateInfo.pQueuePriorities = &queuePriority;
|
||||||
|
|
||||||
// Enable something what may interact with memory/buffer/image support.
|
// Enable something what may interact with memory/buffer/image support.
|
||||||
VkPhysicalDeviceFeatures deviceFeatures = {};
|
VkPhysicalDeviceFeatures enabledFeatures;
|
||||||
deviceFeatures.fullDrawIndexUint32 = VK_TRUE;
|
InitVulkanFeatures(enabledFeatures, supportedFeatures);
|
||||||
deviceFeatures.imageCubeArray = VK_TRUE;
|
|
||||||
deviceFeatures.geometryShader = VK_TRUE;
|
|
||||||
deviceFeatures.tessellationShader = VK_TRUE;
|
|
||||||
deviceFeatures.multiDrawIndirect = VK_TRUE;
|
|
||||||
deviceFeatures.textureCompressionBC = VK_TRUE;
|
|
||||||
|
|
||||||
// Determine list of device extensions to enable.
|
// Determine list of device extensions to enable.
|
||||||
std::vector<const char*> enabledDeviceExtensions;
|
std::vector<const char*> enabledDeviceExtensions;
|
||||||
|
@ -838,7 +854,7 @@ int Player::InitVulkan()
|
||||||
deviceCreateInfo.ppEnabledExtensionNames = !enabledDeviceExtensions.empty() ? enabledDeviceExtensions.data() : nullptr;
|
deviceCreateInfo.ppEnabledExtensionNames = !enabledDeviceExtensions.empty() ? enabledDeviceExtensions.data() : nullptr;
|
||||||
deviceCreateInfo.queueCreateInfoCount = 1;
|
deviceCreateInfo.queueCreateInfoCount = 1;
|
||||||
deviceCreateInfo.pQueueCreateInfos = &deviceQueueCreateInfo;
|
deviceCreateInfo.pQueueCreateInfos = &deviceQueueCreateInfo;
|
||||||
deviceCreateInfo.pEnabledFeatures = &deviceFeatures;
|
deviceCreateInfo.pEnabledFeatures = &enabledFeatures;
|
||||||
|
|
||||||
res = vkCreateDevice(m_PhysicalDevice, &deviceCreateInfo, nullptr, &m_Device);
|
res = vkCreateDevice(m_PhysicalDevice, &deviceCreateInfo, nullptr, &m_Device);
|
||||||
if(res != VK_SUCCESS)
|
if(res != VK_SUCCESS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue