Skip to content

Commit

Permalink
layers: Move more dynamic state VUs as combined
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jun 13, 2024
1 parent 2689326 commit 0438a69
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 275 deletions.
155 changes: 86 additions & 69 deletions layers/core_checks/cc_cmd_buffer_dynamic.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions layers/core_checks/cc_drawdispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ bool CoreChecks::ValidateActionState(const vvl::CommandBuffer &cb_state, const V

if (!pipeline) {
skip |= ValidateShaderObjectBoundShader(last_bound_state, bind_point, vuid);
if (skip) return skip; // if shaders are bound wrong, likely to give false positives after
}

if (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) {
Expand Down
165 changes: 0 additions & 165 deletions layers/drawdispatch/drawdispatch_vuids.cpp

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions layers/drawdispatch/drawdispatch_vuids.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,14 @@ struct DrawDispatchVuid {
const char* external_format_resolve_09370 = kVUIDUndefined;
const char* external_format_resolve_09371 = kVUIDUndefined;
const char* set_rasterizer_discard_enable_08639 = kVUIDUndefined;
const char* set_depth_bias_enable_08640 = kVUIDUndefined;
const char* set_logic_op_08641 = kVUIDUndefined;
const char* set_color_blend_enable_08643 = kVUIDUndefined;
const char* set_rasterization_samples_08644 = kVUIDUndefined;
const char* set_color_write_enable_08646 = kVUIDUndefined;
const char* set_color_write_enable_08647 = kVUIDUndefined;
const char* set_discard_rectangles_enable_08648 = kVUIDUndefined;
const char* set_discard_rectangles_mode_08649 = kVUIDUndefined;
const char* set_depth_clamp_enable_08650 = kVUIDUndefined;
const char* set_polygon_mode_08651 = kVUIDUndefined;
const char* set_rasterization_samples_08652 = kVUIDUndefined;
const char* set_sample_mask_08653 = kVUIDUndefined;
const char* set_alpha_to_coverage_enable_08654 = kVUIDUndefined;
const char* set_alpha_to_one_enable_08655 = kVUIDUndefined;
const char* set_logic_op_enable_08656 = kVUIDUndefined;
const char* set_color_blend_enable_08657 = kVUIDUndefined;
const char* set_color_blend_equation_08658 = kVUIDUndefined;
Expand Down Expand Up @@ -291,12 +285,7 @@ struct DrawDispatchVuid {
const char* set_stencil_write_mask_08624 = kVUIDUndefined;
const char* set_stencil_reference_08625 = kVUIDUndefined;
const char* set_sample_locations_08626 = kVUIDUndefined;
const char* set_cull_mode_08627 = kVUIDUndefined;
const char* set_front_face_08628 = kVUIDUndefined;
const char* set_depth_test_enable_08629 = kVUIDUndefined;
const char* set_depth_write_enable_08630 = kVUIDUndefined;
const char* set_depth_bounds_test_enable_08632 = kVUIDUndefined;
const char* set_stencil_test_enable_08633 = kVUIDUndefined;
const char* set_stencil_op_08634 = kVUIDUndefined;
const char* set_line_width_08619 = kVUIDUndefined;
const char* set_viewport_with_count_08642 = kVUIDUndefined;
Expand Down
11 changes: 11 additions & 0 deletions layers/state_tracker/pipeline_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,17 @@ bool LastBound::IsRasterizationDisabled() const {
return false;
}

bool LastBound::IsLogicOpEnabled() const {
if (!pipeline_state || pipeline_state->IsDynamic(CB_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT)) {
if (cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT)) {
return cb_state.dynamic_state_value.logic_op_enable;
}
} else {
return pipeline_state->ColorBlendState() && pipeline_state->ColorBlendState()->logicOpEnable;
}
return false;
}

VkColorComponentFlags LastBound::GetColorWriteMask(uint32_t i) const {
if (!pipeline_state || pipeline_state->IsDynamic(CB_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT)) {
if (i < cb_state.dynamic_state_value.color_write_masks.size()) {
Expand Down
1 change: 1 addition & 0 deletions layers/state_tracker/pipeline_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ struct LastBound {
VkStencilOpState GetStencilOpStateBack() const;
VkSampleCountFlagBits GetRasterizationSamples() const;
bool IsRasterizationDisabled() const;
bool IsLogicOpEnabled() const;
VkColorComponentFlags GetColorWriteMask(uint32_t i) const;
bool IsColorWriteEnabled(uint32_t i) const;
VkPrimitiveTopology GetPrimitiveTopology() const;
Expand Down
71 changes: 70 additions & 1 deletion layers/vulkan/generated/dynamic_state_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,30 @@ std::string DescribeDynamicStateDependency(CBDynamicState dynamic_state, const v
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_CULL_MODE:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_DEPTH_TEST_ENABLE:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_DEPTH_WRITE_ENABLE:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_DEPTH_COMPARE_OP:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
Expand All @@ -637,8 +661,53 @@ std::string DescribeDynamicStateDependency(CBDynamicState dynamic_state, const v
ss << "VkPipelineDepthStencilStateCreateInfo::depthTestEnable was VK_TRUE in the last bound graphics pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_STENCIL_TEST_ENABLE:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_DEPTH_BIAS_ENABLE:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
break;
case CB_DYNAMIC_STATE_LOGIC_OP_EXT:
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE)) {
ss << "vkCmdSetRasterizerDiscardEnable last set rasterizerDiscardEnable to VK_FALSE.\n";
} else {
ss << "VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable was VK_FALSE in the last bound graphics "
"pipeline.\n";
}
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT)) {
ss << "vkCmdSetLogicOpEnableEXT last set logicOpEnable to VK_TRUE.\n";
} else {
ss << "VkPipelineColorBlendStateCreateInfo::logicOpEnable was VK_TRUE in the last bound graphics pipeline.\n";
}
break;
default:
ss << "(Unknown Dynamic State)";
break; // not all state will be dependent on other state
}

return ss.str();
Expand Down
33 changes: 24 additions & 9 deletions scripts/generators/dynamic_state_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"command" : ["vkCmdSetStencilReference"]
},
"VK_DYNAMIC_STATE_CULL_MODE" : {
"command" : ["vkCmdSetCullMode"]
"command" : ["vkCmdSetCullMode"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_FRONT_FACE" : {
"command" : ["vkCmdSetFrontFace"]
Expand All @@ -68,20 +69,24 @@
"command" : ["vkCmdBindVertexBuffers2"]
},
"VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE" : {
"command" : ["vkCmdSetDepthTestEnable"]
"command" : ["vkCmdSetDepthTestEnable"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE" : {
"command" : ["vkCmdSetDepthWriteEnable"]
"command" : ["vkCmdSetDepthWriteEnable"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_DEPTH_COMPARE_OP" : {
"command" : ["vkCmdSetDepthCompareOp"],
"dependency" : ["rasterizerDiscardEnable", "depthTestEnable"]
},
"VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE" : {
"command" : ["vkCmdSetDepthBoundsTestEnable"]
"command" : ["vkCmdSetDepthBoundsTestEnable"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE" : {
"command" : ["vkCmdSetStencilTestEnable"]
"command" : ["vkCmdSetStencilTestEnable"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_STENCIL_OP" : {
"command" : ["vkCmdSetStencilOp"]
Expand All @@ -90,7 +95,8 @@
"command" : ["vkCmdSetRasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE" : {
"command" : ["vkCmdSetDepthBiasEnable"]
"command" : ["vkCmdSetDepthBiasEnable"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE" : {
"command" : ["vkCmdSetPrimitiveRestartEnable"]
Expand Down Expand Up @@ -123,7 +129,8 @@
"command" : ["vkCmdSetExclusiveScissorNV"]
},
"VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR" : {
"command" : ["vkCmdSetFragmentShadingRateKHR"]
"command" : ["vkCmdSetFragmentShadingRateKHR"],
"dependency" : ["rasterizerDiscardEnable"]
},
"VK_DYNAMIC_STATE_LINE_STIPPLE_KHR" : {
"command" : ["vkCmdSetLineStippleKHR"]
Expand All @@ -135,7 +142,8 @@
"command" : ["vkCmdSetPatchControlPointsEXT"]
},
"VK_DYNAMIC_STATE_LOGIC_OP_EXT" : {
"command" : ["vkCmdSetLogicOpEXT"]
"command" : ["vkCmdSetLogicOpEXT"],
"dependency" : ["rasterizerDiscardEnable", "logicOpEnable"]
},
"VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT" : {
"command" : ["vkCmdSetColorWriteEnableEXT"]
Expand Down Expand Up @@ -452,11 +460,18 @@ def generateSource(self):
} else {
ss << "VkPipelineRasterizationStateCreateInfo::depthTestEnable was VK_TRUE in the last bound graphics pipeline.\\n";
}''')
if 'logicOpEnable' in dependency:
out.append('''
if (!pipeline || pipeline->IsDynamic(CB_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT)) {
ss << "vkCmdSetLogicOpEnableEXT last set logicOpEnable to VK_TRUE.\\n";
} else {
ss << "VkPipelineColorBlendStateCreateInfo::logicOpEnable was VK_TRUE in the last bound graphics pipeline.\\n";
}''')

out.append(' break;')
out.append('''
default:
ss << "(Unknown Dynamic State)";
break; // not all state will be dependent on other state
}
return ss.str();
Expand Down
34 changes: 25 additions & 9 deletions tests/unit/dynamic_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ TEST_F(NegativeDynamicState, ExtendedDynamicState2LogicOpEnabled) {
{
CreatePipelineHelper pipe(*this);
pipe.AddDynamicState(VK_DYNAMIC_STATE_LOGIC_OP_EXT);
pipe.cb_ci_.logicOpEnable = VK_TRUE;
pipe.CreateGraphicsPipeline();

vkt::CommandBuffer command_buffer(*m_device, m_command_pool);
Expand Down Expand Up @@ -1706,15 +1707,9 @@ TEST_F(NegativeDynamicState, DrawNotSetPolygonMode) {
TEST_F(NegativeDynamicState, DrawNotSetAlphaToOneEnable) {
TEST_DESCRIPTION("VK_EXT_extended_dynamic_state3 dynamic state not set before drawing");
AddRequiredExtensions(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

VkPhysicalDeviceExtendedDynamicState3FeaturesEXT extended_dynamic_state3_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(extended_dynamic_state3_features);
if (!extended_dynamic_state3_features.extendedDynamicState3AlphaToOneEnable) {
GTEST_SKIP() << "extendedDynamicState3AlphaToOneEnable not supported";
}
features2.features.alphaToOne = VK_FALSE;
RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::alphaToOne);
AddRequiredFeature(vkt::Feature::extendedDynamicState3AlphaToOneEnable);
RETURN_IF_SKIP(Init());
InitRenderTarget();

m_commandBuffer->begin();
Expand All @@ -1728,6 +1723,26 @@ TEST_F(NegativeDynamicState, DrawNotSetAlphaToOneEnable) {
m_errorMonitor->SetDesiredError("VUID-vkCmdDraw-None-07625");
vk::CmdDraw(m_commandBuffer->handle(), 1, 1, 0, 0);
m_errorMonitor->VerifyFound();
m_commandBuffer->EndRenderPass();
m_commandBuffer->end();
}

TEST_F(NegativeDynamicState, AlphaToOneFeature) {
TEST_DESCRIPTION("VK_EXT_extended_dynamic_state3 dynamic state not set before drawing");
AddRequiredExtensions(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::extendedDynamicState3AlphaToOneEnable);
AddDisabledFeature(vkt::Feature::alphaToOne);
RETURN_IF_SKIP(Init());
InitRenderTarget();

m_commandBuffer->begin();

CreatePipelineHelper pipe(*this);
pipe.AddDynamicState(VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT);
pipe.CreateGraphicsPipeline();
vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.Handle());

m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
m_errorMonitor->SetDesiredError("VUID-vkCmdSetAlphaToOneEnableEXT-alphaToOne-07607");
vk::CmdSetAlphaToOneEnableEXT(m_commandBuffer->handle(), VK_TRUE);
m_errorMonitor->VerifyFound();
Expand Down Expand Up @@ -3698,6 +3713,7 @@ TEST_F(NegativeDynamicState, DrawNotSetDepthWriteEnable) {
}

TEST_F(NegativeDynamicState, DrawNotSetDepthBoundsTestEnable) {
AddRequiredFeature(vkt::Feature::depthBounds);
ExtendedDynamicStateDrawNotSet(VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE, "VUID-vkCmdDraw-None-07846");
}

Expand Down
Loading

0 comments on commit 0438a69

Please sign in to comment.