Browse Source

VulkanHardwareBuffer now properly notifies the command buffer when it's queuing resources on it

BearishSun 9 years ago
parent
commit
976cae3a4d
1 changed files with 9 additions and 0 deletions
  1. 9 0
      Source/BansheeVulkanRenderAPI/Source/BsVulkanHardwareBuffer.cpp

+ 9 - 0
Source/BansheeVulkanRenderAPI/Source/BsVulkanHardwareBuffer.cpp

@@ -5,6 +5,7 @@
 #include "BsVulkanDevice.h"
 #include "BsVulkanDevice.h"
 #include "BsVulkanUtility.h"
 #include "BsVulkanUtility.h"
 #include "BsVulkanCommandBufferManager.h"
 #include "BsVulkanCommandBufferManager.h"
+#include "BsVulkanCommandBuffer.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -349,6 +350,10 @@ namespace BansheeEngine
 				// Queue copy command
 				// Queue copy command
 				mStagingBuffer->copy(transferCB, buffer, mMappedOffset, mMappedOffset, mMappedSize);
 				mStagingBuffer->copy(transferCB, buffer, mMappedOffset, mMappedOffset, mMappedSize);
 
 
+				// Notify the command buffer that these resources are being used on it
+				transferCB->getCB()->registerResource(mStagingBuffer, VK_ACCESS_TRANSFER_READ_BIT, VulkanUseFlag::Read);
+				transferCB->getCB()->registerResource(buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VulkanUseFlag::Write);
+
 				// We don't actually flush the transfer buffer here since it's an expensive operation, but it's instead
 				// We don't actually flush the transfer buffer here since it's an expensive operation, but it's instead
 				// done automatically before next "normal" command buffer submission.
 				// done automatically before next "normal" command buffer submission.
 			}
 			}
@@ -427,6 +432,10 @@ namespace BansheeEngine
 
 
 			src->copy(transferCB, dst, srcOffset, dstOffset, length);
 			src->copy(transferCB, dst, srcOffset, dstOffset, length);
 
 
+			// Notify the command buffer that these resources are being used on it
+			transferCB->getCB()->registerResource(src, VK_ACCESS_TRANSFER_READ_BIT, VulkanUseFlag::Read);
+			transferCB->getCB()->registerResource(dst, VK_ACCESS_TRANSFER_WRITE_BIT, VulkanUseFlag::Write);
+
 			// We don't actually flush the transfer buffer here since it's an expensive operation, but it's instead
 			// We don't actually flush the transfer buffer here since it's an expensive operation, but it's instead
 			// done automatically before next "normal" command buffer submission.
 			// done automatically before next "normal" command buffer submission.
 		}
 		}