aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Zulauf <jzulauf@lunarg.com>2018-03-05 10:36:21 -0700
committerjzulauf-lunarg <32470354+jzulauf-lunarg@users.noreply.github.com>2018-03-20 09:59:54 -0600
commit185404f6b76c6538e4a52bf3babfca1739fe94e7 (patch)
tree4249a445e179942927ee9d212920ae0659b992d0
parent4a1795eef9480abad80d3040a33c2ef3fe0da9eb (diff)
downloadusermoji-185404f6b76c6538e4a52bf3babfca1739fe94e7.tar.xz
layers: Update CmdPushConstant Valid Usages
Updated the core validation layer and matching units to reflect changes to the valid usage statements in the Vulkan specification to better support the use of overlapping push constant ranges. The following valid usage was removed from the specification and the core validation layer. VUID-vkCmdPushConstants-stageFlags-00367 VALIDATION_ERROR_1bc002de Two new valid usages have been added to the core validation layer. VALIDATION_ERROR_1bc00e06 VUID-vkCmdPushConstants-offset-01795 VALIDATION_ERROR_1bc00e08 VUID-vkCmdPushConstants-offset-01796 The individual unit tests within the larger InvalidPushConstants test case have been updated to reflect the changes to the valid usage checks. Change-Id: I9bba3efa19f96c52e82b328bee64f8f2fbb10342
-rw-r--r--layers/core_validation.cpp45
-rw-r--r--layers/vk_validation_error_database.txt2
2 files changed, 30 insertions, 17 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 54ddda75..3879ae4f 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -8308,27 +8308,40 @@ VKAPI_ATTR void VKAPI_CALL CmdPushConstants(VkCommandBuffer commandBuffer, VkPip
"vkCmdPushConstants() call has no stageFlags set. %s", validation_error_map[VALIDATION_ERROR_1bc2dc03]);
}
- // Check if specified push constant range falls within a pipeline-defined range which has matching stageFlags.
- // The spec doesn't seem to disallow having multiple push constant ranges with the
- // same offset and size, but different stageFlags. So we can't just check the
- // stageFlags in the first range with matching offset and size.
+ // Check if pipeline_layout VkPushConstantRange(s) overlapping offset, size have stageFlags set for each stage in the command
+ // stageFlags argument, *and* that the command stageFlags argument has bits set for the stageFlags in each overlapping range.
if (!skip) {
const auto &ranges = *getPipelineLayout(dev_data, layout)->push_constant_ranges;
- bool found_matching_range = false;
+ VkShaderStageFlags found_stages = 0;
for (const auto &range : ranges) {
- if ((stageFlags == range.stageFlags) && (offset >= range.offset) && (offset + size <= range.offset + range.size)) {
- found_matching_range = true;
- break;
+ if ((offset >= range.offset) && (offset + size <= range.offset + range.size)) {
+ VkShaderStageFlags matching_stages = range.stageFlags & stageFlags;
+ if (matching_stages != range.stageFlags) {
+ // VALIDATION_ERROR_1bc00e08 VUID-vkCmdPushConstants-offset-01796
+ skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__,
+ VALIDATION_ERROR_1bc00e08, "DS",
+ "vkCmdPushConstants(): stageFlags (0x%" PRIx32 ", offset (%" PRIu32 "), and size (%" PRIu32
+ "), "
+ "must contain all stages in overlapping VkPushConstantRange stageFlags (0x%" PRIx32
+ "), offset (%" PRIu32 "), and size (%" PRIu32 ") in pipeline layout 0x%" PRIx64 ". %s",
+ (uint32_t)stageFlags, offset, size, (uint32_t)range.stageFlags, range.offset, range.size,
+ HandleToUint64(layout), validation_error_map[VALIDATION_ERROR_1bc00e08]);
+ }
+
+ // Accumulate all stages we've found
+ found_stages = matching_stages | found_stages;
}
}
- if (!found_matching_range) {
- skip |= log_msg(
- dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1bc00e08, "DS",
- "vkCmdPushConstants() stageFlags = 0x%" PRIx32
- " do not match the stageFlags in any of the ranges with offset = %d and size = %d in pipeline layout 0x%" PRIx64
- ". %s",
- (uint32_t)stageFlags, offset, size, HandleToUint64(layout), validation_error_map[VALIDATION_ERROR_1bc00e08]);
+ if (found_stages != stageFlags) {
+ // VALIDATION_ERROR_1bc00e06 VUID-vkCmdPushConstants-offset-01795
+ uint32_t missing_stages = ~found_stages & stageFlags;
+ skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
+ HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1bc00e06, "DS",
+ "vkCmdPushConstants(): stageFlags = 0x%" PRIx32 ", VkPushConstantRange in pipeline layout 0x%" PRIx64
+ " overlapping offset = %d and size = %d, do not contain stageFlags 0x%" PRIx32 ". %s",
+ (uint32_t)stageFlags, HandleToUint64(layout), offset, size, missing_stages,
+ validation_error_map[VALIDATION_ERROR_1bc00e06]);
}
}
lock.unlock();
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index 3f3ee2d8..67f9a30e 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -2302,7 +2302,7 @@ VALIDATION_ERROR_1bc002e0~^~Y~^~Unknown~^~vkCmdPushConstants~^~VUID-vkCmdPushCon
VALIDATION_ERROR_1bc002e2~^~Y~^~Unknown~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-size-00369~^~core~^~The spec valid usage text states 'size must be a multiple of 4' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-size-00369)~^~
VALIDATION_ERROR_1bc002e4~^~Y~^~Unknown~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-offset-00370~^~core~^~The spec valid usage text states 'offset must be less than VkPhysicalDeviceLimits::maxPushConstantsSize' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-offset-00370)~^~
VALIDATION_ERROR_1bc002e6~^~Y~^~Unknown~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-size-00371~^~core~^~The spec valid usage text states 'size must be less than or equal to VkPhysicalDeviceLimits::maxPushConstantsSize minus offset' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-size-00371)~^~
-VALIDATION_ERROR_1bc00e06~^~N~^~None~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-offset-01795~^~core~^~The spec valid usage text states 'For each byte in the range specified by offset and size and for each shader stage in stageFlags, there must be a push constant range in layout that includes that byte and that stage' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-offset-01795)~^~
+VALIDATION_ERROR_1bc00e06~^~Y~^~InvalidPushConstants~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-offset-01795~^~core~^~The spec valid usage text states 'For each byte in the range specified by offset and size and for each shader stage in stageFlags, there must be a push constant range in layout that includes that byte and that stage' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-offset-01795)~^~
VALIDATION_ERROR_1bc00e08~^~Y~^~InvalidPushConstants~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-offset-01796~^~core~^~The spec valid usage text states 'For each byte in the range specified by offset and size and for each push constant range that overlaps that byte, stageFlags must include all stages in that push constant range's VkPushConstantRange::stageFlags' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-offset-01796)~^~
VALIDATION_ERROR_1bc02401~^~Y~^~None~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-commandBuffer-parameter~^~core~^~The spec valid usage text states 'commandBuffer must be a valid VkCommandBuffer handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-commandBuffer-parameter)~^~implicit
VALIDATION_ERROR_1bc02413~^~Y~^~None~^~vkCmdPushConstants~^~VUID-vkCmdPushConstants-commandBuffer-recording~^~core~^~The spec valid usage text states 'commandBuffer must be in the recording state' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPushConstants-commandBuffer-recording)~^~implicit