layers: PR1276, Fix Clang compiler warnings
fixes
- error: using namespace directive in global context in header
- error: comparison of integers of different signs: 'uint32_t'
(aka 'unsigned int') and 'int'
Change-Id: If56d5b9c33f0de813fbb67120650a887eb9368b0
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 9a420b7..b663ce4 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -86,6 +86,10 @@
// 2nd special memory handle used to flag object as unbound from memory
static const VkDeviceMemory MEMORY_UNBOUND = VkDeviceMemory(~((uint64_t)(0)) - 1);
+// A special value of (0xFFFFFFFF, 0xFFFFFFFF) indicates that the surface size will be determined
+// by the extent of a swapchain targeting the surface.
+static const uint32_t kSurfaceSizeFromSwapchain = 0xFFFFFFFFu;
+
struct devExts {
bool wsi_enabled;
bool wsi_display_swapchain_enabled;
@@ -11778,10 +11782,11 @@
// Validate pCreateInfo->imageExtent against
// VkSurfaceCapabilitiesKHR::{current|min|max}ImageExtent:
- if ((capabilities.currentExtent.width == -1) && ((pCreateInfo->imageExtent.width < capabilities.minImageExtent.width) ||
- (pCreateInfo->imageExtent.width > capabilities.maxImageExtent.width) ||
- (pCreateInfo->imageExtent.height < capabilities.minImageExtent.height) ||
- (pCreateInfo->imageExtent.height > capabilities.maxImageExtent.height))) {
+ if ((capabilities.currentExtent.width == kSurfaceSizeFromSwapchain) &&
+ ((pCreateInfo->imageExtent.width < capabilities.minImageExtent.width) ||
+ (pCreateInfo->imageExtent.width > capabilities.maxImageExtent.width) ||
+ (pCreateInfo->imageExtent.height < capabilities.minImageExtent.height) ||
+ (pCreateInfo->imageExtent.height > capabilities.maxImageExtent.height))) {
if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02334, "DS",
"vkCreateSwapchainKHR() called with pCreateInfo->imageExtent = (%d,%d), which is outside the "
@@ -11793,8 +11798,9 @@
validation_error_map[VALIDATION_ERROR_02334]))
return true;
}
- if ((capabilities.currentExtent.width != -1) && ((pCreateInfo->imageExtent.width != capabilities.currentExtent.width) ||
- (pCreateInfo->imageExtent.height != capabilities.currentExtent.height))) {
+ if ((capabilities.currentExtent.width != kSurfaceSizeFromSwapchain) &&
+ ((pCreateInfo->imageExtent.width != capabilities.currentExtent.width) ||
+ (pCreateInfo->imageExtent.height != capabilities.currentExtent.height))) {
if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02334, "DS",
"vkCreateSwapchainKHR() called with pCreateInfo->imageExtent = (%d,%d), which is not equal to the "
diff --git a/layers/parameter_validation_utils.h b/layers/parameter_validation_utils.h
index 9e99964..4e4fd81 100644
--- a/layers/parameter_validation_utils.h
+++ b/layers/parameter_validation_utils.h
@@ -95,14 +95,14 @@
const uint32_t ExtEnumBaseValue = 1000000000;
template <typename T> bool is_extension_added_token(T value) {
- return (std::abs(static_cast<int32_t>(value)) >= ExtEnumBaseValue);
+ return (static_cast<uint32_t>(std::abs(static_cast<int32_t>(value))) >= ExtEnumBaseValue);
}
// VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE token is a special case that was converted from a core token to an
// extension added token. Its original value was intentionally preserved after the conversion, so it does not use
// the base value that other extension added tokens use, and it does not fall within the enum's begin/end range.
template <> bool is_extension_added_token(VkSamplerAddressMode value) {
- bool result = (std::abs(static_cast<int32_t>(value)) >= ExtEnumBaseValue);
+ bool result = (static_cast<uint32_t>(std::abs(static_cast<int32_t>(value))) >= ExtEnumBaseValue);
return (result || (value == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE));
}
diff --git a/layers/swapchain.h b/layers/swapchain.h
index e3c67bd..98e84ea 100644
--- a/layers/swapchain.h
+++ b/layers/swapchain.h
@@ -28,8 +28,6 @@
#include <vector>
#include <unordered_map>
-using namespace std;
-
// Swapchain ERROR codes
enum SWAPCHAIN_ERROR {
SWAPCHAIN_INVALID_HANDLE, // Handle used that isn't currently valid
@@ -93,11 +91,11 @@
VkInstance instance;
// Remember the VkSurfaceKHR's that are created for this VkInstance:
- unordered_map<VkSurfaceKHR, SwpSurface *> surfaces;
+ std::unordered_map<VkSurfaceKHR, SwpSurface *> surfaces;
// When vkEnumeratePhysicalDevices is called, the VkPhysicalDevice's are
// remembered:
- unordered_map<const void *, SwpPhysicalDevice *> physicalDevices;
+ std::unordered_map<const void *, SwpPhysicalDevice *> physicalDevices;
// Set to true if VK_KHR_DISPLAY_EXTENSION_NAME was enabled for this VkInstance:
bool displayExtensionEnabled;
@@ -113,7 +111,7 @@
// When vkCreateSwapchainKHR is called, the VkSwapchainKHR's are
// remembered:
- unordered_map<VkSwapchainKHR, SwpSwapchain *> swapchains;
+ std::unordered_map<VkSwapchainKHR, SwpSwapchain *> swapchains;
// Value of pQueueFamilyPropertyCount that was returned by the
// vkGetPhysicalDeviceQueueFamilyProperties() function:
@@ -144,7 +142,7 @@
// Record all surfaces that vkGetPhysicalDeviceSurfaceSupportKHR() was
// called for:
- unordered_map<VkSurfaceKHR, SwpSurface *> supportedSurfaces;
+ std::unordered_map<VkSurfaceKHR, SwpSurface *> supportedSurfaces;
// Count returned by vkGetPhysicalDeviceDisplayPlanePropertiesKHR():
uint32_t displayPlanePropertyCount;
@@ -161,10 +159,10 @@
// When vkCreateSwapchainKHR is called, the VkSwapchainKHR's are
// remembered:
- unordered_map<VkSwapchainKHR, SwpSwapchain *> swapchains;
+ std::unordered_map<VkSwapchainKHR, SwpSwapchain *> swapchains;
// When vkGetDeviceQueue is called, the VkQueue's are remembered:
- unordered_map<VkQueue, SwpQueue *> queues;
+ std::unordered_map<VkQueue, SwpQueue *> queues;
};
// Create one of these for each VkImage within a VkSwapchainKHR:
diff --git a/layers/threading.cpp b/layers/threading.cpp
index 2228d90..252a8c8 100644
--- a/layers/threading.cpp
+++ b/layers/threading.cpp
@@ -183,7 +183,7 @@
};
static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) {
- for (int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) {
+ for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) {
if (!strcmp(name, procmap[i].name))
return procmap[i].pFunc;
}
diff --git a/layers/unique_objects.cpp b/layers/unique_objects.cpp
index b8564f3..d4aabdf 100644
--- a/layers/unique_objects.cpp
+++ b/layers/unique_objects.cpp
@@ -260,7 +260,7 @@
"Google Validation Layer"};
static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) {
- for (int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) {
+ for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) {
if (!strcmp(name, procmap[i].name))
return procmap[i].pFunc;
}