Skip to content

Commit a0ae5ff

Browse files
committed
layers: Remove QueueSubmissionValidator
Move timeline signal validation from QueueSubmissionValidator to SubmitTimeTracker and remove QueueSubmissionValidator
1 parent ba774d9 commit a0ae5ff

17 files changed

Lines changed: 79 additions & 151 deletions

BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ vvl_sources = [
144144
"layers/core_checks/cc_spirv.cpp",
145145
"layers/core_checks/cc_state_tracker.cpp",
146146
"layers/core_checks/cc_state_tracker.h",
147-
"layers/core_checks/cc_submit.cpp",
148-
"layers/core_checks/cc_submit.h",
149147
"layers/core_checks/cc_sync_vuid_maps.h",
150148
"layers/core_checks/cc_sync_vuid_maps.cpp",
151149
"layers/core_checks/cc_synchronization.cpp",

layers/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ target_sources(vvl PRIVATE
244244
core_checks/cc_shader_object.cpp
245245
core_checks/cc_state_tracker.h
246246
core_checks/cc_state_tracker.cpp
247-
core_checks/cc_submit.h
248-
core_checks/cc_submit.cpp
249247
core_checks/cc_sync_vuid_maps.h
250248
core_checks/cc_sync_vuid_maps.cpp
251249
core_checks/cc_synchronization.h

layers/core_checks/cc_queue.cpp

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,11 @@ bool CoreChecks::PreCallValidateQueueSubmit(VkQueue queue, uint32_t submitCount,
290290
chained_device_group_struct->commandBufferCount, submit.commandBufferCount);
291291
}
292292
}
293-
// Perform submit time validation at the end.
294-
// If submit API is used incorrectly, we want those errors to be reported first
295-
skip |= submit_time_tracker.ProcessSubmitInfo(submit, queue, submit_loc);
293+
// Run submit time validation only if skip is not set. This is mostly for vvl testing,
294+
// some tests expect that submit state is not updated if regular validation fails
295+
if (!skip) {
296+
skip |= submit_time_tracker.ProcessSubmitInfo(submit, queue, submit_loc);
297+
}
296298
}
297299

298300
return skip;
@@ -452,9 +454,11 @@ bool CoreChecks::ValidateQueueSubmit2(VkQueue queue, uint32_t submitCount, const
452454
skip |= LogError("VUID-VkSubmitInfo2-commandBuffer-06010", queue, submit_loc,
453455
"has a suspended render pass instance that was not resumed.");
454456
}
455-
// Perform submit time validation at the end.
456-
// If submit API is used incorrectly, we want those errors to be reported first
457-
skip |= submit_time_tracker.ProcessSubmitInfo(submit, queue, submit_loc);
457+
// Run submit time validation only if skip is not set. This is mostly for vvl testing,
458+
// some tests expect that submit state is not updated if regular validation fails
459+
if (!skip) {
460+
skip |= submit_time_tracker.ProcessSubmitInfo(submit, queue, submit_loc);
461+
}
458462
}
459463

460464
return skip;
@@ -783,8 +787,21 @@ bool CoreChecks::PreCallValidateQueueBindSparse(VkQueue queue, uint32_t bindInfo
783787
return skip;
784788
}
785789

786-
bool CoreChecks::ProcessSubmissionBatch(const std::vector<std::shared_ptr<vvl::CommandBuffer>>& command_buffers,
787-
const Location& submit_loc) {
790+
static Location GetSignaledSemaphoreLocation(const Location& submit_loc, uint32_t index) {
791+
vvl::Field field = vvl::Field::Empty;
792+
if (submit_loc.function == vvl::Func::vkQueueSubmit || submit_loc.function == vvl::Func::vkQueueBindSparse) {
793+
field = vvl::Field::pSignalSemaphores;
794+
} else if (submit_loc.function == vvl::Func::vkQueueSubmit2 || submit_loc.function == vvl::Func::vkQueueSubmit2KHR) {
795+
field = vvl::Field::pSignalSemaphoreInfos;
796+
} else {
797+
assert(false && "Unhandled signaling function");
798+
}
799+
return submit_loc.dot(field, index);
800+
}
801+
802+
bool CoreChecks::ProcessSubmissionBatch(const vvl::SubmitTimeTracker& tracker,
803+
const std::vector<std::shared_ptr<vvl::CommandBuffer>>& command_buffers,
804+
vvl::span<const VkSemaphoreSubmitInfo> signal_semaphores, const Location& submit_loc) {
788805
bool skip = false;
789806
// Validate image layouts on the command buffer boundaries
790807
{
@@ -796,6 +813,27 @@ bool CoreChecks::ProcessSubmissionBatch(const std::vector<std::shared_ptr<vvl::C
796813
}
797814
}
798815
}
816+
// Ensure that timeline signals are monotonically increasing values
817+
for (uint32_t i = 0; i < (uint32_t)signal_semaphores.size(); ++i) {
818+
const VkSemaphore semaphore = signal_semaphores[i].semaphore;
819+
const std::optional<uint64_t> current_value = tracker.GetTimelineValue(semaphore);
820+
if (!current_value.has_value()) {
821+
continue;
822+
}
823+
// Validate the case where the signal value is less than the current payload.
824+
// Equality, which is also invalid, is handled earlier by SemaphoreSubmitState::ValidateTimelineSignal.
825+
// Equality can be checked early because it is invalid regardless submit order.
826+
// For not equal values, the comparison depends on submit ordering and is handled here
827+
const uint64_t signal_value = signal_semaphores[i].value;
828+
const bool invlid_signal_value = signal_value < *current_value;
829+
if (invlid_signal_value) {
830+
const Location signal_semaphore_loc = GetSignaledSemaphoreLocation(submit_loc, i);
831+
const auto& vuid = GetQueueSubmitVUID(signal_semaphore_loc, vvl::SubmitError::kTimelineSemSmallValue);
832+
LogError(vuid, semaphore, signal_semaphore_loc,
833+
"(%s) signaled with value %" PRIu64 " which is smaller than the current value %" PRIu64,
834+
FormatHandle(semaphore).c_str(), signal_value, *current_value);
835+
}
836+
}
799837
if (!skip) {
800838
for (const auto& cb : command_buffers) {
801839
if (cb) {

layers/core_checks/cc_state_tracker.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void CoreChecks::Created(vvl::CommandBuffer& cb) {
4141
}
4242

4343
void CoreChecks::Created(vvl::Queue& queue) {
44-
queue.SetSubState(container_type, std::make_unique<core::QueueSubState>(*this, queue));
44+
queue.SetSubState(container_type, std::make_unique<core::QueueSubState>(queue));
4545
}
4646

4747
namespace core {
@@ -1214,9 +1214,6 @@ void CommandBufferSubState::SubmitTimeValidate() {
12141214
}
12151215
}
12161216

1217-
QueueSubState::QueueSubState(CoreChecks& core_checks, vvl::Queue& q)
1218-
: vvl::QueueSubState(q), queue_submission_validator_(core_checks) {}
1219-
12201217
void QueueSubState::PreSubmit(std::vector<vvl::QueueSubmission>& submissions) {
12211218
for (const auto& submission : submissions) {
12221219
for (auto& cb : submission.cb_submissions) {
@@ -1228,8 +1225,6 @@ void QueueSubState::PreSubmit(std::vector<vvl::QueueSubmission>& submissions) {
12281225
}
12291226

12301227
void QueueSubState::Retire(vvl::QueueSubmission& submission) {
1231-
queue_submission_validator_.Validate(submission);
1232-
12331228
auto is_query_updated_after = [this](const QueryObject& query_object) {
12341229
auto guard = base.Lock();
12351230
bool first_queue_submission = true;

layers/core_checks/cc_state_tracker.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* limitations under the License.
1919
*/
2020
#pragma once
21-
#include "cc_submit.h"
2221
#include "state_tracker/state_tracker.h"
2322
#include "state_tracker/cmd_buffer_state.h"
2423
#include "state_tracker/queue_state.h"
@@ -245,15 +244,12 @@ static inline const CommandBufferSubState &SubState(const vvl::CommandBuffer &cb
245244

246245
class QueueSubState : public vvl::QueueSubState {
247246
public:
248-
QueueSubState(CoreChecks &core_checks, vvl::Queue& q);
247+
QueueSubState(vvl::Queue& q) : vvl::QueueSubState(q) {}
249248

250249
void PreSubmit(std::vector<vvl::QueueSubmission> &submissions) override;
251250

252251
// Override Retire to validate submissions in the order defined by synchronization
253252
void Retire(vvl::QueueSubmission&) override;
254-
255-
private:
256-
QueueSubmissionValidator queue_submission_validator_;
257253
};
258254

259255
} // namespace core

layers/core_checks/cc_submit.cpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

layers/core_checks/cc_submit.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

layers/core_checks/cc_synchronization.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,9 +1648,11 @@ bool CoreChecks::PreCallValidateSignalSemaphore(VkDevice device, const VkSemapho
16481648
FormatHandle(*semaphore_state).c_str(), payload_type, *far_away_payload);
16491649
}
16501650

1651-
// Perform submit time validation at the end.
1652-
// If signal semaphore API is used incorrectly, we want those errors to be reported first
1653-
skip |= submit_time_tracker.ProcessSignalSemaphore(*pSignalInfo);
1651+
// Run submit time validation only if skip is not set. This is mostly for vvl testing,
1652+
// some tests expect that submit state is not updated if regular validation fails
1653+
if (!skip) {
1654+
skip |= submit_time_tracker.ProcessSignalSemaphore(*pSignalInfo);
1655+
}
16541656
return skip;
16551657
}
16561658

layers/core_checks/cc_wsi.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,9 +1263,11 @@ bool CoreChecks::PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentIn
12631263
skip |= ValidateSwapchainPresentFenceInfo(queue, *pPresentInfo, *swapchain_present_fence_info, present_info_loc);
12641264
}
12651265

1266-
// Perform submit time validation at the end.
1267-
// If present API is used incorrectly, we want those errors to be reported first
1268-
skip |= submit_time_tracker.ProcessPresent(*pPresentInfo, present_info_loc);
1266+
// Run submit time validation only if skip is not set. This is mostly for vvl testing,
1267+
// some tests expect that submit state is not updated if regular validation fails
1268+
if (!skip) {
1269+
skip |= submit_time_tracker.ProcessPresent(*pPresentInfo, present_info_loc);
1270+
}
12691271

12701272
return skip;
12711273
}

layers/core_checks/core_validation.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,8 +1587,9 @@ class CoreChecks : public vvl::DeviceProxy {
15871587
const RecordObject& record_obj) override;
15881588
void PostCallRecordQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence,
15891589
const RecordObject& record_obj) override;
1590-
bool ProcessSubmissionBatch(const std::vector<std::shared_ptr<vvl::CommandBuffer>>& command_buffers,
1591-
const Location& submit_loc) override;
1590+
bool ProcessSubmissionBatch(const vvl::SubmitTimeTracker& tracker,
1591+
const std::vector<std::shared_ptr<vvl::CommandBuffer>>& command_buffers,
1592+
vvl::span<const VkSemaphoreSubmitInfo> signal_semaphores, const Location& submit_loc) override;
15921593
bool ProcessPresentBatch(const vvl::Image& swapchain_image, const Location& present_info_loc) override;
15931594
bool IgnoreAllocationSize(const VkMemoryAllocateInfo& allocate_info) const;
15941595
bool HasExternalMemoryImportSupport(const vvl::Buffer& buffer, VkExternalMemoryHandleTypeFlagBits handle_type) const;

0 commit comments

Comments
 (0)