Skip to content

Commit

Permalink
layers: Fix 09376 VU
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jan 15, 2025
1 parent 733faf5 commit 5a1d4c8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion layers/core_checks/cc_cmd_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ bool CoreChecks::PreCallValidateCmdExecuteCommands(VkCommandBuffer commandBuffer
}

// spec: "A maxCommandBufferNestingLevel of UINT32_MAX means there is no limit to the nesting level"
if (enabled_features.nestedCommandBuffer &&
if (enabled_features.nestedCommandBuffer && cb_state.IsSecondary() &&
phys_dev_ext_props.nested_command_buffer_props.maxCommandBufferNestingLevel != UINT32_MAX) {
if (sub_cb_state.nesting_level >= phys_dev_ext_props.nested_command_buffer_props.maxCommandBufferNestingLevel) {
skip |= LogError("VUID-vkCmdExecuteCommands-nestedCommandBuffer-09376", pCommandBuffers[i], cb_loc,
Expand Down
57 changes: 53 additions & 4 deletions tests/unit/secondary_command_buffer_positive.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
* Copyright (c) 2015-2024 Google, Inc.
* Copyright (c) 2015-2025 The Khronos Group Inc.
* Copyright (c) 2015-2025 Valve Corporation
* Copyright (c) 2015-2025 LunarG, Inc.
* Copyright (c) 2015-2025 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -399,3 +399,52 @@ TEST_F(PositiveSecondaryCommandBuffer, Nested) {
vk::CmdEndQuery(secondary2.handle(), query_pool, 0);
secondary2.End();
}

TEST_F(PositiveSecondaryCommandBuffer, NestedPrimary) {
TEST_DESCRIPTION("https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/7090");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_EXT_NESTED_COMMAND_BUFFER_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::nestedCommandBuffer);
AddRequiredFeature(vkt::Feature::nestedCommandBufferRendering);
AddRequiredFeature(vkt::Feature::dynamicRendering);
AddRequiredFeature(vkt::Feature::inheritedQueries);
RETURN_IF_SKIP(Init());
InitRenderTarget();

VkPhysicalDeviceNestedCommandBufferPropertiesEXT nested_cb_props = vku::InitStructHelper();
GetPhysicalDeviceProperties2(nested_cb_props);
if (nested_cb_props.maxCommandBufferNestingLevel != 1) {
GTEST_SKIP() << "needs maxCommandBufferNestingLevel to be 1";
}

vkt::CommandBuffer secondary1(*m_device, m_command_pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
vkt::CommandBuffer secondary2(*m_device, m_command_pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);

VkCommandBufferInheritanceRenderingInfo cbiri = vku::InitStructHelper();
cbiri.colorAttachmentCount = 1;
cbiri.pColorAttachmentFormats = &m_render_target_fmt;
cbiri.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;

VkCommandBufferInheritanceInfo cbii = vku::InitStructHelper(&cbiri);
cbii.occlusionQueryEnable = VK_TRUE;
cbii.queryFlags = 0;

VkCommandBufferBeginInfo cbbi = vku::InitStructHelper();
cbbi.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
cbbi.pInheritanceInfo = &cbii;

secondary1.Begin(&cbbi);
secondary1.End();

secondary2.Begin(&cbbi);
vk::CmdExecuteCommands(secondary2.handle(), 1u, &secondary1.handle());
secondary2.End();

// The primary command buffer doesn't count toward nesting
m_command_buffer.Begin(&cbbi);
m_command_buffer.BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
vk::CmdExecuteCommands(m_command_buffer.handle(), 1u, &secondary2.handle());
m_command_buffer.EndRenderPass();
m_command_buffer.End();
}

0 comments on commit 5a1d4c8

Please sign in to comment.