Fix a few nits

This commit is contained in:
Charles Giessen 2021-08-09 01:05:11 -06:00 committed by Charles Giessen
parent 0408041547
commit 8922a41bd4
2 changed files with 16 additions and 16 deletions

View File

@ -205,7 +205,7 @@ auto get_vector(std::vector<T>& out, F&& f, Ts&&... ts) -> VkResult {
VkResult err; VkResult err;
do { do {
err = f(ts..., &count, nullptr); err = f(ts..., &count, nullptr);
if (err) { if (err != VK_SUCCESS) {
return err; return err;
}; };
out.resize(count); out.resize(count);
@ -229,13 +229,13 @@ auto get_vector_noerror(F&& f, Ts&&... ts) -> std::vector<T> {
const char* to_string_message_severity(VkDebugUtilsMessageSeverityFlagBitsEXT s) { const char* to_string_message_severity(VkDebugUtilsMessageSeverityFlagBitsEXT s) {
switch (s) { switch (s) {
case VkDebugUtilsMessageSeverityFlagBitsEXT::VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT:
return "VERBOSE"; return "VERBOSE";
case VkDebugUtilsMessageSeverityFlagBitsEXT::VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT:
return "ERROR"; return "ERROR";
case VkDebugUtilsMessageSeverityFlagBitsEXT::VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT:
return "WARNING"; return "WARNING";
case VkDebugUtilsMessageSeverityFlagBitsEXT::VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT:
return "INFO"; return "INFO";
default: default:
return "UNKNOWN"; return "UNKNOWN";
@ -1111,7 +1111,7 @@ PhysicalDeviceSelector::Suitable PhysicalDeviceSelector::is_device_suitable(Phys
bool has_required_memory = false; bool has_required_memory = false;
bool has_preferred_memory = false; bool has_preferred_memory = false;
for (uint32_t i = 0; i < pd.mem_properties.memoryHeapCount; i++) { for (uint32_t i = 0; i < pd.mem_properties.memoryHeapCount; i++) {
if (pd.mem_properties.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { if (pd.mem_properties.memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) {
if (pd.mem_properties.memoryHeaps[i].size > criteria.required_mem_size) { if (pd.mem_properties.memoryHeaps[i].size > criteria.required_mem_size) {
has_required_memory = true; has_required_memory = true;
} }
@ -1140,13 +1140,14 @@ detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
#if !defined(NDEBUG) #if !defined(NDEBUG)
// Validation // Validation
for(const auto& node : criteria.extended_features_chain) { for (const auto& node : criteria.extended_features_chain) {
assert(node.sType != 0 && "Features struct sType must be filled with the struct's " assert(node.sType != static_cast<VkStructureType>(0) &&
"corresponding VkStructureType enum"); "Features struct sType must be filled with the struct's "
"corresponding VkStructureType enum");
assert( assert(
node.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 && node.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
"Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An " "Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An "
"instance of this is managed internally for selection criteria and device creation."); "instance of this is managed internally for selection criteria and device creation.");
} }
#endif #endif

View File

@ -121,8 +121,7 @@ struct GenericFeaturesPNextNode {
GenericFeaturesPNextNode(); GenericFeaturesPNextNode();
template <typename T> template <typename T> GenericFeaturesPNextNode(T const& features) noexcept {
GenericFeaturesPNextNode(T const& features) noexcept {
*reinterpret_cast<T*>(this) = features; *reinterpret_cast<T*>(this) = features;
} }
@ -349,7 +348,7 @@ class InstanceBuilder {
// VkInstanceCreateInfo // VkInstanceCreateInfo
std::vector<const char*> layers; std::vector<const char*> layers;
std::vector<const char*> extensions; std::vector<const char*> extensions;
VkInstanceCreateFlags flags = 0; VkInstanceCreateFlags flags = static_cast<VkInstanceCreateFlags>(0);
std::vector<VkBaseOutStructure*> pNext_elements; std::vector<VkBaseOutStructure*> pNext_elements;
// debug callback - use the default so it is not nullptr // debug callback - use the default so it is not nullptr
@ -640,7 +639,7 @@ class DeviceBuilder {
private: private:
PhysicalDevice physical_device; PhysicalDevice physical_device;
struct DeviceInfo { struct DeviceInfo {
VkDeviceCreateFlags flags = 0; VkDeviceCreateFlags flags = static_cast<VkDeviceCreateFlags>(0);
std::vector<VkBaseOutStructure*> pNext_chain; std::vector<VkBaseOutStructure*> pNext_chain;
std::vector<CustomQueueDescription> queue_descriptions; std::vector<CustomQueueDescription> queue_descriptions;
VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE; VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE;