Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layers: Fix checking if event is in use #9089

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion layers/core_checks/cc_synchronization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ void CoreChecks::PreCallRecordCmdPipelineBarrier2(VkCommandBuffer commandBuffer,
bool CoreChecks::PreCallValidateSetEvent(VkDevice device, VkEvent event, const ErrorObject &error_obj) const {
bool skip = false;
if (auto event_state = Get<vvl::Event>(event)) {
if (event_state->write_in_use) {
if (event_state->InUse()) {
ziga-lunarg marked this conversation as resolved.
Show resolved Hide resolved
skip |= LogError("VUID-vkSetEvent-event-09543", event, error_obj.location.dot(Field::event),
"(%s) that is already in use by a command buffer.", FormatHandle(event).c_str());
}
Expand Down
15 changes: 0 additions & 15 deletions layers/state_tracker/cmd_buffer_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,6 @@ void CommandBuffer::Reset(const Location &loc) {
// Track which resources are in-flight by atomically incrementing their "in_use" count
void CommandBuffer::IncrementResources() {
submitCount++;

// TODO : We should be able to remove the NULL look-up checks from the code below as long as
// all the corresponding cases are verified to cause CB_INVALID state and the CB_INVALID state
// should then be flagged prior to calling this function
for (auto event : writeEventsBeforeWait) {
auto event_state = dev_data.Get<vvl::Event>(event);
if (event_state) event_state->write_in_use++;
}
}

// Discussed in details in https://github.com/KhronosGroup/Vulkan-Docs/issues/1081
Expand Down Expand Up @@ -1656,13 +1648,6 @@ void CommandBuffer::Submit(VkQueue queue, uint32_t perf_submit_pass, const Locat
}

void CommandBuffer::Retire(uint32_t perf_submit_pass, const std::function<bool(const QueryObject &)> &is_query_updated_after) {
// First perform decrement on general case bound objects
for (auto event : writeEventsBeforeWait) {
auto event_state = dev_data.Get<vvl::Event>(event);
if (event_state) {
event_state->write_in_use--;
}
}
QueryMap local_query_to_state_map;
VkQueryPool first_pool = VK_NULL_HANDLE;
for (auto &function : query_updates) {
Expand Down
2 changes: 0 additions & 2 deletions layers/state_tracker/cmd_buffer_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class Event : public StateObject {
const bool metal_event_export;
#endif // VK_USE_PLATFORM_METAL_EXT

int write_in_use = 0;

// Signaling state.
// Gets updated at queue submission granularity or when signaled from the host.
bool signaled = false;
Expand Down
18 changes: 15 additions & 3 deletions tests/unit/sync_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3821,15 +3821,28 @@ TEST_F(NegativeSyncObject, ResetEventThenSet) {
m_default_queue->Wait();
}

// TODO: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/8748
// This test should only be used for manual inspection
// Because a command buffer with vkCmdWaitEvents is submitted with an
// event that is never signaled, the test results in a VK_ERROR_DEVICE_LOST
TEST_F(NegativeSyncObject, DISABLED_WaitEventThenSet) {
#if defined(VVL_ENABLE_TSAN)
// NOTE: This test in particular has failed sporadically on CI when TSAN is enabled.
GTEST_SKIP() << "https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5965";
#endif
TEST_DESCRIPTION("Wait on a event then set it after the wait has been submitted.");

RETURN_IF_SKIP(Init());
SetTargetApiVersion(VK_API_VERSION_1_1);
RETURN_IF_SKIP(InitFramework());
void *pNext = nullptr;
VkPhysicalDevicePortabilitySubsetFeaturesKHR portability_subset_features = vku::InitStructHelper();
if (IsExtensionsEnabled(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME)) {
pNext = &portability_subset_features;
GetPhysicalDeviceFeatures2(portability_subset_features);
if (!portability_subset_features.events) {
GTEST_SKIP() << "VkPhysicalDevicePortabilitySubsetFeaturesKHR::events not supported";
}
}
RETURN_IF_SKIP(InitState(nullptr, pNext));

vkt::Event event(*m_device);

Expand All @@ -3843,7 +3856,6 @@ TEST_F(NegativeSyncObject, DISABLED_WaitEventThenSet) {
m_errorMonitor->SetDesiredError("VUID-vkSetEvent-event-09543");
vk::SetEvent(device(), event.handle());
m_errorMonitor->VerifyFound();
m_default_queue->Wait();
}

TEST_F(NegativeSyncObject, RenderPassPipelineBarrierGraphicsStage) {
Expand Down
Loading