summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Gebben <jeremyg@lunarg.com>2022-02-15 16:33:16 -0700
committerjeremyg-lunarg <jeremyg@lunarg.com>2022-02-28 10:52:31 -0700
commita4d1376c7a95a64a934b4547ecc21d778a33245d (patch)
tree6a716f069b6525cc816c7932684850512862c934
parent81ed767116d9370f269a246b5420bafe10e60ad6 (diff)
downloadVulkan-ValidationLayers-a4d1376c7a95a64a934b4547ecc21d778a33245d.tar.gz
Vulkan-ValidationLayers-a4d1376c7a95a64a934b4547ecc21d778a33245d.tar.bz2
Vulkan-ValidationLayers-a4d1376c7a95a64a934b4547ecc21d778a33245d.zip
tests: Add ObjInUseCmdBuildAccelerationStructureNV test
Make sure the state tracker can detect if buffers used by this command are freed prematurely.
-rw-r--r--layers/core_validation.cpp2
-rw-r--r--tests/vklayertests_others.cpp67
2 files changed, 68 insertions, 1 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 887ff1a04..dc52e7a1c 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -8644,7 +8644,7 @@ bool CoreChecks::PreCallValidateDestroyAccelerationStructureNV(VkDevice device,
bool skip = false;
if (as_state) {
skip |= ValidateObjectNotInUse(as_state.get(), "vkDestroyAccelerationStructureNV",
- "VUID-vkDestroyAccelerationStructureKHR-accelerationStructure-02442");
+ "VUID-vkDestroyAccelerationStructureNV-accelerationStructure-03752");
}
return skip;
}
diff --git a/tests/vklayertests_others.cpp b/tests/vklayertests_others.cpp
index a0f6cc6f0..3e57632f1 100644
--- a/tests/vklayertests_others.cpp
+++ b/tests/vklayertests_others.cpp
@@ -6560,6 +6560,73 @@ TEST_F(VkLayerTest, ValidateCmdBuildAccelerationStructureNV) {
m_errorMonitor->VerifyFound();
}
+TEST_F(VkLayerTest, ObjInUseCmdBuildAccelerationStructureNV) {
+ TEST_DESCRIPTION("Validate acceleration structure building tracks the objects used.");
+ if (!InitFrameworkForRayTracingTest(this, false, m_instance_extension_names, m_device_extension_names, m_errorMonitor)) {
+ return;
+ }
+
+ auto vkCmdBuildAccelerationStructureNV = reinterpret_cast<PFN_vkCmdBuildAccelerationStructureNV>(
+ vk::GetDeviceProcAddr(m_device->handle(), "vkCmdBuildAccelerationStructureNV"));
+ assert(vkCmdBuildAccelerationStructureNV != nullptr);
+ auto vkDestroyAccelerationStructureNV = reinterpret_cast<PFN_vkDestroyAccelerationStructureNV>(
+ vk::GetDeviceProcAddr(m_device->handle(), "vkDestroyAccelerationStructureNV"));
+ assert(vkCmdBuildAccelerationStructureNV != nullptr);
+
+ auto vbo = layer_data::make_unique<VkBufferObj>();
+ auto ibo = layer_data::make_unique<VkBufferObj>();
+ VkGeometryNV geometry;
+ GetSimpleGeometryForAccelerationStructureTests(*m_device, vbo.get(), ibo.get(), &geometry);
+
+ VkAccelerationStructureCreateInfoNV bot_level_as_create_info = LvlInitStruct<VkAccelerationStructureCreateInfoNV>();
+ bot_level_as_create_info.info = LvlInitStruct<VkAccelerationStructureInfoNV>();
+ bot_level_as_create_info.info.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV;
+ bot_level_as_create_info.info.instanceCount = 0;
+ bot_level_as_create_info.info.geometryCount = 1;
+ bot_level_as_create_info.info.pGeometries = &geometry;
+
+ auto bot_level_as = layer_data::make_unique<VkAccelerationStructureObj>(*m_device, bot_level_as_create_info);
+
+ auto bot_level_as_scratch = layer_data::make_unique<VkBufferObj>();
+ bot_level_as->create_scratch_buffer(*m_device, bot_level_as_scratch.get());
+
+ m_commandBuffer->begin();
+ vkCmdBuildAccelerationStructureNV(m_commandBuffer->handle(), &bot_level_as_create_info.info, VK_NULL_HANDLE, 0, VK_FALSE,
+ bot_level_as->handle(), VK_NULL_HANDLE, bot_level_as_scratch->handle(), 0);
+ m_commandBuffer->end();
+
+ VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>();
+ submit_info.commandBufferCount = 1;
+ submit_info.pCommandBuffers = &m_commandBuffer->handle();
+ vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
+ m_errorMonitor->VerifyNotFound();
+
+ m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyBuffer-buffer-00922");
+ vk::DestroyBuffer(m_device->handle(), ibo->handle(), nullptr);
+ m_errorMonitor->VerifyFound();
+
+ m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyBuffer-buffer-00922");
+ vk::DestroyBuffer(m_device->handle(), vbo->handle(), nullptr);
+ m_errorMonitor->VerifyFound();
+
+ m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyBuffer-buffer-00922");
+ vk::DestroyBuffer(m_device->handle(), bot_level_as_scratch->handle(), nullptr);
+ m_errorMonitor->VerifyFound();
+
+ m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyAccelerationStructureNV-accelerationStructure-03752");
+ vkDestroyAccelerationStructureNV(m_device->handle(), bot_level_as->handle(), nullptr);
+ m_errorMonitor->VerifyFound();
+
+ m_errorMonitor->ExpectSuccess();
+ vk::QueueWaitIdle(m_device->m_queue);
+
+ ibo.reset();
+ vbo.reset();
+ bot_level_as_scratch.reset();
+ bot_level_as.reset();
+ m_errorMonitor->VerifyNotFound();
+}
+
TEST_F(VkLayerTest, ValidateGetAccelerationStructureHandleNV) {
TEST_DESCRIPTION("Validate acceleration structure handle querying.");
if (!InitFrameworkForRayTracingTest(this, false, m_instance_extension_names, m_device_extension_names, m_errorMonitor)) {