Use explicit ctor, remove unreachable code, and make functions const

This commit is contained in:
Hanif Bin Ariffin 2020-06-03 10:35:29 -04:00
parent 4818f85916
commit 050ccf469e

View file

@ -53,14 +53,14 @@ namespace vks
} queueFamilyIndices; } queueFamilyIndices;
/** @brief Typecast to VkDevice */ /** @brief Typecast to VkDevice */
operator VkDevice() { return logicalDevice; }; operator VkDevice() const { return logicalDevice; };
/** /**
* Default constructor * Default constructor
* *
* @param physicalDevice Physical device that is to be used * @param physicalDevice Physical device that is to be used
*/ */
VulkanDevice(VkPhysicalDevice physicalDevice) explicit VulkanDevice(VkPhysicalDevice physicalDevice)
{ {
assert(physicalDevice); assert(physicalDevice);
this->physicalDevice = physicalDevice; this->physicalDevice = physicalDevice;
@ -123,7 +123,7 @@ namespace vks
* *
* @throw Throws an exception if memTypeFound is null and no memory type could be found that supports the requested properties * @throw Throws an exception if memTypeFound is null and no memory type could be found that supports the requested properties
*/ */
uint32_t getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound = nullptr) uint32_t getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound = nullptr) const
{ {
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++)
{ {
@ -161,7 +161,7 @@ namespace vks
* *
* @throw Throws an exception if no queue family index could be found that supports the requested flags * @throw Throws an exception if no queue family index could be found that supports the requested flags
*/ */
uint32_t getQueueFamilyIndex(VkQueueFlagBits queueFlags) uint32_t getQueueFamilyIndex(VkQueueFlagBits queueFlags) const
{ {
// Dedicated queue for compute // Dedicated queue for compute
// Try to find a queue family index that supports compute but not graphics // Try to find a queue family index that supports compute but not graphics
@ -172,7 +172,6 @@ namespace vks
if ((queueFamilyProperties[i].queueFlags & queueFlags) && ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0)) if ((queueFamilyProperties[i].queueFlags & queueFlags) && ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0))
{ {
return i; return i;
break;
} }
} }
} }
@ -186,7 +185,6 @@ namespace vks
if ((queueFamilyProperties[i].queueFlags & queueFlags) && ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0) && ((queueFamilyProperties[i].queueFlags & VK_QUEUE_COMPUTE_BIT) == 0)) if ((queueFamilyProperties[i].queueFlags & queueFlags) && ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0) && ((queueFamilyProperties[i].queueFlags & VK_QUEUE_COMPUTE_BIT) == 0))
{ {
return i; return i;
break;
} }
} }
} }
@ -197,7 +195,6 @@ namespace vks
if (queueFamilyProperties[i].queueFlags & queueFlags) if (queueFamilyProperties[i].queueFlags & queueFlags)
{ {
return i; return i;
break;
} }
} }