فهرست منبع

Added descriptor structs for texture resource creation, so it is neater

BearishSun 9 سال پیش
والد
کامیت
7206fcc52f
28فایلهای تغییر یافته به همراه319 افزوده شده و 339 حذف شده
  1. 2 14
      Source/BansheeCore/Include/BsRenderTexture.h
  2. 70 91
      Source/BansheeCore/Include/BsTexture.h
  3. 16 31
      Source/BansheeCore/Include/BsTextureManager.h
  4. 19 42
      Source/BansheeCore/Include/BsTextureRTTI.h
  5. 7 9
      Source/BansheeCore/Source/BsRenderTexture.cpp
  6. 40 68
      Source/BansheeCore/Source/BsTexture.cpp
  7. 28 17
      Source/BansheeCore/Source/BsTextureManager.cpp
  8. 1 3
      Source/BansheeD3D11RenderAPI/Include/BsD3D11Texture.h
  9. 2 3
      Source/BansheeD3D11RenderAPI/Include/BsD3D11TextureManager.h
  10. 9 4
      Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderWindow.cpp
  11. 13 11
      Source/BansheeD3D11RenderAPI/Source/BsD3D11Texture.cpp
  12. 3 4
      Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureManager.cpp
  13. 3 3
      Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureView.cpp
  14. 8 2
      Source/BansheeEditor/Source/BsScenePicking.cpp
  15. 6 2
      Source/BansheeEngine/Source/BsGUIManager.cpp
  16. 2 2
      Source/BansheeEngine/Source/BsRendererUtility.cpp
  17. 6 1
      Source/BansheeFontImporter/Source/BsFontImporter.cpp
  18. 10 2
      Source/BansheeFreeImgImporter/Source/BsFreeImgImporter.cpp
  19. 2 2
      Source/BansheeGLRenderAPI/Include/BsGLTexture.h
  20. 2 3
      Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h
  21. 12 11
      Source/BansheeGLRenderAPI/Source/BsGLTexture.cpp
  22. 3 4
      Source/BansheeGLRenderAPI/Source/BsGLTextureManager.cpp
  23. 12 3
      Source/RenderBeast/Source/BsRenderTexturePool.cpp
  24. 9 3
      Source/SBansheeEngine/Source/BsScriptRenderTexture2D.cpp
  25. 1 1
      Source/SBansheeEngine/Source/BsScriptTexture.cpp
  26. 11 1
      Source/SBansheeEngine/Source/BsScriptTexture2D.cpp
  27. 11 1
      Source/SBansheeEngine/Source/BsScriptTexture3D.cpp
  28. 11 1
      Source/SBansheeEngine/Source/BsScriptTextureCube.cpp

+ 2 - 14
Source/BansheeCore/Include/BsRenderTexture.h

@@ -47,20 +47,8 @@ namespace BansheeEngine
 	public:
 		virtual ~RenderTexture() { }
 
-		/**
-		 * Creates a new render texture with a single color and optionally depth/stencil surfaces.
-		 *
-		 * @param[in]	textureType			Type of texture to render to.
-		 * @param[in]	width				Width of the render texture, in pixels.
-		 * @param[in]	height				Height of the render texture, in pixels.
-		 * @param[in]	format				Pixel format used by the texture color surface.
-		 * @param[in]	hwGamma				Should the written pixels be gamma corrected.
-		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param[in]	createDepth			Should a depth/stencil surface be created along with the color surface.
-		 * @param[in]	depthStencilFormat	Format used by the depth stencil surface, if one is created.
-		 */
-		static SPtr<RenderTexture> create(TextureType textureType, UINT32 width, UINT32 height, 
-			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
+		/** @copydoc TextureManager::createRenderTexture(const TEXTURE_DESC&, bool, PixelFormat) */
+		static SPtr<RenderTexture> create(const TEXTURE_DESC& desc, 
 			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
 
 		/** @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */

+ 70 - 91
Source/BansheeCore/Include/BsTexture.h

@@ -41,43 +41,79 @@ namespace BansheeEngine
 		MIP_UNLIMITED = 0x7FFFFFFF /**< Create all mip maps down to 1x1. */
 	};
 
+	/** Descriptor structure used for initialization of a Texture. */
+	struct TEXTURE_DESC
+	{
+		/** Type of the texture. */
+		TextureType type = TEX_TYPE_2D;
+
+		/** Format of pixels in the texture. */
+		PixelFormat format = PF_R8G8B8A8;
+
+		/** Width of the texture in pixels. */
+		UINT32 width = 1;
+
+		/** Height of the texture in pixels. */
+		UINT32 height = 1;
+
+		/** Depth of the texture in pixels (Must be 1 for 2D textures). */
+		UINT32 depth = 1;
+
+		/** Number of mip-maps the texture has. This number excludes the full resolution map. */
+		UINT32 numMips = 0;
+
+		/** Describes how the caller plans on using the texture in the pipeline. */
+		INT32 usage = TU_DEFAULT;
+
+		/** 
+		 * If true the texture data is assumed to have been gamma corrected and will be converted back to linear space when
+		 * sampled on GPU.
+		 */
+		bool hwGamma = false; 
+
+		/** Number of samples per pixel. Set to 1 or 0 to use the default of a single sample per pixel. */
+		UINT32 numSamples = 0;
+
+		/** Number of texture slices to create if creating a texture array. Ignored for 3D textures. */
+		UINT32 numArraySlices = 1;
+	};
+
 	/** Properties of a Texture. Shared between sim and core thread versions of a Texture. */
 	class BS_CORE_EXPORT TextureProperties
 	{
 	public:
 		TextureProperties();
-		TextureProperties(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices);
+		TextureProperties(const TEXTURE_DESC& desc);
 
 		/**	Gets the type of texture. */
-        TextureType getTextureType() const { return mTextureType; }
+        TextureType getTextureType() const { return mDesc.type; }
 
         /**
 		 * Gets the number of mipmaps to be used for this texture. This number excludes the top level map (which is always
 		 * assumed to be present).
          */
-        UINT32 getNumMipmaps() const {return mNumMipmaps;}
+        UINT32 getNumMipmaps() const {return mDesc.numMips;}
 
 		/** Gets whether this texture will be set up so that on sampling it, hardware gamma correction is applied. */
-		bool isHardwareGammaEnabled() const { return mHwGamma; }
+		bool isHardwareGammaEnabled() const { return mDesc.hwGamma; }
 
 		/**	Gets the number of samples used for multisampling (0 if multisampling is not used). */
-		UINT32 getMultisampleCount() const { return mMultisampleCount; }
+		UINT32 getNumSamples() const { return mDesc.numSamples; }
 
         /**	Returns the height of the texture.  */
-        UINT32 getHeight() const { return mHeight; }
+        UINT32 getHeight() const { return mDesc.height; }
 
         /**	Returns the width of the texture. */
-        UINT32 getWidth() const { return mWidth; }
+        UINT32 getWidth() const { return mDesc.width; }
 
         /**	Returns the depth of the texture (only applicable for 3D textures). */
-        UINT32 getDepth() const { return mDepth; }
+        UINT32 getDepth() const { return mDesc.depth; }
 
         /**	Returns texture usage (TextureUsage) of this texture. */
-        int getUsage() const { return mUsage; }
+        int getUsage() const { return mDesc.usage; }
 
 		/**	Returns the pixel format for the texture surface. */
-		PixelFormat getFormat() const { return mFormat; }
+		PixelFormat getFormat() const { return mDesc.format; }
 
         /**	Returns true if the texture has an alpha layer. */
         bool hasAlpha() const;
@@ -86,7 +122,7 @@ namespace BansheeEngine
         UINT32 getNumFaces() const;
 
 		/** Returns the number of array slices of the texture (if the texture is an array texture). */
-		UINT32 getNumArraySlices() const { return mNumArraySlices; }
+		UINT32 getNumArraySlices() const { return mDesc.numArraySlices; }
 
 		/**
 		 * Maps a sub-resource index to an exact face and mip level. Sub-resource indexes are used when reading or writing
@@ -120,19 +156,9 @@ namespace BansheeEngine
 
 	protected:
 		friend class TextureRTTI;
+		friend class Texture;
 
-		UINT32 mHeight;
-		UINT32 mWidth;
-		UINT32 mDepth;
-		UINT32 mNumArraySlices;
-
-		UINT32 mNumMipmaps;
-		bool mHwGamma;
-		UINT32 mMultisampleCount;
-
-		TextureType mTextureType;
-		PixelFormat mFormat;
-		int mUsage;
+		TEXTURE_DESC mDesc;
 	};
 
 	/**
@@ -206,42 +232,9 @@ namespace BansheeEngine
 		/**
 		 * Creates a new empty texture.
 		 *
-		 * @param[in]	texType				Type of the texture.
-		 * @param[in]	width				Width of the texture in pixels.
-		 * @param[in]	height				Height of the texture in pixels.
-		 * @param[in]	depth				Depth of the texture in pixels (Must be 1 for 2D textures).
-		 * @param[in]	numMips				Number of mip-maps the texture has. This number excludes the full resolution map.
-		 * @param[in]	format				Format of the pixels.
-		 * @param[in]	usage				Describes how we plan on using the texture in the pipeline.
-		 * @param[in]	hwGammaCorrection	If true the texture data is assumed to have been gamma corrected and will be
-		 *									converted back to linear space when sampled on GPU.
-		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param[in]	numArraySlices		Number of texture slices to create if creating a texture array. Ignored for
-		 *									3D textures.
-		 */
-		static HTexture create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
-
-
-		/**
-		 * Creates a new empty texture.
-		 *
-		 * @param[in]	texType				Type of the texture.
-		 * @param[in]	width				Width of the texture in pixels.
-		 * @param[in]	height				Height of the texture in pixels.
-		 * @param[in]	numMips				Number of mip-maps the texture has. This number excludes the full resolution map.
-		 * @param[in]	format				Format of the pixels.
-		 * @param[in]	usage				Describes planned texture use.
-		 * @param[in]	hwGammaCorrection	If true the texture data is assumed to have been gamma corrected and will be
-		 *									converted back to linear space when sampled on GPU.
-		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param[in]	numArraySlices		Number of texture slices to create if creating a texture array. Ignored for
-		 *									3D textures.
+		 * @param[in]	desc  	Description of the texture to create.
 		 */
-		static HTexture create(TextureType texType, UINT32 width, UINT32 height, int numMips,
-			PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
+		static HTexture create(const TEXTURE_DESC& desc);
 
 		/**
 		 * Creates a new 2D or 3D texture initialized using the provided pixel data. Texture will not have any mipmaps.
@@ -258,39 +251,27 @@ namespace BansheeEngine
 		 */
 
 		/**
-		 * @copydoc	create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32)
+		 * @copydoc	create(const TEXTURE_DESC&)
 		 *
 		 * @note	Internal method. Creates a texture pointer without a handle. Use create() for normal usage.
 		 */
-		static SPtr<Texture> _createPtr(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
-
-		/**
-		 * @copydoc	create(TextureType, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32)
-		 *
-		 * @note	Internal method. Creates a texture pointer without a handle. Use create() for normal usage.
-		 */
-		static SPtr<Texture> _createPtr(TextureType texType, UINT32 width, UINT32 height, int numMips,
-			PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, UINT32 multisampleCount = 0, 
-			UINT32 numArraySlices = 1);
+		static SPtr<Texture> _createPtr(const TEXTURE_DESC& desc);
 
 		/**
 		 * @copydoc	create(const SPtr<PixelData>&, int, bool)
 		 *
 		 * @note	Internal method. Creates a texture pointer without a handle. Use create() for normal usage.
 		 */
-		static SPtr<Texture> _createPtr(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
+		static SPtr<Texture> _createPtr(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT, 
+			bool hwGammaCorrection = false);
 
 		/** @} */
 
     protected:
 		friend class TextureManager;
 
-		Texture(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices);
-
-		Texture(const SPtr<PixelData>& pixelData, int usage, bool hwGamma);
+		Texture(const TEXTURE_DESC& desc);
+		Texture(const TEXTURE_DESC& desc, const SPtr<PixelData>& pixelData);
 
 		/** @copydoc Resource::initialize */
 		void initialize() override;
@@ -341,9 +322,7 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TextureCore : public CoreObjectCore
 	{
 	public:
-		TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices, 
-			const SPtr<PixelData>& initData);
+		TextureCore(const TEXTURE_DESC& desc, const SPtr<PixelData>& initData, GpuDeviceFlags deviceMask);
 		virtual ~TextureCore() {}
 
 
@@ -432,18 +411,18 @@ namespace BansheeEngine
 		/* 								STATICS		                     		*/
 		/************************************************************************/
 
-		/** @copydoc Texture::create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32) */
-		static SPtr<TextureCore> create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
-
-		/** @copydoc Texture::create(TextureType, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32) */
-		static SPtr<TextureCore> create(TextureType texType, UINT32 width, UINT32 height, int numMips,
-			PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
+		/** 
+		 * @copydoc Texture::create(const TEXTURE_DESC&) 
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the object be created on.
+		 */
+		static SPtr<TextureCore> create(const TEXTURE_DESC& desc, GpuDeviceFlags deviceMask = GDF_DEFAULT);
 
-		/** @copydoc Texture::create(const SPtr<PixelData>&, int, bool) */
-		static SPtr<TextureCore> create(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
+		/** 
+		 * @copydoc Texture::create(const SPtr<PixelData>&, int, bool) 
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the object be created on.
+		 */
+		static SPtr<TextureCore> create(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT, 
+			bool hwGammaCorrection = false, GpuDeviceFlags deviceMask = GDF_DEFAULT);
 
 		/************************************************************************/
 		/* 								TEXTURE VIEW                      		*/

+ 16 - 31
Source/BansheeCore/Include/BsTextureManager.h

@@ -23,22 +23,16 @@ namespace BansheeEngine
     public:
 		virtual ~TextureManager() { }
 
-		/** @copydoc Texture::create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32) */
-        SPtr<Texture> createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
-			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
+		/** @copydoc Texture::create(const TEXTURE_DESC&) */
+        SPtr<Texture> createTexture(const TEXTURE_DESC& desc);
 			
-		/** @copydoc Texture::create(TextureType, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32) */
-		SPtr<Texture> createTexture(TextureType texType, UINT32 width, UINT32 height, int numMips,
-			PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, UINT32 multisampleCount = 0, 
-			UINT32 numArraySlices = 1)
-		{
-			return createTexture(texType, width, height, 1, 
-				numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
-		}
-
-		/** @copydoc Texture::create(const SPtr<PixelData>&, int, bool) */
-		SPtr<Texture> createTexture(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
+		/**
+		 * Creates a new 2D or 3D texture initialized using the provided pixel data. Texture will not have any mipmaps.
+		 *
+		 * @param[in]	desc  		Description of the texture to create. Must match the pixel data.
+		 * @param[in]	pixelData	Data to initialize the texture width.
+		 */
+		SPtr<Texture> createTexture(const TEXTURE_DESC& desc, const SPtr<PixelData>& pixelData);
 
 		/**
 		 * Creates a completely empty and uninitialized Texture.
@@ -53,19 +47,12 @@ namespace BansheeEngine
 		 * Creates a new RenderTexture and automatically generates a single color surface and (optionally) a depth/stencil 
 		 * surface.
 		 *
-		 * @param[in]	textureType			Type of the texture.
-		 * @param[in]	width				Width of the texture in pixels.
-		 * @param[in]	height				Height of the texture in pixels.
-		 * @param[in]	format				Format of the pixels.
-		 * @param[in]	hwGamma				If true, any color data will be gamma corrected before being written into the 
-		 *									texture.
-		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
+		 * @param[in]	colorDesc			Description of the color surface to create.
 		 * @param[in]	createDepth			Determines will a depth/stencil buffer of the same size as the color buffer be
 		 *									created for the render texture.
 		 * @param[in]	depthStencilFormat	Format of the depth/stencil buffer if enabled.
 		 */
-		virtual SPtr<RenderTexture> createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
-			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
+		virtual SPtr<RenderTexture> createRenderTexture(const TEXTURE_DESC& colorDesc,
 			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
 
 		/** Creates a RenderTexture using the description struct. */
@@ -105,11 +92,10 @@ namespace BansheeEngine
 		void onShutDown() override;
 
 		/**
-		 * @copydoc	TextureManager::createTexture(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, UINT32)
+		 * @copydoc	TextureManager::createTexture(const TEXTURE_DESC&)
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the object be created on.
 		 */
-		SPtr<TextureCore> createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
-			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
+		SPtr<TextureCore> createTexture(const TEXTURE_DESC& desc, GpuDeviceFlags deviceMask = GDF_DEFAULT);
 
 		/**
 		 * @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) 
@@ -127,9 +113,8 @@ namespace BansheeEngine
 		 * Creates an empty and uninitialized texture of a specific type. This is to be implemented	by render systems with
 		 * their own implementations.
 		 */
-		virtual SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) = 0;
+		virtual SPtr<TextureCore> createTextureInternal(const TEXTURE_DESC& desc, 
+			const SPtr<PixelData>& initialData = nullptr, GpuDeviceFlags deviceMask = GDF_DEFAULT) = 0;
 
 		/** @copydoc createRenderTexture */
 		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 

+ 19 - 42
Source/BansheeCore/Include/BsTextureRTTI.h

@@ -21,42 +21,27 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TextureRTTI : public RTTIType<Texture, Resource, TextureRTTI>
 	{
 	private:
-		UINT32& getSize(Texture* obj) { return obj->mSize; }
-		void setSize(Texture* obj, UINT32& val) { obj->mSize = val; }
-
-		UINT32& getWidth(Texture* obj) { return obj->mProperties.mWidth; }
-		void setWidth(Texture* obj, UINT32& val) { obj->mProperties.mWidth = val; }
-
-		UINT32& getHeight(Texture* obj) { return obj->mProperties.mHeight; }
-		void setHeight(Texture* obj, UINT32& val) { obj->mProperties.mHeight = val; }
-
-		UINT32& getDepth(Texture* obj) { return obj->mProperties.mDepth; }
-		void setDepth(Texture* obj, UINT32& val) { obj->mProperties.mDepth = val; }
-
-		UINT32& getNumMipmaps(Texture* obj) { return obj->mProperties.mNumMipmaps; }
-		void setNumMipmaps(Texture* obj, UINT32& val) { obj->mProperties.mNumMipmaps = val; }
-
-		bool& getHwGamma(Texture* obj) { return obj->mProperties.mHwGamma; }
-		void setHwGamma(Texture* obj, bool& val) { obj->mProperties.mHwGamma = val; }
-
-		UINT32& getMultisampleCount(Texture* obj) { return obj->mProperties.mMultisampleCount; }
-		void setMultisampleCount(Texture* obj, UINT32& val) { obj->mProperties.mMultisampleCount = val; }
-
-		TextureType& getTextureType(Texture* obj) { return obj->mProperties.mTextureType; }
-		void setTextureType(Texture* obj, TextureType& val) { obj->mProperties.mTextureType = val; }
-
-		PixelFormat& getFormat(Texture* obj) { return obj->mProperties.mFormat; }
-		void setFormat(Texture* obj, PixelFormat& val) { obj->mProperties.mFormat = val; }
-
-		INT32& getUsage(Texture* obj) { return obj->mProperties.mUsage; }
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_PLAIN(mSize, 0)
+			BS_RTTI_MEMBER_PLAIN_NAMED(height, mProperties.mDesc.height, 2)
+			BS_RTTI_MEMBER_PLAIN_NAMED(width, mProperties.mDesc.width, 3)
+			BS_RTTI_MEMBER_PLAIN_NAMED(depth, mProperties.mDesc.depth, 4)
+			BS_RTTI_MEMBER_PLAIN_NAMED(numMips, mProperties.mDesc.numMips, 5)
+			BS_RTTI_MEMBER_PLAIN_NAMED(hwGamma, mProperties.mDesc.hwGamma, 6)
+			BS_RTTI_MEMBER_PLAIN_NAMED(numSamples, mProperties.mDesc.numSamples, 7)
+			BS_RTTI_MEMBER_PLAIN_NAMED(type, mProperties.mDesc.type, 9)
+			BS_RTTI_MEMBER_PLAIN_NAMED(format, mProperties.mDesc.format, 10)
+		BS_END_RTTI_MEMBERS
+
+		INT32& getUsage(Texture* obj) { return obj->mProperties.mDesc.usage; }
 		void setUsage(Texture* obj, INT32& val) 
 		{ 
 			// Render target and depth stencil texture formats are for in-memory use only
 			// and don't make sense when serialized
 			if (val == TU_DEPTHSTENCIL || val == TU_RENDERTARGET)
-				obj->mProperties.mUsage = TU_STATIC;
+				obj->mProperties.mDesc.usage = TU_STATIC;
 			else
-				obj->mProperties.mUsage = val;
+				obj->mProperties.mDesc.usage = val;
 		}
 
 #define BS_ADD_PLAINFIELD(name, id, parentType) \
@@ -97,16 +82,8 @@ namespace BansheeEngine
 
 	public:
 		TextureRTTI()
+			:mInitMembers(this)
 		{
-			addPlainField("mSize", 0, &TextureRTTI::getSize, &TextureRTTI::setSize);
-			addPlainField("mHeight", 2, &TextureRTTI::getHeight, &TextureRTTI::setHeight);
-			addPlainField("mWidth", 3, &TextureRTTI::getWidth, &TextureRTTI::setWidth);
-			addPlainField("mDepth", 4, &TextureRTTI::getDepth, &TextureRTTI::setDepth);
-			addPlainField("mNumMipmaps", 5, &TextureRTTI::getNumMipmaps, &TextureRTTI::setNumMipmaps);
-			addPlainField("mHwGamma", 6, &TextureRTTI::getHwGamma, &TextureRTTI::setHwGamma);
-			addPlainField("mMultisampleCount", 7, &TextureRTTI::getMultisampleCount, &TextureRTTI::setMultisampleCount);
-			addPlainField("mTextureType", 9, &TextureRTTI::getTextureType, &TextureRTTI::setTextureType);
-			addPlainField("mFormat", 10, &TextureRTTI::getFormat, &TextureRTTI::setFormat);
 			addPlainField("mUsage", 11, &TextureRTTI::getUsage, &TextureRTTI::setUsage);
 
 			addReflectablePtrArrayField("mPixelData", 12, &TextureRTTI::getPixelData, &TextureRTTI::getPixelDataArraySize, 
@@ -131,14 +108,14 @@ namespace BansheeEngine
 
 			// Update pixel format if needed as it's possible the original texture was saved using some other render API
 			// that has an unsupported format.
-			PixelFormat originalFormat = texProps.mFormat;
+			PixelFormat originalFormat = texProps.getFormat();
 			PixelFormat validFormat = TextureManager::instance().getNativeFormat(
-				texProps.mTextureType, texProps.mFormat, texProps.mUsage, texProps.mHwGamma);
+				texProps.getTextureType(), texProps.getFormat(), texProps.getUsage(), texProps.isHardwareGammaEnabled());
 
 			Vector<SPtr<PixelData>>* pixelData = any_cast<Vector<SPtr<PixelData>>*>(texture->mRTTIData);
 			if (originalFormat != validFormat)
 			{
-				texProps.mFormat = validFormat;
+				texProps.mDesc.format = validFormat;
 
 				for (size_t i = 0; i < pixelData->size(); i++)
 				{

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

@@ -50,7 +50,7 @@ namespace BansheeEngine
 			mHeight = textureProps->getHeight();
 			mColorDepth = BansheeEngine::PixelUtil::getNumElemBits(textureProps->getFormat());
 			mHwGamma = textureProps->isHardwareGammaEnabled();
-			mMultisampleCount = textureProps->getMultisampleCount();
+			mMultisampleCount = textureProps->getNumSamples();
 		}
 
 		mActive = true;
@@ -139,8 +139,8 @@ namespace BansheeEngine
 			const TextureProperties& curTexProps = mColorSurfaces[i]->getTexture()->getProperties();
 			const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
 
-			UINT32 curMsCount = curTexProps.getMultisampleCount();
-			UINT32 firstMsCount = firstTexProps.getMultisampleCount();
+			UINT32 curMsCount = curTexProps.getNumSamples();
+			UINT32 firstMsCount = firstTexProps.getNumSamples();
 
 			if (curMsCount == 0)
 				curMsCount = 1;
@@ -186,8 +186,8 @@ namespace BansheeEngine
 				return;
 
 			const TextureProperties& depthTexProps = mDepthStencilSurface->getTexture()->getProperties();
-			UINT32 depthMsCount = depthTexProps.getMultisampleCount();
-			UINT32 colorMsCount = firstTexProps.getMultisampleCount();
+			UINT32 depthMsCount = depthTexProps.getNumSamples();
+			UINT32 colorMsCount = firstTexProps.getNumSamples();
 
 			if (depthMsCount == 0)
 				depthMsCount = 1;
@@ -208,12 +208,10 @@ namespace BansheeEngine
 		}
 	}
 
-	SPtr<RenderTexture> RenderTexture::create(TextureType textureType, UINT32 width, UINT32 height, 
-		PixelFormat format, bool hwGamma, UINT32 multisampleCount, 
+	SPtr<RenderTexture> RenderTexture::create(const TEXTURE_DESC& desc, 
 		bool createDepth, PixelFormat depthStencilFormat)
 	{
-		return TextureManager::instance().createRenderTexture(textureType, width, height, format, hwGamma, 
-			multisampleCount, createDepth, depthStencilFormat);
+		return TextureManager::instance().createRenderTexture(desc, createDepth, depthStencilFormat);
 	}
 
 	SPtr<RenderTexture> RenderTexture::create(const RENDER_TEXTURE_DESC& desc)

+ 40 - 68
Source/BansheeCore/Source/BsTexture.cpp

@@ -13,32 +13,24 @@
 namespace BansheeEngine 
 {
 	TextureProperties::TextureProperties()
-		:mHeight(32), mWidth(32), mDepth(1), mNumArraySlices(1), mNumMipmaps(0),
-		mHwGamma(false), mMultisampleCount(0), mTextureType(TEX_TYPE_2D),
-		mFormat(PF_UNKNOWN), mUsage(TU_DEFAULT)
-	{
-
-	}
+	{ }
 
-	TextureProperties::TextureProperties(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices)
-		:mHeight(height), mWidth(width), mDepth(depth), mNumArraySlices(numArraySlices), mNumMipmaps(numMipmaps),
-		mHwGamma(hwGamma), mMultisampleCount(multisampleCount), mTextureType(textureType),
-		mFormat(format), mUsage(usage)
+	TextureProperties::TextureProperties(const TEXTURE_DESC& desc)
+		:mDesc(desc)
 	{
 
 	}
 
 	bool TextureProperties::hasAlpha() const
 	{
-		return PixelUtil::hasAlpha(mFormat);
+		return PixelUtil::hasAlpha(mDesc.format);
 	}
 
 	UINT32 TextureProperties::getNumFaces() const
 	{
 		UINT32 facesPerSlice = getTextureType() == TEX_TYPE_CUBE_MAP ? 6 : 1;
 
-		return facesPerSlice * mNumArraySlices;
+		return facesPerSlice * mDesc.numArraySlices;
 	}
 
 	void TextureProperties::mapFromSubresourceIdx(UINT32 subresourceIdx, UINT32& face, UINT32& mip) const
@@ -86,11 +78,8 @@ namespace BansheeEngine
 	SPtr<TextureCore> TextureCore::BLACK;
 	SPtr<TextureCore> TextureCore::NORMAL;
 
-	TextureCore::TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices, 
-		const SPtr<PixelData>& initData)
-		:mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, numArraySlices), 
-		mInitData(initData)
+	TextureCore::TextureCore(const TEXTURE_DESC& desc, const SPtr<PixelData>& initData, GpuDeviceFlags deviceMask)
+		:mProperties(desc), mInitData(initData)
 	{ }
 
 	void TextureCore::initialize()
@@ -184,7 +173,7 @@ namespace BansheeEngine
 		if (mProperties.getFormat() != target->mProperties.getFormat()) // Note: It might be okay to use different formats of the same size
 			BS_EXCEPT(InvalidParametersException, "Source and destination texture formats must match.");
 
-		if (target->mProperties.getMultisampleCount() > 0 && mProperties.getMultisampleCount() != target->mProperties.getMultisampleCount())
+		if (target->mProperties.getNumSamples() > 0 && mProperties.getNumSamples() != target->mProperties.getNumSamples())
 			BS_EXCEPT(InvalidParametersException, "When copying to a multisampled texture, source texture must have the same number of samples.");
 
 		UINT32 srcFace = 0;
@@ -303,25 +292,24 @@ namespace BansheeEngine
 	/************************************************************************/
 	/* 								STATICS	                      			*/
 	/************************************************************************/
-	SPtr<TextureCore> TextureCore::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
+	SPtr<TextureCore> TextureCore::create(const TEXTURE_DESC& desc, GpuDeviceFlags deviceMask)
 	{
-		return TextureCoreManager::instance().createTexture(texType,
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
+		return TextureCoreManager::instance().createTexture(desc, deviceMask);
 	}
 
-	SPtr<TextureCore> TextureCore::create(TextureType texType, UINT32 width, UINT32 height,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
+	SPtr<TextureCore> TextureCore::create(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection, 
+		GpuDeviceFlags deviceMask)
 	{
-		return TextureCoreManager::instance().createTexture(texType,
-			width, height, 1, numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
-	}
+		TEXTURE_DESC desc;
+		desc.type = pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D;
+		desc.width = pixelData->getWidth();
+		desc.height = pixelData->getHeight();
+		desc.depth = pixelData->getHeight();
+		desc.format = pixelData->getFormat();
+		desc.usage = usage;
+		desc.hwGamma = hwGammaCorrection;
 
-	SPtr<TextureCore> TextureCore::create(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection)
-	{
-		return TextureCoreManager::instance().createTextureInternal(pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D, 
-			pixelData->getWidth(), pixelData->getHeight(),
-			pixelData->getDepth(), 0, pixelData->getFormat(), usage, hwGammaCorrection, 0, 1, pixelData);
+		return TextureCoreManager::instance().createTextureInternal(desc, pixelData, deviceMask);
 	}
 
 	Texture::Texture()
@@ -329,16 +317,14 @@ namespace BansheeEngine
 
 	}
 
-	Texture::Texture(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices)
-		:mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, numArraySlices)
+	Texture::Texture(const TEXTURE_DESC& desc)
+		:mProperties(desc)
     {
         
     }
 
-	Texture::Texture(const SPtr<PixelData>& pixelData, int usage, bool hwGamma)
-		: mProperties(pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D, pixelData->getWidth(), pixelData->getHeight(),
-		pixelData->getDepth(), 0, pixelData->getFormat(), usage, hwGamma, 0, 1), mInitData(pixelData)
+	Texture::Texture(const TEXTURE_DESC& desc, const SPtr<PixelData>& pixelData)
+		: mProperties(desc), mInitData(pixelData)
 	{
 		if (mInitData != nullptr)
 			mInitData->_lock();
@@ -364,10 +350,7 @@ namespace BansheeEngine
 	{
 		const TextureProperties& props = getProperties();
 
-		SPtr<CoreObjectCore> coreObj = TextureCoreManager::instance().createTextureInternal(props.getTextureType(), 
-			props.getWidth(), props.getHeight(), props.getDepth(), props.getNumMipmaps(), props.getFormat(), 
-			props.getUsage(), props.isHardwareGammaEnabled(), props.getMultisampleCount(), props.getNumArraySlices(), 
-			mInitData);
+		SPtr<CoreObjectCore> coreObj = TextureCoreManager::instance().createTextureInternal(props.mDesc, mInitData);
 
 		if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
 			mInitData = nullptr;
@@ -542,24 +525,13 @@ namespace BansheeEngine
 	/************************************************************************/
 	/* 								STATICS	                      			*/
 	/************************************************************************/
-	HTexture Texture::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
+	HTexture Texture::create(const TEXTURE_DESC& desc)
 	{
-		SPtr<Texture> texturePtr = _createPtr(texType, 
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
+		SPtr<Texture> texturePtr = _createPtr(desc);
 
 		return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
 	}
 	
-	HTexture Texture::create(TextureType texType, UINT32 width, UINT32 height, 
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
-	{
-		SPtr<Texture> texturePtr = _createPtr(texType, 
-			width, height, numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
-
-		return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
-	}
-
 	HTexture Texture::create(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection)
 	{
 		SPtr<Texture> texturePtr = _createPtr(pixelData, usage, hwGammaCorrection);
@@ -567,22 +539,22 @@ namespace BansheeEngine
 		return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
 	}
 
-	SPtr<Texture> Texture::_createPtr(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
+	SPtr<Texture> Texture::_createPtr(const TEXTURE_DESC& desc)
 	{
-		return TextureManager::instance().createTexture(texType, 
-			width, height, depth, num_mips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
-	}
-
-	SPtr<Texture> Texture::_createPtr(TextureType texType, UINT32 width, UINT32 height, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
-	{
-		return TextureManager::instance().createTexture(texType, 
-			width, height, num_mips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices);
+		return TextureManager::instance().createTexture(desc);
 	}
 
 	SPtr<Texture> Texture::_createPtr(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection)
 	{
-		return TextureManager::instance().createTexture(pixelData, usage, hwGammaCorrection);
+		TEXTURE_DESC desc;
+		desc.type = pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D;
+		desc.width = pixelData->getWidth();
+		desc.height = pixelData->getHeight();
+		desc.depth = pixelData->getHeight();
+		desc.format = pixelData->getFormat();
+		desc.usage = usage;
+		desc.hwGamma = hwGammaCorrection;
+
+		return TextureManager::instance().createTexture(desc, pixelData);
 	}
 }

+ 28 - 17
Source/BansheeCore/Source/BsTextureManager.cpp

@@ -7,10 +7,9 @@
 
 namespace BansheeEngine 
 {
-    SPtr<Texture> TextureManager::createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, int numMipmaps,
-        PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices)
+    SPtr<Texture> TextureManager::createTexture(const TEXTURE_DESC& desc)
     {
-		Texture* tex = new (bs_alloc<Texture>()) Texture(texType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, numArraySlices);
+		Texture* tex = new (bs_alloc<Texture>()) Texture(desc);
 		SPtr<Texture> ret = bs_core_ptr<Texture>(tex);
 
 		ret->_setThisPtr(ret);
@@ -19,9 +18,9 @@ namespace BansheeEngine
 		return ret;
     }
 
-	SPtr<Texture> TextureManager::createTexture(const SPtr<PixelData>& pixelData, int usage , bool hwGammaCorrection)
+	SPtr<Texture> TextureManager::createTexture(const TEXTURE_DESC& desc, const SPtr<PixelData>& pixelData)
     {
-		Texture* tex = new (bs_alloc<Texture>()) Texture(pixelData, usage, hwGammaCorrection);
+		Texture* tex = new (bs_alloc<Texture>()) Texture(desc, pixelData);
 		SPtr<Texture> ret = bs_core_ptr<Texture>(tex);
 
 		ret->_setThisPtr(ret);
@@ -39,16 +38,23 @@ namespace BansheeEngine
 		return texture;
 	}
 
-	SPtr<RenderTexture> TextureManager::createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
-			PixelFormat format, bool hwGamma, UINT32 multisampleCount, 
-			bool createDepth, PixelFormat depthStencilFormat)
+	SPtr<RenderTexture> TextureManager::createRenderTexture(const TEXTURE_DESC& colorDesc, bool createDepth,
+		PixelFormat depthStencilFormat)
 	{
-		HTexture texture = Texture::create(textureType, width, height, 0, format, TU_RENDERTARGET, hwGamma, multisampleCount);
+		TEXTURE_DESC textureDesc = colorDesc;
+		textureDesc.usage = TU_RENDERTARGET;
+		textureDesc.numMips = 0;
+
+		HTexture texture = Texture::create(textureDesc);
 
 		HTexture depthStencil;
 		if(createDepth)
 		{
-			depthStencil = Texture::create(TEX_TYPE_2D, width, height, 0, depthStencilFormat, TU_DEPTHSTENCIL, false, multisampleCount);
+			textureDesc.format = depthStencilFormat;
+			textureDesc.hwGamma = false;
+			textureDesc.usage = TU_DEPTHSTENCIL;
+
+			depthStencil = Texture::create(textureDesc);
 		}
 
 		RENDER_TEXTURE_DESC desc;
@@ -78,8 +84,15 @@ namespace BansheeEngine
 
 	void TextureCoreManager::onStartUp()
     {
+		TEXTURE_DESC desc;
+		desc.type = TEX_TYPE_2D;
+		desc.width = 2;
+		desc.height = 2;
+		desc.format = PF_R8G8B8A8;
+		desc.usage = TU_STATIC;
+
 		// White built-in texture
-		SPtr<TextureCore> whiteTexture = createTexture(TEX_TYPE_2D, 2, 2, 1, 0, PF_R8G8B8A8, TU_STATIC);
+		SPtr<TextureCore> whiteTexture = createTexture(desc);
 
 		SPtr<PixelData> whitePixelData = PixelData::create(2, 2, 1, PF_R8G8B8A8);
 		whitePixelData->setColorAt(Color::White, 0, 0);
@@ -91,7 +104,7 @@ namespace BansheeEngine
 		TextureCore::WHITE = whiteTexture;
 
 		// Black built-in texture
-		SPtr<TextureCore> blackTexture = createTexture(TEX_TYPE_2D, 2, 2, 1, 0, PF_R8G8B8A8, TU_STATIC);
+		SPtr<TextureCore> blackTexture = createTexture(desc);
 
 		SPtr<PixelData> blackPixelData = PixelData::create(2, 2, 1, PF_R8G8B8A8);
 		blackPixelData->setColorAt(Color::Black, 0, 0);
@@ -103,7 +116,7 @@ namespace BansheeEngine
 		TextureCore::BLACK = blackTexture;
 
 		// Normal (Y = Up) built-in texture
-		SPtr<TextureCore> normalTexture = createTexture(TEX_TYPE_2D, 2, 2, 1, 0, PF_R8G8B8A8, TU_STATIC);
+		SPtr<TextureCore> normalTexture = createTexture(desc);
 		SPtr<PixelData> normalPixelData = PixelData::create(2, 2, 1, PF_R8G8B8A8);
 
 		Color encodedNormal(0.5f, 0.5f, 1.0f);
@@ -124,11 +137,9 @@ namespace BansheeEngine
 		TextureCore::NORMAL = nullptr;
     }
 
-	SPtr<TextureCore> TextureCoreManager::createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices)
+	SPtr<TextureCore> TextureCoreManager::createTexture(const TEXTURE_DESC& desc, GpuDeviceFlags deviceMask)
 	{
-		SPtr<TextureCore> newRT = createTextureInternal(texType, width, height, depth, numMips, format, 
-			usage, hwGammaCorrection, multisampleCount, numArraySlices);
+		SPtr<TextureCore> newRT = createTextureInternal(desc, nullptr, deviceMask);
 		newRT->initialize();
 
 		return newRT;

+ 1 - 3
Source/BansheeD3D11RenderAPI/Include/BsD3D11Texture.h

@@ -35,9 +35,7 @@ namespace BansheeEngine
 	protected:
 		friend class D3D11TextureCoreManager;
 
-		D3D11TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices, 
-			const SPtr<PixelData>& initialData);
+		D3D11TextureCore(const TEXTURE_DESC& desc, const SPtr<PixelData>& initialData, GpuDeviceFlags deviceMask);
 
 		/** @copydoc CoreObjectCore::initialize() */
 		void initialize() override;

+ 2 - 3
Source/BansheeD3D11RenderAPI/Include/BsD3D11TextureManager.h

@@ -28,9 +28,8 @@ namespace BansheeEngine
 	{
 	protected:
 		/** @copydoc	TextureCoreManager::createTextureInternal */
-		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) override;
+		SPtr<TextureCore> createTextureInternal(const TEXTURE_DESC& desc, 
+			const SPtr<PixelData>& initialData = nullptr, GpuDeviceFlags deviceMask = GDF_DEFAULT) override;
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 

+ 9 - 4
Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderWindow.cpp

@@ -645,10 +645,15 @@ namespace BansheeEngine
 
 		if (mDesc.depthBuffer)
 		{
-			mDepthStencilBuffer = TextureCoreManager::instance().createTexture(TEX_TYPE_2D,
-				BBDesc.Width, BBDesc.Height, 0, 0, PF_D24S8, TU_DEPTHSTENCIL, false,
-				getProperties().getMultisampleCount());
-
+			TEXTURE_DESC texDesc;
+			texDesc.type = TEX_TYPE_2D;
+			texDesc.width = BBDesc.Width;
+			texDesc.height = BBDesc.Height;
+			texDesc.format = PF_D24S8;
+			texDesc.usage = TU_DEPTHSTENCIL;
+			texDesc.numSamples = getProperties().getMultisampleCount();
+
+			mDepthStencilBuffer = TextureCore::create(texDesc);
 			mDepthStencilView = TextureCore::requestView(mDepthStencilBuffer, 0, 1, 0, 1, GVU_DEPTHSTENCIL);
 		}
 		else

+ 13 - 11
Source/BansheeD3D11RenderAPI/Source/BsD3D11Texture.cpp

@@ -13,13 +13,15 @@
 
 namespace BansheeEngine
 {
-	D3D11TextureCore::D3D11TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices, const SPtr<PixelData>& initialData)
-		: TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, numArraySlices, initialData),
+	D3D11TextureCore::D3D11TextureCore(const TEXTURE_DESC& desc, const SPtr<PixelData>& initialData, 
+		GpuDeviceFlags deviceMask)
+		: TextureCore(desc, initialData, deviceMask),
 		m1DTex(nullptr), m2DTex(nullptr), m3DTex(nullptr), mDXGIFormat(DXGI_FORMAT_UNKNOWN), mDXGIColorFormat(DXGI_FORMAT_UNKNOWN),
 		mTex(nullptr), mStagingBuffer(nullptr), mDXGIDepthStencilFormat(DXGI_FORMAT_UNKNOWN),
 		mLockedSubresourceIdx(-1), mLockedForReading(false), mStaticBuffer(nullptr)
-	{ }
+	{
+		assert((deviceMask == GDF_DEFAULT || deviceMask == GDF_PRIMARY) && "Multiple GPUs not supported natively on DirectX 11.");
+	}
 
 	D3D11TextureCore::~D3D11TextureCore()
 	{ 
@@ -66,10 +68,10 @@ namespace BansheeEngine
 		D3D11RenderAPI* rs = static_cast<D3D11RenderAPI*>(RenderAPICore::instancePtr());
 		D3D11Device& device = rs->getPrimaryDevice();
 
-		bool srcHasMultisample = mProperties.getMultisampleCount() > 1;
-		bool destHasMultisample = target->getProperties().getMultisampleCount() > 1;
+		bool srcHasMultisample = mProperties.getNumSamples() > 1;
+		bool destHasMultisample = target->getProperties().getNumSamples() > 1;
 
-		if (srcHasMultisample && destHasMultisample && mProperties.getMultisampleCount() != target->getProperties().getMultisampleCount()) // Resolving from MS to non-MS texture
+		if (srcHasMultisample && destHasMultisample && mProperties.getNumSamples() != target->getProperties().getNumSamples()) // Resolving from MS to non-MS texture
 		{
 			device.getImmediateContext()->ResolveSubresource(other->getDX11Resource(), destResIdx, mTex, srcResIdx, mDXGIFormat);
 		}
@@ -87,7 +89,7 @@ namespace BansheeEngine
 
 	PixelData D3D11TextureCore::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
-		if (mProperties.getMultisampleCount() > 1)
+		if (mProperties.getNumSamples() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 #if BS_PROFILING_ENABLED
@@ -153,7 +155,7 @@ namespace BansheeEngine
 
 	void D3D11TextureCore::readData(PixelData& dest, UINT32 mipLevel, UINT32 face)
 	{
-		if (mProperties.getMultisampleCount() > 1)
+		if (mProperties.getNumSamples() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		PixelData myData = lock(GBL_READ_ONLY, mipLevel, face);
@@ -175,7 +177,7 @@ namespace BansheeEngine
 	{
 		PixelFormat format = mProperties.getFormat();
 
-		if (mProperties.getMultisampleCount() > 1)
+		if (mProperties.getNumSamples() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		mipLevel = Math::clamp(mipLevel, (UINT32)mipLevel, mProperties.getNumMipmaps());
@@ -338,7 +340,7 @@ namespace BansheeEngine
 		UINT32 numMips = mProperties.getNumMipmaps();
 		PixelFormat format = mProperties.getFormat();
 		bool hwGamma = mProperties.isHardwareGammaEnabled();
-		UINT32 sampleCount = mProperties.getMultisampleCount();
+		UINT32 sampleCount = mProperties.getNumSamples();
 		TextureType texType = mProperties.getTextureType();
 		PixelFormat closestFormat = D3D11Mappings::getClosestSupportedPF(format, hwGamma);
 		UINT32 numFaces = mProperties.getNumFaces();

+ 3 - 4
Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureManager.cpp

@@ -23,11 +23,10 @@ namespace BansheeEngine
 		return D3D11Mappings::getPF(d3dPF);
 	}
 
-	SPtr<TextureCore> D3D11TextureCoreManager::createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices, const SPtr<PixelData>& initialData)
+	SPtr<TextureCore> D3D11TextureCoreManager::createTextureInternal(const TEXTURE_DESC& desc,
+		const SPtr<PixelData>& initialData, GpuDeviceFlags deviceMask)
 	{
-		D3D11TextureCore* tex = new (bs_alloc<D3D11TextureCore>()) D3D11TextureCore(texType, 
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices, initialData);
+		D3D11TextureCore* tex = new (bs_alloc<D3D11TextureCore>()) D3D11TextureCore(desc, initialData, deviceMask);
 
 		SPtr<D3D11TextureCore> texPtr = bs_shared_ptr<D3D11TextureCore>(tex);
 		texPtr->_setThisPtr(texPtr);

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

@@ -65,7 +65,7 @@ namespace BansheeEngine
 			}
 			break;
 		case TEX_TYPE_2D:
-			if (texProps.getMultisampleCount() > 1)
+			if (texProps.getNumSamples() > 1)
 			{
 				if (numFaces <= 1)
 				{
@@ -163,7 +163,7 @@ namespace BansheeEngine
 			}
 			break;
 		case TEX_TYPE_2D:
-			if (texProps.getMultisampleCount() > 1)
+			if (texProps.getNumSamples() > 1)
 			{
 				if (numFaces <= 1)
 				{
@@ -321,7 +321,7 @@ namespace BansheeEngine
 			}
 			break;
 		case TEX_TYPE_2D:
-			if (texProps.getMultisampleCount() > 1)
+			if (texProps.getNumSamples() > 1)
 			{
 				if (numFaces <= 1)
 				{

+ 8 - 2
Source/BansheeEditor/Source/BsScenePicking.cpp

@@ -289,8 +289,14 @@ namespace BansheeEngine
 		SPtr<TextureCore> outputTexture = rtt->getColorTexture(0);
 		TextureProperties outputTextureProperties = outputTexture->getProperties();
 
-		SPtr<TextureCore> normalsTexture = TextureCore::create(TEX_TYPE_2D, outputTextureProperties.getWidth(),
-			outputTextureProperties.getHeight(), 0, PF_R8G8B8A8, TU_RENDERTARGET, false, 1);
+		TEXTURE_DESC normalTexDesc;
+		normalTexDesc.type = TEX_TYPE_2D;
+		normalTexDesc.width = outputTextureProperties.getWidth();
+		normalTexDesc.height = outputTextureProperties.getHeight();
+		normalTexDesc.format = PF_R8G8B8A8;
+		normalTexDesc.usage = TU_RENDERTARGET;
+
+		SPtr<TextureCore> normalsTexture = TextureCore::create(normalTexDesc);
 		SPtr<TextureCore> depthTexture = rtt->getDepthStencilTexture();
 
 		RENDER_TEXTURE_DESC_CORE pickingMRT;

+ 6 - 2
Source/BansheeEngine/Source/BsGUIManager.cpp

@@ -703,7 +703,9 @@ namespace BansheeEngine
 	{
 		if(mCaretTexture == nullptr)
 		{
-			HTexture newTex = Texture::create(TEX_TYPE_2D, 1, 1, 0, PF_R8G8B8A8);
+			TEXTURE_DESC texDesc; // Default
+
+			HTexture newTex = Texture::create(texDesc);
 			mCaretTexture = SpriteTexture::create(newTex);
 		}
 
@@ -719,7 +721,9 @@ namespace BansheeEngine
 	{
 		if(mTextSelectionTexture == nullptr)
 		{
-			HTexture newTex = Texture::create(TEX_TYPE_2D, 1, 1, 0, PF_R8G8B8A8);
+			TEXTURE_DESC texDesc; // Default
+
+			HTexture newTex = Texture::create(texDesc);
 			mTextSelectionTexture = SpriteTexture::create(newTex);
 		}
 

+ 2 - 2
Source/BansheeEngine/Source/BsRendererUtility.cpp

@@ -236,7 +236,7 @@ namespace BansheeEngine
 		auto& texProps = texture->getProperties();
 		SPtr<MaterialCore> mat;
 		SPtr<GpuParamsSetCore> params;
-		if (texProps.getMultisampleCount() > 1)
+		if (texProps.getNumSamples() > 1)
 		{
 			mat = mResolveMat->getMaterial();
 			params = mResolveMat->getParamsSet();
@@ -356,7 +356,7 @@ namespace BansheeEngine
 	{
 		mSource.set(source);
 
-		UINT32 sampleCount = source->getProperties().getMultisampleCount();
+		UINT32 sampleCount = source->getProperties().getNumSamples();
 		mNumSamples.set(sampleCount);
 
 		mMaterial->updateParamsSet(mParamsSet);

+ 6 - 1
Source/BansheeFontImporter/Source/BsFontImporter.cpp

@@ -323,7 +323,12 @@ namespace BansheeEngine
 					}
 				}
 
-				HTexture newTex = Texture::create(TEX_TYPE_2D, pageIter->width, pageIter->height, 0, PF_R8G8);
+				TEXTURE_DESC texDesc;
+				texDesc.width = pageIter->width;
+				texDesc.height = pageIter->height;
+				texDesc.format = PF_R8G8;
+
+				HTexture newTex = Texture::create(texDesc);
 				UINT32 subresourceIdx = newTex->getProperties().mapToSubresourceIdx(0, 0);
 
 				// It's possible the formats no longer match

+ 10 - 2
Source/BansheeFreeImgImporter/Source/BsFreeImgImporter.cpp

@@ -156,8 +156,16 @@ namespace BansheeEngine
 
 		bool sRGB = textureImportOptions->getSRGB();
 
-		SPtr<Texture> newTexture = Texture::_createPtr(TEX_TYPE_2D, 
-			imgData->getWidth(), imgData->getHeight(), numMips, textureImportOptions->getFormat(), usage, sRGB);
+		TEXTURE_DESC texDesc;
+		texDesc.type = TEX_TYPE_2D;
+		texDesc.width = imgData->getWidth();
+		texDesc.height = imgData->getHeight();
+		texDesc.numMips = numMips;
+		texDesc.format = textureImportOptions->getFormat();
+		texDesc.usage = usage;
+		texDesc.hwGamma = sRGB;
+
+		SPtr<Texture> newTexture = Texture::_createPtr(texDesc);
 
 		Vector<SPtr<PixelData>> mipLevels;
 		if (numMips > 0)

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

@@ -41,8 +41,8 @@ namespace BansheeEngine
     protected:
 		friend class GLTextureCoreManager;
 
-		GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices, const SPtr<PixelData>& initialData);
+		GLTextureCore(GLSupport& support, const TEXTURE_DESC& desc, const SPtr<PixelData>& initialData, 
+			GpuDeviceFlags deviceMask);
 
 		/** @copydoc TextureCore::initialize */
 		void initialize() override;

+ 2 - 3
Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h

@@ -40,9 +40,8 @@ namespace BansheeEngine
 
 	protected:		
 		/** @copydoc TextureCoreManager::createTextureInternal */
-		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) override;
+		SPtr<TextureCore> createTextureInternal(const TEXTURE_DESC& desc,
+			const SPtr<PixelData>& initialData = nullptr, GpuDeviceFlags deviceMask = GDF_DEFAULT) override;
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 

+ 12 - 11
Source/BansheeGLRenderAPI/Source/BsGLTexture.cpp

@@ -13,12 +13,13 @@
 
 namespace BansheeEngine 
 {
-	GLTextureCore::GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, 
-		UINT32 numMipmaps, PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, UINT32 numArraySlices, 
-		const SPtr<PixelData>& initialData)
-		: TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, numArraySlices, initialData),
+	GLTextureCore::GLTextureCore(GLSupport& support, const TEXTURE_DESC& desc, const SPtr<PixelData>& initialData, 
+		GpuDeviceFlags deviceMask)
+		: TextureCore(desc, initialData, deviceMask),
 		mTextureID(0), mGLFormat(0), mGLSupport(support)
-    { }
+	{
+		assert((deviceMask == GDF_DEFAULT || deviceMask == GDF_PRIMARY) && "Multiple GPUs not supported natively on OpenGL.");
+	}
 
 	GLTextureCore::~GLTextureCore()
     { 
@@ -76,7 +77,7 @@ namespace BansheeEngine
 				BS_EXCEPT(InvalidParametersException, "Cannot use a compressed format for a depth stencil target.");
 		}
 
-		UINT32 sampleCount = mProperties.getMultisampleCount();
+		UINT32 sampleCount = mProperties.getNumSamples();
 		if((usage & (TU_RENDERTARGET | TU_DEPTHSTENCIL)) != 0 && mProperties.getTextureType() == TEX_TYPE_2D && sampleCount > 1)
 		{
 			if (numFaces <= 1)
@@ -175,7 +176,7 @@ namespace BansheeEngine
 				else
 					return GL_TEXTURE_1D_ARRAY;
             case TEX_TYPE_2D:
-				if (mProperties.getMultisampleCount() > 1)
+				if (mProperties.getNumSamples() > 1)
 				{
 					if (mProperties.getNumFaces() <= 1)
 						return GL_TEXTURE_2D_MULTISAMPLE;
@@ -210,7 +211,7 @@ namespace BansheeEngine
 
 	PixelData GLTextureCore::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
-		if (mProperties.getMultisampleCount() > 1)
+		if (mProperties.getNumSamples() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		if(mLockedBuffer != nullptr)
@@ -239,7 +240,7 @@ namespace BansheeEngine
 
 	void GLTextureCore::readData(PixelData& dest, UINT32 mipLevel, UINT32 face)
 	{
-		if (mProperties.getMultisampleCount() > 1)
+		if (mProperties.getNumSamples() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		getBuffer(face, mipLevel)->download(dest);
@@ -247,7 +248,7 @@ namespace BansheeEngine
 
 	void GLTextureCore::writeData(const PixelData& src, UINT32 mipLevel, UINT32 face, bool discardWholeBuffer)
 	{
-		if (mProperties.getMultisampleCount() > 1)
+		if (mProperties.getNumSamples() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		getBuffer(face, mipLevel)->upload(src, src.getExtents());
@@ -271,7 +272,7 @@ namespace BansheeEngine
 			{
                 GLPixelBuffer *buf = bs_new<GLTextureBuffer>(getGLTextureTarget(), mTextureID, face, mip,
 					static_cast<GpuBufferUsage>(mProperties.getUsage()), 
-					mProperties.isHardwareGammaEnabled(), mProperties.getMultisampleCount());
+					mProperties.isHardwareGammaEnabled(), mProperties.getNumSamples());
 
 				mSurfaceList.push_back(bs_shared_ptr<GLPixelBuffer>(buf));
                 if(buf->getWidth() == 0 || buf->getHeight() == 0 || buf->getDepth() == 0)

+ 3 - 4
Source/BansheeGLRenderAPI/Source/BsGLTextureManager.cpp

@@ -58,11 +58,10 @@ namespace BansheeEngine
 		:mGLSupport(support)
 	{ }
 
-	SPtr<TextureCore> GLTextureCoreManager::createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, UINT32 numArraySlices, const SPtr<PixelData>& initialData)
+	SPtr<TextureCore> GLTextureCoreManager::createTextureInternal(const TEXTURE_DESC& desc,
+		const SPtr<PixelData>& initialData, GpuDeviceFlags deviceMask)
 	{
-		GLTextureCore* tex = new (bs_alloc<GLTextureCore>()) GLTextureCore(mGLSupport, texType,
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, numArraySlices, initialData);
+		GLTextureCore* tex = new (bs_alloc<GLTextureCore>()) GLTextureCore(mGLSupport, desc, initialData, deviceMask);
 
 		SPtr<GLTextureCore> texPtr = bs_shared_ptr<GLTextureCore>(tex);
 		texPtr->_setThisPtr(texPtr);

+ 12 - 3
Source/RenderBeast/Source/BsRenderTexturePool.cpp

@@ -45,8 +45,17 @@ namespace BansheeEngine
 		SPtr<PooledRenderTexture> newTextureData = bs_shared_ptr_new<PooledRenderTexture>(this);
 		_registerTexture(newTextureData);
 
-		newTextureData->texture = TextureCoreManager::instance().createTexture(desc.type, desc.width, desc.height, 
-			desc.depth, 0, desc.format, desc.flag, desc.hwGamma, desc.numSamples);
+		TEXTURE_DESC texDesc;
+		texDesc.type = desc.type;
+		texDesc.width = desc.width;
+		texDesc.height = desc.height;
+		texDesc.depth = desc.depth;
+		texDesc.format = desc.format;
+		texDesc.usage = desc.flag;
+		texDesc.hwGamma = desc.hwGamma;
+		texDesc.numSamples = desc.numSamples;
+
+		newTextureData->texture = TextureCoreManager::instance().createTexture(texDesc);
 		
 		if ((desc.flag & (TU_RENDERTARGET | TU_DEPTHSTENCIL)) != 0)
 		{
@@ -92,7 +101,7 @@ namespace BansheeEngine
 			&& (
 				(desc.type == TEX_TYPE_2D 
 					&& texProps.isHardwareGammaEnabled() == desc.hwGamma 
-					&& texProps.getMultisampleCount() == desc.numSamples)
+					&& texProps.getNumSamples() == desc.numSamples)
 				|| (desc.type == TEX_TYPE_3D 
 					&& texProps.getDepth() == desc.depth)
 				|| (desc.type == TEX_TYPE_CUBE_MAP)

+ 9 - 3
Source/SBansheeEngine/Source/BsScriptRenderTexture2D.cpp

@@ -34,9 +34,15 @@ namespace BansheeEngine
 	void ScriptRenderTexture2D::internal_createDetailed(MonoObject* instance, PixelFormat format, UINT32 width, UINT32 height,
 		UINT32 numSamples, bool gammaCorrection, bool createDepth, PixelFormat depthStencilFormat)
 	{
-		SPtr<RenderTexture> tex = RenderTexture::create(TEX_TYPE_2D, width, height, format, gammaCorrection, numSamples, 
-			createDepth, depthStencilFormat);
-
+		TEXTURE_DESC texDesc;
+		texDesc.type = TEX_TYPE_2D;
+		texDesc.width = width;
+		texDesc.height = height;
+		texDesc.format = format;
+		texDesc.hwGamma = gammaCorrection;
+		texDesc.numSamples = numSamples;
+
+		SPtr<RenderTexture> tex = RenderTexture::create(texDesc, createDepth, depthStencilFormat);
 		new (bs_alloc<ScriptRenderTexture2D>()) ScriptRenderTexture2D(tex, instance);
 	}
 

+ 1 - 1
Source/SBansheeEngine/Source/BsScriptTexture.cpp

@@ -58,7 +58,7 @@ namespace BansheeEngine
 	void ScriptTexture::internal_getSampleCount(ScriptTexture* thisPtr, int* value)
 	{
 		HTexture texture = static_resource_cast<Texture>(thisPtr->getGenericHandle());
-		*value = (TextureUsage)texture->getProperties().getMultisampleCount();
+		*value = (TextureUsage)texture->getProperties().getNumSamples();
 	}
 
 	void ScriptTexture::internal_getMipmapCount(ScriptTexture* thisPtr, int* value)

+ 11 - 1
Source/SBansheeEngine/Source/BsScriptTexture2D.cpp

@@ -39,7 +39,17 @@ namespace BansheeEngine
 		if(hasMipmaps)
 			numMips = PixelUtil::getMaxMipmaps(width, height, 1, format);
 
-		HTexture texture = Texture::create(TEX_TYPE_2D, width, height, numMips, format, usage, gammaCorrection, numSamples);
+		TEXTURE_DESC texDesc;
+		texDesc.type = TEX_TYPE_2D;
+		texDesc.width = width;
+		texDesc.height = height;
+		texDesc.numMips = numMips;
+		texDesc.format = format;
+		texDesc.usage = usage;
+		texDesc.hwGamma = gammaCorrection;
+		texDesc.numSamples = numSamples;
+
+		HTexture texture = Texture::create(texDesc);
 
 		ScriptTexture2D* scriptInstance;
 		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);

+ 11 - 1
Source/SBansheeEngine/Source/BsScriptTexture3D.cpp

@@ -38,7 +38,17 @@ namespace BansheeEngine
 		if (hasMipmaps)
 			numMips = PixelUtil::getMaxMipmaps(width, height, depth, format);
 
-		HTexture texture = Texture::create(TEX_TYPE_3D, width, height, depth, numMips, format, usage, gammaCorrection);
+		TEXTURE_DESC texDesc;
+		texDesc.type = TEX_TYPE_3D;
+		texDesc.width = width;
+		texDesc.height = height;
+		texDesc.depth = depth;
+		texDesc.numMips = numMips;
+		texDesc.format = format;
+		texDesc.usage = usage;
+		texDesc.hwGamma = gammaCorrection;
+
+		HTexture texture = Texture::create(texDesc);
 
 		ScriptTexture3D* scriptInstance;
 		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);

+ 11 - 1
Source/SBansheeEngine/Source/BsScriptTextureCube.cpp

@@ -38,7 +38,17 @@ namespace BansheeEngine
 		if (hasMipmaps)
 			numMips = PixelUtil::getMaxMipmaps(width, height, 1, format);
 
-		HTexture texture = Texture::create(TEX_TYPE_CUBE_MAP, width, height, numMips, format, usage, gammaCorrection, numSamples);
+		TEXTURE_DESC texDesc;
+		texDesc.type = TEX_TYPE_CUBE_MAP;
+		texDesc.width = width;
+		texDesc.height = height;
+		texDesc.numMips = numMips;
+		texDesc.format = format;
+		texDesc.usage = usage;
+		texDesc.hwGamma = gammaCorrection;
+		texDesc.numSamples = numSamples;
+
+		HTexture texture = Texture::create(texDesc);
 
 		ScriptTextureCube* scriptInstance;
 		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);