aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Madill <jmadill@chromium.org>2016-12-15 09:35:36 -0500
committerMark Lobodzinski <mark@lunarg.com>2016-12-15 11:17:11 -0700
commit225d54a5fedc1ce56703fe0f44b33dd4deb3bbf4 (patch)
tree190972273a56a849f510a5812caac017706082d2
parent8b896c16e3013b5a5130d9b5e8a80dfe4e5c3c9c (diff)
downloadusermoji-225d54a5fedc1ce56703fe0f44b33dd4deb3bbf4.tar.xz
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
-rw-r--r--layers/core_validation.cpp18
-rw-r--r--layers/parameter_validation_utils.h4
-rw-r--r--layers/swapchain.h14
-rw-r--r--layers/threading.cpp2
-rw-r--r--layers/unique_objects.cpp2
5 files changed, 22 insertions, 18 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 9a420b7f..b663ce45 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -86,6 +86,10 @@ static const VkDeviceMemory MEMTRACKER_SWAP_CHAIN_IMAGE_KEY = (VkDeviceMemory)(-
// 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 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, VkSwapchainC
// 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 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, VkSwapchainC
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 9e999643..4e4fd812 100644
--- a/layers/parameter_validation_utils.h
+++ b/layers/parameter_validation_utils.h
@@ -95,14 +95,14 @@ const std::string UnsupportedResultString = "Unhandled VkResult";
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 e3c67bd9..98e84ea4 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 @@ struct SwpInstance {
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 @@ struct SwpSurface {
// 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 @@ struct SwpPhysicalDevice {
// 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 @@ struct SwpDevice {
// 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 2228d908..252a8c82 100644
--- a/layers/threading.cpp
+++ b/layers/threading.cpp
@@ -183,7 +183,7 @@ static const VkLayerProperties layerProps = {
};
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 b8564f36..d4aabdfe 100644
--- a/layers/unique_objects.cpp
+++ b/layers/unique_objects.cpp
@@ -260,7 +260,7 @@ static const VkLayerProperties globalLayerProps = {"VK_LAYER_GOOGLE_unique_objec
"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;
}