Prechádzať zdrojové kódy

Render texture now keeps a handle to a texture instead of a pointer

Marko Pintera 11 rokov pred
rodič
commit
0b1d2c1bd9
39 zmenil súbory, kde vykonal 259 pridanie a 145 odobranie
  1. 1 0
      BansheeCore/Include/BsCorePrerequisites.h
  2. 16 2
      BansheeCore/Include/BsMultiRenderTexture.h
  3. 13 1
      BansheeCore/Include/BsRenderTarget.h
  4. 20 5
      BansheeCore/Include/BsRenderTexture.h
  5. 10 10
      BansheeCore/Include/BsTexture.h
  6. 5 4
      BansheeCore/Include/BsTextureManager.h
  7. 1 1
      BansheeCore/Include/BsTextureRTTI.h
  8. 58 19
      BansheeCore/Source/BsMultiRenderTexture.cpp
  9. 49 16
      BansheeCore/Source/BsRenderTexture.cpp
  10. 30 32
      BansheeCore/Source/BsTexture.cpp
  11. 5 5
      BansheeCore/Source/BsTextureManager.cpp
  12. 1 1
      BansheeD3D11RenderSystem/Include/BsD3D11MultiRenderTexture.h
  13. 1 1
      BansheeD3D11RenderSystem/Include/BsD3D11RenderTexture.h
  14. 2 2
      BansheeD3D11RenderSystem/Include/BsD3D11TextureManager.h
  15. 1 1
      BansheeD3D11RenderSystem/Source/BsD3D11MultiRenderTexture.cpp
  16. 1 1
      BansheeD3D11RenderSystem/Source/BsD3D11RenderTexture.cpp
  17. 2 2
      BansheeD3D11RenderSystem/Source/BsD3D11TextureManager.cpp
  18. 1 1
      BansheeD3D9RenderSystem/Include/BsD3D9MultiRenderTexture.h
  19. 1 1
      BansheeD3D9RenderSystem/Include/BsD3D9RenderTexture.h
  20. 2 2
      BansheeD3D9RenderSystem/Include/BsD3D9TextureManager.h
  21. 1 1
      BansheeD3D9RenderSystem/Source/BsD3D9MultiRenderTexture.cpp
  22. 1 1
      BansheeD3D9RenderSystem/Source/BsD3D9RenderTexture.cpp
  23. 2 2
      BansheeD3D9RenderSystem/Source/BsD3D9TextureManager.cpp
  24. 3 3
      BansheeEditor/Source/BsScenePicking.cpp
  25. 10 10
      BansheeEngine/Source/BsBuiltinResources.cpp
  26. 2 2
      BansheeEngine/Source/BsGUIManager.cpp
  27. 1 1
      BansheeFontImporter/Source/BsFontImporter.cpp
  28. 1 1
      BansheeFreeImgImporter/Source/BsFreeImgImporter.cpp
  29. 1 1
      BansheeGLRenderSystem/Include/BsGLMultiRenderTexture.h
  30. 1 1
      BansheeGLRenderSystem/Include/BsGLRenderTexture.h
  31. 2 2
      BansheeGLRenderSystem/Include/BsGLTextureManager.h
  32. 1 1
      BansheeGLRenderSystem/Source/BsGLMultiRenderTexture.cpp
  33. 1 1
      BansheeGLRenderSystem/Source/BsGLRenderTexture.cpp
  34. 2 2
      BansheeGLRenderSystem/Source/BsGLTextureManager.cpp
  35. 3 3
      SBansheeEngine/Source/BsScriptRenderTexture2D.cpp
  36. 2 2
      SBansheeEngine/Source/BsScriptTexture2D.cpp
  37. 2 2
      SBansheeEngine/Source/BsScriptTexture3D.cpp
  38. 2 2
      SBansheeEngine/Source/BsScriptTextureCube.cpp
  39. 1 0
      TODO.txt

+ 1 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -158,6 +158,7 @@ namespace BansheeEngine
 	class MaterialCore;
 	class MaterialCore;
 	class GpuProgramCore;
 	class GpuProgramCore;
 	class IResourceListener;
 	class IResourceListener;
+	class TextureProperties;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;
 	class Importer;
 	class Importer;

+ 16 - 2
BansheeCore/Include/BsMultiRenderTexture.h

@@ -16,6 +16,17 @@ namespace BansheeEngine
 		RENDER_SURFACE_DESC depthStencilSurface;
 		RENDER_SURFACE_DESC depthStencilSurface;
 	};
 	};
 
 
+	/**
+	 * @see		MULTI_RENDER_TEXTURE_DESC
+	 *
+	 * @note	References core textures instead of texture handles.
+	 */
+	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_CORE_DESC
+	{
+		Vector<RENDER_SURFACE_CORE_DESC> colorSurfaces;
+		RENDER_SURFACE_CORE_DESC depthStencilSurface;
+	};
+
 	/**
 	/**
 	 * @brief	Contains various properties that describe a render texture.
 	 * @brief	Contains various properties that describe a render texture.
 	 */
 	 */
@@ -23,11 +34,14 @@ namespace BansheeEngine
 	{
 	{
 	public:
 	public:
 		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc);
 		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc);
+		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~MultiRenderTextureProperties() { }
 		virtual ~MultiRenderTextureProperties() { }
 
 
 	protected:
 	protected:
 		friend class MultiRenderTextureCore;
 		friend class MultiRenderTextureCore;
 		friend class MultiRenderTexture;
 		friend class MultiRenderTexture;
+
+		void construct(const TextureProperties* props);
 	};
 	};
 
 
 	/**
 	/**
@@ -52,7 +66,7 @@ namespace BansheeEngine
 		const MultiRenderTextureProperties& getProperties() const;
 		const MultiRenderTextureProperties& getProperties() const;
 
 
 	protected:
 	protected:
-		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc);
+		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		/**
 		/**
 		 * @copydoc	CoreObjectCore::syncFromCore
 		 * @copydoc	CoreObjectCore::syncFromCore
@@ -78,7 +92,7 @@ namespace BansheeEngine
 		Vector<TextureViewPtr> mColorSurfaces;
 		Vector<TextureViewPtr> mColorSurfaces;
 		TextureViewPtr mDepthStencilSurface;
 		TextureViewPtr mDepthStencilSurface;
 
 
-		MULTI_RENDER_TEXTURE_DESC mDesc;
+		MULTI_RENDER_TEXTURE_CORE_DESC mDesc;
 	};
 	};
 
 
 	/**
 	/**

+ 13 - 1
BansheeCore/Include/BsRenderTarget.h

@@ -14,7 +14,19 @@ namespace BansheeEngine
 	 */
 	 */
 	struct BS_CORE_EXPORT RENDER_SURFACE_DESC
 	struct BS_CORE_EXPORT RENDER_SURFACE_DESC
 	{
 	{
-		TexturePtr texture;
+		HTexture texture;
+		UINT32 face;
+		UINT32 mipLevel;
+	};
+
+	/**
+	 * @see		RENDER_SURFACE_DESC
+	 *
+	 * @note	References core textures instead of texture handles.
+	 */
+	struct BS_CORE_EXPORT RENDER_SURFACE_CORE_DESC
+	{
+		SPtr<TextureCore> texture;
 		UINT32 face;
 		UINT32 face;
 		UINT32 mipLevel;
 		UINT32 mipLevel;
 	};
 	};

+ 20 - 5
BansheeCore/Include/BsRenderTexture.h

@@ -15,6 +15,17 @@ namespace BansheeEngine
 		RENDER_SURFACE_DESC depthStencilSurface;
 		RENDER_SURFACE_DESC depthStencilSurface;
 	};
 	};
 
 
+	/**
+	 * @see		RENDER_TEXTURE_DESC
+	 *
+	 * @note	References core textures instead of texture handles.
+	 */
+	struct BS_CORE_EXPORT RENDER_TEXTURE_CORE_DESC
+	{
+		RENDER_SURFACE_CORE_DESC colorSurface;
+		RENDER_SURFACE_CORE_DESC depthStencilSurface;
+	};
+
 	/**
 	/**
 	 * @brief	Contains various properties that describe a render texture.
 	 * @brief	Contains various properties that describe a render texture.
 	 */
 	 */
@@ -22,9 +33,12 @@ namespace BansheeEngine
 	{
 	{
 	public:
 	public:
 		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
 		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
+		RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping);
 		virtual ~RenderTextureProperties() { }
 		virtual ~RenderTextureProperties() { }
 
 
 	private:
 	private:
+		void construct(const TextureProperties* textureProps, bool requiresFlipping);
+
 		friend class RenderTextureCore;
 		friend class RenderTextureCore;
 		friend class RenderTexture;
 		friend class RenderTexture;
 	};
 	};
@@ -37,7 +51,7 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
 	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
 	{
 	{
 	public:
 	public:
-		RenderTextureCore(const RENDER_TEXTURE_DESC& desc);
+		RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~RenderTextureCore();
 		virtual ~RenderTextureCore();
 
 
 		/**
 		/**
@@ -50,14 +64,15 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
-		const TexturePtr& getBindableColorTexture() const { return mDesc.colorSurface.texture; }
+		SPtr<TextureCore> getBindableColorTexture() const { return mDesc.colorSurface.texture; }
 
 
 		/**
 		/**
 		 * @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
 		 * @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
 		 *
 		 *
-		 * @note		Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
-		const TexturePtr& getBindableDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
+		SPtr<TextureCore> getBindableDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
+
 
 
 		/**
 		/**
 		 * @brief	Returns properties that describe the render texture.
 		 * @brief	Returns properties that describe the render texture.
@@ -87,7 +102,7 @@ namespace BansheeEngine
 		TextureViewPtr mColorSurface;
 		TextureViewPtr mColorSurface;
 		TextureViewPtr mDepthStencilSurface;
 		TextureViewPtr mDepthStencilSurface;
 
 
-		RENDER_TEXTURE_DESC mDesc;
+		RENDER_TEXTURE_CORE_DESC mDesc;
 	};
 	};
 
 
 	/**
 	/**

+ 10 - 10
BansheeCore/Include/BsTexture.h

@@ -128,6 +128,16 @@ namespace BansheeEngine
 		 */
 		 */
 		UINT32 mapToSubresourceIdx(UINT32 face, UINT32 mip) const;
 		UINT32 mapToSubresourceIdx(UINT32 face, UINT32 mip) const;
 
 
+		/**
+		 * @brief	Allocates a buffer you may use for storage when reading or writing a sub-resource. You
+		 * 			need to allocate such a buffer if you are calling "readSubresource".
+		 *
+		 *			You can retrieve a sub-resource index by calling "mapToSubresourceIdx".
+		 * 			
+		 * @note	Thread safe.
+		 */
+		PixelDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
+
 	protected:
 	protected:
 		friend class TextureRTTI;
 		friend class TextureRTTI;
 
 
@@ -348,16 +358,6 @@ namespace BansheeEngine
 		 */
 		 */
 		AsyncOp readSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const PixelDataPtr& data);
 		AsyncOp readSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const PixelDataPtr& data);
 
 
-		/**
-		 * @brief	Allocates a buffer you may use for storage when reading or writing a sub-resource. You
-		 * 			need to allocate such a buffer if you are calling "readSubresource".
-		 *
-		 *			You can retrieve a sub-resource index by calling "mapToSubresourceIdx".
-		 * 			
-		 * @note	Thread safe.
-		 */
-		PixelDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
-
 		/**
 		/**
 		 * @brief	Reads data from the cached system memory texture buffer into the provided buffer. 
 		 * @brief	Reads data from the cached system memory texture buffer into the provided buffer. 
 		 * 		  
 		 * 		  

+ 5 - 4
BansheeCore/Include/BsTextureManager.h

@@ -3,6 +3,7 @@
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 
 
 #include "BsTexture.h"
 #include "BsTexture.h"
+#include "BsRenderTexture.h"
 #include "BsMultiRenderTexture.h"
 #include "BsMultiRenderTexture.h"
 #include "BsModule.h"
 #include "BsModule.h"
 
 
@@ -118,12 +119,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&)
 		 * @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&)
 		 */
 		 */
-		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_DESC& desc);
+		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		/**
 		/**
 		 * @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&)
 		 * @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&)
 		 */
 		 */
-		SPtr<MultiRenderTextureCore> createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
+		SPtr<MultiRenderTextureCore> createMultiRenderTexture(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 
 
 	protected:
 	protected:
 		friend class Texture;
 		friend class Texture;
@@ -141,11 +142,11 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	TextureManager::createRenderTextureImpl
 		 * @copydoc	TextureManager::createRenderTextureImpl
 		 */
 		 */
-		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc) = 0;
+		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) = 0;
 
 
 		/**
 		/**
 		 * @copydoc	TextureManager::createMultiRenderTextureImpl
 		 * @copydoc	TextureManager::createMultiRenderTextureImpl
 		 */
 		 */
-		virtual SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc) = 0;
+		virtual SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) = 0;
     };
     };
 }
 }

+ 1 - 1
BansheeCore/Include/BsTextureRTTI.h

@@ -63,7 +63,7 @@ namespace BansheeEngine
 			UINT32 mipmap = idx % (obj->mProperties.getNumMipmaps() + 1);
 			UINT32 mipmap = idx % (obj->mProperties.getNumMipmaps() + 1);
 
 
 			UINT32 subresourceIdx = obj->mProperties.mapToSubresourceIdx(face, mipmap);
 			UINT32 subresourceIdx = obj->mProperties.mapToSubresourceIdx(face, mipmap);
-			PixelDataPtr pixelData = obj->allocateSubresourceBuffer(subresourceIdx);
+			PixelDataPtr pixelData = obj->mProperties.allocateSubresourceBuffer(subresourceIdx);
 
 
 			obj->readSubresource(gCoreAccessor(), subresourceIdx, pixelData);
 			obj->readSubresource(gCoreAccessor(), subresourceIdx, pixelData);
 			gCoreAccessor().submitToCoreThread(true);
 			gCoreAccessor().submitToCoreThread(true);

+ 58 - 19
BansheeCore/Source/BsMultiRenderTexture.cpp

@@ -13,27 +13,50 @@ namespace BansheeEngine
 	{
 	{
 		for (size_t i = 0; i < desc.colorSurfaces.size(); i++)
 		for (size_t i = 0; i < desc.colorSurfaces.size(); i++)
 		{
 		{
-			TexturePtr texture = desc.colorSurfaces[i].texture;
+			HTexture texture = desc.colorSurfaces[i].texture;
 
 
 			if (texture != nullptr)
 			if (texture != nullptr)
 			{
 			{
 				const TextureProperties& texProps = texture->getProperties();
 				const TextureProperties& texProps = texture->getProperties();
+				construct(&texProps);
 
 
-				mWidth = texProps.getWidth();
-				mHeight = texProps.getWidth();
-				mColorDepth = BansheeEngine::PixelUtil::getNumElemBits(texProps.getFormat());
-				mActive = true;
-				mHwGamma = texProps.isHardwareGammaEnabled();
-				mMultisampleCount = texProps.getMultisampleCount();
-				mIsWindow = false;
-				mRequiresTextureFlipping = requiresTextureFlipping();
+				break;
+			}
+		}
+	}
+
+	MultiRenderTextureProperties::MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
+	{
+		for (size_t i = 0; i < desc.colorSurfaces.size(); i++)
+		{
+			SPtr<TextureCore> texture = desc.colorSurfaces[i].texture;
+
+			if (texture != nullptr)
+			{
+				const TextureProperties& texProps = texture->getProperties();
+				construct(&texProps);
 
 
 				break;
 				break;
 			}
 			}
 		}
 		}
 	}
 	}
 
 
-	MultiRenderTextureCore::MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc)
+	void MultiRenderTextureProperties::construct(const TextureProperties* props)
+	{
+		if (props == nullptr)
+			return;
+
+		mWidth = props->getWidth();
+		mHeight = props->getWidth();
+		mColorDepth = PixelUtil::getNumElemBits(props->getFormat());
+		mActive = true;
+		mHwGamma = props->isHardwareGammaEnabled();
+		mMultisampleCount = props->getMultisampleCount();
+		mIsWindow = false;
+		mRequiresTextureFlipping = requiresTextureFlipping();
+	}
+
+	MultiRenderTextureCore::MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 		:mDesc(desc)
 		:mDesc(desc)
 	{ }
 	{ }
 
 
@@ -67,7 +90,7 @@ namespace BansheeEngine
 					continue;
 					continue;
 				}
 				}
 
 
-				SPtr<TextureCore> texture = mDesc.colorSurfaces[i].texture->getCore();
+				SPtr<TextureCore> texture = mDesc.colorSurfaces[i].texture;
 
 
 				if (texture->getProperties().getUsage() != TU_RENDERTARGET)
 				if (texture->getProperties().getUsage() != TU_RENDERTARGET)
 					BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
 					BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
@@ -79,7 +102,7 @@ namespace BansheeEngine
 
 
 		if (mDesc.depthStencilSurface.texture != nullptr)
 		if (mDesc.depthStencilSurface.texture != nullptr)
 		{
 		{
-			SPtr<TextureCore> texture = mDesc.depthStencilSurface.texture->getCore();
+			SPtr<TextureCore> texture = mDesc.depthStencilSurface.texture;
 
 
 			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
 			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
@@ -186,23 +209,39 @@ namespace BansheeEngine
 	MultiRenderTexture::MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
 	MultiRenderTexture::MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
 		:mDesc(desc)
 		:mDesc(desc)
 	{
 	{
-		// Create non-persistent resource handles for the used textures (we only need them because a lot of the code accepts only handles,
-		// since they're non persistent they don't really have any benefit over shared pointers)
-
 		for (UINT32 i = 0; i < (UINT32)desc.colorSurfaces.size(); i++)
 		for (UINT32 i = 0; i < (UINT32)desc.colorSurfaces.size(); i++)
 		{
 		{
 			if (desc.colorSurfaces[i].texture != nullptr)
 			if (desc.colorSurfaces[i].texture != nullptr)
-				mBindableColorTex.push_back(static_resource_cast<Texture>(gResources()._createResourceHandle(desc.colorSurfaces[i].texture)));
+				mBindableColorTex.push_back(desc.colorSurfaces[i].texture);
 		}
 		}
 
 
-
 		if (desc.depthStencilSurface.texture != nullptr)
 		if (desc.depthStencilSurface.texture != nullptr)
-			mBindableDepthStencilTex = static_resource_cast<Texture>(gResources()._createResourceHandle(desc.depthStencilSurface.texture));
+			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
 	}
 	}
 
 
 	SPtr<CoreObjectCore> MultiRenderTexture::createCore() const
 	SPtr<CoreObjectCore> MultiRenderTexture::createCore() const
 	{
 	{
-		return TextureCoreManager::instance().createMultiRenderTextureInternal(mDesc);
+		MULTI_RENDER_TEXTURE_CORE_DESC coreDesc;
+
+		for (auto& colorSurface : mDesc.colorSurfaces)
+		{
+			RENDER_SURFACE_CORE_DESC surfaceDesc;
+			if (colorSurface.texture.isLoaded())
+				surfaceDesc.texture = colorSurface.texture->getCore();
+
+			surfaceDesc.face = colorSurface.face;
+			surfaceDesc.mipLevel = colorSurface.mipLevel;
+
+			coreDesc.colorSurfaces.push_back(surfaceDesc);
+		}
+
+		if (mDesc.depthStencilSurface.texture.isLoaded())
+			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
+
+		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
+		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
+
+		return TextureCoreManager::instance().createMultiRenderTextureInternal(coreDesc);
 	}
 	}
 
 
 	SPtr<MultiRenderTextureCore> MultiRenderTexture::getCore() const
 	SPtr<MultiRenderTextureCore> MultiRenderTexture::getCore() const

+ 49 - 16
BansheeCore/Source/BsRenderTexture.cpp

@@ -11,17 +11,39 @@ namespace BansheeEngine
 {
 {
 	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
 	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
 	{
 	{
-		TexturePtr texture = desc.colorSurface.texture;
+		HTexture texture = desc.colorSurface.texture;
+
+		if (texture.isLoaded())
+		{
+			const TextureProperties& props = texture->getProperties();
+			construct(&props, requiresFlipping);
+		}
+		else
+			construct(nullptr, requiresFlipping);
+	}
+
+	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping)
+	{
+		SPtr<TextureCore> texture = desc.colorSurface.texture;
 
 
 		if (texture != nullptr)
 		if (texture != nullptr)
 		{
 		{
 			const TextureProperties& props = texture->getProperties();
 			const TextureProperties& props = texture->getProperties();
+			construct(&props, requiresFlipping);
+		}
+		else
+			construct(nullptr, requiresFlipping);
+	}
 
 
-			mWidth = props.getWidth();
-			mHeight = props.getHeight();
-			mColorDepth = BansheeEngine::PixelUtil::getNumElemBits(props.getFormat());
-			mHwGamma = props.isHardwareGammaEnabled();
-			mMultisampleCount = props.getMultisampleCount();
+	void RenderTextureProperties::construct(const TextureProperties* textureProps, bool requiresFlipping)
+	{
+		if (textureProps != nullptr)
+		{
+			mWidth = textureProps->getWidth();
+			mHeight = textureProps->getHeight();
+			mColorDepth = BansheeEngine::PixelUtil::getNumElemBits(textureProps->getFormat());
+			mHwGamma = textureProps->isHardwareGammaEnabled();
+			mMultisampleCount = textureProps->getMultisampleCount();
 		}
 		}
 
 
 		mActive = true;
 		mActive = true;
@@ -29,7 +51,7 @@ namespace BansheeEngine
 		mRequiresTextureFlipping = requiresFlipping;
 		mRequiresTextureFlipping = requiresFlipping;
 	}
 	}
 
 
-	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC& desc)
+	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
 		:mColorSurface(nullptr), mDepthStencilSurface(nullptr), mDesc(desc)
 		:mColorSurface(nullptr), mDepthStencilSurface(nullptr), mDesc(desc)
 	{ }
 	{ }
 
 
@@ -46,10 +68,10 @@ namespace BansheeEngine
 	{
 	{
 		RenderTargetCore::initialize();
 		RenderTargetCore::initialize();
 
 
-		const RENDER_SURFACE_DESC& colorSurface = mDesc.colorSurface;
+		const RENDER_SURFACE_CORE_DESC& colorSurface = mDesc.colorSurface;
 		if (colorSurface.texture != nullptr)
 		if (colorSurface.texture != nullptr)
 		{
 		{
-			SPtr<TextureCore> texture = colorSurface.texture->getCore();
+			SPtr<TextureCore> texture = colorSurface.texture;
 
 
 			if (texture->getProperties().getUsage() != TU_RENDERTARGET)
 			if (texture->getProperties().getUsage() != TU_RENDERTARGET)
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
@@ -58,10 +80,10 @@ namespace BansheeEngine
 				colorSurface.face, 1, GVU_RENDERTARGET);
 				colorSurface.face, 1, GVU_RENDERTARGET);
 		}
 		}
 
 
-		const RENDER_SURFACE_DESC& depthStencilSurface = mDesc.depthStencilSurface;
+		const RENDER_SURFACE_CORE_DESC& depthStencilSurface = mDesc.depthStencilSurface;
 		if (depthStencilSurface.texture != nullptr)
 		if (depthStencilSurface.texture != nullptr)
 		{
 		{
-			SPtr<TextureCore> texture = depthStencilSurface.texture->getCore();
+			SPtr<TextureCore> texture = depthStencilSurface.texture;
 
 
 			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
 			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
@@ -156,18 +178,29 @@ namespace BansheeEngine
 	{
 	{
 		mDesc = desc;
 		mDesc = desc;
 
 
-		// Create non-persistent resource handles for the used textures (we only need them because a lot of the code accepts only handles,
-		// since they're non persistent they don't really have any benefit over shared pointers)
 		if (desc.colorSurface.texture != nullptr)
 		if (desc.colorSurface.texture != nullptr)
-			mBindableColorTex = static_resource_cast<Texture>(gResources()._createResourceHandle(desc.colorSurface.texture));
+			mBindableColorTex = desc.colorSurface.texture;
 
 
 		if (desc.depthStencilSurface.texture != nullptr)
 		if (desc.depthStencilSurface.texture != nullptr)
-			mBindableDepthStencilTex = static_resource_cast<Texture>(gResources()._createResourceHandle(desc.depthStencilSurface.texture));
+			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
 	}
 	}
 
 
 	SPtr<CoreObjectCore> RenderTexture::createCore() const
 	SPtr<CoreObjectCore> RenderTexture::createCore() const
 	{
 	{
-		return TextureCoreManager::instance().createRenderTextureInternal(mDesc);
+		RENDER_TEXTURE_CORE_DESC coreDesc;
+
+		if (mDesc.colorSurface.texture.isLoaded())
+			coreDesc.colorSurface.texture = mDesc.colorSurface.texture->getCore();
+
+		if (mDesc.depthStencilSurface.texture.isLoaded())
+			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
+
+		coreDesc.colorSurface.face = mDesc.colorSurface.face;
+		coreDesc.colorSurface.mipLevel = mDesc.colorSurface.mipLevel;
+		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
+		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
+
+		return TextureCoreManager::instance().createRenderTextureInternal(coreDesc);
 	}
 	}
 
 
 	CoreSyncData RenderTexture::syncToCore(FrameAlloc* allocator)
 	CoreSyncData RenderTexture::syncToCore(FrameAlloc* allocator)

+ 30 - 32
BansheeCore/Source/BsTexture.cpp

@@ -51,6 +51,35 @@ namespace BansheeEngine
 		return face * (getNumMipmaps() + 1) + mip;
 		return face * (getNumMipmaps() + 1) + mip;
 	}
 	}
 
 
+	PixelDataPtr TextureProperties::allocateSubresourceBuffer(UINT32 subresourceIdx) const
+	{
+		UINT32 face = 0;
+		UINT32 mip = 0;
+		mapFromSubresourceIdx(subresourceIdx, face, mip);
+
+		UINT32 numMips = getNumMipmaps();
+		UINT32 width = getWidth();
+		UINT32 height = getHeight();
+		UINT32 depth = getDepth();
+
+		UINT32 totalSize = PixelUtil::getMemorySize(width, height, depth, getFormat());
+
+		for (UINT32 j = 0; j < mip; j++)
+		{
+			totalSize = PixelUtil::getMemorySize(width, height, depth, getFormat());
+
+			if (width != 1) width /= 2;
+			if (height != 1) height /= 2;
+			if (depth != 1) depth /= 2;
+		}
+
+		PixelDataPtr dst = bs_shared_ptr<PixelData, PoolAlloc>(width, height, depth, getFormat());
+
+		dst->allocateInternalBuffer();
+
+		return dst;
+	}
+
 	TextureCore::TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
 	TextureCore::TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
 		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
 		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
 		:mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount)
 		:mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount)
@@ -349,37 +378,6 @@ namespace BansheeEngine
 		memcpy(dest, src, pixelData.getSize());
 		memcpy(dest, src, pixelData.getSize());
 	}
 	}
 
 
-	PixelDataPtr Texture::allocateSubresourceBuffer(UINT32 subresourceIdx) const
-	{
-		UINT32 face = 0;
-		UINT32 mip = 0;
-		mProperties.mapFromSubresourceIdx(subresourceIdx, face, mip);
-
-		UINT32 numMips = mProperties.getNumMipmaps();
-		UINT32 width = mProperties.getWidth();
-		UINT32 height = mProperties.getHeight();
-		UINT32 depth = mProperties.getDepth();
-
-		UINT32 totalSize = PixelUtil::getMemorySize(width, height, depth, mProperties.getFormat());
-
-		for(UINT32 j = 0; j < mip; j++)
-		{
-			totalSize = PixelUtil::getMemorySize(width, height, depth, mProperties.getFormat());
-
-			if(width != 1) width /= 2;
-			if(height != 1) height /= 2;
-			if(depth != 1) depth /= 2;
-		}
-
-		PixelDataPtr dst = bs_shared_ptr<PixelData, PoolAlloc>(width, height, depth, mProperties.getFormat());
-
-		dst->allocateInternalBuffer();
-
-		return dst;
-	}
-
-
-
 	void Texture::readData(PixelData& dest, UINT32 mipLevel, UINT32 face)
 	void Texture::readData(PixelData& dest, UINT32 mipLevel, UINT32 face)
 	{
 	{
 		if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
 		if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
@@ -510,7 +508,7 @@ namespace BansheeEngine
 			dummyTexture = create(TEX_TYPE_2D, 2, 2, 0, PF_R8G8B8A8);
 			dummyTexture = create(TEX_TYPE_2D, 2, 2, 0, PF_R8G8B8A8);
 
 
 			UINT32 subresourceIdx = dummyTexture->getProperties().mapToSubresourceIdx(0, 0);
 			UINT32 subresourceIdx = dummyTexture->getProperties().mapToSubresourceIdx(0, 0);
-			PixelDataPtr data = dummyTexture->allocateSubresourceBuffer(subresourceIdx);
+			PixelDataPtr data = dummyTexture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 			data->setColorAt(Color::Red, 0, 0);
 			data->setColorAt(Color::Red, 0, 0);
 			data->setColorAt(Color::Red, 0, 1);
 			data->setColorAt(Color::Red, 0, 1);

+ 5 - 5
BansheeCore/Source/BsTextureManager.cpp

@@ -31,12 +31,12 @@ namespace BansheeEngine
 			PixelFormat format, bool hwGamma, UINT32 multisampleCount, 
 			PixelFormat format, bool hwGamma, UINT32 multisampleCount, 
 			bool createDepth, PixelFormat depthStencilFormat)
 			bool createDepth, PixelFormat depthStencilFormat)
 	{
 	{
-		TexturePtr texture = createTexture(textureType, width, height, 0, format, TU_RENDERTARGET, hwGamma, multisampleCount);
+		HTexture texture = Texture::create(textureType, width, height, 0, format, TU_RENDERTARGET, hwGamma, multisampleCount);
 
 
-		TexturePtr depthStencil = nullptr;
+		HTexture depthStencil;
 		if(createDepth)
 		if(createDepth)
 		{
 		{
-			depthStencil = createTexture(TEX_TYPE_2D, width, height, 0, depthStencilFormat, TU_DEPTHSTENCIL, false, multisampleCount);
+			depthStencil = Texture::create(TEX_TYPE_2D, width, height, 0, depthStencilFormat, TU_DEPTHSTENCIL, false, multisampleCount);
 		}
 		}
 
 
 		RENDER_TEXTURE_DESC desc;
 		RENDER_TEXTURE_DESC desc;
@@ -80,7 +80,7 @@ namespace BansheeEngine
 		return newRT;
 		return newRT;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC& desc)
+	SPtr<RenderTextureCore> TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<RenderTextureCore> newRT = createRenderTextureInternal(desc);
 		SPtr<RenderTextureCore> newRT = createRenderTextureInternal(desc);
 		newRT->initialize();
 		newRT->initialize();
@@ -88,7 +88,7 @@ namespace BansheeEngine
 		return newRT;
 		return newRT;
 	}
 	}
 
 
-	SPtr<MultiRenderTextureCore> TextureCoreManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
+	SPtr<MultiRenderTextureCore> TextureCoreManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<MultiRenderTextureCore> newRT = createMultiRenderTextureInternal(desc);
 		SPtr<MultiRenderTextureCore> newRT = createMultiRenderTextureInternal(desc);
 		newRT->initialize();
 		newRT->initialize();

+ 1 - 1
BansheeD3D11RenderSystem/Include/BsD3D11MultiRenderTexture.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	class BS_D3D11_EXPORT D3D11MultiRenderTextureCore : public MultiRenderTextureCore
 	class BS_D3D11_EXPORT D3D11MultiRenderTextureCore : public MultiRenderTextureCore
 	{
 	{
 	public:
 	public:
-		D3D11MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc);
+		D3D11MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~D3D11MultiRenderTextureCore();
 		virtual ~D3D11MultiRenderTextureCore();
 		
 		
 		/**
 		/**

+ 1 - 1
BansheeD3D11RenderSystem/Include/BsD3D11RenderTexture.h

@@ -16,7 +16,7 @@ namespace BansheeEngine
 	class D3D11RenderTextureCore : public RenderTextureCore
 	class D3D11RenderTextureCore : public RenderTextureCore
 	{
 	{
 	public:
 	public:
-		D3D11RenderTextureCore(const RENDER_TEXTURE_DESC& desc);
+		D3D11RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~D3D11RenderTextureCore() { }
 		virtual ~D3D11RenderTextureCore() { }
 
 
 		/**
 		/**

+ 2 - 2
BansheeD3D11RenderSystem/Include/BsD3D11TextureManager.h

@@ -44,11 +44,11 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal
 		 */
 		 */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc);
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		/**
 		/**
 		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
 		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
 		 */
 		 */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc);
+		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 	};
 	};
 }
 }

+ 1 - 1
BansheeD3D11RenderSystem/Source/BsD3D11MultiRenderTexture.cpp

@@ -5,7 +5,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	D3D11MultiRenderTextureCore::D3D11MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc)
+	D3D11MultiRenderTextureCore::D3D11MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 		:MultiRenderTextureCore(desc), mProperties(desc)
 		:MultiRenderTextureCore(desc), mProperties(desc)
 	{
 	{
 
 

+ 1 - 1
BansheeD3D11RenderSystem/Source/BsD3D11RenderTexture.cpp

@@ -9,7 +9,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_DESC& desc)
+	D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
 		:RenderTextureCore(desc), mProperties(desc, false)
 		:RenderTextureCore(desc), mProperties(desc, false)
 	{ 
 	{ 
 
 

+ 2 - 2
BansheeD3D11RenderSystem/Source/BsD3D11TextureManager.cpp

@@ -41,7 +41,7 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> D3D11TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc)
+	SPtr<RenderTextureCore> D3D11TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<D3D11RenderTextureCore> texPtr = bs_shared_ptr<D3D11RenderTextureCore>(desc);
 		SPtr<D3D11RenderTextureCore> texPtr = bs_shared_ptr<D3D11RenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
@@ -49,7 +49,7 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<MultiRenderTextureCore> D3D11TextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc)
+	SPtr<MultiRenderTextureCore> D3D11TextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<D3D11MultiRenderTextureCore> texPtr = bs_shared_ptr<D3D11MultiRenderTextureCore>(desc);
 		SPtr<D3D11MultiRenderTextureCore> texPtr = bs_shared_ptr<D3D11MultiRenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);

+ 1 - 1
BansheeD3D9RenderSystem/Include/BsD3D9MultiRenderTexture.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	class BS_D3D9_EXPORT D3D9MultiRenderTextureCore : public MultiRenderTextureCore
 	class BS_D3D9_EXPORT D3D9MultiRenderTextureCore : public MultiRenderTextureCore
 	{
 	{
 	public:
 	public:
-		D3D9MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc);
+		D3D9MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~D3D9MultiRenderTextureCore();
 		virtual ~D3D9MultiRenderTextureCore();
 		
 		
 		/**
 		/**

+ 1 - 1
BansheeD3D9RenderSystem/Include/BsD3D9RenderTexture.h

@@ -16,7 +16,7 @@ namespace BansheeEngine
 	class BS_D3D9_EXPORT D3D9RenderTextureCore : public RenderTextureCore, public D3D9Resource
 	class BS_D3D9_EXPORT D3D9RenderTextureCore : public RenderTextureCore, public D3D9Resource
 	{
 	{
 	public:
 	public:
-		D3D9RenderTextureCore(const RENDER_TEXTURE_DESC& desc);
+		D3D9RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		virtual ~D3D9RenderTextureCore();
 		virtual ~D3D9RenderTextureCore();
 
 

+ 2 - 2
BansheeD3D9RenderSystem/Include/BsD3D9TextureManager.h

@@ -48,11 +48,11 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal
 		 */
 		 */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc);
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		/**
 		/**
 		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
 		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
 		 */
 		 */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc);
+		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 	};
 	};
 }
 }

+ 1 - 1
BansheeD3D9RenderSystem/Source/BsD3D9MultiRenderTexture.cpp

@@ -4,7 +4,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	D3D9MultiRenderTextureCore::D3D9MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc)
+	D3D9MultiRenderTextureCore::D3D9MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 		:MultiRenderTextureCore(desc), mProperties(desc), mDX9DepthStencilSurface(nullptr)
 		:MultiRenderTextureCore(desc), mProperties(desc), mDX9DepthStencilSurface(nullptr)
 	{ }
 	{ }
 
 

+ 1 - 1
BansheeD3D9RenderSystem/Source/BsD3D9RenderTexture.cpp

@@ -6,7 +6,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	D3D9RenderTextureCore::D3D9RenderTextureCore(const RENDER_TEXTURE_DESC& desc)
+	D3D9RenderTextureCore::D3D9RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
 		:RenderTextureCore(desc), mProperties(desc, false), mDX9ColorSurface(nullptr),
 		:RenderTextureCore(desc), mProperties(desc, false), mDX9ColorSurface(nullptr),
 		mDX9DepthStencilSurface(nullptr), mIsBindableToShader(false)
 		mDX9DepthStencilSurface(nullptr), mIsBindableToShader(false)
 	{ }
 	{ }

+ 2 - 2
BansheeD3D9RenderSystem/Source/BsD3D9TextureManager.cpp

@@ -58,7 +58,7 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> D3D9TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc)
+	SPtr<RenderTextureCore> D3D9TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<D3D9RenderTextureCore> texPtr = bs_shared_ptr<D3D9RenderTextureCore>(desc);
 		SPtr<D3D9RenderTextureCore> texPtr = bs_shared_ptr<D3D9RenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
@@ -66,7 +66,7 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<MultiRenderTextureCore> D3D9TextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc)
+	SPtr<MultiRenderTextureCore> D3D9TextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<D3D9MultiRenderTextureCore> texPtr = bs_shared_ptr<D3D9MultiRenderTextureCore>(desc);
 		SPtr<D3D9MultiRenderTextureCore> texPtr = bs_shared_ptr<D3D9MultiRenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);

+ 3 - 3
BansheeEditor/Source/BsScenePicking.cpp

@@ -318,7 +318,7 @@ namespace BansheeEngine
 		}
 		}
 
 
 		SPtr<RenderTextureCore> rtt = std::static_pointer_cast<RenderTextureCore>(target);
 		SPtr<RenderTextureCore> rtt = std::static_pointer_cast<RenderTextureCore>(target);
-		TexturePtr outputTexture = rtt->getBindableColorTexture();
+		SPtr<TextureCore> outputTexture = rtt->getBindableColorTexture();
 
 
 		if (position.x < 0 || position.x >= (INT32)outputTexture->getProperties().getWidth() ||
 		if (position.x < 0 || position.x >= (INT32)outputTexture->getProperties().getWidth() ||
 			position.y < 0 || position.y >= (INT32)outputTexture->getProperties().getHeight())
 			position.y < 0 || position.y >= (INT32)outputTexture->getProperties().getHeight())
@@ -327,13 +327,13 @@ namespace BansheeEngine
 			return;
 			return;
 		}
 		}
 
 
-		PixelDataPtr outputPixelData = outputTexture->allocateSubresourceBuffer(0);
+		PixelDataPtr outputPixelData = outputTexture->getProperties().allocateSubresourceBuffer(0);
 		AsyncOp unused;
 		AsyncOp unused;
 
 
 		RenderAPICore& rs = RenderAPICore::instance();
 		RenderAPICore& rs = RenderAPICore::instance();
 
 
 		rs.endFrame();
 		rs.endFrame();
-		outputTexture->getCore()->readSubresource(0, *outputPixelData);
+		outputTexture->readSubresource(0, *outputPixelData);
 
 
 		Map<UINT32, UINT32> selectionScores;
 		Map<UINT32, UINT32> selectionScores;
 		UINT32 numPixels = outputPixelData->getWidth() * outputPixelData->getHeight();
 		UINT32 numPixels = outputPixelData->getWidth() * outputPixelData->getHeight();

+ 10 - 10
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -217,34 +217,34 @@ namespace BansheeEngine
 		HTexture cursorSizeNWSETex = getCursorTexture(CursorSizeNWSETex);
 		HTexture cursorSizeNWSETex = getCursorTexture(CursorSizeNWSETex);
 		HTexture cursorSizeWETex = getCursorTexture(CursorSizeWETex);
 		HTexture cursorSizeWETex = getCursorTexture(CursorSizeWETex);
 
 
-		mCursorArrow = cursorArrowTex->allocateSubresourceBuffer(0);
+		mCursorArrow = cursorArrowTex->getProperties().allocateSubresourceBuffer(0);
 		cursorArrowTex->readSubresource(gCoreAccessor(), 0, mCursorArrow);
 		cursorArrowTex->readSubresource(gCoreAccessor(), 0, mCursorArrow);
 
 
-		mCursorArrowDrag = cursorArrowDragTex->allocateSubresourceBuffer(0);
+		mCursorArrowDrag = cursorArrowDragTex->getProperties().allocateSubresourceBuffer(0);
 		cursorArrowDragTex->readSubresource(gCoreAccessor(), 0, mCursorArrowDrag);
 		cursorArrowDragTex->readSubresource(gCoreAccessor(), 0, mCursorArrowDrag);
 
 
-		mCursorArrowLeftRight = cursorArrowLeftRightTex->allocateSubresourceBuffer(0);
+		mCursorArrowLeftRight = cursorArrowLeftRightTex->getProperties().allocateSubresourceBuffer(0);
 		cursorArrowLeftRightTex->readSubresource(gCoreAccessor(), 0, mCursorArrowLeftRight);
 		cursorArrowLeftRightTex->readSubresource(gCoreAccessor(), 0, mCursorArrowLeftRight);
 
 
-		mCursorIBeam = cursorIBeamTex->allocateSubresourceBuffer(0);
+		mCursorIBeam = cursorIBeamTex->getProperties().allocateSubresourceBuffer(0);
 		cursorIBeamTex->readSubresource(gCoreAccessor(), 0, mCursorIBeam);
 		cursorIBeamTex->readSubresource(gCoreAccessor(), 0, mCursorIBeam);
 
 
-		mCursorDeny = cursorDenyTex->allocateSubresourceBuffer(0);
+		mCursorDeny = cursorDenyTex->getProperties().allocateSubresourceBuffer(0);
 		cursorDenyTex->readSubresource(gCoreAccessor(), 0, mCursorDeny);
 		cursorDenyTex->readSubresource(gCoreAccessor(), 0, mCursorDeny);
 
 
-		mCursorWait = cursorWaitTex->allocateSubresourceBuffer(0);
+		mCursorWait = cursorWaitTex->getProperties().allocateSubresourceBuffer(0);
 		cursorWaitTex->readSubresource(gCoreAccessor(), 0, mCursorWait);
 		cursorWaitTex->readSubresource(gCoreAccessor(), 0, mCursorWait);
 
 
-		mCursorSizeNESW = cursorSizeNESWTex->allocateSubresourceBuffer(0);
+		mCursorSizeNESW = cursorSizeNESWTex->getProperties().allocateSubresourceBuffer(0);
 		cursorSizeNESWTex->readSubresource(gCoreAccessor(), 0, mCursorSizeNESW);
 		cursorSizeNESWTex->readSubresource(gCoreAccessor(), 0, mCursorSizeNESW);
 
 
-		mCursorSizeNS = cursorSizeNSTex->allocateSubresourceBuffer(0);
+		mCursorSizeNS = cursorSizeNSTex->getProperties().allocateSubresourceBuffer(0);
 		cursorSizeNSTex->readSubresource(gCoreAccessor(), 0, mCursorSizeNS);
 		cursorSizeNSTex->readSubresource(gCoreAccessor(), 0, mCursorSizeNS);
 
 
-		mCursorSizeNWSE = cursorSizeNWSETex->allocateSubresourceBuffer(0);
+		mCursorSizeNWSE = cursorSizeNWSETex->getProperties().allocateSubresourceBuffer(0);
 		cursorSizeNWSETex->readSubresource(gCoreAccessor(), 0, mCursorSizeNWSE);
 		cursorSizeNWSETex->readSubresource(gCoreAccessor(), 0, mCursorSizeNWSE);
 
 
-		mCursorSizeWE = cursorSizeWETex->allocateSubresourceBuffer(0);
+		mCursorSizeWE = cursorSizeWETex->getProperties().allocateSubresourceBuffer(0);
 		cursorSizeWETex->readSubresource(gCoreAccessor(), 0, mCursorSizeWE);
 		cursorSizeWETex->readSubresource(gCoreAccessor(), 0, mCursorSizeWE);
 
 
 		gCoreAccessor().submitToCoreThread(true);
 		gCoreAccessor().submitToCoreThread(true);

+ 2 - 2
BansheeEngine/Source/BsGUIManager.cpp

@@ -603,7 +603,7 @@ namespace BansheeEngine
 
 
 		const HTexture& tex = mCaretTexture->getTexture();
 		const HTexture& tex = mCaretTexture->getTexture();
 		UINT32 subresourceIdx = tex->getProperties().mapToSubresourceIdx(0, 0);
 		UINT32 subresourceIdx = tex->getProperties().mapToSubresourceIdx(0, 0);
-		PixelDataPtr data = tex->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr data = tex->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		data->setColorAt(mCaretColor, 0, 0);
 		data->setColorAt(mCaretColor, 0, 0);
 		tex->writeSubresource(gCoreAccessor(), subresourceIdx, data, false);
 		tex->writeSubresource(gCoreAccessor(), subresourceIdx, data, false);
@@ -619,7 +619,7 @@ namespace BansheeEngine
 
 
 		const HTexture& tex = mTextSelectionTexture->getTexture();
 		const HTexture& tex = mTextSelectionTexture->getTexture();
 		UINT32 subresourceIdx = tex->getProperties().mapToSubresourceIdx(0, 0);
 		UINT32 subresourceIdx = tex->getProperties().mapToSubresourceIdx(0, 0);
-		PixelDataPtr data = tex->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr data = tex->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		data->setColorAt(mTextSelectionColor, 0, 0);
 		data->setColorAt(mTextSelectionColor, 0, 0);
 
 

+ 1 - 1
BansheeFontImporter/Source/BsFontImporter.cpp

@@ -278,7 +278,7 @@ namespace BansheeEngine
 				// It's possible the formats no longer match
 				// It's possible the formats no longer match
 				if (newTex->getProperties().getFormat() != pixelData->getFormat())
 				if (newTex->getProperties().getFormat() != pixelData->getFormat())
 				{
 				{
-					PixelDataPtr temp = newTex->allocateSubresourceBuffer(subresourceIdx);
+					PixelDataPtr temp = newTex->getProperties().allocateSubresourceBuffer(subresourceIdx);
 					PixelUtil::bulkPixelConversion(*pixelData, *temp);
 					PixelUtil::bulkPixelConversion(*pixelData, *temp);
 
 
 					newTex->writeSubresource(gCoreAccessor(), subresourceIdx, temp, false);
 					newTex->writeSubresource(gCoreAccessor(), subresourceIdx, temp, false);

+ 1 - 1
BansheeFreeImgImporter/Source/BsFreeImgImporter.cpp

@@ -161,7 +161,7 @@ namespace BansheeEngine
 		for (UINT32 mip = 0; mip < (UINT32)mipLevels.size(); ++mip)
 		for (UINT32 mip = 0; mip < (UINT32)mipLevels.size(); ++mip)
 		{
 		{
 			UINT32 subresourceIdx = newTexture->getProperties().mapToSubresourceIdx(0, mip);
 			UINT32 subresourceIdx = newTexture->getProperties().mapToSubresourceIdx(0, mip);
-			PixelDataPtr dst = newTexture->allocateSubresourceBuffer(subresourceIdx);
+			PixelDataPtr dst = newTexture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 			PixelUtil::bulkPixelConversion(*mipLevels[mip], *dst);
 			PixelUtil::bulkPixelConversion(*mipLevels[mip], *dst);
 
 

+ 1 - 1
BansheeGLRenderSystem/Include/BsGLMultiRenderTexture.h

@@ -16,7 +16,7 @@ namespace BansheeEngine
 	class BS_RSGL_EXPORT GLMultiRenderTextureCore : public MultiRenderTextureCore
 	class BS_RSGL_EXPORT GLMultiRenderTextureCore : public MultiRenderTextureCore
 	{
 	{
 	public:
 	public:
-		GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc);
+		GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~GLMultiRenderTextureCore();
 		virtual ~GLMultiRenderTextureCore();
 
 
 		/**
 		/**

+ 1 - 1
BansheeGLRenderSystem/Include/BsGLRenderTexture.h

@@ -19,7 +19,7 @@ namespace BansheeEngine
     class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
     class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
     {
     {
 	public:
 	public:
-		GLRenderTextureCore(const RENDER_TEXTURE_DESC& desc);
+		GLRenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~GLRenderTextureCore();
 		virtual ~GLRenderTextureCore();
 
 
 		/**
 		/**

+ 2 - 2
BansheeGLRenderSystem/Include/BsGLTextureManager.h

@@ -55,12 +55,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal
 		 */
 		 */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc);
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		/**
 		/**
 		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
 		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
 		 */
 		 */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc);
+		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		GLSupport& mGLSupport;
 		GLSupport& mGLSupport;
 	};
 	};

+ 1 - 1
BansheeGLRenderSystem/Source/BsGLMultiRenderTexture.cpp

@@ -3,7 +3,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	GLMultiRenderTextureCore::GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc)
+	GLMultiRenderTextureCore::GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 		:MultiRenderTextureCore(desc), mProperties(desc), mFB(nullptr)
 		:MultiRenderTextureCore(desc), mProperties(desc), mFB(nullptr)
 	{ }
 	{ }
 
 

+ 1 - 1
BansheeGLRenderSystem/Source/BsGLRenderTexture.cpp

@@ -23,7 +23,7 @@ namespace BansheeEngine
 
 
 #define DEPTHFORMAT_COUNT (sizeof(depthFormats)/sizeof(GLenum))
 #define DEPTHFORMAT_COUNT (sizeof(depthFormats)/sizeof(GLenum))
 
 
-	GLRenderTextureCore::GLRenderTextureCore(const RENDER_TEXTURE_DESC& desc)
+	GLRenderTextureCore::GLRenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
 		:RenderTextureCore(desc), mProperties(desc, true), mFB(nullptr)
 		:RenderTextureCore(desc), mProperties(desc, true), mFB(nullptr)
 	{ }
 	{ }
 
 

+ 2 - 2
BansheeGLRenderSystem/Source/BsGLTextureManager.cpp

@@ -76,7 +76,7 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc)
+	SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr<GLRenderTextureCore>(desc);
 		SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr<GLRenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
@@ -84,7 +84,7 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<MultiRenderTextureCore> GLTextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_DESC& desc)
+	SPtr<MultiRenderTextureCore> GLTextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
 	{
 	{
 		SPtr<GLMultiRenderTextureCore> texPtr = bs_shared_ptr<GLMultiRenderTextureCore>(desc);
 		SPtr<GLMultiRenderTextureCore> texPtr = bs_shared_ptr<GLMultiRenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);

+ 3 - 3
SBansheeEngine/Source/BsScriptRenderTexture2D.cpp

@@ -66,7 +66,7 @@ namespace BansheeEngine
 				LOGERR("Render texture must be created using a fully loaded texture.");
 				LOGERR("Render texture must be created using a fully loaded texture.");
 			}
 			}
 			else
 			else
-				depthStencilSurfaceDesc.texture = textureHandle.getInternalPtr();
+				depthStencilSurfaceDesc.texture = textureHandle;
 		}
 		}
 
 
 		RenderTargetPtr tex;
 		RenderTargetPtr tex;
@@ -94,7 +94,7 @@ namespace BansheeEngine
 						LOGERR("Render texture must be created using a fully loaded texture.");
 						LOGERR("Render texture must be created using a fully loaded texture.");
 					}
 					}
 					else
 					else
-						surfaceDesc.texture = textureHandle.getInternalPtr();
+						surfaceDesc.texture = textureHandle;
 				}
 				}
 
 
 				desc.colorSurfaces.push_back(surfaceDesc);
 				desc.colorSurfaces.push_back(surfaceDesc);
@@ -123,7 +123,7 @@ namespace BansheeEngine
 						LOGERR("Render texture must be created using a fully loaded texture.");
 						LOGERR("Render texture must be created using a fully loaded texture.");
 					}
 					}
 					else
 					else
-						surfaceDesc.texture = textureHandle.getInternalPtr();
+						surfaceDesc.texture = textureHandle;
 				}
 				}
 			}
 			}
 
 

+ 2 - 2
SBansheeEngine/Source/BsScriptTexture2D.cpp

@@ -46,7 +46,7 @@ namespace BansheeEngine
 		HTexture texture = thisPtr->mTexture;
 		HTexture texture = thisPtr->mTexture;
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 
 
-		PixelDataPtr pixelData = thisPtr->mTexture->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr pixelData = thisPtr->mTexture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		thisPtr->mTexture->readData(*pixelData, mipLevel);
 		thisPtr->mTexture->readData(*pixelData, mipLevel);
 
 
@@ -58,7 +58,7 @@ namespace BansheeEngine
 		HTexture texture = thisPtr->mTexture;
 		HTexture texture = thisPtr->mTexture;
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 
 
-		PixelDataPtr readData = texture->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr readData = texture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		AsyncOp asyncOp = texture->readSubresource(gCoreAccessor(), subresourceIdx, readData);
 		AsyncOp asyncOp = texture->readSubresource(gCoreAccessor(), subresourceIdx, readData);
 
 

+ 2 - 2
SBansheeEngine/Source/BsScriptTexture3D.cpp

@@ -46,7 +46,7 @@ namespace BansheeEngine
 		HTexture texture = thisPtr->mTexture;
 		HTexture texture = thisPtr->mTexture;
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 
 
-		PixelDataPtr pixelData = thisPtr->mTexture->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr pixelData = thisPtr->mTexture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		thisPtr->mTexture->readData(*pixelData, mipLevel);
 		thisPtr->mTexture->readData(*pixelData, mipLevel);
 
 
@@ -58,7 +58,7 @@ namespace BansheeEngine
 		HTexture texture = thisPtr->mTexture;
 		HTexture texture = thisPtr->mTexture;
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(0, mipLevel);
 
 
-		PixelDataPtr readData = texture->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr readData = texture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		AsyncOp asyncOp = texture->readSubresource(gCoreAccessor(), subresourceIdx, readData);
 		AsyncOp asyncOp = texture->readSubresource(gCoreAccessor(), subresourceIdx, readData);
 
 

+ 2 - 2
SBansheeEngine/Source/BsScriptTextureCube.cpp

@@ -46,7 +46,7 @@ namespace BansheeEngine
 		HTexture texture = thisPtr->mTexture;
 		HTexture texture = thisPtr->mTexture;
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(face, mipLevel);
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(face, mipLevel);
 
 
-		PixelDataPtr pixelData = thisPtr->mTexture->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr pixelData = thisPtr->mTexture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 
 
 		thisPtr->mTexture->readData(*pixelData, mipLevel, face);
 		thisPtr->mTexture->readData(*pixelData, mipLevel, face);
 
 
@@ -58,7 +58,7 @@ namespace BansheeEngine
 		HTexture texture = thisPtr->mTexture;
 		HTexture texture = thisPtr->mTexture;
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(face, mipLevel);
 		UINT32 subresourceIdx = texture->getProperties().mapToSubresourceIdx(face, mipLevel);
 
 
-		PixelDataPtr readData = texture->allocateSubresourceBuffer(subresourceIdx);
+		PixelDataPtr readData = texture->getProperties().allocateSubresourceBuffer(subresourceIdx);
 		AsyncOp asyncOp = texture->readSubresource(gCoreAccessor(), subresourceIdx, readData);
 		AsyncOp asyncOp = texture->readSubresource(gCoreAccessor(), subresourceIdx, readData);
 
 
 		std::function<MonoObject*(const AsyncOp&, const PixelDataPtr&)> asyncOpToMono =
 		std::function<MonoObject*(const AsyncOp&, const PixelDataPtr&)> asyncOpToMono =

+ 1 - 0
TODO.txt

@@ -6,6 +6,7 @@ TODO - Material waits to Shader to be loaded but doesn't wait for shader GpuProg
  - What's the best way to ensure initialization is done when all these are loaded?
  - What's the best way to ensure initialization is done when all these are loaded?
 
 
 Make RenderTexture accept a HTexture
 Make RenderTexture accept a HTexture
+ - Fix up RenderTextureCore so it doesn't hold a resource handle and instead holds TextureCore ptr (same goes for MultiRenderTexture)
 
 
 When resource loading starts synchonously read all dependencies (and recurse over their dependencies too)
 When resource loading starts synchonously read all dependencies (and recurse over their dependencies too)
  - Create a ResourceLoadGroup that contains all the non-loaded resources
  - Create a ResourceLoadGroup that contains all the non-loaded resources