11/*
2- * Copyright 2019-2022 Diligent Graphics LLC
2+ * Copyright 2019-2025 Diligent Graphics LLC
33 * Copyright 2015-2019 Egor Yusov
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,8 +52,8 @@ FenceVkImpl::FenceVkImpl(IReferenceCounters* pRefCounters,
5252 if (m_Desc.Type == FENCE_TYPE_GENERAL &&
5353 pRenderDeviceVkImpl->GetFeatures ().NativeFence )
5454 {
55- const auto & LogicalDevice = pRenderDeviceVkImpl->GetLogicalDevice ();
56- m_TimelineSemaphore = LogicalDevice.CreateTimelineSemaphore (0 , m_Desc.Name );
55+ const VulkanUtilities::VulkanLogicalDevice & LogicalDevice{ pRenderDeviceVkImpl->GetLogicalDevice ()} ;
56+ m_TimelineSemaphore = LogicalDevice.CreateTimelineSemaphore (0 , m_Desc.Name );
5757 }
5858}
5959
@@ -110,9 +110,10 @@ Uint64 FenceVkImpl::GetCompletedValue()
110110 {
111111 // GetSemaphoreCounter() is thread safe
112112
113- const auto & LogicalDevice = m_pDevice->GetLogicalDevice ();
114- Uint64 SemaphoreCounter = ~Uint64{0 };
115- auto err = LogicalDevice.GetSemaphoreCounter (m_TimelineSemaphore, &SemaphoreCounter);
113+ const VulkanUtilities::VulkanLogicalDevice& LogicalDevice = m_pDevice->GetLogicalDevice ();
114+
115+ Uint64 SemaphoreCounter = ~Uint64{0 };
116+ VkResult err = LogicalDevice.GetSemaphoreCounter (m_TimelineSemaphore, &SemaphoreCounter);
116117 DEV_CHECK_ERR (err == VK_SUCCESS, " Failed to get timeline semaphore counter" );
117118 return SemaphoreCounter;
118119 }
@@ -127,12 +128,12 @@ Uint64 FenceVkImpl::InternalGetCompletedValue()
127128{
128129 VERIFY_EXPR (!IsTimelineSemaphore ());
129130
130- const auto & LogicalDevice = m_pDevice->GetLogicalDevice ();
131+ const VulkanUtilities::VulkanLogicalDevice & LogicalDevice = m_pDevice->GetLogicalDevice ();
131132 while (!m_SyncPoints.empty ())
132133 {
133- auto & Item = m_SyncPoints.front ();
134+ SyncPointData & Item = m_SyncPoints.front ();
134135
135- auto status = LogicalDevice.GetFenceStatus (Item.SyncPoint ->GetFence ());
136+ VkResult status = LogicalDevice.GetFenceStatus (Item.SyncPoint ->GetFence ());
136137 if (status == VK_SUCCESS)
137138 {
138139 UpdateLastCompletedFenceValue (Item.Value );
@@ -163,8 +164,9 @@ void FenceVkImpl::Signal(Uint64 Value)
163164 SignalInfo.semaphore = m_TimelineSemaphore;
164165 SignalInfo.value = Value;
165166
166- const auto & LogicalDevice = m_pDevice->GetLogicalDevice ();
167- auto err = LogicalDevice.SignalSemaphore (SignalInfo);
167+ const VulkanUtilities::VulkanLogicalDevice& LogicalDevice = m_pDevice->GetLogicalDevice ();
168+
169+ VkResult err = LogicalDevice.SignalSemaphore (SignalInfo);
168170 DEV_CHECK_ERR (err == VK_SUCCESS, " Failed to signal timeline semaphore" );
169171 }
170172 else
@@ -192,7 +194,7 @@ void FenceVkImpl::Wait(Uint64 Value)
192194{
193195 if (IsTimelineSemaphore ())
194196 {
195- const auto & LogicalDevice = m_pDevice->GetLogicalDevice ();
197+ const VulkanUtilities::VulkanLogicalDevice & LogicalDevice = m_pDevice->GetLogicalDevice ();
196198
197199 VkSemaphoreWaitInfo WaitInfo{};
198200 WaitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
@@ -202,22 +204,22 @@ void FenceVkImpl::Wait(Uint64 Value)
202204 WaitInfo.pSemaphores = &m_TimelineSemaphore;
203205 WaitInfo.pValues = &Value;
204206
205- auto err = LogicalDevice.WaitSemaphores (WaitInfo, UINT64_MAX);
207+ VkResult err = LogicalDevice.WaitSemaphores (WaitInfo, UINT64_MAX);
206208 DEV_CHECK_ERR (err == VK_SUCCESS, " Failed to wait timeline semaphore" );
207209 }
208210 else
209211 {
210212 std::lock_guard<std::mutex> Lock{m_SyncPointsGuard};
211213
212- const auto & LogicalDevice = m_pDevice->GetLogicalDevice ();
214+ const VulkanUtilities::VulkanLogicalDevice & LogicalDevice = m_pDevice->GetLogicalDevice ();
213215 while (!m_SyncPoints.empty ())
214216 {
215- auto & Item = m_SyncPoints.front ();
217+ SyncPointData & Item = m_SyncPoints.front ();
216218 if (Item.Value > Value)
217219 break ;
218220
219- VkFence Fence = Item.SyncPoint ->GetFence ();
220- auto status = LogicalDevice.GetFenceStatus (Fence);
221+ VkFence Fence = Item.SyncPoint ->GetFence ();
222+ VkResult status = LogicalDevice.GetFenceStatus (Fence);
221223 if (status == VK_NOT_READY)
222224 {
223225 status = LogicalDevice.WaitForFences (1 , &Fence, VK_TRUE, UINT64_MAX);
@@ -247,7 +249,7 @@ VulkanUtilities::VulkanRecycledSemaphore FenceVkImpl::ExtractSignalSemaphore(Sof
247249
248250#ifdef DILIGENT_DEVELOPMENT
249251 {
250- const auto LastValue = m_SyncPoints.empty () ? m_LastCompletedFenceValue.load () : m_SyncPoints.back ().Value ;
252+ const Uint64 LastValue = m_SyncPoints.empty () ? m_LastCompletedFenceValue.load () : m_SyncPoints.back ().Value ;
251253 DEV_CHECK_ERR (Value <= LastValue,
252254 " Can not wait for value " , Value, " that is greater than the last known value (" , LastValue,
253255 " ). Binary semaphore for these value is not enqueued for signal operation. " ,
@@ -258,7 +260,7 @@ VulkanUtilities::VulkanRecycledSemaphore FenceVkImpl::ExtractSignalSemaphore(Sof
258260 // Find the last non-null semaphore
259261 for (auto Iter = m_SyncPoints.begin (); Iter != m_SyncPoints.end (); ++Iter)
260262 {
261- auto SemaphoreForContext = Iter->SyncPoint ->ExtractSemaphore (CommandQueueId);
263+ VulkanUtilities::VulkanRecycledSemaphore SemaphoreForContext = Iter->SyncPoint ->ExtractSemaphore (CommandQueueId);
262264 if (SemaphoreForContext)
263265 Result = std::move (SemaphoreForContext);
264266
@@ -288,7 +290,7 @@ void FenceVkImpl::AddPendingSyncPoint(SoftwareQueueIndex CommandQueueId, Uint64
288290
289291#ifdef DILIGENT_DEVELOPMENT
290292 {
291- const auto LastValue = m_SyncPoints.empty () ? m_LastCompletedFenceValue.load () : m_SyncPoints.back ().Value ;
293+ const Uint64 LastValue = m_SyncPoints.empty () ? m_LastCompletedFenceValue.load () : m_SyncPoints.back ().Value ;
292294 DEV_CHECK_ERR (Value > LastValue,
293295 " New value (" , Value, " ) must be greater than previous value (" , LastValue, " )" );
294296 }
0 commit comments