2
0
Эх сурвалжийг харах

Fixing hardware buffer transfer default queue indices

BearishSun 9 жил өмнө
parent
commit
252c0e9f0a

+ 6 - 6
Source/BansheeCore/Include/BsHardwareBuffer.h

@@ -43,7 +43,7 @@ namespace BansheeEngine
 		 *							This value is a global queue index which encodes both the queue type and queue index.
 		 *							Retrieve it from CommandSyncMask::getGlobalQueueIdx().
 		 */
-		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 1)
+		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 0)
         {
             assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
             void* ret = map(offset, length, options, deviceIdx, queueIdx);
@@ -73,7 +73,7 @@ namespace BansheeEngine
 		 *							This value is a global queue index which encodes both the queue type and queue index.
 		 *							Retrieve it from CommandSyncMask::getGlobalQueueIdx().
 		 */
-        void* lock(GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 1)
+        void* lock(GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 0)
         {
             return this->lock(0, mSize, options, deviceIdx, queueIdx);
         }
@@ -105,7 +105,7 @@ namespace BansheeEngine
 		 *							This value is a global queue index which encodes both the queue type and queue index.
 		 *							Retrieve it from CommandSyncMask::getGlobalQueueIdx().
 		 */
-        virtual void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) = 0;
+        virtual void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) = 0;
 
 		/**
 		 * Writes data into a portion of the buffer from the source memory. 
@@ -126,7 +126,7 @@ namespace BansheeEngine
 		 *							Retrieve it from CommandSyncMask::getGlobalQueueIdx().
 		 */
         virtual void writeData(UINT32 offset, UINT32 length, const void* source,
-				BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) = 0;
+				BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) = 0;
 
 		/**
 		 * Copies data from a specific portion of the source buffer into a specific portion of this buffer.
@@ -149,7 +149,7 @@ namespace BansheeEngine
 		 *									index. Retrieve it from CommandSyncMask::getGlobalQueueIdx().
 		 */
 		virtual void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 1)
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 0)
 		{
 			const void *srcData = srcBuffer.lock(
 				srcOffset, length, GBL_READ_ONLY, queueIdx);
@@ -171,7 +171,7 @@ namespace BansheeEngine
 		 *							This value is a global queue index which encodes both the queue type and queue index.
 		 *							Retrieve it from CommandSyncMask::getGlobalQueueIdx().
 		 */
-		virtual void copyData(HardwareBuffer& srcBuffer, UINT32 queueIdx = 1)
+		virtual void copyData(HardwareBuffer& srcBuffer, UINT32 queueIdx = 0)
 		{
 			UINT32 sz = std::min(getSize(), srcBuffer.getSize());
 			copyData(srcBuffer, 0, 0, sz, true, queueIdx);

+ 4 - 4
Source/BansheeD3D11RenderAPI/Include/BsD3D11GpuBuffer.h

@@ -20,21 +20,21 @@ namespace BansheeEngine
 
 		/** @copydoc GpuBufferCore::lock */
 		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0,
-				   UINT32 queueIdx = 1) override;
+				   UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::unlock */
 		void unlock() override;
 
 		/** @copydoc GpuBufferCore::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::writeData */
         void writeData(UINT32 offset, UINT32 length, const void* pSource,
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 		/**
 		 * Creates a buffer view that may be used for binding a buffer to a slot in the pipeline. Views allow you to specify

+ 3 - 3
Source/BansheeD3D11RenderAPI/Include/BsD3D11HardwareBuffer.h

@@ -42,15 +42,15 @@ namespace BansheeEngine
 		~D3D11HardwareBuffer();
 
 		/** @copydoc HardwareBuffer::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc HardwareBuffer::writeData */
 		void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc HardwareBuffer::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, 
-			UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 		/**	Returns the internal DX11 buffer object. */
 		ID3D11Buffer* getD3DBuffer() const { return mD3DBuffer; }

+ 3 - 3
Source/BansheeD3D11RenderAPI/Include/BsD3D11IndexBuffer.h

@@ -21,15 +21,15 @@ namespace BansheeEngine
 		~D3D11IndexBufferCore();
 
 		/** @copydoc IndexBufferCore::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc IndexBufferCore::writeData */
 		void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc IndexBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length, 
-			bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 		/**	Gets the internal DX11 index buffer object. */
 		ID3D11Buffer* getD3DIndexBuffer() const { return mBuffer->getD3DBuffer(); }		

+ 3 - 3
Source/BansheeD3D11RenderAPI/Include/BsD3D11VertexBuffer.h

@@ -21,15 +21,15 @@ namespace BansheeEngine
 		~D3D11VertexBufferCore();
 
 		/** @copydoc VertexBufferCore::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc VertexBufferCore::writeData */
 		void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc VertexBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length, 
-			bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 		/**	Get the D3D-specific index buffer */
 		ID3D11Buffer* getD3DVertexBuffer() const { return mBuffer->getD3DBuffer(); }		

+ 4 - 4
Source/BansheeGLRenderAPI/Include/BsGLGpuBuffer.h

@@ -19,21 +19,21 @@ namespace BansheeEngine
 		~GLGpuBufferCore();
 
 		/** @copydoc GpuBufferCore::lock */
-		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 1) override;
+		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::unlock */
 		void unlock() override;
 
 		/** @copydoc GpuBufferCore::readData */
-        void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+        void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::writeData */
         void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+				BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset,
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 		/**	
 		 * Returns internal OpenGL buffer ID. If binding the buffer to the pipeline, bind the texture using

+ 2 - 2
Source/BansheeGLRenderAPI/Include/BsGLIndexBuffer.h

@@ -20,11 +20,11 @@ namespace BansheeEngine
 		~GLIndexBufferCore();
 
 		/** @copydoc IndexBufferCore::readData */
-        void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+        void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc IndexBufferCore::writeData */
         void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/**	Returns internal OpenGL index buffer handle. */
         GLuint getGLBufferId() const { return mBuffer.getGLBufferId(); }

+ 2 - 2
Source/BansheeGLRenderAPI/Include/BsGLVertexBuffer.h

@@ -21,11 +21,11 @@ namespace BansheeEngine
 		~GLVertexBufferCore();
 
 		/** @copydoc VertexBufferCore::readData */
-        void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+        void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc VertexBufferCore::writeData */
         void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/**	Returns internal OpenGL buffer ID. */
         GLuint getGLBufferId() const { return mBuffer.getGLBufferId(); }

+ 4 - 4
Source/BansheeVulkanRenderAPI/Include/BsVulkanGpuBuffer.h

@@ -18,21 +18,21 @@ namespace BansheeEngine
 		~VulkanGpuBufferCore();
 
 		/** @copydoc GpuBufferCore::lock */
-		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 1) override;
+		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::unlock */
 		void unlock() override;
 
 		/** @copydoc GpuBufferCore::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::writeData */
         void writeData(UINT32 offset, UINT32 length, const void* source,
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc GpuBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 		
 		/** 
 		 * Gets the resource wrapping the buffer object, on the specified device. If GPU param block buffer's device mask

+ 3 - 3
Source/BansheeVulkanRenderAPI/Include/BsVulkanHardwareBuffer.h

@@ -57,15 +57,15 @@ namespace BansheeEngine
 		~VulkanHardwareBuffer();
 
 		/** @copydoc HardwareBuffer::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc HardwareBuffer::writeData */
 		void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc HardwareBuffer::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, 
-			UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			UINT32 length, bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 		/** 
 		 * Gets the resource wrapping the buffer object, on the specified device. If hardware buffer device mask doesn't 

+ 3 - 3
Source/BansheeVulkanRenderAPI/Include/BsVulkanIndexBuffer.h

@@ -20,15 +20,15 @@ namespace BansheeEngine
 		~VulkanIndexBufferCore();
 
 		/** @copydoc IndexBufferCore::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc IndexBufferCore::writeData */
 		void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc IndexBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length, 
-			bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 	protected:
 		/** @copydoc IndexBufferCore::map */

+ 3 - 3
Source/BansheeVulkanRenderAPI/Include/BsVulkanVertexBuffer.h

@@ -19,15 +19,15 @@ namespace BansheeEngine
 		~VulkanVertexBufferCore();
 
 		/** @copydoc VertexBufferCore::readData */
-		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 1) override;
+		void readData(UINT32 offset, UINT32 length, void* dest, UINT32 queueIdx = 0) override;
 
 		/** @copydoc VertexBufferCore::writeData */
 		void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 1) override;
+			BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
 
 		/** @copydoc VertexBufferCore::copyData */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length, 
-			bool discardWholeBuffer = false, UINT32 queueIdx = 1) override;
+			bool discardWholeBuffer = false, UINT32 queueIdx = 0) override;
 
 	protected: 
 		/** @copydoc VertexBufferCore::map */

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

@@ -166,6 +166,7 @@ namespace BansheeEngine
 
 		// TODO - Special
 		//      - Keep a list of upload command buffers per queue to avoid allocating them
+		//        - Submit and clear all upload command buffers whenever new command buffer is submitted
 		//      - Can I easily determine sync mask of which buffers a resource is used on from VulkanResource?
 
 		switch (options)