Skip to content

Commit 82e4be3

Browse files
committed
sync: Misc cleanup
1 parent 62ee3b0 commit 82e4be3

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

layers/sync/sync_submit.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
namespace syncval {
2424

2525
AcquiredImage::AcquiredImage(const PresentedImage& presented, ResourceUsageTag acq_tag)
26-
: image(presented.image), generator(presented.range_gen), present_tag(presented.tag), acquire_tag(acq_tag) {}
27-
28-
bool AcquiredImage::Invalid() const { return vvl::StateObject::Invalid(image); }
26+
: image(presented.image), generator(presented.range_gen), acquire_tag(acq_tag), present_tag(presented.tag) {}
2927

3028
SignalInfo::SignalInfo(const std::shared_ptr<const vvl::Semaphore>& semaphore_state, const BatchContextPtr& batch,
3129
const SyncExecScope& exec_scope, uint64_t timeline_value)
@@ -929,7 +927,7 @@ PresentedImage::PresentedImage(std::shared_ptr<vvl::Swapchain>&& swapchain, uint
929927
bool PresentedImage::Invalid() const { return vvl::StateObject::Invalid(image); }
930928

931929
// Export uses move semantics...
932-
void PresentedImage::ExportToSwapchain(SyncValidator&) { // Include this argument to prove the const cast is safe
930+
void PresentedImage::ExportToSwapchain() {
933931
// If the swapchain is dead just ignore the present
934932
auto swap_lock = swapchain_state.lock();
935933
if (vvl::StateObject::Invalid(swap_lock)) return;

layers/sync/sync_submit.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ using CommandBufferConstPtr = std::shared_ptr<const vvl::CommandBuffer>;
3939
struct AcquiredImage {
4040
std::shared_ptr<const vvl::Image> image;
4141
subresource_adapter::ImageRangeGenerator generator;
42-
ResourceUsageTag present_tag;
42+
43+
// Tag of the image acquire operation
4344
ResourceUsageTag acquire_tag;
44-
bool Invalid() const;
45+
46+
// Last present before the acquire operation above.
47+
// kInvalidTag if the image has never been presented
48+
ResourceUsageTag present_tag;
4549

4650
AcquiredImage() = default;
47-
AcquiredImage(const PresentedImage &presented, ResourceUsageTag acq_tag);
51+
AcquiredImage(const PresentedImage& presented, ResourceUsageTag acquire_tag);
4852
};
4953

5054
// Information associated with a semaphore signal
@@ -171,7 +175,7 @@ struct PresentedImage : public PresentedImageRecord {
171175
// For non-previsously presented images..
172176
PresentedImage(std::shared_ptr<vvl::Swapchain> &&swapchain, uint32_t at_index);
173177
bool Invalid() const;
174-
void ExportToSwapchain(SyncValidator &);
178+
void ExportToSwapchain();
175179
void SetImage(uint32_t at_index);
176180
};
177181
using PresentedImages = std::vector<PresentedImage>;

layers/sync/sync_validation.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void SyncValidator::WaitForFence(VkFence fence) {
253253
FenceHostSyncPoint& wait_for = fence_it->second;
254254
if (wait_for.queue_id != kQueueIdInvalid) {
255255
ApplyTaggedWait(wait_for.queue_id, wait_for.tag, {}, wait_for.queue_sync_tags);
256-
} else if (!wait_for.acquired.Invalid()) {
256+
} else if (!vvl::StateObject::Invalid(wait_for.acquired.image)) {
257257
ApplyAcquireWait(wait_for.acquired);
258258
}
259259
waitable_fences_.erase(fence_it);
@@ -2248,8 +2248,9 @@ void SyncValidator::PostCallRecordDeviceWaitIdle(VkDevice device, const RecordOb
22482248
// The last signal is needed to represent the current timeline state.
22492249
EnsureTimelineSignalsLimit(1);
22502250

2251-
// As we we've waited for everything on device, any waits are mooted. (except for acquires)
2252-
vvl::EraseIf(waitable_fences_, [](const auto& waitable) { return waitable.second.acquired.Invalid(); });
2251+
// Cleanup fence waits associated with queues. Acquire fence waits are preserved
2252+
auto is_queue_fence = [](const auto& waitable) { return waitable.second.queue_id != kQueueIdInvalid; };
2253+
vvl::EraseIf(waitable_fences_, is_queue_fence);
22532254
host_waitable_semaphores_.clear();
22542255
}
22552256

@@ -2312,7 +2313,7 @@ bool SyncValidator::ProcessQueuePresent(VkQueue queue, const VkPresentInfoKHR* p
23122313
queue_state.SetLastBatch(std::move(batch));
23132314
ApplySignalsUpdate(signals_update, queue_state.LastBatch());
23142315
for (auto& presented : presented_images) {
2315-
presented.ExportToSwapchain(*this);
2316+
presented.ExportToSwapchain();
23162317
}
23172318
}
23182319
return skip;

0 commit comments

Comments
 (0)