aboutsummaryrefslogtreecommitdiff
path: root/layers
diff options
context:
space:
mode:
authorPetr Kraus <petr_kraus@email.cz>2018-01-05 04:05:12 +0100
committerMike Weiblen <mikew@lunarg.com>2018-01-16 11:28:24 -0700
commitbdf7c5add72c664bbc71336f6dc849294d3e456a (patch)
tree648f64960fa87ac17e54e425bbef5d78674212f8 /layers
parent1a333fe9cd67c812a7f00f484f0d7433d7d7e0bb (diff)
downloadusermoji-bdf7c5add72c664bbc71336f6dc849294d3e456a.tar.xz
layers: Make ValidateGreaterThan report vuid etc.
- make ValidateGreaterThan report proper vuid and other log_msg parameters - make ValidateGreaterThanZero to avoid having to convert common 0 literal (for template deduction) - update check and remove redundant ones in core_validation
Diffstat (limited to 'layers')
-rw-r--r--layers/buffer_validation.cpp9
-rw-r--r--layers/core_validation.cpp6
-rw-r--r--layers/parameter_validation.h25
-rw-r--r--layers/parameter_validation_utils.cpp35
-rw-r--r--layers/vk_validation_error_database.txt12
5 files changed, 47 insertions, 40 deletions
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index 112972f0..b2268277 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -709,15 +709,6 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo
VkDeviceSize imageGranularity = GetPhysicalDeviceProperties(device_data)->limits.bufferImageGranularity;
imageGranularity = imageGranularity == 1 ? 0 : imageGranularity;
- // TODO : This is also covering 2918 & 2919. Break out into separate checks
- if ((pCreateInfo->extent.width <= 0) || (pCreateInfo->extent.height <= 0) || (pCreateInfo->extent.depth <= 0)) {
- skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__,
- VALIDATION_ERROR_09e007b8, "Image",
- "CreateImage extent is 0 for at least one required dimension for image: "
- "Width = %d Height = %d Depth = %d. %s",
- pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth,
- validation_error_map[VALIDATION_ERROR_09e007b8]);
- }
// TODO: VALIDATION_ERROR_09e00770 VALIDATION_ERROR_09e00772 VALIDATION_ERROR_09e00776 VALIDATION_ERROR_09e0076e
// All these extent-related VUs should be checked here
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 9b8c9abe..6c58c5e1 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -9703,11 +9703,11 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char *
return true;
}
// Validate pCreateInfo->imageArrayLayers against VkSurfaceCapabilitiesKHR::maxImageArrayLayers:
- if ((pCreateInfo->imageArrayLayers < 1) || (pCreateInfo->imageArrayLayers > capabilities.maxImageArrayLayers)) {
+ if (pCreateInfo->imageArrayLayers > capabilities.maxImageArrayLayers) {
if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_146009f6, "DS",
- "%s called with a non-supported imageArrayLayers (i.e. %d). Minimum value is 1, maximum value is %d. %s",
- func_name, pCreateInfo->imageArrayLayers, capabilities.maxImageArrayLayers,
+ "%s called with a non-supported imageArrayLayers (i.e. %d). Maximum value is %d. %s", func_name,
+ pCreateInfo->imageArrayLayers, capabilities.maxImageArrayLayers,
validation_error_map[VALIDATION_ERROR_146009f6]))
return true;
}
diff --git a/layers/parameter_validation.h b/layers/parameter_validation.h
index ced0810c..e3c5d8f9 100644
--- a/layers/parameter_validation.h
+++ b/layers/parameter_validation.h
@@ -143,6 +143,14 @@ const uint32_t ExtEnumBaseValue = 1000000000;
// The value of all VK_xxx_MAX_ENUM tokens
const uint32_t MaxEnumValue = 0x7FFFFFFF;
+// Misc parameters of log_msg that are likely constant per command (or low frequency change)
+struct LogMiscParams {
+ const debug_report_data *debug_data;
+ VkDebugReportObjectTypeEXT objectType;
+ uint64_t srcObject;
+ const char *pLayerPrefix;
+ const char *api_name;
+};
/**
* Validate a minimum value.
@@ -157,21 +165,26 @@ const uint32_t MaxEnumValue = 0x7FFFFFFF;
* @return Boolean value indicating that the call should be skipped.
*/
template <typename T>
-bool ValidateGreaterThan(debug_report_data *report_data, const char *api_name, const ParameterName &parameter_name, T value,
- T lower_bound) {
+bool ValidateGreaterThan(const T value, const T lower_bound, const ParameterName &parameter_name,
+ const UNIQUE_VALIDATION_ERROR_CODE vuid, const LogMiscParams &misc) {
bool skip_call = false;
if (value <= lower_bound) {
std::ostringstream ss;
- ss << api_name << ": parameter " << parameter_name.get_name() << " is " << value << " but must be greater than "
- << lower_bound;
- skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
- LayerName, "%s", ss.str().c_str());
+ ss << misc.api_name << ": parameter " << parameter_name.get_name() << " (= " << value << ") is greater than " << lower_bound
+ << ". " << validation_error_map[vuid];
+ skip_call |= log_msg(misc.debug_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, misc.objectType, misc.srcObject, __LINE__, vuid,
+ misc.pLayerPrefix, "%s", ss.str().c_str());
}
return skip_call;
}
+template <typename T>
+bool ValidateGreaterThanZero(const T value, const ParameterName &parameter_name, const UNIQUE_VALIDATION_ERROR_CODE vuid,
+ const LogMiscParams &misc) {
+ return ValidateGreaterThan(value, T{0}, parameter_name, vuid, misc);
+}
/**
* Validate a required pointer.
*
diff --git a/layers/parameter_validation_utils.cpp b/layers/parameter_validation_utils.cpp
index 4f446ad0..694a3f92 100644
--- a/layers/parameter_validation_utils.cpp
+++ b/layers/parameter_validation_utils.cpp
@@ -643,10 +643,10 @@ bool pv_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, c
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
debug_report_data *report_data = device_data->report_data;
+ const LogMiscParams log_misc{report_data, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, VK_NULL_HANDLE, LayerName, "vkCreateBuffer"};
+
if (pCreateInfo != nullptr) {
- // Buffer size must be greater than 0 (error 00663)
- skip |=
- ValidateGreaterThan(report_data, "vkCreateBuffer", "pCreateInfo->size", pCreateInfo->size, static_cast<VkDeviceSize>(0));
+ skip |= ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", VALIDATION_ERROR_01400720, log_misc);
// Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
@@ -697,6 +697,8 @@ bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, con
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
debug_report_data *report_data = device_data->report_data;
+ const LogMiscParams log_misc{report_data, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, VK_NULL_HANDLE, LayerName, "vkCreateImage"};
+
if (pCreateInfo != nullptr) {
if ((device_data->physical_device_features.textureCompressionETC2 == false) &&
FormatIsCompressed_ETC2_EAC(pCreateInfo->format)) {
@@ -753,16 +755,15 @@ bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, con
}
}
- // width, height, and depth members of extent must be greater than 0
- skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.width", pCreateInfo->extent.width, 0u);
- skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.height", pCreateInfo->extent.height, 0u);
- skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.depth", pCreateInfo->extent.depth, 0u);
-
- // mipLevels must be greater than 0
- skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->mipLevels", pCreateInfo->mipLevels, 0u);
+ skip |=
+ ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", VALIDATION_ERROR_09e00760, log_misc);
+ skip |=
+ ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", VALIDATION_ERROR_09e00762, log_misc);
+ skip |=
+ ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", VALIDATION_ERROR_09e00764, log_misc);
- // arrayLayers must be greater than 0
- skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->arrayLayers", pCreateInfo->arrayLayers, 0u);
+ skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", VALIDATION_ERROR_09e00766, log_misc);
+ skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", VALIDATION_ERROR_09e00768, log_misc);
// If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && (pCreateInfo->extent.height != 1) && (pCreateInfo->extent.depth != 1)) {
@@ -797,7 +798,7 @@ bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, con
// mipLevels must be less than or equal to floor(log2(max(extent.width,extent.height,extent.depth)))+1
uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
- if (pCreateInfo->mipLevels > (floor(log2(maxDim)) + 1)) {
+ if (maxDim > 0 && pCreateInfo->mipLevels > (floor(log2(maxDim)) + 1)) {
skip |=
log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
VALIDATION_ERROR_09e0077c, LayerName,
@@ -2359,6 +2360,9 @@ bool pv_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pC
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
debug_report_data *report_data = device_data->report_data;
+ const LogMiscParams log_misc{report_data, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, VK_NULL_HANDLE, LayerName,
+ "vkCreateSwapchainKHR"};
+
if (pCreateInfo != nullptr) {
if ((device_data->physical_device_features.textureCompressionETC2 == false) &&
FormatIsCompressed_ETC2_EAC(pCreateInfo->imageFormat)) {
@@ -2416,9 +2420,8 @@ bool pv_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pC
}
}
- // imageArrayLayers must be greater than 0
- skip |= ValidateGreaterThan(report_data, "vkCreateSwapchainKHR", "pCreateInfo->imageArrayLayers",
- pCreateInfo->imageArrayLayers, 0u);
+ skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", VALIDATION_ERROR_146009f6,
+ log_misc);
}
return skip;
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index c0b82b50..4f824b3f 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -129,7 +129,7 @@ VALIDATION_ERROR_0121c40d~^~Y~^~Unknown~^~vkQueueBindSparse~^~VUID-VkBindSparseI
VALIDATION_ERROR_01223401~^~Y~^~Unknown~^~vkQueueBindSparse~^~VUID-VkBindSparseInfo-pSignalSemaphores-parameter~^~core~^~The spec valid usage text states 'If signalSemaphoreCount is not 0, pSignalSemaphores must be a valid pointer to an array of signalSemaphoreCount valid VkSemaphore handles' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBindSparseInfo-pSignalSemaphores-parameter)~^~implicit
VALIDATION_ERROR_01227601~^~Y~^~Unknown~^~vkQueueBindSparse~^~VUID-VkBindSparseInfo-pWaitSemaphores-parameter~^~core~^~The spec valid usage text states 'If waitSemaphoreCount is not 0, pWaitSemaphores must be a valid pointer to an array of waitSemaphoreCount valid VkSemaphore handles' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBindSparseInfo-pWaitSemaphores-parameter)~^~implicit
VALIDATION_ERROR_0122b00b~^~N~^~Unknown~^~vkQueueBindSparse~^~VUID-VkBindSparseInfo-sType-sType~^~core~^~The spec valid usage text states 'sType must be VK_STRUCTURE_TYPE_BIND_SPARSE_INFO' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBindSparseInfo-sType-sType)~^~implicit, TBD in parameter validation layer.
-VALIDATION_ERROR_01400720~^~N~^~None~^~vkCreateBuffer~^~VUID-VkBufferCreateInfo-size-00912~^~core~^~The spec valid usage text states 'size must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBufferCreateInfo-size-00912)~^~
+VALIDATION_ERROR_01400720~^~Y~^~None~^~vkCreateBuffer~^~VUID-VkBufferCreateInfo-size-00912~^~core~^~The spec valid usage text states 'size must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBufferCreateInfo-size-00912)~^~
VALIDATION_ERROR_01400722~^~Y~^~None~^~vkCreateBuffer~^~VUID-VkBufferCreateInfo-sharingMode-00913~^~core~^~The spec valid usage text states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a valid pointer to an array of queueFamilyIndexCount uint32_t values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBufferCreateInfo-sharingMode-00913)~^~
VALIDATION_ERROR_01400724~^~Y~^~None~^~vkCreateBuffer~^~VUID-VkBufferCreateInfo-sharingMode-00914~^~core~^~The spec valid usage text states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBufferCreateInfo-sharingMode-00914)~^~
VALIDATION_ERROR_01400726~^~Y~^~None~^~vkCreateBuffer~^~VUID-VkBufferCreateInfo-flags-00915~^~core~^~The spec valid usage text states 'If the sparse bindings feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBufferCreateInfo-flags-00915)~^~
@@ -693,11 +693,11 @@ VALIDATION_ERROR_09e00758~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo
VALIDATION_ERROR_09e0075a~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-sharingMode-00941~^~core~^~The spec valid usage text states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a valid pointer to an array of queueFamilyIndexCount uint32_t values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-sharingMode-00941)~^~
VALIDATION_ERROR_09e0075c~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-sharingMode-00942~^~core~^~The spec valid usage text states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-sharingMode-00942)~^~
VALIDATION_ERROR_09e0075e~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-format-00943~^~core~^~The spec valid usage text states 'format must not be VK_FORMAT_UNDEFINED' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-format-00943)~^~
-VALIDATION_ERROR_09e00760~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-extent-00944~^~core~^~The spec valid usage text states 'extent::width must be greater than 0.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-extent-00944)~^~
-VALIDATION_ERROR_09e00762~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-extent-00945~^~core~^~The spec valid usage text states 'extent::height must be greater than 0.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-extent-00945)~^~
-VALIDATION_ERROR_09e00764~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-extent-00946~^~core~^~The spec valid usage text states 'extent::depth must be greater than 0.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-extent-00946)~^~
-VALIDATION_ERROR_09e00766~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-mipLevels-00947~^~core~^~The spec valid usage text states 'mipLevels must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-mipLevels-00947)~^~
-VALIDATION_ERROR_09e00768~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-arrayLayers-00948~^~core~^~The spec valid usage text states 'arrayLayers must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-arrayLayers-00948)~^~
+VALIDATION_ERROR_09e00760~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-extent-00944~^~core~^~The spec valid usage text states 'extent::width must be greater than 0.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-extent-00944)~^~
+VALIDATION_ERROR_09e00762~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-extent-00945~^~core~^~The spec valid usage text states 'extent::height must be greater than 0.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-extent-00945)~^~
+VALIDATION_ERROR_09e00764~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-extent-00946~^~core~^~The spec valid usage text states 'extent::depth must be greater than 0.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-extent-00946)~^~
+VALIDATION_ERROR_09e00766~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-mipLevels-00947~^~core~^~The spec valid usage text states 'mipLevels must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-mipLevels-00947)~^~
+VALIDATION_ERROR_09e00768~^~Y~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-arrayLayers-00948~^~core~^~The spec valid usage text states 'arrayLayers must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-arrayLayers-00948)~^~
VALIDATION_ERROR_09e0076a~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-flags-00949~^~core~^~The spec valid usage text states 'If flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, imageType must be VK_IMAGE_TYPE_2D' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-flags-00949)~^~
VALIDATION_ERROR_09e0076c~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-flags-00950~^~(VK_KHR_maintenance1)~^~The spec valid usage text states 'If flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR, imageType must be VK_IMAGE_TYPE_3D' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkImageCreateInfo-flags-00950)~^~
VALIDATION_ERROR_09e0076e~^~N~^~Unknown~^~vkCreateImage~^~VUID-VkImageCreateInfo-imageType-00951~^~core~^~The spec valid usage text states 'If imageType is VK_IMAGE_TYPE_1D, extent.width must be less than or equal to VkPhysicalDeviceLimits::maxImageDimension1D, or VkImageFormatProperties::maxExtent.width (as returned by vkGetPhysicalDeviceImageFormatProperties with format, imageType, tiling, usage, and flags equal to those in this structure) - whichever is higher' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-imageType-00951)~^~