diff options
| -rw-r--r-- | layers/parameter_validation_utils.cpp | 89 | ||||
| -rw-r--r-- | layers/vk_validation_error_database.txt | 6 |
2 files changed, 60 insertions, 35 deletions
diff --git a/layers/parameter_validation_utils.cpp b/layers/parameter_validation_utils.cpp index 40891381..56962654 100644 --- a/layers/parameter_validation_utils.cpp +++ b/layers/parameter_validation_utils.cpp @@ -2266,46 +2266,71 @@ bool pv_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, ui layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); debug_report_data *report_data = device_data->report_data; - if (device_data->physical_device_features.multiViewport == false) { - if (scissorCount != 1) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - DEVICE_FEATURE, LayerName, - "vkCmdSetScissor(): The multiViewport feature is not enabled, so scissorCount must be 1 but is %d.", - scissorCount); - } + if (!device_data->physical_device_features.multiViewport) { if (firstScissor != 0) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - DEVICE_FEATURE, LayerName, - "vkCmdSetScissor(): The multiViewport feature is not enabled, so firstScissor must be 0 but is %d.", - firstScissor); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a2, LayerName, + "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0. %s", + firstScissor, validation_error_map[VALIDATION_ERROR_1d8004a2]); + } + if (scissorCount > 1) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a4, LayerName, + "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1. %s", + scissorCount, validation_error_map[VALIDATION_ERROR_1d8004a4]); + } + } else { // multiViewport enabled + const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount); + if (sum > device_data->device_limits.maxViewports) { + skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a0, LayerName, + "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 + ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "). %s", + firstScissor, scissorCount, sum, device_data->device_limits.maxViewports, + validation_error_map[VALIDATION_ERROR_1d8004a0]); } } - for (uint32_t scissorIndex = 0; scissorIndex < scissorCount; ++scissorIndex) { - const VkRect2D &pScissor = pScissors[scissorIndex]; + if (pScissors) { + for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { + const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr - if (pScissor.offset.x < 0) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.x (%d) must not be negative. %s", - scissorIndex, pScissor.offset.x, validation_error_map[VALIDATION_ERROR_1d8004a6]); - } else if (static_cast<int32_t>(pScissor.extent.width) > (INT_MAX - pScissor.offset.x)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - VALIDATION_ERROR_1d8004a8, LayerName, - "vkCmdSetScissor %d: adding offset.x (%d) and extent.width (%u) will overflow. %s", scissorIndex, - pScissor.offset.x, pScissor.extent.width, validation_error_map[VALIDATION_ERROR_1d8004a8]); - } + if (scissor.offset.x < 0) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a6, LayerName, + "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative. %s", scissor_i, + scissor.offset.x, validation_error_map[VALIDATION_ERROR_1d8004a6]); + } - if (pScissor.offset.y < 0) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.y (%d) must not be negative. %s", - scissorIndex, pScissor.offset.y, validation_error_map[VALIDATION_ERROR_1d8004a6]); - } else if (static_cast<int32_t>(pScissor.extent.height) > (INT_MAX - pScissor.offset.y)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - VALIDATION_ERROR_1d8004aa, LayerName, - "vkCmdSetScissor %d: adding offset.y (%d) and extent.height (%u) will overflow. %s", scissorIndex, - pScissor.offset.y, pScissor.extent.height, validation_error_map[VALIDATION_ERROR_1d8004aa]); + if (scissor.offset.y < 0) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a6, LayerName, + "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative. %s", scissor_i, + scissor.offset.y, validation_error_map[VALIDATION_ERROR_1d8004a6]); + } + + const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); + if (x_sum > INT32_MAX) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a8, LayerName, + "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 + ") of pScissors[%" PRIu32 "] will overflow int32_t. %s", + scissor.offset.x, scissor.extent.width, x_sum, scissor_i, + validation_error_map[VALIDATION_ERROR_1d8004a8]); + } + + const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); + if (y_sum > INT32_MAX) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004aa, LayerName, + "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 + ") of pScissors[%" PRIu32 "] will overflow int32_t. %s", + scissor.offset.y, scissor.extent.height, y_sum, scissor_i, + validation_error_map[VALIDATION_ERROR_1d8004aa]); + } } } + return skip; } diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt index 8cf774a8..2d04a845 100644 --- a/layers/vk_validation_error_database.txt +++ b/layers/vk_validation_error_database.txt @@ -2530,9 +2530,9 @@ VALIDATION_ERROR_1d602413~^~Y~^~None~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidt VALIDATION_ERROR_1d602415~^~Y~^~Unknown~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidth-commandBuffer-cmdpool~^~core~^~The spec valid usage text states 'The VkCommandPool that commandBuffer was allocated from must support graphics operations' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetLineWidth-commandBuffer-cmdpool)~^~implicit VALIDATION_ERROR_1d80049c~^~Y~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-None-00590~^~core~^~The spec valid usage text states 'The currently bound graphics pipeline must have been created with the VK_DYNAMIC_STATE_SCISSOR dynamic state enabled' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-None-00590)~^~ VALIDATION_ERROR_1d80049e~^~N~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-firstScissor-00591~^~core~^~The spec valid usage text states 'firstScissor must be less than VkPhysicalDeviceLimits::maxViewports' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-firstScissor-00591)~^~ -VALIDATION_ERROR_1d8004a0~^~N~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-firstScissor-00592~^~core~^~The spec valid usage text states 'The sum of firstScissor and scissorCount must be between 1 and VkPhysicalDeviceLimits::maxViewports, inclusive' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-firstScissor-00592)~^~ -VALIDATION_ERROR_1d8004a2~^~N~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-firstScissor-00593~^~core~^~The spec valid usage text states 'If the multiple viewports feature is not enabled, firstScissor must be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-firstScissor-00593)~^~ -VALIDATION_ERROR_1d8004a4~^~N~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-scissorCount-00594~^~core~^~The spec valid usage text states 'If the multiple viewports feature is not enabled, scissorCount must be 1' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-scissorCount-00594)~^~ +VALIDATION_ERROR_1d8004a0~^~Y~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-firstScissor-00592~^~core~^~The spec valid usage text states 'The sum of firstScissor and scissorCount must be between 1 and VkPhysicalDeviceLimits::maxViewports, inclusive' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-firstScissor-00592)~^~ +VALIDATION_ERROR_1d8004a2~^~Y~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-firstScissor-00593~^~core~^~The spec valid usage text states 'If the multiple viewports feature is not enabled, firstScissor must be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-firstScissor-00593)~^~ +VALIDATION_ERROR_1d8004a4~^~Y~^~Unknown~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-scissorCount-00594~^~core~^~The spec valid usage text states 'If the multiple viewports feature is not enabled, scissorCount must be 1' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-scissorCount-00594)~^~ VALIDATION_ERROR_1d8004a6~^~Y~^~ScissorBoundsChecking~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-x-00595~^~core~^~The spec valid usage text states 'The x and y members of offset must be greater than or equal to 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-x-00595)~^~ VALIDATION_ERROR_1d8004a8~^~Y~^~ScissorBoundsChecking~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-offset-00596~^~core~^~The spec valid usage text states 'Evaluation of (offset.x + extent.width) must not cause a signed integer addition overflow' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-offset-00596)~^~ VALIDATION_ERROR_1d8004aa~^~Y~^~ScissorBoundsChecking~^~vkCmdSetScissor~^~VUID-vkCmdSetScissor-offset-00597~^~core~^~The spec valid usage text states 'Evaluation of (offset.y + extent.height) must not cause a signed integer addition overflow' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetScissor-offset-00597)~^~ |
