Browse Source

Fix bugs in fence and semaphore waits. Async compute should be working now

Panagiotis Christopoulos Charitos 4 years ago
parent
commit
9518f993eb

+ 7 - 3
AnKi/Gr/Vulkan/Common.h

@@ -84,9 +84,13 @@ ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(QueueType)
 
 /// @name Constants
 /// @{
-const U DESCRIPTOR_POOL_INITIAL_SIZE = 64;
-const F32 DESCRIPTOR_POOL_SIZE_SCALE = 2.0;
-const U DESCRIPTOR_FRAME_BUFFERING = 60 * 5; ///< How many frames worth of descriptors to buffer.
+constexpr U DESCRIPTOR_POOL_INITIAL_SIZE = 64;
+constexpr F32 DESCRIPTOR_POOL_SIZE_SCALE = 2.0f;
+constexpr U DESCRIPTOR_FRAME_BUFFERING = 60 * 5; ///< How many frames worth of descriptors to buffer.
+
+/// There is no need to ask for a fence or a semaphore to be waited for more than 10 seconds. The GPU will timeout
+/// anyway.
+constexpr Second MAX_FENCE_OR_SEMAPHORE_WAIT_TIME = 10.0;
 /// @}
 
 /// Some internal buffer usage flags.

+ 1 - 3
AnKi/Gr/Vulkan/FenceFactory.h

@@ -42,9 +42,7 @@ public:
 
 	void wait()
 	{
-		// This is supposed to wait forever. Don't do that. If someone has to wait for more than 5 seconds then
-		// something is wrong
-		const Bool timeout = !clientWait(5.0);
+		const Bool timeout = !clientWait(MAX_SECOND);
 		if(ANKI_UNLIKELY(timeout))
 		{
 			ANKI_VK_LOGF("Waiting for a fence timed out");

+ 2 - 0
AnKi/Gr/Vulkan/FenceFactory.inl.h

@@ -52,6 +52,8 @@ inline Bool MicroFence::clientWait(Second seconds)
 	}
 	else
 	{
+		seconds = min(seconds, MAX_FENCE_OR_SEMAPHORE_WAIT_TIME);
+
 		const F64 nsf = 1e+9 * seconds;
 		const U64 ns = U64(nsf);
 		VkResult res;

+ 2 - 0
AnKi/Gr/Vulkan/SemaphoreFactory.inl.h

@@ -47,6 +47,8 @@ inline Bool MicroSemaphore::clientWait(Second seconds)
 {
 	ANKI_ASSERT(m_isTimeline);
 
+	seconds = min(seconds, MAX_FENCE_OR_SEMAPHORE_WAIT_TIME);
+
 	VkSemaphoreWaitInfo waitInfo = {};
 	waitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
 	waitInfo.semaphoreCount = 1;