Skip to content

Commit

Permalink
layers: Misc pipeline renderpass cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jun 28, 2024
1 parent e6678d1 commit 70a10e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
43 changes: 24 additions & 19 deletions layers/core_checks/cc_pipeline_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,26 +1651,30 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendAttachmentState(const vvl::Pi
}

if (advance_blend) {
const uint32_t color_attachment_count = pipeline.rendering_create_info
? pipeline.rendering_create_info->colorAttachmentCount
: subpass_desc->colorAttachmentCount;
if (attachment_state.colorBlendOp != attachment_state.alphaBlendOp) {
skip |=
LogError("VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01406", device, attachment_loc,
"has different colorBlendOp (%s) and alphaBlendOp (%s) but one of "
"them is an advance blend operation.",
string_VkBlendOp(attachment_state.colorBlendOp), string_VkBlendOp(attachment_state.alphaBlendOp));
} else if (color_attachment_count >
phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments) {
// color_attachment_count is found one of multiple spots above
//
// error can guarantee it is the same VkBlendOp
skip |= LogError("VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410", device, attachment_loc,
"has an advance blend operation (%s) but the colorAttachmentCount (%" PRIu32
") is larger than advancedBlendMaxColorAttachments (%" PRIu32 ").",
string_VkBlendOp(attachment_state.colorBlendOp), color_attachment_count,
phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments);
break; // if this fails once, will fail every iteration
} else {
const uint32_t color_attachment_count = pipeline.rendering_create_info
? pipeline.rendering_create_info->colorAttachmentCount
: subpass_desc ? subpass_desc->colorAttachmentCount
: 0;
if (color_attachment_count != 0 &&
color_attachment_count >
phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments) {
// color_attachment_count is found one of multiple spots above
//
// error can guarantee it is the same VkBlendOp
skip |= LogError("VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410", device, attachment_loc,
"has an advance blend operation (%s) but the colorAttachmentCount (%" PRIu32
") is larger than advancedBlendMaxColorAttachments (%" PRIu32 ").",
string_VkBlendOp(attachment_state.colorBlendOp), color_attachment_count,
phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments);
break; // if this fails once, will fail every iteration
}
}
}
}
Expand Down Expand Up @@ -1727,8 +1731,7 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendState(const vvl::Pipeline &pi
color_loc.dot(Field::logicOpEnable), "is VK_TRUE, but the logicOp feature was not enabled.");
}

auto color_write = vku::FindStructInPNextChain<VkPipelineColorWriteCreateInfoEXT>(color_blend_state->pNext);
if (color_write) {
if (auto color_write = vku::FindStructInPNextChain<VkPipelineColorWriteCreateInfoEXT>(color_blend_state->pNext)) {
if (color_write->attachmentCount > phys_dev_props.limits.maxColorAttachments) {
skip |= LogError("VUID-VkPipelineColorWriteCreateInfoEXT-attachmentCount-06655", device,
color_loc.pNext(Struct::VkPipelineColorWriteCreateInfoEXT, Field::attachmentCount),
Expand All @@ -1745,8 +1748,9 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendState(const vvl::Pipeline &pi
}
}
}
const auto *color_blend_advanced = vku::FindStructInPNextChain<VkPipelineColorBlendAdvancedStateCreateInfoEXT>(color_blend_state->pNext);
if (color_blend_advanced) {

if (const auto *color_blend_advanced =
vku::FindStructInPNextChain<VkPipelineColorBlendAdvancedStateCreateInfoEXT>(color_blend_state->pNext)) {
if (!phys_dev_ext_props.blend_operation_advanced_props.advancedBlendCorrelatedOverlap &&
color_blend_advanced->blendOverlap != VK_BLEND_OVERLAP_UNCORRELATED_EXT) {
skip |= LogError("VUID-VkPipelineColorBlendAdvancedStateCreateInfoEXT-blendOverlap-01426", device,
Expand All @@ -1772,8 +1776,9 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendState(const vvl::Pipeline &pi

bool CoreChecks::ValidateGraphicsPipelineRasterizationState(const vvl::Pipeline &pipeline, const Location &create_info_loc) const {
bool skip = false;
const Location raster_loc = create_info_loc.dot(Field::pRasterizationState);
const auto raster_state = pipeline.RasterizationState();
if (!raster_state) return skip;
const Location raster_loc = create_info_loc.dot(Field::pRasterizationState);

if ((raster_state->depthClampEnable == VK_TRUE) && (!enabled_features.depthClamp)) {
skip |= LogError("VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782", device,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/graphics_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ TEST_F(NegativeGraphicsLibrary, BadRenderPassFragmentShader) {
pipe.InitFragmentLibInfo(&fs_stage.stage_ci);
VkRenderPass bad_rp = CastToHandle<VkRenderPass, uintptr_t>(0xbaadbeef);
pipe.gp_ci_.renderPass = bad_rp;
m_errorMonitor->SetDesiredError("VUID-VkGraphicsPipelineCreateInfo-renderPass-09035");
m_errorMonitor->SetDesiredError("VUID-VkGraphicsPipelineCreateInfo-flags-06643");
pipe.CreateGraphicsPipeline();
m_errorMonitor->VerifyFound();
Expand Down Expand Up @@ -3206,6 +3205,7 @@ TEST_F(NegativeGraphicsLibrary, MissingFragmentOutput) {

VkGraphicsPipelineCreateInfo exe_pipe_ci = vku::InitStructHelper(&link_info);
exe_pipe_ci.layout = pre_raster_lib.gp_ci_.layout;
exe_pipe_ci.renderPass = renderPass();
m_errorMonitor->SetDesiredError("VUID-VkGraphicsPipelineCreateInfo-flags-08909");
vkt::Pipeline exe_pipe(*m_device, exe_pipe_ci);
m_errorMonitor->VerifyFound();
Expand Down

0 comments on commit 70a10e4

Please sign in to comment.