瀏覽代碼

Vulkan render texture implementation

BearishSun 9 年之前
父節點
當前提交
81c38aea72

+ 9 - 10
Source/BansheeCore/Include/BsRenderTarget.h

@@ -65,20 +65,18 @@ namespace bs
 		RenderTargetProperties() { }
 		RenderTargetProperties() { }
 		virtual ~RenderTargetProperties() { }
 		virtual ~RenderTargetProperties() { }
 
 
-		/**
-		 * Returns width of the render target, in pixels.
-		 * 
-		 * @note	Sim thread only.
-		 */
+		/** Returns width of the render target, in pixels. */
         UINT32 getWidth() const { return mWidth; }
         UINT32 getWidth() const { return mWidth; }
 
 
-		/**
-		 * Returns height of the render target, in pixels.
-		 *
-		 * @note	Sim thread only.
-		 */
+		/** Returns height of the render target, in pixels. */
         UINT32 getHeight() const { return mHeight; }
         UINT32 getHeight() const { return mHeight; }
 
 
+		/** 
+		 * Returns the number of three dimensional slices of the render target. This will be the depth for 3D textures,
+		 * or number of layers for array textures.
+		 */
+        UINT32 getNumSlices() const { return mNumSlices; }
+
 		/** Gets the number of samples used for multisampling. (0 or 1 if multisampling is not used). */
 		/** Gets the number of samples used for multisampling. (0 or 1 if multisampling is not used). */
 		UINT32 getMultisampleCount() const { return mMultisampleCount; }
 		UINT32 getMultisampleCount() const { return mMultisampleCount; }
 
 
@@ -126,6 +124,7 @@ namespace bs
 
 
 		UINT32 mWidth = 0;
 		UINT32 mWidth = 0;
 		UINT32 mHeight = 0;
 		UINT32 mHeight = 0;
+		UINT32 mNumSlices = 0;
 		UINT32 mColorDepth = 32;
 		UINT32 mColorDepth = 32;
 
 
 		INT32 mPriority = 0;
 		INT32 mPriority = 0;

+ 4 - 4
Source/BansheeCore/Include/BsRenderTexture.h

@@ -30,7 +30,7 @@ namespace bs
 		virtual ~RenderTextureProperties() { }
 		virtual ~RenderTextureProperties() { }
 
 
 	private:
 	private:
-		void construct(const TextureProperties* textureProps, bool requiresFlipping);
+		void construct(const TextureProperties* textureProps, UINT32 numSlices, bool requiresFlipping);
 
 
 		friend class RenderTextureCore;
 		friend class RenderTextureCore;
 		friend class RenderTexture;
 		friend class RenderTexture;
@@ -121,14 +121,14 @@ namespace bs
 	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
 	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
 	{
 	{
 	public:
 	public:
-		RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask);
+		RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx);
 		virtual ~RenderTextureCore();
 		virtual ~RenderTextureCore();
 
 
 		/** @copydoc CoreObjectCore::initialize */
 		/** @copydoc CoreObjectCore::initialize */
 		void initialize() override;
 		void initialize() override;
 
 
-		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC_CORE&, GpuDeviceFlags) */
-		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask = GDF_DEFAULT);
+		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC_CORE&, UINT32) */
+		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx = 0);
 
 
 		/**
 		/**
 		 * Returns a color surface texture you may bind as an input to an GPU program.
 		 * Returns a color surface texture you may bind as an input to an GPU program.

+ 3 - 3
Source/BansheeCore/Include/BsTextureManager.h

@@ -103,10 +103,10 @@ namespace bs
 
 
 		/**
 		/**
 		 * @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) 
 		 * @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) 
-		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the object be created on.
+		 * @param[in]	deviceIdx		Index of the GPU device to create the object on.
 		 */
 		 */
 		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_DESC_CORE& desc, 
 		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_DESC_CORE& desc, 
-			GpuDeviceFlags deviceMask = GDF_DEFAULT);
+													UINT32 deviceIdx = 0);
 
 
 	protected:
 	protected:
 		friend class Texture;
 		friend class Texture;
@@ -122,7 +122,7 @@ namespace bs
 
 
 		/** @copydoc createRenderTexture */
 		/** @copydoc createRenderTexture */
 		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
-			GpuDeviceFlags deviceMask = GDF_DEFAULT) = 0;
+			UINT32 deviceIdx = 0) = 0;
     };
     };
 
 
 	/** @} */
 	/** @} */

+ 13 - 7
Source/BansheeCore/Source/BsRenderTexture.cpp

@@ -19,7 +19,7 @@ namespace bs
 			if (texture.isLoaded())
 			if (texture.isLoaded())
 			{
 			{
 				const TextureProperties& texProps = texture->getProperties();
 				const TextureProperties& texProps = texture->getProperties();
-				construct(&texProps, requiresFlipping);
+				construct(&texProps, desc.colorSurfaces[i].numFaces, requiresFlipping);
 
 
 				break;
 				break;
 			}
 			}
@@ -35,19 +35,20 @@ namespace bs
 			if (texture != nullptr)
 			if (texture != nullptr)
 			{
 			{
 				const TextureProperties& texProps = texture->getProperties();
 				const TextureProperties& texProps = texture->getProperties();
-				construct(&texProps, requiresFlipping);
+				construct(&texProps, desc.colorSurfaces[i].numFaces, requiresFlipping);
 
 
 				break;
 				break;
 			}
 			}
 		}
 		}
 	}
 	}
 
 
-	void RenderTextureProperties::construct(const TextureProperties* textureProps, bool requiresFlipping)
+	void RenderTextureProperties::construct(const TextureProperties* textureProps, UINT32 numSlices, bool requiresFlipping)
 	{
 	{
 		if (textureProps != nullptr)
 		if (textureProps != nullptr)
 		{
 		{
 			mWidth = textureProps->getWidth();
 			mWidth = textureProps->getWidth();
 			mHeight = textureProps->getHeight();
 			mHeight = textureProps->getHeight();
+			mNumSlices = numSlices;
 			mColorDepth = bs::PixelUtil::getNumElemBits(textureProps->getFormat());
 			mColorDepth = bs::PixelUtil::getNumElemBits(textureProps->getFormat());
 			mHwGamma = textureProps->isHardwareGammaEnabled();
 			mHwGamma = textureProps->isHardwareGammaEnabled();
 			mMultisampleCount = textureProps->getNumSamples();
 			mMultisampleCount = textureProps->getNumSamples();
@@ -58,7 +59,7 @@ namespace bs
 		mRequiresTextureFlipping = requiresFlipping;
 		mRequiresTextureFlipping = requiresFlipping;
 	}
 	}
 
 
-	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask)
+	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
 		:mDesc(desc)
 		:mDesc(desc)
 	{ }
 	{ }
 
 
@@ -106,9 +107,9 @@ namespace bs
 		throwIfBuffersDontMatch();
 		throwIfBuffersDontMatch();
 	}
 	}
 
 
-	SPtr<RenderTextureCore> RenderTextureCore::create(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask)
+	SPtr<RenderTextureCore> RenderTextureCore::create(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
 	{
 	{
-		return TextureCoreManager::instance().createRenderTexture(desc, deviceMask);
+		return TextureCoreManager::instance().createRenderTexture(desc, deviceIdx);
 	}
 	}
 
 
 	void RenderTextureCore::syncToCore(const CoreSyncData& data)
 	void RenderTextureCore::syncToCore(const CoreSyncData& data)
@@ -142,6 +143,9 @@ namespace bs
 			UINT32 curMsCount = curTexProps.getNumSamples();
 			UINT32 curMsCount = curTexProps.getNumSamples();
 			UINT32 firstMsCount = firstTexProps.getNumSamples();
 			UINT32 firstMsCount = firstTexProps.getNumSamples();
 
 
+			UINT32 curNumSlices = mColorSurfaces[i]->getNumArraySlices();
+			UINT32 firstNumSlices = firstSurfaceDesc->getNumArraySlices();
+
 			if (curMsCount == 0)
 			if (curMsCount == 0)
 				curMsCount = 1;
 				curMsCount = 1;
 
 
@@ -150,10 +154,12 @@ namespace bs
 
 
 			if (curTexProps.getWidth() != firstTexProps.getWidth() ||
 			if (curTexProps.getWidth() != firstTexProps.getWidth() ||
 				curTexProps.getHeight() != firstTexProps.getHeight() ||
 				curTexProps.getHeight() != firstTexProps.getHeight() ||
-				curMsCount != firstMsCount)
+				curMsCount != firstMsCount ||
+				curNumSlices != firstNumSlices)
 			{
 			{
 				String errorInfo = "\nWidth: " + toString(curTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
 				String errorInfo = "\nWidth: " + toString(curTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
 				errorInfo += "\nHeight: " + toString(curTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
 				errorInfo += "\nHeight: " + toString(curTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
+				errorInfo += "\nNum. slices: " + toString(curNumSlices) + "/" + toString(firstNumSlices);
 				errorInfo += "\nMultisample Count: " + toString(curMsCount) + "/" + toString(firstMsCount);
 				errorInfo += "\nMultisample Count: " + toString(curMsCount) + "/" + toString(firstMsCount);
 
 
 				BS_EXCEPT(InvalidParametersException, "Provided color textures don't match!" + errorInfo);
 				BS_EXCEPT(InvalidParametersException, "Provided color textures don't match!" + errorInfo);

+ 2 - 2
Source/BansheeCore/Source/BsTextureManager.cpp

@@ -146,9 +146,9 @@ namespace bs
 	}
 	}
 
 
 	SPtr<RenderTextureCore> TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC_CORE& desc, 
 	SPtr<RenderTextureCore> TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC_CORE& desc, 
-		GpuDeviceFlags deviceMask)
+																	UINT32 deviceIdx)
 	{
 	{
-		SPtr<RenderTextureCore> newRT = createRenderTextureInternal(desc, deviceMask);
+		SPtr<RenderTextureCore> newRT = createRenderTextureInternal(desc, deviceIdx);
 		newRT->initialize();
 		newRT->initialize();
 
 
 		return newRT;
 		return newRT;

+ 1 - 1
Source/BansheeD3D11RenderAPI/Include/BsD3D11RenderTexture.h

@@ -22,7 +22,7 @@ namespace bs
 	class D3D11RenderTextureCore : public RenderTextureCore
 	class D3D11RenderTextureCore : public RenderTextureCore
 	{
 	{
 	public:
 	public:
-		D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask);
+		D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx);
 		virtual ~D3D11RenderTextureCore() { }
 		virtual ~D3D11RenderTextureCore() { }
 
 
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		/** @copydoc RenderTextureCore::getCustomAttribute */

+ 1 - 1
Source/BansheeD3D11RenderAPI/Include/BsD3D11TextureManager.h

@@ -33,7 +33,7 @@ namespace bs
 
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
-			GpuDeviceFlags deviceMask = GDF_DEFAULT) override;
+			UINT32 deviceIdx = 0) override;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 3 - 3
Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderTexture.cpp

@@ -5,10 +5,10 @@
 
 
 namespace bs
 namespace bs
 {
 {
-	D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask)
-		:RenderTextureCore(desc, deviceMask), mProperties(desc, false)
+	D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
+		:RenderTextureCore(desc, deviceIdx), mProperties(desc, false)
 	{ 
 	{ 
-		assert((deviceMask == GDF_DEFAULT || deviceMask == GDF_PRIMARY) && "Multiple GPUs not supported natively on DirectX 11.");
+		assert(deviceIdx == 0 && "Multiple GPUs not supported natively on DirectX 11.");
 	}
 	}
 
 
 	void D3D11RenderTextureCore::getCustomAttribute(const String& name, void* data) const
 	void D3D11RenderTextureCore::getCustomAttribute(const String& name, void* data) const

+ 2 - 2
Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureManager.cpp

@@ -35,9 +35,9 @@ namespace bs
 	}
 	}
 
 
 	SPtr<RenderTextureCore> D3D11TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc,
 	SPtr<RenderTextureCore> D3D11TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc,
-		GpuDeviceFlags deviceMask)
+																				 UINT32 deviceIdx)
 	{
 	{
-		SPtr<D3D11RenderTextureCore> texPtr = bs_shared_ptr_new<D3D11RenderTextureCore>(desc, deviceMask);
+		SPtr<D3D11RenderTextureCore> texPtr = bs_shared_ptr_new<D3D11RenderTextureCore>(desc, deviceIdx);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
 
 
 		return texPtr;
 		return texPtr;

+ 1 - 1
Source/BansheeGLRenderAPI/Include/BsGLRenderTexture.h

@@ -25,7 +25,7 @@ namespace bs
     class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
     class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
     {
     {
 	public:
 	public:
-		GLRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask);
+		GLRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx);
 		virtual ~GLRenderTextureCore();
 		virtual ~GLRenderTextureCore();
 
 
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		/** @copydoc RenderTextureCore::getCustomAttribute */

+ 1 - 1
Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h

@@ -45,7 +45,7 @@ namespace bs
 
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
-			GpuDeviceFlags deviceMask = GDF_DEFAULT) override;
+			UINT32 deviceIdx = 0) override;
 
 
 		GLSupport& mGLSupport;
 		GLSupport& mGLSupport;
 	};
 	};

+ 3 - 3
Source/BansheeGLRenderAPI/Source/BsGLRenderTexture.cpp

@@ -20,10 +20,10 @@ namespace bs
 
 
 #define DEPTHFORMAT_COUNT (sizeof(depthFormats)/sizeof(GLenum))
 #define DEPTHFORMAT_COUNT (sizeof(depthFormats)/sizeof(GLenum))
 
 
-	GLRenderTextureCore::GLRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask)
-		:RenderTextureCore(desc, deviceMask), mProperties(desc, true), mFB(nullptr)
+	GLRenderTextureCore::GLRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
+		:RenderTextureCore(desc, deviceIdx), mProperties(desc, true), mFB(nullptr)
 	{
 	{
-		assert((deviceMask == GDF_DEFAULT || deviceMask == GDF_PRIMARY) && "Multiple GPUs not supported natively on OpenGL.");
+		assert(deviceIdx == 0 && "Multiple GPUs not supported natively on OpenGL.");
 	}
 	}
 
 
 	GLRenderTextureCore::~GLRenderTextureCore()
 	GLRenderTextureCore::~GLRenderTextureCore()

+ 2 - 2
Source/BansheeGLRenderAPI/Source/BsGLTextureManager.cpp

@@ -50,9 +50,9 @@ namespace bs
 	}
 	}
 
 
 	SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 	SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
-		GpuDeviceFlags deviceMask)
+																			  UINT32 deviceIdx)
 	{
 	{
-		SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr_new<GLRenderTextureCore>(desc, deviceMask);
+		SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr_new<GLRenderTextureCore>(desc, deviceIdx);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
 
 
 		return texPtr;
 		return texPtr;

+ 7 - 2
Source/BansheeVulkanRenderAPI/Include/BsVulkanRenderTexture.h

@@ -22,17 +22,22 @@ namespace bs
 	class VulkanRenderTextureCore : public RenderTextureCore
 	class VulkanRenderTextureCore : public RenderTextureCore
 	{
 	{
 	public:
 	public:
-		VulkanRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask);
-		virtual ~VulkanRenderTextureCore() { }
+		VulkanRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx);
+		virtual ~VulkanRenderTextureCore();
 
 
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		void getCustomAttribute(const String& name, void* data) const override;
 		void getCustomAttribute(const String& name, void* data) const override;
 
 
 	protected:
 	protected:
+		/** @copydoc CoreObjectCore::initialize() */
+		void initialize() override;
+
 		/** @copydoc RenderTextureCore::getProperties */
 		/** @copydoc RenderTextureCore::getProperties */
 		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
 		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
 
 
 		RenderTextureProperties mProperties;
 		RenderTextureProperties mProperties;
+		UINT32 mDeviceIdx;
+		VulkanFramebuffer* mFramebuffer;
 	};
 	};
 
 
 	/**
 	/**

+ 1 - 1
Source/BansheeVulkanRenderAPI/Include/BsVulkanTextureManager.h

@@ -33,7 +33,7 @@ namespace bs
 
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
-			GpuDeviceFlags deviceMask = GDF_DEFAULT) override;
+			UINT32 deviceIdx = 0) override;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 65 - 10
Source/BansheeVulkanRenderAPI/Source/BsVulkanRenderTexture.cpp

@@ -1,28 +1,83 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsVulkanRenderTexture.h"
 #include "BsVulkanRenderTexture.h"
+#include "BsVulkanFramebuffer.h"
+#include "BsVulkanTexture.h"
+#include "BsVulkanUtility.h"
+#include "BsVulkanRenderAPI.h"
+#include "BsVulkanDevice.h"
 
 
 namespace bs
 namespace bs
 {
 {
-	VulkanRenderTextureCore::VulkanRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, GpuDeviceFlags deviceMask)
-		:RenderTextureCore(desc, deviceMask), mProperties(desc, false)
+	VulkanRenderTextureCore::VulkanRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
+		:RenderTextureCore(desc, deviceIdx), mProperties(desc, false), mDeviceIdx(deviceIdx), mFramebuffer(nullptr)
 	{
 	{
 		
 		
 	}
 	}
 
 
-	void VulkanRenderTextureCore::getCustomAttribute(const String& name, void* data) const
+	VulkanRenderTextureCore::~VulkanRenderTextureCore()
 	{
 	{
-		if (name == "FB")
+		mFramebuffer->destroy();
+	}
+
+	void VulkanRenderTextureCore::initialize()
+	{
+		RenderTextureCore::initialize();
+
+		VULKAN_FRAMEBUFFER_DESC fbDesc;
+		fbDesc.width = mProperties.getWidth();
+		fbDesc.height = mProperties.getHeight();
+		fbDesc.layers = mProperties.getNumSlices();
+		fbDesc.numSamples = mProperties.getMultisampleCount() > 1 ? mProperties.getMultisampleCount() : 1;
+		fbDesc.offscreen = true;
+
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; ++i)
 		{
 		{
-			VkFramebuffer* fb = (VkFramebuffer*)data;
-			// TODO - Assign framebuffer
-			return;
+			if (mColorSurfaces[i] == nullptr)
+				continue;
+
+			const SPtr<TextureView>& view = mColorSurfaces[i];
+			VulkanTextureCore* texture = static_cast<VulkanTextureCore*>(view->getTexture().get());
+
+			TextureSurface surface;
+			surface.arraySlice = view->getFirstArraySlice();
+			surface.numArraySlices = view->getNumArraySlices();
+			surface.mipLevel = view->getMostDetailedMip();
+			surface.numMipLevels = view->getNumMips();
+
+			fbDesc.color[i].view = texture->getView(mDeviceIdx, surface);
+			fbDesc.color[i].format = VulkanUtility::getPixelFormat(texture->getProperties().getFormat());
+			fbDesc.color[i].baseLayer = view->getFirstArraySlice();
 		}
 		}
 
 
-		if (name == "RP")
+		if(mDepthStencilSurface != nullptr)
+		{
+			const SPtr<TextureView>& view = mDepthStencilSurface;
+			VulkanTextureCore* texture = static_cast<VulkanTextureCore*>(view->getTexture().get());
+
+			TextureSurface surface;
+			surface.arraySlice = view->getFirstArraySlice();
+			surface.numArraySlices = view->getNumArraySlices();
+			surface.mipLevel = view->getMostDetailedMip();
+			surface.numMipLevels = view->getNumMips();
+
+			fbDesc.depth.view = texture->getView(mDeviceIdx, surface);
+			fbDesc.depth.format = VulkanUtility::getPixelFormat(texture->getProperties().getFormat());
+			fbDesc.depth.baseLayer = view->getFirstArraySlice();
+		}
+
+		VulkanRenderAPI& rapi = static_cast<VulkanRenderAPI&>(RenderAPICore::instance());
+		SPtr<VulkanDevice> device = rapi._getDevice(mDeviceIdx);
+
+		mFramebuffer = device->getResourceManager().create<VulkanFramebuffer>(fbDesc);
+	}
+
+	void VulkanRenderTextureCore::getCustomAttribute(const String& name, void* data) const
+	{
+		if (name == "FB")
 		{
 		{
-			VkRenderPass* renderPass = (VkRenderPass*)data;
-			// TODO - Assign render pass
+			VulkanFramebuffer** fb = (VulkanFramebuffer**)data;
+			*fb = mFramebuffer;
 			return;
 			return;
 		}
 		}
 	}
 	}

+ 2 - 2
Source/BansheeVulkanRenderAPI/Source/BsVulkanTextureManager.cpp

@@ -30,9 +30,9 @@ namespace bs
 	}
 	}
 
 
 	SPtr<RenderTextureCore> VulkanTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc,
 	SPtr<RenderTextureCore> VulkanTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc,
-		GpuDeviceFlags deviceMask)
+																				  UINT32 deviceIdx)
 	{
 	{
-		SPtr<VulkanRenderTextureCore> texPtr = bs_shared_ptr_new<VulkanRenderTextureCore>(desc, deviceMask);
+		SPtr<VulkanRenderTextureCore> texPtr = bs_shared_ptr_new<VulkanRenderTextureCore>(desc, deviceIdx);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
 
 
 		return texPtr;
 		return texPtr;