Skip to content

Commit

Permalink
layers: Combine viewportCount dynamic state
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Sep 27, 2024
1 parent efd219a commit 1f020da
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 71 deletions.
68 changes: 19 additions & 49 deletions layers/core_checks/cc_cmd_buffer_dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ bool CoreChecks::ValidateDynamicStateIsSet(const LastBound& last_bound_state, co
case CB_DYNAMIC_STATE_FRONT_FACE:
vuid_str = vuid.dynamic_front_face_07841;
break;
case CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT:
vuid_str = vuid.viewport_count_03417;
break;
case CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT:
vuid_str = vuid.scissor_count_03418;
break;
case CB_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV:
vuid_str = vuid.set_viewport_coarse_sample_order_09233;
break;
Expand Down Expand Up @@ -379,6 +385,19 @@ bool CoreChecks::ValidateGraphicsDynamicStateSetStatus(const LastBound& last_bou
}
}

if (cb_state.inheritedViewportDepths.empty()) {
skip |= ValidateDynamicStateIsSet(last_bound_state, state_status_cb, CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT, vuid);
skip |= ValidateDynamicStateIsSet(last_bound_state, state_status_cb, CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT, vuid);
}
if (has_dynamic_state(CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT) && has_dynamic_state(CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT)) {
if (cb_state.dynamic_state_value.viewport_count != cb_state.dynamic_state_value.scissor_count) {
skip |= LogError(vuid.viewport_and_scissor_with_count_03419, cb_state.Handle(), vuid.loc(),
"Graphics stages are bound, but viewportCount set with vkCmdSetViewportWithCount() was %" PRIu32
" and scissorCount set with vkCmdSetScissorWithCount() was %" PRIu32 ".",
cb_state.dynamic_state_value.viewport_count, cb_state.dynamic_state_value.scissor_count);
}
}

if (vertex_shader_bound) {
skip |= ValidateDynamicStateIsSet(last_bound_state, state_status_cb, CB_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY, vuid);
skip |= ValidateDynamicStateIsSet(last_bound_state, state_status_cb, CB_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE, vuid);
Expand Down Expand Up @@ -954,43 +973,6 @@ bool CoreChecks::ValidateGraphicsDynamicStateViewportScissor(const LastBound& la
missing_scissor_mask);
}
}

const bool dyn_viewport_count = pipeline.IsDynamic(CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT);
const bool dyn_scissor_count = pipeline.IsDynamic(CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT);

if (dyn_viewport_count && !dyn_scissor_count) {
const auto required_viewport_mask = (1 << viewport_state->scissorCount) - 1;
const auto missing_viewport_mask = ~cb_state.viewportWithCountMask & required_viewport_mask;
if (missing_viewport_mask || !cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT)) {
skip |= LogError(vuid.viewport_count_03417, objlist, vuid.loc(),
"Dynamic viewport with count 0x%x are used by pipeline state object, but were not provided "
"via calls to vkCmdSetViewportWithCountEXT().",
missing_viewport_mask);
}
}

if (dyn_scissor_count && !dyn_viewport_count) {
const auto required_scissor_mask = (1 << viewport_state->viewportCount) - 1;
const auto missing_scissor_mask = ~cb_state.scissorWithCountMask & required_scissor_mask;
if (missing_scissor_mask || !cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT)) {
skip |= LogError(vuid.scissor_count_03418, objlist, vuid.loc(),
"Dynamic scissor with count 0x%x are used by pipeline state object, but were not provided via "
"calls to vkCmdSetScissorWithCountEXT().",
missing_scissor_mask);
}
}

if (dyn_scissor_count && dyn_viewport_count) {
if (cb_state.viewportWithCountMask != cb_state.scissorWithCountMask ||
!cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT) ||
!cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT)) {
skip |= LogError(vuid.viewport_scissor_count_03419, objlist, vuid.loc(),
"Dynamic viewport and scissor with count 0x%x are used by pipeline state object, but were not "
"provided via matching calls to "
"vkCmdSetViewportWithCountEXT and vkCmdSetScissorWithCountEXT().",
(cb_state.viewportWithCountMask ^ cb_state.scissorWithCountMask));
}
}
}

// If inheriting viewports, verify that not using more than inherited.
Expand Down Expand Up @@ -1410,18 +1392,6 @@ bool CoreChecks::ValidateDrawDynamicStateShaderObject(const LastBound& last_boun
bool geom_shader_line_topology =
geom_shader_bound && isLineTopology(last_bound_state.GetShaderState(ShaderObjectStage::GEOMETRY)->GetTopology());

if (!cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_VIEWPORT_WITH_COUNT) ||
!cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_SCISSOR_WITH_COUNT)) {
skip |= LogError(vuid.viewport_and_scissor_with_count_08635, cb_state.Handle(), loc,
"Graphics shader objects are bound, but vkCmdSetViewportWithCount() and "
"vkCmdSetScissorWithCount() were not both called.");
} else if (cb_state.dynamic_state_value.viewport_count != cb_state.dynamic_state_value.scissor_count) {
skip |= LogError(vuid.viewport_and_scissor_with_count_08635, cb_state.Handle(), loc,
"Graphics shader objects are bound, but viewportCount set with vkCmdSetViewportWithCount() was %" PRIu32
" and scissorCount set with vkCmdSetScissorWithCount() was %" PRIu32 ".",
cb_state.dynamic_state_value.viewport_count, cb_state.dynamic_state_value.scissor_count);
}

if (!cb_state.dynamic_state_value.rasterizer_discard_enable) {
for (uint32_t i = 0; i < cb_state.active_attachments.size(); ++i) {
const auto* attachment = cb_state.active_attachments[i].image_view;
Expand Down
30 changes: 15 additions & 15 deletions layers/drawdispatch/drawdispatch_vuids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ struct DispatchVuidsCmdDraw : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDraw-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDraw-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDraw-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDraw-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDraw-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDraw-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDraw-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDraw-colorAttachmentCount-09362";
Expand Down Expand Up @@ -461,7 +461,7 @@ struct DispatchVuidsCmdDrawMultiEXT : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMultiEXT-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMultiEXT-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMultiEXT-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMultiEXT-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMultiEXT-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMultiEXT-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMultiEXT-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMultiEXT-colorAttachmentCount-09362";
Expand Down Expand Up @@ -733,7 +733,7 @@ struct DispatchVuidsCmdDrawIndexed : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawIndexed-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawIndexed-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawIndexed-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawIndexed-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawIndexed-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawIndexed-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawIndexed-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawIndexed-colorAttachmentCount-09362";
Expand Down Expand Up @@ -1005,7 +1005,7 @@ struct DispatchVuidsCmdDrawMultiIndexedEXT : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMultiIndexedEXT-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMultiIndexedEXT-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMultiIndexedEXT-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMultiIndexedEXT-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMultiIndexedEXT-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMultiIndexedEXT-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMultiIndexedEXT-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMultiIndexedEXT-colorAttachmentCount-09362";
Expand Down Expand Up @@ -1277,7 +1277,7 @@ struct DispatchVuidsCmdDrawIndirect : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawIndirect-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawIndirect-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawIndirect-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawIndirect-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawIndirect-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawIndirect-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawIndirect-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawIndirect-colorAttachmentCount-09362";
Expand Down Expand Up @@ -1548,7 +1548,7 @@ struct DispatchVuidsCmdDrawIndexedIndirect : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawIndexedIndirect-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawIndexedIndirect-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawIndexedIndirect-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawIndexedIndirect-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawIndexedIndirect-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawIndexedIndirect-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawIndexedIndirect-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawIndexedIndirect-colorAttachmentCount-09362";
Expand Down Expand Up @@ -1918,7 +1918,7 @@ struct DispatchVuidsCmdDrawIndirectCount : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawIndirectCount-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawIndirectCount-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawIndirectCount-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawIndirectCount-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawIndirectCount-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawIndirectCount-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawIndirectCount-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawIndirectCount-colorAttachmentCount-09362";
Expand Down Expand Up @@ -2192,7 +2192,7 @@ struct DispatchVuidsCmdDrawIndexedIndirectCount : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawIndexedIndirectCount-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawIndexedIndirectCount-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawIndexedIndirectCount-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawIndexedIndirectCount-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawIndexedIndirectCount-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawIndexedIndirectCount-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawIndexedIndirectCount-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawIndexedIndirectCount-colorAttachmentCount-09362";
Expand Down Expand Up @@ -2645,7 +2645,7 @@ struct DispatchVuidsCmdDrawMeshTasksNV: DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMeshTasksNV-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMeshTasksNV-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMeshTasksNV-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMeshTasksNV-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMeshTasksNV-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMeshTasksNV-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMeshTasksNV-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMeshTasksNV-colorAttachmentCount-09362";
Expand Down Expand Up @@ -2902,7 +2902,7 @@ struct DispatchVuidsCmdDrawMeshTasksIndirectNV: DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMeshTasksIndirectNV-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMeshTasksIndirectNV-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMeshTasksIndirectNV-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMeshTasksIndirectNV-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMeshTasksIndirectNV-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMeshTasksIndirectNV-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMeshTasksIndirectNV-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMeshTasksIndirectNV-colorAttachmentCount-09362";
Expand Down Expand Up @@ -3162,7 +3162,7 @@ struct DispatchVuidsCmdDrawMeshTasksIndirectCountNV : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMeshTasksIndirectCountNV-colorAttachmentCount-09362";
Expand Down Expand Up @@ -3416,7 +3416,7 @@ struct DispatchVuidsCmdDrawMeshTasksEXT: DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMeshTasksEXT-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMeshTasksEXT-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMeshTasksEXT-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMeshTasksEXT-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMeshTasksEXT-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMeshTasksEXT-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMeshTasksEXT-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMeshTasksEXT-colorAttachmentCount-09362";
Expand Down Expand Up @@ -3673,7 +3673,7 @@ struct DispatchVuidsCmdDrawMeshTasksIndirectEXT: DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMeshTasksIndirectEXT-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMeshTasksIndirectEXT-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMeshTasksIndirectEXT-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMeshTasksIndirectEXT-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMeshTasksIndirectEXT-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMeshTasksIndirectEXT-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMeshTasksIndirectEXT-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMeshTasksIndirectEXT-colorAttachmentCount-09362";
Expand Down Expand Up @@ -3933,7 +3933,7 @@ struct DispatchVuidsCmdDrawMeshTasksIndirectCountEXT : DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawMeshTasksIndirectCountEXT-colorAttachmentCount-09362";
Expand Down Expand Up @@ -4200,7 +4200,7 @@ struct DispatchVuidsCmdDrawIndirectByteCountEXT: DrawDispatchVuid {
stippled_bresenham_lines_07496 = "VUID-vkCmdDrawIndirectByteCountEXT-stippledLineEnable-07496";
stippled_smooth_lines_07497 = "VUID-vkCmdDrawIndirectByteCountEXT-stippledLineEnable-07497";
stippled_default_strict_07498 = "VUID-vkCmdDrawIndirectByteCountEXT-stippledLineEnable-07498";
viewport_and_scissor_with_count_08635 = "VUID-vkCmdDrawIndirectByteCountEXT-None-08635";
viewport_and_scissor_with_count_03419 = "VUID-vkCmdDrawIndirectByteCountEXT-viewportCount-03419";
viewport_w_scaling_08636 = "VUID-vkCmdDrawIndirectByteCountEXT-None-08636";
shading_rate_palette_08637 = "VUID-vkCmdDrawIndirectByteCountEXT-None-08637";
external_format_resolve_09362 = "VUID-vkCmdDrawIndirectByteCountEXT-colorAttachmentCount-09362";
Expand Down
Loading

0 comments on commit 1f020da

Please sign in to comment.