layers: Fix lineWidth checks
- migrate to parameter_validatio
- do not check against limit (outside limits is valid; impl clamps
value)
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 0070bcf..c3431c6 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -1234,34 +1234,6 @@
}
}
-// Validate HW line width capabilities prior to setting requested line width.
-static bool verifyLineWidth(layer_data *dev_data, DRAW_STATE_ERROR dsError, VulkanObjectType object_type, const uint64_t &target,
- float lineWidth) {
- bool skip = false;
-
- // First check to see if the physical device supports wide lines.
- if ((VK_FALSE == dev_data->enabled_features.wideLines) && (1.0f != lineWidth)) {
- skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], target, __LINE__,
- dsError, "DS",
- "Attempt to set lineWidth to %f but physical device wideLines feature "
- "not supported/enabled so lineWidth must be 1.0f!",
- lineWidth);
- } else {
- // Otherwise, make sure the width falls in the valid range.
- if ((dev_data->phys_dev_properties.properties.limits.lineWidthRange[0] > lineWidth) ||
- (dev_data->phys_dev_properties.properties.limits.lineWidthRange[1] < lineWidth)) {
- skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], target,
- __LINE__, dsError, "DS",
- "Attempt to set lineWidth to %f but physical device limits line width "
- "to between [%f, %f]!",
- lineWidth, dev_data->phys_dev_properties.properties.limits.lineWidthRange[0],
- dev_data->phys_dev_properties.properties.limits.lineWidthRange[1]);
- }
- }
-
- return skip;
-}
-
static bool ValidatePipelineLocked(layer_data *dev_data, std::vector<std::unique_ptr<PIPELINE_STATE>> const &pPipelines, int pipelineIndex) {
bool skip = false;
@@ -1432,13 +1404,6 @@
// If a rasterization state is provided...
if (pPipeline->graphicsPipelineCI.pRasterizationState) {
- // Make sure that the line width conforms to the HW.
- if (!isDynamic(pPipeline, VK_DYNAMIC_STATE_LINE_WIDTH)) {
- skip |=
- verifyLineWidth(dev_data, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, kVulkanObjectTypePipeline,
- HandleToUint64(pPipeline->pipeline), pPipeline->graphicsPipelineCI.pRasterizationState->lineWidth);
- }
-
if ((pPipeline->graphicsPipelineCI.pRasterizationState->depthClampEnable == VK_TRUE) &&
(!dev_data->enabled_features.depthClamp)) {
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
@@ -5354,9 +5319,6 @@
"vkCmdSetLineWidth called but pipeline was created without VK_DYNAMIC_STATE_LINE_WIDTH "
"flag. %s",
validation_error_map[VALIDATION_ERROR_1d600626]);
- } else {
- skip |= verifyLineWidth(dev_data, DRAWSTATE_INVALID_SET, kVulkanObjectTypeCommandBuffer, HandleToUint64(commandBuffer),
- lineWidth);
}
if (!skip) {
pCB->status |= CBSTATUS_LINE_WIDTH_SET;
diff --git a/layers/parameter_validation_utils.cpp b/layers/parameter_validation_utils.cpp
index 1975299..c689680 100644
--- a/layers/parameter_validation_utils.cpp
+++ b/layers/parameter_validation_utils.cpp
@@ -912,6 +912,19 @@
if (pCreateInfos != nullptr) {
for (uint32_t i = 0; i < createInfoCount; ++i) {
+ bool has_dynamic_viewport = false;
+ bool has_dynamic_scissor = false;
+ bool has_dynamic_line_width = false;
+ if (pCreateInfos[i].pDynamicState != nullptr) {
+ const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
+ for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
+ const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
+ if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true;
+ if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true;
+ if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true;
+ }
+ }
+
// Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
if (pCreateInfos[i].pVertexInputState != nullptr) {
auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
@@ -1127,17 +1140,6 @@
validation_error_map[VALIDATION_ERROR_10c00988]);
}
- bool has_dynamic_viewport = false;
- bool has_dynamic_scissor = false;
- if (pCreateInfos[i].pDynamicState != nullptr) {
- const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
- for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
- const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
- if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true;
- if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true;
- }
- }
-
if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
skip |= log_msg(
report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
@@ -1449,6 +1451,18 @@
"be "
"VK_POLYGON_MODE_POINT or VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
}
+
+ if (!has_dynamic_line_width && !device_data->physical_device_features.wideLines &&
+ (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
+ skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, 0, __LINE__, VALIDATION_ERROR_096005da, LayerName,
+ "The line width state is static (pCreateInfos[%" PRIu32
+ "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
+ "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
+ "].pRasterizationState->lineWidth (=%f) is not 1.0. %s",
+ i, i, pCreateInfos[i].pRasterizationState->lineWidth,
+ validation_error_map[VALIDATION_ERROR_096005da]);
+ }
}
for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
@@ -1999,6 +2013,21 @@
return skip;
}
+bool pv_vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) {
+ bool skip = false;
+ 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.wideLines && (lineWidth != 1.0f)) {
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
+ HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d600628, LayerName,
+ "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0. %s", lineWidth,
+ validation_error_map[VALIDATION_ERROR_1d600628]);
+ }
+
+ return skip;
+}
+
bool pv_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
uint32_t firstInstance) {
bool skip = false;
@@ -2438,6 +2467,7 @@
custom_functions["vkBeginCommandBuffer"] = (void*)pv_vkBeginCommandBuffer;
custom_functions["vkCmdSetViewport"] = (void*)pv_vkCmdSetViewport;
custom_functions["vkCmdSetScissor"] = (void*)pv_vkCmdSetScissor;
+ custom_functions["vkCmdSetLineWidth"] = (void *)pv_vkCmdSetLineWidth;
custom_functions["vkCmdDraw"] = (void*)pv_vkCmdDraw;
custom_functions["vkCmdDrawIndirect"] = (void*)pv_vkCmdDrawIndirect;
custom_functions["vkCmdDrawIndexedIndirect"] = (void*)pv_vkCmdDrawIndexedIndirect;
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index 6be24ca..4bbfb61 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -581,7 +581,7 @@
VALIDATION_ERROR_096005d4~^~Y~^~NumBlendAttachMismatch~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-attachmentCount-00746~^~core~^~The spec valid usage text states 'If rasterization is not disabled and the subpass uses color attachments, the attachmentCount member of pColorBlendState must be equal to the colorAttachmentCount used to create subpass' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-attachmentCount-00746)~^~
VALIDATION_ERROR_096005d6~^~Y~^~PSOViewportStateTests,PSOViewportStateMultiViewportTests~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747~^~core~^~The spec valid usage text states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_VIEWPORT, the pViewports member of pViewportState must be a valid pointer to an array of pViewportState::viewportCount VkViewport structures' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747)~^~
VALIDATION_ERROR_096005d8~^~Y~^~PSOViewportStateTests,PSOViewportStateMultiViewportTests~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748~^~core~^~The spec valid usage text states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SCISSOR, the pScissors member of pViewportState must be a valid pointer to an array of pViewportState::scissorCount VkRect2D structures' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748)~^~
-VALIDATION_ERROR_096005da~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749~^~core~^~The spec valid usage text states 'If the wide lines feature is not enabled, and no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_LINE_WIDTH, the lineWidth member of pRasterizationState must be 1.0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749)~^~
+VALIDATION_ERROR_096005da~^~Y~^~Unknown~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749~^~core~^~The spec valid usage text states 'If the wide lines feature is not enabled, and no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_LINE_WIDTH, the lineWidth member of pRasterizationState must be 1.0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749)~^~
VALIDATION_ERROR_096005dc~^~Y~^~PSOViewportStateTests~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750~^~core~^~The spec valid usage text states 'If the rasterizerDiscardEnable member of pRasterizationState is VK_FALSE, pViewportState must be a valid pointer to a valid VkPipelineViewportStateCreateInfo structure' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750)~^~
VALIDATION_ERROR_096005de~^~Y~^~Unknown~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751~^~core~^~The spec valid usage text states 'If the rasterizerDiscardEnable member of pRasterizationState is VK_FALSE, pMultisampleState must be a valid pointer to a valid VkPipelineMultisampleStateCreateInfo structure' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751)~^~
VALIDATION_ERROR_096005e0~^~Y~^~Unknown~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00752~^~core~^~The spec valid usage text states 'If the rasterizerDiscardEnable member of pRasterizationState is VK_FALSE, and subpass uses a depth/stencil attachment, pDepthStencilState must be a valid pointer to a valid VkPipelineDepthStencilStateCreateInfo structure' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00752)~^~
@@ -2493,7 +2493,7 @@
VALIDATION_ERROR_1d42de01~^~N~^~Unknown~^~vkCmdSetEvent~^~VUID-vkCmdSetEvent-stageMask-parameter~^~core~^~The spec valid usage text states 'stageMask must be a valid combination of VkPipelineStageFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetEvent-stageMask-parameter)~^~implicit
VALIDATION_ERROR_1d42de03~^~Y~^~Unknown~^~vkCmdSetEvent~^~VUID-vkCmdSetEvent-stageMask-requiredbitmask~^~core~^~The spec valid usage text states 'stageMask must not be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetEvent-stageMask-requiredbitmask)~^~implicit
VALIDATION_ERROR_1d600626~^~Y~^~Unknown~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidth-None-00787~^~core~^~The spec valid usage text states 'The currently bound graphics pipeline must have been created with the VK_DYNAMIC_STATE_LINE_WIDTH dynamic state enabled' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetLineWidth-None-00787)~^~
-VALIDATION_ERROR_1d600628~^~N~^~Unknown~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidth-lineWidth-00788~^~core~^~The spec valid usage text states 'If the wide lines feature is not enabled, lineWidth must be 1.0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetLineWidth-lineWidth-00788)~^~
+VALIDATION_ERROR_1d600628~^~Y~^~Unknown~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidth-lineWidth-00788~^~core~^~The spec valid usage text states 'If the wide lines feature is not enabled, lineWidth must be 1.0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdSetLineWidth-lineWidth-00788)~^~
VALIDATION_ERROR_1d602401~^~Y~^~None~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidth-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-vkCmdSetLineWidth-commandBuffer-parameter)~^~implicit
VALIDATION_ERROR_1d602413~^~N~^~Unknown~^~vkCmdSetLineWidth~^~VUID-vkCmdSetLineWidth-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-vkCmdSetLineWidth-commandBuffer-recording)~^~implicit
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