Bladeren bron

Refactored TextureView and VertexDeclaration to comply with new CoreObject design

Marko Pintera 11 jaren geleden
bovenliggende
commit
01910311ca
48 gewijzigde bestanden met toevoegingen van 320 en 211 verwijderingen
  1. 1 0
      BansheeCore/Include/BsCorePrerequisites.h
  2. 12 6
      BansheeCore/Include/BsHardwareBufferManager.h
  3. 1 1
      BansheeCore/Include/BsMeshHeap.h
  4. 1 1
      BansheeCore/Include/BsRenderSystem.h
  5. 2 2
      BansheeCore/Include/BsTexture.h
  6. 2 10
      BansheeCore/Include/BsTextureView.h
  7. 1 1
      BansheeCore/Include/BsVertexData.h
  8. 5 5
      BansheeCore/Include/BsVertexDataDesc.h
  9. 88 19
      BansheeCore/Include/BsVertexDeclaration.h
  10. 14 6
      BansheeCore/Include/BsVertexDeclarationRTTI.h
  11. 1 1
      BansheeCore/Source/BsCoreThreadAccessor.cpp
  12. 26 10
      BansheeCore/Source/BsHardwareBufferManager.cpp
  13. 4 2
      BansheeCore/Source/BsMesh.cpp
  14. 5 3
      BansheeCore/Source/BsMeshHeap.cpp
  15. 3 7
      BansheeCore/Source/BsTexture.cpp
  16. 2 7
      BansheeCore/Source/BsTextureView.cpp
  17. 5 6
      BansheeCore/Source/BsVertexDataDesc.cpp
  18. 39 13
      BansheeCore/Source/BsVertexDeclaration.cpp
  19. 2 2
      BansheeD3D11RenderSystem/Include/BsD3D11GpuProgram.h
  20. 1 1
      BansheeD3D11RenderSystem/Include/BsD3D11HLSLParamParser.h
  21. 4 4
      BansheeD3D11RenderSystem/Include/BsD3D11InputLayoutManager.h
  22. 2 2
      BansheeD3D11RenderSystem/Include/BsD3D11RenderSystem.h
  23. 1 1
      BansheeD3D11RenderSystem/Include/BsD3D11Texture.h
  24. 3 12
      BansheeD3D11RenderSystem/Include/BsD3D11TextureView.h
  25. 2 2
      BansheeD3D11RenderSystem/Source/BsD3D11GpuProgram.cpp
  26. 1 1
      BansheeD3D11RenderSystem/Source/BsD3D11HLSLParamParser.cpp
  27. 10 0
      BansheeD3D11RenderSystem/Source/BsD3D11HLSLProgramFactory.cpp
  28. 14 9
      BansheeD3D11RenderSystem/Source/BsD3D11InputLayoutManager.cpp
  29. 1 1
      BansheeD3D11RenderSystem/Source/BsD3D11RenderSystem.cpp
  30. 2 5
      BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp
  31. 6 17
      BansheeD3D11RenderSystem/Source/BsD3D11TextureView.cpp
  32. 8 7
      BansheeD3D9RenderSystem/Include/BsD3D9HardwareBufferManager.h
  33. 1 1
      BansheeD3D9RenderSystem/Include/BsD3D9Prerequisites.h
  34. 1 1
      BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h
  35. 6 6
      BansheeD3D9RenderSystem/Include/BsD3D9VertexDeclaration.h
  36. 10 6
      BansheeD3D9RenderSystem/Source/BsD3D9HardwareBufferManager.cpp
  37. 2 2
      BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp
  38. 16 14
      BansheeD3D9RenderSystem/Source/BsD3D9VertexDeclaration.cpp
  39. 1 1
      BansheeEditorExec/BsEditorExec.cpp
  40. 2 2
      BansheeGLRenderSystem/Include/BsGLRenderSystem.h
  41. 1 1
      BansheeGLRenderSystem/Include/BsGLVertexArrayObjectManager.h
  42. 1 1
      BansheeGLRenderSystem/Source/BsGLRenderSystem.cpp
  43. 2 2
      BansheeGLRenderSystem/Source/BsGLSLParamParser.cpp
  44. 3 3
      BansheeGLRenderSystem/Source/BsGLVertexArrayObjectManager.cpp
  45. 2 2
      BansheeGLRenderSystem/Source/GLSL/include/BsGLSLGpuProgram.h
  46. 1 1
      BansheeGLRenderSystem/Source/GLSL/include/BsGLSLParamParser.h
  47. 2 2
      BansheeGLRenderSystem/Source/GLSL/src/BsGLSLGpuProgram.cpp
  48. 0 2
      TODO.txt

+ 1 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -152,6 +152,7 @@ namespace BansheeEngine
 	class TransientMeshCore;
 	class TransientMeshCore;
 	class TextureCore;
 	class TextureCore;
 	class MeshHeapCore;
 	class MeshHeapCore;
+	class VertexDeclarationCore;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;
 	class Importer;
 	class Importer;

+ 12 - 6
BansheeCore/Include/BsHardwareBufferManager.h

@@ -74,7 +74,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Creates a new vertex declaration from a list of vertex elements.
 		 * @brief	Creates a new vertex declaration from a list of vertex elements.
 		 */
 		 */
-		virtual VertexDeclarationPtr createVertexDeclaration(const VertexDeclaration::VertexElementList& elements);
+		virtual VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
 
 
 	protected:
 	protected:
 		/**
 		/**
@@ -87,11 +87,6 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
 		virtual GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
 			bool randomGpuWrite = false, bool useCounter = false) = 0;
 			bool randomGpuWrite = false, bool useCounter = false) = 0;
-
-		/**
-		 * @copydoc	createVertexDeclaration
-		 */
-		virtual VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
 	};
 	};
 
 
 	/**
 	/**
@@ -114,9 +109,15 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual SPtr<IndexBufferCore> createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
 		virtual SPtr<IndexBufferCore> createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
 
 
+		/**
+		 * @copydoc	HardwareBufferManager::createVertexDeclaration
+		 */
+		virtual SPtr<VertexDeclarationCore> createVertexDeclaration(const List<VertexElement>& elements);
+
 	protected:
 	protected:
 		friend class IndexBuffer;
 		friend class IndexBuffer;
 		friend class VertexBuffer;
 		friend class VertexBuffer;
+		friend class VertexDeclaration;
 
 
 		/**
 		/**
 		 * @copydoc	createVertexBuffer
 		 * @copydoc	createVertexBuffer
@@ -127,6 +128,11 @@ namespace BansheeEngine
 		 * @copydoc	createIndexBuffer
 		 * @copydoc	createIndexBuffer
 		 */
 		 */
 		virtual SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
 		virtual SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
+
+		/**
+		 * @copydoc	createVertexDeclaration
+		 */
+		virtual SPtr<VertexDeclarationCore> createVertexDeclarationInternal(const List<VertexElement>& elements);
 	};
 	};
 }
 }
 
 

+ 1 - 1
BansheeCore/Include/BsMeshHeap.h

@@ -246,7 +246,7 @@ namespace BansheeEngine
 			const VertexDataDescPtr& vertexDesc, IndexType indexType = IT_32BIT);
 			const VertexDataDescPtr& vertexDesc, IndexType indexType = IT_32BIT);
 
 
 		/**
 		/**
-		 * @copydoc	RenderTarget::createCore
+		 * @copydoc	CoreObject::createCore
 		 */
 		 */
 		SPtr<CoreObjectCore> createCore() const;
 		SPtr<CoreObjectCore> createCore() const;
 
 

+ 1 - 1
BansheeCore/Include/BsRenderSystem.h

@@ -128,7 +128,7 @@ namespace BansheeEngine
 		 * @brief	Sets the vertex declaration to use when drawing. Vertex declaration
 		 * @brief	Sets the vertex declaration to use when drawing. Vertex declaration
 		 * 			is used to decode contents of a single vertex in a vertex buffer.
 		 * 			is used to decode contents of a single vertex in a vertex buffer.
 		 */
 		 */
-		virtual void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration) = 0;
+		virtual void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration) = 0;
 
 
 		/**
 		/**
 		 * @brief	Sets the draw operation that determines how to interpret the elements
 		 * @brief	Sets the draw operation that determines how to interpret the elements

+ 2 - 2
BansheeCore/Include/BsTexture.h

@@ -256,7 +256,7 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		static TextureViewPtr requestView(const SPtr<TextureCore>& texture, UINT32 mostDetailMip, UINT32 numMips, 
+		static TextureViewPtr requestView(const SPtr<TextureCore>& texture, UINT32 mostDetailMip, UINT32 numMips,
 			UINT32 firstArraySlice, UINT32 numArraySlices, GpuViewUsage usage);
 			UINT32 firstArraySlice, UINT32 numArraySlices, GpuViewUsage usage);
 
 
 		/**
 		/**
@@ -289,7 +289,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Creates a new empty/undefined texture view.
 		 * @brief	Creates a new empty/undefined texture view.
 		 */
 		 */
-		virtual TextureViewPtr createView();
+		virtual TextureViewPtr createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
 
 
 		/**
 		/**
 		 * @brief	Releases all internal texture view references. Views won't get destroyed if there are external references still held.
 		 * @brief	Releases all internal texture view references. Views won't get destroyed if there are external references still held.

+ 2 - 10
BansheeCore/Include/BsTextureView.h

@@ -49,11 +49,8 @@ namespace BansheeEngine
 	 *
 	 *
 	 *			They also allow you to re-purpose a texture. (e.g. make a render target 
 	 *			They also allow you to re-purpose a texture. (e.g. make a render target 
 	 *			a bindable texture).
 	 *			a bindable texture).
-	 *
-	 * @note	Right now texture views are only used for very specific internal purposes, 
-	 *			but a more general use might come in the future.
 	 */
 	 */
-	class BS_CORE_EXPORT TextureView : public CoreObject
+	class BS_CORE_EXPORT TextureView
 	{
 	{
 	public:
 	public:
 		class HashFunction
 		class HashFunction
@@ -107,17 +104,12 @@ namespace BansheeEngine
 		SPtr<TextureCore> getTexture() const { return mOwnerTexture; }
 		SPtr<TextureCore> getTexture() const { return mOwnerTexture; }
 
 
 	protected:
 	protected:
-		/**
-		 * @brief	Initializes the texture view. This must be called right after construction.
-		 */
-		virtual void initialize(const SPtr<TextureCore>& texture, TEXTURE_VIEW_DESC& _desc);
+		TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& _desc);
 
 
 	protected:
 	protected:
 		friend class TextureCore;
 		friend class TextureCore;
 
 
 		TEXTURE_VIEW_DESC mDesc;
 		TEXTURE_VIEW_DESC mDesc;
 		SPtr<TextureCore> mOwnerTexture;
 		SPtr<TextureCore> mOwnerTexture;
-
-		TextureView();
 	};
 	};
 }
 }

+ 1 - 1
BansheeCore/Include/BsVertexData.h

@@ -21,7 +21,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Declaration used for the contained vertex buffers.
 		 * @brief	Declaration used for the contained vertex buffers.
 		 */
 		 */
-		VertexDeclarationPtr vertexDeclaration;
+		SPtr<VertexDeclarationCore> vertexDeclaration;
 
 
 		/**
 		/**
 		 * @brief	Number of vertices to use.
 		 * @brief	Number of vertices to use.

+ 5 - 5
BansheeCore/Include/BsVertexDataDesc.h

@@ -31,11 +31,6 @@ namespace BansheeEngine
 		 */
 		 */
 		bool hasElement(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
 		bool hasElement(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
 
 
-		/**
-		 * @brief	Creates a new vertex declaration based on currently set vertex elements.
-		 */
-		VertexDeclarationPtr createDeclaration() const;
-
 		/**
 		/**
 		 * @brief	Returns the size in bytes of the vertex element with the specified semantic.
 		 * @brief	Returns the size in bytes of the vertex element with the specified semantic.
 		 */
 		 */
@@ -70,6 +65,11 @@ namespace BansheeEngine
 		 * @brief	Returns the vertex element at the specified index.
 		 * @brief	Returns the vertex element at the specified index.
 		 */
 		 */
 		const VertexElement& getElement(UINT32 idx) const { return mVertexElements[idx]; }
 		const VertexElement& getElement(UINT32 idx) const { return mVertexElements[idx]; }
+
+		/**
+		 * @brief	Creates a list of vertex elements from internal data.
+		 */
+		List<VertexElement> createElements() const;
 	private:
 	private:
 		friend class Mesh;
 		friend class Mesh;
 		friend class MeshCore;
 		friend class MeshCore;

+ 88 - 19
BansheeCore/Include/BsVertexDeclaration.h

@@ -117,63 +117,132 @@ namespace BansheeEngine
 	BS_ALLOW_MEMCPY_SERIALIZATION(VertexElement);
 	BS_ALLOW_MEMCPY_SERIALIZATION(VertexElement);
 
 
 	/**
 	/**
-	 * @brief	Describes a set of vertex elements, used for describing contents of
-	 *			a vertex buffer or inputs to a vertex GPU program.
+	 * @brief	Contains information about a vertex declaration.
 	 */
 	 */
-	class BS_CORE_EXPORT VertexDeclaration : public IReflectable, public CoreObject
-    {
-    public:
-        typedef List<VertexElement> VertexElementList;
-
+	class BS_CORE_EXPORT VertexDeclarationProperties
+	{
 	public:
 	public:
-        virtual ~VertexDeclaration();
+		VertexDeclarationProperties(const List<VertexElement>& elements);
 
 
-		bool operator== (const VertexDeclaration& rhs) const;
-		bool operator!= (const VertexDeclaration& rhs) const;
+		bool operator== (const VertexDeclarationProperties& rhs) const;
+		bool operator!= (const VertexDeclarationProperties& rhs) const;
 
 
 		/**
 		/**
 		 * @brief	Get the number of elements in the declaration.
 		 * @brief	Get the number of elements in the declaration.
 		 */
 		 */
-        UINT32 getElementCount() { return (UINT32)mElementList.size(); }
+        UINT32 getElementCount() const { return (UINT32)mElementList.size(); }
         
         
 		/**
 		/**
 		 * @brief	Returns a list of vertex elements in the declaration.
 		 * @brief	Returns a list of vertex elements in the declaration.
 		 */
 		 */
-		const VertexElementList& getElements() const { return mElementList; }
+		const List<VertexElement>& getElements() const { return mElementList; }
 
 
 		/**
 		/**
 		 * @brief	Returns a single vertex element at the specified index.
 		 * @brief	Returns a single vertex element at the specified index.
 		 */
 		 */
-        const VertexElement* getElement(UINT16 index);
+		const VertexElement* getElement(UINT16 index) const;
 
 
 		/**
 		/**
 		 * @brief	Attempts to find an element by the given semantic and semantic index. If no element
 		 * @brief	Attempts to find an element by the given semantic and semantic index. If no element
 		 *			can be found null is returned.
 		 *			can be found null is returned.
 		 */
 		 */
-		virtual const VertexElement* findElementBySemantic(VertexElementSemantic sem, UINT16 index = 0);
+		virtual const VertexElement* findElementBySemantic(VertexElementSemantic sem, UINT16 index = 0) const;
 
 
 		/**
 		/**
 		 * @brief	Returns a list of all elements that use the provided source index.
 		 * @brief	Returns a list of all elements that use the provided source index.
 		 */
 		 */
-		virtual VertexElementList findElementsBySource(UINT16 source);
+		virtual List<VertexElement> findElementsBySource(UINT16 source) const;
 
 
 		/**
 		/**
 		 * @brief	Returns the total size of all vertex elements using the provided source index.
 		 * @brief	Returns the total size of all vertex elements using the provided source index.
 		 */
 		 */
-		virtual UINT32 getVertexSize(UINT16 source);
+		virtual UINT32 getVertexSize(UINT16 source) const;
+
+	protected:
+		friend class VertexDeclaration;
+		friend class VertexDeclarationRTTI;
+
+		List<VertexElement> mElementList;
+	};
+
+	/**
+	 * @brief	Core thread portion of a VertexDeclaration.
+	 *
+	 * @see		VertexDeclaration.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT VertexDeclarationCore : public CoreObjectCore
+    {
+	public:
+		virtual ~VertexDeclarationCore() { }
+
+		/**
+		 * @copydoc	CoreObjectCore::initialize
+		 */
+		void initialize();
+
+		/**
+		 * @brief	Returns properties describing the vertex declaration.
+		 */
+		const VertexDeclarationProperties& getProperties() const { return mProperties; }
+
+		/**
+		 * @brief	Returns an ID unique to this declaration.
+		 */
+		UINT32 getId() const { return mId; }
+
+    protected:
+		friend class HardwareBufferCoreManager;
+
+		VertexDeclarationCore(const List<VertexElement>& elements);
+
+	protected:
+		VertexDeclarationProperties mProperties;
+		UINT32 mId;
+
+		static UINT32 NextFreeId;
+    };
+
+	/**
+	 * @brief	Describes a set of vertex elements, used for describing contents of
+	 *			a vertex buffer or inputs to a vertex GPU program.
+	 *
+	 * @note	Sim thread.
+	 */
+	class BS_CORE_EXPORT VertexDeclaration : public IReflectable, public CoreObject
+    {
+	public:
+		virtual ~VertexDeclaration() { }
+
+		/**
+		 * @brief	Returns properties describing the vertex declaration.
+		 */
+		const VertexDeclarationProperties& getProperties() const { return mProperties; }
+
+		/**
+		 * @brief	Retrieves a core implementation of a vertex declaration usable only from the
+		 *			core thread.
+		 */
+		SPtr<VertexDeclarationCore> getCore() const;
 
 
 		/**
 		/**
 		 * @copydoc		HardwareBufferManager::createVertexDeclaration
 		 * @copydoc		HardwareBufferManager::createVertexDeclaration
 		 */
 		 */
-		static VertexDeclarationPtr createVertexDeclaration(const VertexDeclaration::VertexElementList& elements);
+		static VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
 
 
     protected:
     protected:
 		friend class HardwareBufferManager;
 		friend class HardwareBufferManager;
 
 
-		VertexDeclaration(const VertexElementList& elements);
+		VertexDeclaration(const List<VertexElement>& elements);
+
+		/**
+		 * @copydoc	CoreObject::createCore
+		 */
+		SPtr<CoreObjectCore> createCore() const;
 
 
 	protected:
 	protected:
-		VertexElementList mElementList;
+		VertexDeclarationProperties mProperties;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/* 								SERIALIZATION                      		*/

+ 14 - 6
BansheeCore/Include/BsVertexDeclarationRTTI.h

@@ -12,7 +12,9 @@ namespace BansheeEngine
 	private:
 	private:
 		VertexElement& getElement(VertexDeclaration* obj, UINT32 idx)
 		VertexElement& getElement(VertexDeclaration* obj, UINT32 idx)
 		{
 		{
-			auto iter = obj->mElementList.begin();
+			List<VertexElement>& elemList = obj->mProperties.mElementList;
+
+			auto iter = elemList.begin();
 			for(UINT32 i = 0; i < idx; i++)
 			for(UINT32 i = 0; i < idx; i++)
 				++iter;
 				++iter;
 
 
@@ -21,7 +23,9 @@ namespace BansheeEngine
 
 
 		void setElement(VertexDeclaration* obj, UINT32 idx, VertexElement& data)
 		void setElement(VertexDeclaration* obj, UINT32 idx, VertexElement& data)
 		{
 		{
-			auto iter = obj->mElementList.begin();
+			List<VertexElement>& elemList = obj->mProperties.mElementList;
+
+			auto iter = elemList.begin();
 			for(UINT32 i = 0; i < idx; i++)
 			for(UINT32 i = 0; i < idx; i++)
 				++iter;
 				++iter;
 
 
@@ -30,13 +34,17 @@ namespace BansheeEngine
 
 
 		UINT32 getElementArraySize(VertexDeclaration* obj)
 		UINT32 getElementArraySize(VertexDeclaration* obj)
 		{
 		{
-			return (UINT32)obj->mElementList.size();
+			List<VertexElement>& elemList = obj->mProperties.mElementList;
+
+			return (UINT32)elemList.size();
 		}
 		}
 
 
 		void setElementArraySize(VertexDeclaration* obj, UINT32 size)
 		void setElementArraySize(VertexDeclaration* obj, UINT32 size)
 		{
 		{
-			for(size_t i = obj->mElementList.size(); i < size; i++)
-				obj->mElementList.push_back(VertexElement());
+			List<VertexElement>& elemList = obj->mProperties.mElementList;
+
+			for (size_t i = elemList.size(); i < size; i++)
+				elemList.push_back(VertexElement());
 		}
 		}
 
 
 	public:
 	public:
@@ -48,7 +56,7 @@ namespace BansheeEngine
 
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{
 		{
-			return HardwareBufferManager::instance().createVertexDeclaration(VertexDeclaration::VertexElementList());
+			return HardwareBufferManager::instance().createVertexDeclaration(List<VertexElement>());
 		}
 		}
 
 
 		virtual const String& getRTTIName() 
 		virtual const String& getRTTIName() 

+ 1 - 1
BansheeCore/Source/BsCoreThreadAccessor.cpp

@@ -85,7 +85,7 @@ namespace BansheeEngine
 
 
 	void CoreThreadAccessorBase::setVertexDeclaration(const VertexDeclarationPtr& vertexDeclaration)
 	void CoreThreadAccessorBase::setVertexDeclaration(const VertexDeclarationPtr& vertexDeclaration)
 	{
 	{
-		mCommandQueue->queue(std::bind(&RenderSystem::setVertexDeclaration, RenderSystem::instancePtr(), vertexDeclaration));
+		mCommandQueue->queue(std::bind(&RenderSystem::setVertexDeclaration, RenderSystem::instancePtr(), vertexDeclaration->getCore()));
 	}
 	}
 
 
 	void CoreThreadAccessorBase::setViewport(const Rect2& vp)
 	void CoreThreadAccessorBase::setViewport(const Rect2& vp)

+ 26 - 10
BansheeCore/Source/BsHardwareBufferManager.cpp

@@ -14,12 +14,15 @@ namespace BansheeEngine
     {
     {
     }
     }
 
 
-	VertexDeclarationPtr HardwareBufferManager::createVertexDeclaration(const VertexDeclaration::VertexElementList& elements)
+	VertexDeclarationPtr HardwareBufferManager::createVertexDeclaration(const List<VertexElement>& elements)
     {
     {
-        VertexDeclarationPtr decl = createVertexDeclarationImpl(elements);
-		decl->_setThisPtr(decl);
-		decl->initialize();
-        return decl;
+		VertexDeclaration* decl = new (bs_alloc<VertexDeclaration, GenAlloc>()) VertexDeclaration(elements);
+
+		VertexDeclarationPtr declPtr = bs_core_ptr<VertexDeclaration, GenAlloc>(decl);
+		declPtr->_setThisPtr(declPtr);
+		declPtr->initialize();
+
+		return declPtr;
     }
     }
 
 
 	VertexBufferPtr HardwareBufferManager::createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
 	VertexBufferPtr HardwareBufferManager::createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
@@ -61,11 +64,6 @@ namespace BansheeEngine
 		return gbuf;
 		return gbuf;
 	}
 	}
 
 
-	VertexDeclarationPtr HardwareBufferManager::createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements)
-	{
-		return bs_core_ptr<VertexDeclaration, PoolAlloc>(new (bs_alloc<VertexDeclaration, PoolAlloc>()) VertexDeclaration(elements));
-	}
-
 	SPtr<IndexBufferCore> HardwareBufferCoreManager::createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
 	SPtr<IndexBufferCore> HardwareBufferCoreManager::createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
 	{
 	{
 		assert(numIndexes > 0);
 		assert(numIndexes > 0);
@@ -84,4 +82,22 @@ namespace BansheeEngine
 		vbuf->initialize();
 		vbuf->initialize();
 		return vbuf;
 		return vbuf;
 	}
 	}
+
+	SPtr<VertexDeclarationCore> HardwareBufferCoreManager::createVertexDeclaration(const List<VertexElement>& elements)
+	{
+		SPtr<VertexDeclarationCore> declPtr = createVertexDeclarationInternal(elements);
+		declPtr->initialize();
+
+		return declPtr;
+	}
+
+	SPtr<VertexDeclarationCore> HardwareBufferCoreManager::createVertexDeclarationInternal(const List<VertexElement>& elements)
+	{
+		VertexDeclarationCore* decl = new (bs_alloc<VertexDeclarationCore, GenAlloc>()) VertexDeclarationCore(elements);
+
+		SPtr<VertexDeclarationCore> ret = bs_shared_ptr<VertexDeclarationCore, GenAlloc>(decl);
+		ret->_setThisPtr(ret);
+
+		return ret;
+	}
 }
 }

+ 4 - 2
BansheeCore/Source/BsMesh.cpp

@@ -31,7 +31,9 @@ namespace BansheeEngine
 		mVertexData = std::shared_ptr<VertexData>(bs_new<VertexData, PoolAlloc>());
 		mVertexData = std::shared_ptr<VertexData>(bs_new<VertexData, PoolAlloc>());
 
 
 		mVertexData->vertexCount = mProperties.mNumVertices;
 		mVertexData->vertexCount = mProperties.mNumVertices;
-		mVertexData->vertexDeclaration = mVertexDesc->createDeclaration();
+
+		List<VertexElement> elements = mVertexDesc->createElements();
+		mVertexData->vertexDeclaration = HardwareBufferCoreManager::instance().createVertexDeclaration(elements);
 
 
 		for (UINT32 i = 0; i <= mVertexDesc->getMaxStreamIdx(); i++)
 		for (UINT32 i = 0; i <= mVertexDesc->getMaxStreamIdx(); i++)
 		{
 		{
@@ -39,7 +41,7 @@ namespace BansheeEngine
 				continue;
 				continue;
 
 
 			SPtr<VertexBufferCore> vertexBuffer = HardwareBufferCoreManager::instance().createVertexBuffer(
 			SPtr<VertexBufferCore> vertexBuffer = HardwareBufferCoreManager::instance().createVertexBuffer(
-				mVertexData->vertexDeclaration->getVertexSize(i),
+				mVertexData->vertexDeclaration->getProperties().getVertexSize(i),
 				mVertexData->vertexCount,
 				mVertexData->vertexCount,
 				mBufferType == MeshBufferType::Dynamic ? GBU_DYNAMIC : GBU_STATIC);
 				mBufferType == MeshBufferType::Dynamic ? GBU_DYNAMIC : GBU_STATIC);
 
 

+ 5 - 3
BansheeCore/Source/BsMeshHeap.cpp

@@ -226,7 +226,7 @@ namespace BansheeEngine
 				continue;
 				continue;
 
 
 			// Ensure vertex sizes match
 			// Ensure vertex sizes match
-			UINT32 vertSize = mVertexData->vertexDeclaration->getVertexSize(i);
+			UINT32 vertSize = mVertexData->vertexDeclaration->getProperties().getVertexSize(i);
 			UINT32 otherVertSize = meshData->getVertexDesc()->getVertexStride(i);
 			UINT32 otherVertSize = meshData->getVertexDesc()->getVertexStride(i);
 			if (otherVertSize != vertSize)
 			if (otherVertSize != vertSize)
 			{
 			{
@@ -307,7 +307,9 @@ namespace BansheeEngine
 		mVertexData = std::shared_ptr<VertexData>(bs_new<VertexData, PoolAlloc>());
 		mVertexData = std::shared_ptr<VertexData>(bs_new<VertexData, PoolAlloc>());
 
 
 		mVertexData->vertexCount = mNumVertices;
 		mVertexData->vertexCount = mNumVertices;
-		mVertexData->vertexDeclaration = mVertexDesc->createDeclaration();
+		List<VertexElement> elements = mVertexDesc->createElements();
+
+		mVertexData->vertexDeclaration = HardwareBufferCoreManager::instance().createVertexDeclaration(elements);
 
 
 		// Create buffers and copy data
 		// Create buffers and copy data
 		for (UINT32 i = 0; i <= mVertexDesc->getMaxStreamIdx(); i++)
 		for (UINT32 i = 0; i <= mVertexDesc->getMaxStreamIdx(); i++)
@@ -315,7 +317,7 @@ namespace BansheeEngine
 			if (!mVertexDesc->hasStream(i))
 			if (!mVertexDesc->hasStream(i))
 				continue;
 				continue;
 
 
-			UINT32 vertSize = mVertexData->vertexDeclaration->getVertexSize(i);
+			UINT32 vertSize = mVertexData->vertexDeclaration->getProperties().getVertexSize(i);
 			SPtr<VertexBufferCore> vertexBuffer = HardwareBufferCoreManager::instance().createVertexBuffer(
 			SPtr<VertexBufferCore> vertexBuffer = HardwareBufferCoreManager::instance().createVertexBuffer(
 				vertSize, mVertexData->vertexCount, GBU_DYNAMIC);
 				vertSize, mVertexData->vertexCount, GBU_DYNAMIC);
 
 

+ 3 - 7
BansheeCore/Source/BsTexture.cpp

@@ -179,12 +179,9 @@ namespace BansheeEngine
 	/* 								TEXTURE VIEW                      		*/
 	/* 								TEXTURE VIEW                      		*/
 	/************************************************************************/
 	/************************************************************************/
 
 
-	TextureViewPtr TextureCore::createView()
+	TextureViewPtr TextureCore::createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc)
 	{
 	{
-		TextureViewPtr viewPtr = bs_core_ptr<TextureView, PoolAlloc>(new (bs_alloc<TextureView, PoolAlloc>()) TextureView());
-		viewPtr->_setThisPtr(viewPtr);
-
-		return viewPtr;
+		return bs_shared_ptr<TextureView, PoolAlloc>(new (bs_alloc<TextureView, PoolAlloc>()) TextureView(texture, desc));
 	}
 	}
 
 
 	void TextureCore::clearBufferViews()
 	void TextureCore::clearBufferViews()
@@ -208,8 +205,7 @@ namespace BansheeEngine
 		auto iterFind = texture->mTextureViews.find(key);
 		auto iterFind = texture->mTextureViews.find(key);
 		if (iterFind == texture->mTextureViews.end())
 		if (iterFind == texture->mTextureViews.end())
 		{
 		{
-			TextureViewPtr newView = texture->createView();
-			newView->initialize(texture, key);
+			TextureViewPtr newView = texture->createView(texture, key);
 			texture->mTextureViews[key] = new (bs_alloc<TextureViewReference, PoolAlloc>()) TextureViewReference(newView);
 			texture->mTextureViews[key] = new (bs_alloc<TextureViewReference, PoolAlloc>()) TextureViewReference(newView);
 
 
 			iterFind = texture->mTextureViews.find(key);
 			iterFind = texture->mTextureViews.find(key);

+ 2 - 7
BansheeCore/Source/BsTextureView.cpp

@@ -23,17 +23,12 @@ namespace BansheeEngine
 			&& a.firstArraySlice == b.firstArraySlice && a.numArraySlices == b.numArraySlices && a.usage == b.usage;
 			&& a.firstArraySlice == b.firstArraySlice && a.numArraySlices == b.numArraySlices && a.usage == b.usage;
 	}
 	}
 
 
-	TextureView::TextureView()
-	{ }
-
 	TextureView::~TextureView()
 	TextureView::~TextureView()
 	{ }
 	{ }
 
 
-	void TextureView::initialize(const SPtr<TextureCore>& texture, TEXTURE_VIEW_DESC& _desc)
+	TextureView::TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc)
+		:mOwnerTexture(texture), mDesc(desc)
 	{
 	{
-		mOwnerTexture = texture;
-		mDesc = _desc;
 
 
-		CoreObject::initialize();
 	}
 	}
 }
 }

+ 5 - 6
BansheeCore/Source/BsVertexDataDesc.cpp

@@ -27,17 +27,17 @@ namespace BansheeEngine
 		mVertexElements.insert(mVertexElements.begin() + insertToIndex, newElement);
 		mVertexElements.insert(mVertexElements.begin() + insertToIndex, newElement);
 	}
 	}
 
 
-	VertexDeclarationPtr VertexDataDesc::createDeclaration() const
+	List<VertexElement> VertexDataDesc::createElements() const
 	{
 	{
 		UINT32 maxStreamIdx = getMaxStreamIdx();
 		UINT32 maxStreamIdx = getMaxStreamIdx();
 
 
 		UINT32 numStreams = maxStreamIdx + 1;
 		UINT32 numStreams = maxStreamIdx + 1;
 		UINT32* streamOffsets = bs_newN<UINT32, ScratchAlloc>(numStreams);
 		UINT32* streamOffsets = bs_newN<UINT32, ScratchAlloc>(numStreams);
-		for(UINT32 i = 0; i < numStreams; i++)
+		for (UINT32 i = 0; i < numStreams; i++)
 			streamOffsets[i] = 0;
 			streamOffsets[i] = 0;
 
 
-		VertexDeclaration::VertexElementList declarationElements;
-		for(auto& vertElem : mVertexElements)
+		List<VertexElement> declarationElements;
+		for (auto& vertElem : mVertexElements)
 		{
 		{
 			UINT32 streamIdx = vertElem.getStreamIdx();
 			UINT32 streamIdx = vertElem.getStreamIdx();
 
 
@@ -49,8 +49,7 @@ namespace BansheeEngine
 
 
 		bs_deleteN<ScratchAlloc>(streamOffsets, numStreams);
 		bs_deleteN<ScratchAlloc>(streamOffsets, numStreams);
 
 
-		VertexDeclarationPtr declaration = HardwareBufferManager::instance().createVertexDeclaration(declarationElements);
-		return declaration;
+		return declarationElements;
 	}
 	}
 
 
 	UINT32 VertexDataDesc::getMaxStreamIdx() const
 	UINT32 VertexDataDesc::getMaxStreamIdx() const

+ 39 - 13
BansheeCore/Source/BsVertexDeclaration.cpp

@@ -115,7 +115,7 @@ namespace BansheeEngine
 		return !(*this == rhs);
 		return !(*this == rhs);
 	}
 	}
 
 
-	VertexDeclaration::VertexDeclaration(const VertexElementList& elements)
+	VertexDeclarationProperties::VertexDeclarationProperties(const List<VertexElement>& elements)
 	{
 	{
 		for (auto& elem : elements)
 		for (auto& elem : elements)
 		{
 		{
@@ -128,11 +128,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	VertexDeclaration::~VertexDeclaration()
-	{
-	}
-
-	bool VertexDeclaration::operator== (const VertexDeclaration& rhs) const
+	bool VertexDeclarationProperties::operator== (const VertexDeclarationProperties& rhs) const
 	{
 	{
 		if (mElementList.size() != rhs.mElementList.size())
 		if (mElementList.size() != rhs.mElementList.size())
 			return false;
 			return false;
@@ -149,12 +145,12 @@ namespace BansheeEngine
 		return true;
 		return true;
 	}
 	}
 
 
-	bool VertexDeclaration::operator!= (const VertexDeclaration& rhs) const
+	bool VertexDeclarationProperties::operator!= (const VertexDeclarationProperties& rhs) const
 	{
 	{
 		return !(*this == rhs);
 		return !(*this == rhs);
 	}
 	}
 
 
-	const VertexElement* VertexDeclaration::getElement(UINT16 index)
+	const VertexElement* VertexDeclarationProperties::getElement(UINT16 index) const
 	{
 	{
 		assert(index < mElementList.size() && "Index out of bounds");
 		assert(index < mElementList.size() && "Index out of bounds");
 
 
@@ -166,7 +162,7 @@ namespace BansheeEngine
 
 
 	}
 	}
 	
 	
-	const VertexElement* VertexDeclaration::findElementBySemantic(VertexElementSemantic sem, UINT16 index)
+	const VertexElement* VertexDeclarationProperties::findElementBySemantic(VertexElementSemantic sem, UINT16 index) const
 	{
 	{
 		for (auto& elem : mElementList)
 		for (auto& elem : mElementList)
 		{
 		{
@@ -179,9 +175,9 @@ namespace BansheeEngine
 		return nullptr;
 		return nullptr;
 	}
 	}
 
 
-	VertexDeclaration::VertexElementList VertexDeclaration::findElementsBySource(UINT16 source)
+	List<VertexElement> VertexDeclarationProperties::findElementsBySource(UINT16 source) const
 	{
 	{
-		VertexElementList retList;
+		List<VertexElement> retList;
 
 
 		for (auto& elem : mElementList)
 		for (auto& elem : mElementList)
 		{
 		{
@@ -194,7 +190,7 @@ namespace BansheeEngine
 		return retList;
 		return retList;
 	}
 	}
 
 
-	UINT32 VertexDeclaration::getVertexSize(UINT16 source)
+	UINT32 VertexDeclarationProperties::getVertexSize(UINT16 source) const
 	{
 	{
 		UINT32 size = 0;
 		UINT32 size = 0;
 
 
@@ -209,7 +205,37 @@ namespace BansheeEngine
 		return size;
 		return size;
 	}
 	}
 
 
-	VertexDeclarationPtr VertexDeclaration::createVertexDeclaration(const VertexDeclaration::VertexElementList& elements)
+	UINT32 VertexDeclarationCore::NextFreeId = 0;
+
+	VertexDeclarationCore::VertexDeclarationCore(const List<VertexElement>& elements)
+		:mProperties(elements)
+	{
+		
+	}
+
+	void VertexDeclarationCore::initialize()
+	{
+		mId = NextFreeId++;
+		CoreObjectCore::initialize();
+	}
+
+	VertexDeclaration::VertexDeclaration(const List<VertexElement>& elements)
+		:mProperties(elements)
+	{
+
+	}
+
+	SPtr<VertexDeclarationCore> VertexDeclaration::getCore() const
+	{
+		return std::static_pointer_cast<VertexDeclarationCore>(mCoreSpecific);
+	}
+
+	SPtr<CoreObjectCore> VertexDeclaration::createCore() const
+	{
+		return HardwareBufferCoreManager::instance().createVertexDeclarationInternal(mProperties.mElementList);
+	}
+
+	VertexDeclarationPtr VertexDeclaration::createVertexDeclaration(const List<VertexElement>& elements)
 	{
 	{
 		return HardwareBufferManager::instance().createVertexDeclaration(elements);
 		return HardwareBufferManager::instance().createVertexDeclaration(elements);
 	}
 	}

+ 2 - 2
BansheeD3D11RenderSystem/Include/BsD3D11GpuProgram.h

@@ -26,7 +26,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Returns GPU program input declaration. Only relevant for vertex programs.
 		 * @brief	Returns GPU program input declaration. Only relevant for vertex programs.
 		 */
 		 */
-		VertexDeclarationPtr getInputDeclaration() const { return mInputDeclaration; }
+		SPtr<VertexDeclarationCore> getInputDeclaration() const { return mInputDeclaration; }
 
 
 		/**
 		/**
 		 * @brief	Returns unique GPU program ID.
 		 * @brief	Returns unique GPU program ID.
@@ -74,7 +74,7 @@ namespace BansheeEngine
 		UINT32 mProgramId;
 		UINT32 mProgramId;
 
 
 		HLSLMicroCode mMicrocode;
 		HLSLMicroCode mMicrocode;
-		VertexDeclarationPtr mInputDeclaration;
+		SPtr<VertexDeclarationCore> mInputDeclaration;
 	};
 	};
 
 
 	/**
 	/**

+ 1 - 1
BansheeD3D11RenderSystem/Include/BsD3D11HLSLParamParser.h

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		 * @param	inputParams	Output object that will contain a set of program input parameters. Can be null if not required.
 		 * @param	inputParams	Output object that will contain a set of program input parameters. Can be null if not required.
 		 *						Only relevant for vertex programs.
 		 *						Only relevant for vertex programs.
 		 */
 		 */
-		void parse(ID3DBlob* microcode, GpuParamDesc& desc, VertexDeclaration::VertexElementList* inputParams);
+		void parse(ID3DBlob* microcode, GpuParamDesc& desc, List<VertexElement>* inputParams);
 
 
 	private:
 	private:
 		/**
 		/**

+ 4 - 4
BansheeD3D11RenderSystem/Include/BsD3D11InputLayoutManager.h

@@ -64,14 +64,14 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @note	Error will be thrown if the vertex buffer doesn't provide all the necessary data that the shader expects.
 		 * @note	Error will be thrown if the vertex buffer doesn't provide all the necessary data that the shader expects.
 		 */
 		 */
-		ID3D11InputLayout* retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, 
-			VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgramCore& vertexProgram);
+		ID3D11InputLayout* retrieveInputLayout(const SPtr<VertexDeclarationCore>& vertexShaderDecl,
+			const SPtr<VertexDeclarationCore>& vertexBufferDecl, D3D11GpuProgramCore& vertexProgram);
 
 
 	private:
 	private:
 		/**
 		/**
 		 * @brief	Creates a new input layout using the specified parameters and stores it in the input layout map.
 		 * @brief	Creates a new input layout using the specified parameters and stores it in the input layout map.
 		 */
 		 */
-		void addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, 
+		void addNewInputLayout(const SPtr<VertexDeclarationCore>& vertexShaderDecl, const SPtr<VertexDeclarationCore>& vertexBufferDecl,
 			D3D11GpuProgramCore& vertexProgram);
 			D3D11GpuProgramCore& vertexProgram);
 
 
 		/**
 		/**
@@ -84,7 +84,7 @@ namespace BansheeEngine
 		 *			Vertex buffer must provide all inputs to the shader in order for them to be compatible
 		 *			Vertex buffer must provide all inputs to the shader in order for them to be compatible
 		 *			(extra data is allowed).
 		 *			(extra data is allowed).
 		 */
 		 */
-		bool areCompatible(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl);
+		bool areCompatible(const SPtr<VertexDeclarationCore>& vertexShaderDecl, const SPtr<VertexDeclarationCore>& vertexBufferDecl);
 
 
 	private:
 	private:
 		static const int DECLARATION_BUFFER_SIZE = 1024;
 		static const int DECLARATION_BUFFER_SIZE = 1024;

+ 2 - 2
BansheeD3D11RenderSystem/Include/BsD3D11RenderSystem.h

@@ -109,7 +109,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	RenderSystem::setVertexDeclaration
 		 * @copydoc	RenderSystem::setVertexDeclaration
 		 */
 		 */
-		void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration);
+		void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration);
 
 
 		/**
 		/**
 		 * @copydoc	RenderSystem::setDrawOperation
 		 * @copydoc	RenderSystem::setDrawOperation
@@ -262,7 +262,7 @@ namespace BansheeEngine
 		D3D11_VIEWPORT mViewport;
 		D3D11_VIEWPORT mViewport;
 		D3D11_RECT mScissorRect;
 		D3D11_RECT mScissorRect;
 
 
-		VertexDeclarationPtr mActiveVertexDeclaration;
+		SPtr<VertexDeclarationCore> mActiveVertexDeclaration;
 		SPtr<D3D11GpuProgramCore> mActiveVertexShader;
 		SPtr<D3D11GpuProgramCore> mActiveVertexShader;
 
 
 		DrawOperationType mActiveDrawOp;
 		DrawOperationType mActiveDrawOp;

+ 1 - 1
BansheeD3D11RenderSystem/Include/BsD3D11Texture.h

@@ -153,7 +153,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Creates an empty and uninitialized texture view object.
 		 * @brief	Creates an empty and uninitialized texture view object.
 		 */
 		 */
-		TextureViewPtr createView();
+		TextureViewPtr createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
 
 
 	protected:
 	protected:
 		ID3D11Texture1D* m1DTex;
 		ID3D11Texture1D* m1DTex;

+ 3 - 12
BansheeD3D11RenderSystem/Include/BsD3D11TextureView.h

@@ -11,6 +11,8 @@ namespace BansheeEngine
 	class BS_D3D11_EXPORT D3D11TextureView : public TextureView
 	class BS_D3D11_EXPORT D3D11TextureView : public TextureView
 	{
 	{
 	public:
 	public:
+		~D3D11TextureView();
+
 		/**
 		/**
 		 * @brief	Returns a shader resource view. Caller must take care this texture view
 		 * @brief	Returns a shader resource view. Caller must take care this texture view
 		 *			actually contains a shader resource view, otherwise it returns null.
 		 *			actually contains a shader resource view, otherwise it returns null.
@@ -38,18 +40,7 @@ namespace BansheeEngine
 	protected:
 	protected:
 		friend class D3D11TextureCore;
 		friend class D3D11TextureCore;
 
 
-		D3D11TextureView();
-
-		/**
-		 * @copydoc	TextureView::initialize_internal
-		 */
-		void initialize_internal();
-
-		/**
-		 * @copydoc	TextureView::destroy_internal
-		 */
-		void destroy_internal();
-
+		D3D11TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
 	private:
 	private:
 		/**
 		/**
 		 * @brief	Creates a shader resource view that allows the provided surfaces 
 		 * @brief	Creates a shader resource view that allows the provided surfaces 

+ 2 - 2
BansheeD3D11RenderSystem/Source/BsD3D11GpuProgram.cpp

@@ -135,10 +135,10 @@ namespace BansheeEngine
 		D3D11HLSLParamParser parser;
 		D3D11HLSLParamParser parser;
 		if (mProperties.getType() == GPT_VERTEX_PROGRAM)
 		if (mProperties.getType() == GPT_VERTEX_PROGRAM)
 		{
 		{
-			VertexDeclaration::VertexElementList inputParams;
+			List<VertexElement> inputParams;
 			parser.parse(microcode, *mParametersDesc, &inputParams);
 			parser.parse(microcode, *mParametersDesc, &inputParams);
 
 
-			mInputDeclaration = HardwareBufferManager::instance().createVertexDeclaration(inputParams);
+			mInputDeclaration = HardwareBufferCoreManager::instance().createVertexDeclaration(inputParams);
 		}
 		}
 		else
 		else
 		{
 		{

+ 1 - 1
BansheeD3D11RenderSystem/Source/BsD3D11HLSLParamParser.cpp

@@ -6,7 +6,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	void D3D11HLSLParamParser::parse(ID3DBlob* microcode, GpuParamDesc& desc, VertexDeclaration::VertexElementList* inputParams)
+	void D3D11HLSLParamParser::parse(ID3DBlob* microcode, GpuParamDesc& desc, List<VertexElement>* inputParams)
 	{
 	{
 		const char* commentString = nullptr;
 		const char* commentString = nullptr;
 		ID3DBlob* pIDisassembly = nullptr;
 		ID3DBlob* pIDisassembly = nullptr;

+ 10 - 0
BansheeD3D11RenderSystem/Source/BsD3D11HLSLProgramFactory.cpp

@@ -28,18 +28,23 @@ namespace BansheeEngine
 		case GPT_VERTEX_PROGRAM:
 		case GPT_VERTEX_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuVertexProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuVertexProgramCore, GenAlloc>())
 				D3D11GpuVertexProgramCore(source, entryPoint, profile));
 				D3D11GpuVertexProgramCore(source, entryPoint, profile));
+			break;
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuFragmentProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuFragmentProgramCore, GenAlloc>())
 				D3D11GpuFragmentProgramCore(source, entryPoint, profile));
 				D3D11GpuFragmentProgramCore(source, entryPoint, profile));
+			break;
 		case GPT_HULL_PROGRAM:
 		case GPT_HULL_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuHullProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuHullProgramCore, GenAlloc>())
 				D3D11GpuHullProgramCore(source, entryPoint, profile));
 				D3D11GpuHullProgramCore(source, entryPoint, profile));
+			break;
 		case GPT_DOMAIN_PROGRAM:
 		case GPT_DOMAIN_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuDomainProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuDomainProgramCore, GenAlloc>())
 				D3D11GpuDomainProgramCore(source, entryPoint, profile));
 				D3D11GpuDomainProgramCore(source, entryPoint, profile));
+			break;
 		case GPT_GEOMETRY_PROGRAM:
 		case GPT_GEOMETRY_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuGeometryProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuGeometryProgramCore, GenAlloc>())
 				D3D11GpuGeometryProgramCore(source, entryPoint, profile, requireAdjacencyInfo));
 				D3D11GpuGeometryProgramCore(source, entryPoint, profile, requireAdjacencyInfo));
+			break;
 		}
 		}
 
 
 		if (gpuProg != nullptr)
 		if (gpuProg != nullptr)
@@ -57,18 +62,23 @@ namespace BansheeEngine
 		case GPT_VERTEX_PROGRAM:
 		case GPT_VERTEX_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuVertexProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuVertexProgramCore, GenAlloc>())
 				D3D11GpuVertexProgramCore("", "", GPP_NONE));
 				D3D11GpuVertexProgramCore("", "", GPP_NONE));
+			break;
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuFragmentProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuFragmentProgramCore, GenAlloc>())
 				D3D11GpuFragmentProgramCore("", "", GPP_NONE));
 				D3D11GpuFragmentProgramCore("", "", GPP_NONE));
+			break;
 		case GPT_HULL_PROGRAM:
 		case GPT_HULL_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuHullProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuHullProgramCore, GenAlloc>())
 				D3D11GpuHullProgramCore("", "", GPP_NONE));
 				D3D11GpuHullProgramCore("", "", GPP_NONE));
+			break;
 		case GPT_DOMAIN_PROGRAM:
 		case GPT_DOMAIN_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuDomainProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuDomainProgramCore, GenAlloc>())
 				D3D11GpuDomainProgramCore("", "", GPP_NONE));
 				D3D11GpuDomainProgramCore("", "", GPP_NONE));
+			break;
 		case GPT_GEOMETRY_PROGRAM:
 		case GPT_GEOMETRY_PROGRAM:
 			gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuGeometryProgramCore, GenAlloc>())
 			gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuGeometryProgramCore, GenAlloc>())
 				D3D11GpuGeometryProgramCore("", "", GPP_NONE, false));
 				D3D11GpuGeometryProgramCore("", "", GPP_NONE, false));
+			break;
 		}
 		}
 
 
 		if (gpuProg != nullptr)
 		if (gpuProg != nullptr)

+ 14 - 9
BansheeD3D11RenderSystem/Source/BsD3D11InputLayoutManager.cpp

@@ -53,10 +53,10 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	ID3D11InputLayout* D3D11InputLayoutManager::retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgramCore& vertexProgram)
+	ID3D11InputLayout* D3D11InputLayoutManager::retrieveInputLayout(const SPtr<VertexDeclarationCore>& vertexShaderDecl, const SPtr<VertexDeclarationCore>& vertexBufferDecl, D3D11GpuProgramCore& vertexProgram)
 	{
 	{
 		VertexDeclarationKey pair;
 		VertexDeclarationKey pair;
-		pair.vertxDeclId = vertexBufferDecl->getInternalID();
+		pair.vertxDeclId = vertexBufferDecl->getId();
 		pair.vertexProgramId = vertexProgram.getProgramId();
 		pair.vertexProgramId = vertexProgram.getProgramId();
 
 
 		auto iterFind = mInputLayoutMap.find(pair);
 		auto iterFind = mInputLayoutMap.find(pair);
@@ -77,17 +77,19 @@ namespace BansheeEngine
 		return iterFind->second->inputLayout;
 		return iterFind->second->inputLayout;
 	}
 	}
 
 
-	void D3D11InputLayoutManager::addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgramCore& vertexProgram)
+	void D3D11InputLayoutManager::addNewInputLayout(const SPtr<VertexDeclarationCore>& vertexShaderDecl, const SPtr<VertexDeclarationCore>& vertexBufferDecl, D3D11GpuProgramCore& vertexProgram)
 	{
 	{
 		if(!areCompatible(vertexShaderDecl, vertexBufferDecl))
 		if(!areCompatible(vertexShaderDecl, vertexBufferDecl))
 			return; // Error was already reported, so just quit here
 			return; // Error was already reported, so just quit here
 
 
-		UINT32 numElements = vertexBufferDecl->getElementCount();
+		const VertexDeclarationProperties& declProps = vertexBufferDecl->getProperties();
+
+		UINT32 numElements = declProps.getElementCount();
 		D3D11_INPUT_ELEMENT_DESC* declElements = bs_newN<D3D11_INPUT_ELEMENT_DESC, ScratchAlloc>(numElements);
 		D3D11_INPUT_ELEMENT_DESC* declElements = bs_newN<D3D11_INPUT_ELEMENT_DESC, ScratchAlloc>(numElements);
 		ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
 		ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
 
 
 		unsigned int idx = 0;
 		unsigned int idx = 0;
-		for(auto iter = vertexBufferDecl->getElements().begin(); iter != vertexBufferDecl->getElements().end(); ++iter)
+		for (auto iter = declProps.getElements().begin(); iter != declProps.getElements().end(); ++iter)
 		{
 		{
 			declElements[idx].SemanticName			= D3D11Mappings::get(iter->getSemantic());
 			declElements[idx].SemanticName			= D3D11Mappings::get(iter->getSemantic());
 			declElements[idx].SemanticIndex			= iter->getSemanticIdx();
 			declElements[idx].SemanticIndex			= iter->getSemanticIdx();
@@ -122,7 +124,7 @@ namespace BansheeEngine
 
 
 		// Create key and add to the layout map
 		// Create key and add to the layout map
 		VertexDeclarationKey pair;
 		VertexDeclarationKey pair;
-		pair.vertxDeclId = vertexBufferDecl->getInternalID();
+		pair.vertxDeclId = vertexBufferDecl->getId();
 		pair.vertexProgramId = vertexProgram.getProgramId();
 		pair.vertexProgramId = vertexProgram.getProgramId();
 
 
 		mInputLayoutMap[pair] = newEntry;
 		mInputLayoutMap[pair] = newEntry;
@@ -162,12 +164,15 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	bool D3D11InputLayoutManager::areCompatible(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl)
+	bool D3D11InputLayoutManager::areCompatible(const SPtr<VertexDeclarationCore>& vertexShaderDecl, const SPtr<VertexDeclarationCore>& vertexBufferDecl)
 	{
 	{
-		for(auto shaderIter = vertexShaderDecl->getElements().begin(); shaderIter != vertexShaderDecl->getElements().end(); ++shaderIter)
+		const List<VertexElement>& shaderElems = vertexShaderDecl->getProperties().getElements();
+		const List<VertexElement>& bufferElems = vertexBufferDecl->getProperties().getElements();
+
+		for (auto shaderIter = shaderElems.begin(); shaderIter != shaderElems.end(); ++shaderIter)
 		{
 		{
 			const VertexElement* foundElement = nullptr;
 			const VertexElement* foundElement = nullptr;
-			for(auto bufferIter = vertexBufferDecl->getElements().begin(); bufferIter != vertexBufferDecl->getElements().end(); ++bufferIter)
+			for (auto bufferIter = bufferElems.begin(); bufferIter != bufferElems.end(); ++bufferIter)
 			{
 			{
 				if(shaderIter->getSemantic() == bufferIter->getSemantic() && shaderIter->getSemanticIdx() == bufferIter->getSemanticIdx())
 				if(shaderIter->getSemantic() == bufferIter->getSemantic() && shaderIter->getSemanticIdx() == bufferIter->getSemanticIdx())
 				{
 				{

+ 1 - 1
BansheeD3D11RenderSystem/Source/BsD3D11RenderSystem.cpp

@@ -455,7 +455,7 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT(NumIndexBufferBinds);
 		BS_INC_RENDER_STAT(NumIndexBufferBinds);
 	}
 	}
 
 
-	void D3D11RenderSystem::setVertexDeclaration(VertexDeclarationPtr vertexDeclaration)
+	void D3D11RenderSystem::setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 

+ 2 - 5
BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp

@@ -744,11 +744,8 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	TextureViewPtr D3D11TextureCore::createView()
+	TextureViewPtr D3D11TextureCore::createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc)
 	{
 	{
-		TextureViewPtr viewPtr = bs_core_ptr<D3D11TextureView, PoolAlloc>(new (bs_alloc<D3D11TextureView, PoolAlloc>()) D3D11TextureView());
-		viewPtr->_setThisPtr(viewPtr);
-
-		return viewPtr;
+		return bs_shared_ptr<D3D11TextureView, PoolAlloc>(new (bs_alloc<D3D11TextureView, PoolAlloc>()) D3D11TextureView(texture, desc));
 	}
 	}
 }
 }

+ 6 - 17
BansheeD3D11RenderSystem/Source/BsD3D11TextureView.cpp

@@ -8,38 +8,27 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	D3D11TextureView::D3D11TextureView()
-		:TextureView(), mSRV(nullptr), mUAV(nullptr), mDSV(nullptr), mRTV(nullptr)
-	{
-
-	}
-
-	void D3D11TextureView::initialize_internal()
+	D3D11TextureView::D3D11TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc)
+		:TextureView(texture, desc), mSRV(nullptr), mUAV(nullptr), mDSV(nullptr), mRTV(nullptr)
 	{
 	{
 		D3D11TextureCore* d3d11Texture = static_cast<D3D11TextureCore*>(mOwnerTexture.get());
 		D3D11TextureCore* d3d11Texture = static_cast<D3D11TextureCore*>(mOwnerTexture.get());
 
 
-		if((mDesc.usage & GVU_RANDOMWRITE) != 0)
+		if ((mDesc.usage & GVU_RANDOMWRITE) != 0)
 			mUAV = createUAV(d3d11Texture, mDesc.mostDetailMip, mDesc.firstArraySlice, mDesc.numArraySlices);
 			mUAV = createUAV(d3d11Texture, mDesc.mostDetailMip, mDesc.firstArraySlice, mDesc.numArraySlices);
-		else if((mDesc.usage & GVU_RENDERTARGET) != 0)
+		else if ((mDesc.usage & GVU_RENDERTARGET) != 0)
 			mRTV = createRTV(d3d11Texture, mDesc.mostDetailMip, mDesc.firstArraySlice, mDesc.numArraySlices);
 			mRTV = createRTV(d3d11Texture, mDesc.mostDetailMip, mDesc.firstArraySlice, mDesc.numArraySlices);
-		else if((mDesc.usage & GVU_DEPTHSTENCIL) != 0)
+		else if ((mDesc.usage & GVU_DEPTHSTENCIL) != 0)
 			mDSV = createDSV(d3d11Texture, mDesc.mostDetailMip, mDesc.firstArraySlice, mDesc.numArraySlices);
 			mDSV = createDSV(d3d11Texture, mDesc.mostDetailMip, mDesc.firstArraySlice, mDesc.numArraySlices);
 		else
 		else
 			mSRV = createSRV(d3d11Texture, mDesc.mostDetailMip, mDesc.numMips, mDesc.firstArraySlice, mDesc.numArraySlices);
 			mSRV = createSRV(d3d11Texture, mDesc.mostDetailMip, mDesc.numMips, mDesc.firstArraySlice, mDesc.numArraySlices);
-
-		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_ResourceView);
-		TextureView::initialize_internal();
 	}
 	}
 
 
-	void D3D11TextureView::destroy_internal()
+	D3D11TextureView::~D3D11TextureView()
 	{
 	{
 		SAFE_RELEASE(mSRV);
 		SAFE_RELEASE(mSRV);
 		SAFE_RELEASE(mUAV);
 		SAFE_RELEASE(mUAV);
 		SAFE_RELEASE(mDSV);
 		SAFE_RELEASE(mDSV);
 		SAFE_RELEASE(mRTV);
 		SAFE_RELEASE(mRTV);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_ResourceView);
-		TextureView::destroy_internal();
 	}
 	}
 
 
 	ID3D11ShaderResourceView* D3D11TextureView::createSRV(D3D11TextureCore* texture, 
 	ID3D11ShaderResourceView* D3D11TextureView::createSRV(D3D11TextureCore* texture, 

+ 8 - 7
BansheeD3D9RenderSystem/Include/BsD3D9HardwareBufferManager.h

@@ -11,11 +11,6 @@ namespace BansheeEngine
     class BS_D3D9_EXPORT D3D9HardwareBufferManager : public HardwareBufferManager
     class BS_D3D9_EXPORT D3D9HardwareBufferManager : public HardwareBufferManager
     {
     {
 	protected:     
 	protected:     
-		/**
-		 * @copydoc	HardwareBufferManager::createVertexDeclarationImpl
-		 */
-		VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
-
 		/** @copydoc HardwareBufferManager::createGpuParamBlockBufferImpl */
 		/** @copydoc HardwareBufferManager::createGpuParamBlockBufferImpl */
 		GpuParamBlockBufferPtr createGpuParamBlockBufferImpl();
 		GpuParamBlockBufferPtr createGpuParamBlockBufferImpl();
 
 
@@ -33,13 +28,19 @@ namespace BansheeEngine
     {
     {
 	protected:     
 	protected:     
 		/**
 		/**
-		 * @copydoc HardwareBufferCoreManager::createVertexBufferImpl
+		 * @copydoc HardwareBufferCoreManager::createVertexBufferInternal
 		 */
 		 */
 		SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 		SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 
 
 		/**
 		/**
-		 * @copydoc HardwareBufferCoreManager::createIndexBufferImpl
+		 * @copydoc HardwareBufferCoreManager::createIndexBufferInternal
 		 */
 		 */
 		SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
 		SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
+		/**
+		 * @copydoc	HardwareBufferCoreManager::createVertexDeclarationInternal
+		 */
+		SPtr<VertexDeclarationCore> createVertexDeclarationInternal(const List<VertexElement>& elements);
+
     };
     };
 }
 }

+ 1 - 1
BansheeD3D9RenderSystem/Include/BsD3D9Prerequisites.h

@@ -44,7 +44,7 @@ namespace BansheeEngine
     class D3D9IndexBuffer;
     class D3D9IndexBuffer;
     class D3D9HLSLProgramFactory;
     class D3D9HLSLProgramFactory;
     class D3D9HLSLProgramCore;
     class D3D9HLSLProgramCore;
-    class D3D9VertexDeclaration;
+    class D3D9VertexDeclarationCore;
 	class D3D9Resource;
 	class D3D9Resource;
 
 
 	typedef std::shared_ptr<D3D9RenderWindow> D3D9RenderWindowPtr;
 	typedef std::shared_ptr<D3D9RenderWindow> D3D9RenderWindowPtr;

+ 1 - 1
BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h

@@ -63,7 +63,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc RenderSystem::setVertexDeclaration()
 		 * @copydoc RenderSystem::setVertexDeclaration()
 		 */
 		 */
-		void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration);
+		void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration);
 
 
 		/**
 		/**
 		 * @copydoc RenderSystem::setDrawOperation()
 		 * @copydoc RenderSystem::setDrawOperation()

+ 6 - 6
BansheeD3D9RenderSystem/Include/BsD3D9VertexDeclaration.h

@@ -9,10 +9,10 @@ namespace BansheeEngine
 	/**
 	/**
 	 * @brief	DirectX 9 implementation of a vertex declaration.
 	 * @brief	DirectX 9 implementation of a vertex declaration.
 	 */
 	 */
-    class BS_D3D9_EXPORT D3D9VertexDeclaration : public VertexDeclaration, public D3D9Resource
+    class BS_D3D9_EXPORT D3D9VertexDeclarationCore : public VertexDeclarationCore, public D3D9Resource
     {
     {
     public:
     public:
-        ~D3D9VertexDeclaration();
+		~D3D9VertexDeclarationCore();
         
         
 		/**
 		/**
 		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
 		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
@@ -30,9 +30,9 @@ namespace BansheeEngine
         IDirect3DVertexDeclaration9* getD3DVertexDeclaration();
         IDirect3DVertexDeclaration9* getD3DVertexDeclaration();
 
 
 	protected:
 	protected:
-		friend class D3D9HardwareBufferManager;
+		friend class D3D9HardwareBufferCoreManager;
 
 
-		D3D9VertexDeclaration(const VertexDeclaration::VertexElementList& elements);
+		D3D9VertexDeclarationCore(const List<VertexElement>& elements);
 
 
 		/**
 		/**
 		 * @brief	Releases the internal DirectX 9 vertex declaration object.
 		 * @brief	Releases the internal DirectX 9 vertex declaration object.
@@ -40,9 +40,9 @@ namespace BansheeEngine
 		void releaseDeclaration();
 		void releaseDeclaration();
 
 
 		/**
 		/**
-		 * @copydoc	VertexDeclaration::destroy_internal
+		 * @copydoc	VertexDeclarationCore::destroy
 		 */
 		 */
-		void destroy_internal();
+		void destroy();
 
 
 	protected:        
 	protected:        
 		Map<IDirect3DDevice9*, IDirect3DVertexDeclaration9*> mMapDeviceToDeclaration;
 		Map<IDirect3DDevice9*, IDirect3DVertexDeclaration9*> mMapDeviceToDeclaration;

+ 10 - 6
BansheeD3D9RenderSystem/Source/BsD3D9HardwareBufferManager.cpp

@@ -21,12 +21,6 @@ namespace BansheeEngine
 		return bs_core_ptr<D3D9GpuBuffer, PoolAlloc>(buffer);
 		return bs_core_ptr<D3D9GpuBuffer, PoolAlloc>(buffer);
 	}
 	}
 
 
-	VertexDeclarationPtr D3D9HardwareBufferManager::createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements)
-    {
-		D3D9VertexDeclaration* decl = new (bs_alloc<D3D9VertexDeclaration, PoolAlloc>()) D3D9VertexDeclaration(elements);
-		return bs_core_ptr<D3D9VertexDeclaration, PoolAlloc>(decl);
-    }
-
 	SPtr<VertexBufferCore> D3D9HardwareBufferCoreManager::createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
 	SPtr<VertexBufferCore> D3D9HardwareBufferCoreManager::createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
 	{
 	{
 		assert(numVerts > 0);
 		assert(numVerts > 0);
@@ -46,4 +40,14 @@ namespace BansheeEngine
 
 
 		return ret;
 		return ret;
 	}
 	}
+
+	SPtr<VertexDeclarationCore> D3D9HardwareBufferCoreManager::createVertexDeclarationInternal(const List<VertexElement>& elements)
+	{
+		D3D9VertexDeclarationCore* decl = new (bs_alloc<D3D9VertexDeclarationCore, GenAlloc>()) D3D9VertexDeclarationCore(elements);
+		
+		SPtr<D3D9VertexDeclarationCore> declPtr = bs_shared_ptr<D3D9VertexDeclarationCore, GenAlloc>(decl);
+		declPtr->_setThisPtr(declPtr);
+
+		return declPtr;
+	}
 }
 }

+ 2 - 2
BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp

@@ -1130,11 +1130,11 @@ namespace BansheeEngine
 		mIsFrameInProgress = false;
 		mIsFrameInProgress = false;
 	}
 	}
 
 
-	void D3D9RenderSystem::setVertexDeclaration(VertexDeclarationPtr decl)
+	void D3D9RenderSystem::setVertexDeclaration(const SPtr<VertexDeclarationCore>& decl)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 
-		std::shared_ptr<D3D9VertexDeclaration> d3ddecl = std::static_pointer_cast<D3D9VertexDeclaration>(decl);
+		std::shared_ptr<D3D9VertexDeclarationCore> d3ddecl = std::static_pointer_cast<D3D9VertexDeclarationCore>(decl);
 
 
 		HRESULT hr;
 		HRESULT hr;
 		if (FAILED(hr = getActiveD3D9Device()->SetVertexDeclaration(d3ddecl->getD3DVertexDeclaration())))
 		if (FAILED(hr = getActiveD3D9Device()->SetVertexDeclaration(d3ddecl->getD3DVertexDeclaration())))

+ 16 - 14
BansheeD3D9RenderSystem/Source/BsD3D9VertexDeclaration.cpp

@@ -7,27 +7,27 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
-	D3D9VertexDeclaration::D3D9VertexDeclaration(const VertexDeclaration::VertexElementList& elements)
-		:VertexDeclaration(elements)
+	D3D9VertexDeclarationCore::D3D9VertexDeclarationCore(const List<VertexElement>& elements)
+		:VertexDeclarationCore(elements)
     { }
     { }
 
 
-    D3D9VertexDeclaration::~D3D9VertexDeclaration()
+	D3D9VertexDeclarationCore::~D3D9VertexDeclarationCore()
     {    }
     {    }
 
 
-	void D3D9VertexDeclaration::destroy_internal()
+	void D3D9VertexDeclarationCore::destroy()
 	{
 	{
 		releaseDeclaration();
 		releaseDeclaration();
 
 
 		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexDeclaration);
 		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexDeclaration);
-		VertexDeclaration::destroy_internal();
+		VertexDeclarationCore::destroy();
 	}
 	}
 
 
-	void D3D9VertexDeclaration::notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device)
+	void D3D9VertexDeclarationCore::notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device)
 	{
 	{
 		
 		
 	}
 	}
 
 
-	void D3D9VertexDeclaration::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
+	void D3D9VertexDeclarationCore::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	{
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 
@@ -40,21 +40,23 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-    IDirect3DVertexDeclaration9* D3D9VertexDeclaration::getD3DVertexDeclaration()
+	IDirect3DVertexDeclaration9* D3D9VertexDeclarationCore::getD3DVertexDeclaration()
     {
     {
 		IDirect3DDevice9* pCurDevice   = D3D9RenderSystem::getActiveD3D9Device();
 		IDirect3DDevice9* pCurDevice   = D3D9RenderSystem::getActiveD3D9Device();
 		auto it = mMapDeviceToDeclaration.find(pCurDevice);
 		auto it = mMapDeviceToDeclaration.find(pCurDevice);
 		IDirect3DVertexDeclaration9* lpVertDecl = NULL;
 		IDirect3DVertexDeclaration9* lpVertDecl = NULL;
 
 
+		const List<VertexElement>& elementList = getProperties().getElements();
+
 		// Case we have to create the declaration for this device.
 		// Case we have to create the declaration for this device.
 		if (it == mMapDeviceToDeclaration.end() || it->second == NULL)
 		if (it == mMapDeviceToDeclaration.end() || it->second == NULL)
 		{
 		{
-			D3DVERTEXELEMENT9* d3delems = bs_newN<D3DVERTEXELEMENT9, PoolAlloc>((UINT32)(mElementList.size() + 1));
+			D3DVERTEXELEMENT9* d3delems = bs_newN<D3DVERTEXELEMENT9, PoolAlloc>((UINT32)( getProperties().getElements().size() + 1));
 
 
-			VertexElementList::const_iterator i, iend;
 			unsigned int idx;
 			unsigned int idx;
-			iend = mElementList.end();
-			for (idx = 0, i = mElementList.begin(); i != iend; ++i, ++idx)
+			auto iend = elementList.end();
+			auto i = elementList.begin();
+			for (idx = 0, i = elementList.begin(); i != iend; ++i, ++idx)
 			{
 			{
 				d3delems[idx].Method = D3DDECLMETHOD_DEFAULT;
 				d3delems[idx].Method = D3DDECLMETHOD_DEFAULT;
 				d3delems[idx].Offset = static_cast<WORD>(i->getOffset());
 				d3delems[idx].Offset = static_cast<WORD>(i->getOffset());
@@ -80,7 +82,7 @@ namespace BansheeEngine
 				BS_EXCEPT(InternalErrorException, "Cannot create D3D9 vertex declaration: ");
 				BS_EXCEPT(InternalErrorException, "Cannot create D3D9 vertex declaration: ");
 			}
 			}
 
 
-			bs_deleteN<PoolAlloc>(d3delems, (UINT32)(mElementList.size() + 1));
+			bs_deleteN<PoolAlloc>(d3delems, (UINT32)(elementList.size() + 1));
 
 
 			mMapDeviceToDeclaration[pCurDevice] = lpVertDecl;
 			mMapDeviceToDeclaration[pCurDevice] = lpVertDecl;
 
 
@@ -96,7 +98,7 @@ namespace BansheeEngine
         return lpVertDecl;
         return lpVertDecl;
     }
     }
 
 
-	void D3D9VertexDeclaration::releaseDeclaration()
+	void D3D9VertexDeclarationCore::releaseDeclaration()
 	{
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 

+ 1 - 1
BansheeEditorExec/BsEditorExec.cpp

@@ -11,7 +11,7 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	_In_  int nCmdShow
 	)
 	)
 {
 {
-	EditorApplication::startUp(RenderSystemPlugin::OpenGL);
+	EditorApplication::startUp(RenderSystemPlugin::DX11);
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();
 	EditorApplication::shutDown();
 
 

+ 2 - 2
BansheeGLRenderSystem/Include/BsGLRenderSystem.h

@@ -46,7 +46,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc RenderSystem::setVertexDeclaration()
 		 * @copydoc RenderSystem::setVertexDeclaration()
 		 */
 		 */
-		void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration);
+		void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration);
 
 
 		/**
 		/**
 		 * @copydoc RenderSystem::setDrawOperation()
 		 * @copydoc RenderSystem::setDrawOperation()
@@ -581,7 +581,7 @@ namespace BansheeEngine
 		UINT32 mComputeUBOffset;
 		UINT32 mComputeUBOffset;
 
 
 		Vector<SPtr<VertexBufferCore>> mBoundVertexBuffers;
 		Vector<SPtr<VertexBufferCore>> mBoundVertexBuffers;
-		VertexDeclarationPtr mBoundVertexDeclaration;
+		SPtr<VertexDeclarationCore> mBoundVertexDeclaration;
 		SPtr<IndexBufferCore> mBoundIndexBuffer;
 		SPtr<IndexBufferCore> mBoundIndexBuffer;
 		DrawOperationType mCurrentDrawOperation;
 		DrawOperationType mCurrentDrawOperation;
 
 

+ 1 - 1
BansheeGLRenderSystem/Include/BsGLVertexArrayObjectManager.h

@@ -67,7 +67,7 @@ namespace BansheeEngine
 		 *			Lifetime of returned VAO is managed by the vertex buffers that it binds.
 		 *			Lifetime of returned VAO is managed by the vertex buffers that it binds.
 		 */
 		 */
 		const GLVertexArrayObject& getVAO(const SPtr<GLSLGpuProgramCore>& vertexProgram,
 		const GLVertexArrayObject& getVAO(const SPtr<GLSLGpuProgramCore>& vertexProgram,
-			const VertexDeclarationPtr& vertexDecl, const Vector<SPtr<VertexBufferCore>>& boundBuffers);
+			const SPtr<VertexDeclarationCore>& vertexDecl, const Vector<SPtr<VertexBufferCore>>& boundBuffers);
 
 
 		/**
 		/**
 		 * @brief	Called when a vertex buffer containing the provided VAO is destroyed.
 		 * @brief	Called when a vertex buffer containing the provided VAO is destroyed.

+ 1 - 1
BansheeGLRenderSystem/Source/BsGLRenderSystem.cpp

@@ -651,7 +651,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GLRenderSystem::setVertexDeclaration(VertexDeclarationPtr vertexDeclaration)
+	void GLRenderSystem::setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 

+ 2 - 2
BansheeGLRenderSystem/Source/BsGLSLParamParser.cpp

@@ -16,7 +16,7 @@ namespace BansheeEngine
 		return -1;
 		return -1;
 	}
 	}
 
 
-	VertexDeclaration::VertexElementList GLSLParamParser::buildVertexDeclaration(GLuint glProgram)
+	List<VertexElement> GLSLParamParser::buildVertexDeclaration(GLuint glProgram)
 	{
 	{
 		GLint numAttributes = 0;
 		GLint numAttributes = 0;
 		glGetProgramiv(glProgram, GL_ACTIVE_ATTRIBUTES, &numAttributes);
 		glGetProgramiv(glProgram, GL_ACTIVE_ATTRIBUTES, &numAttributes);
@@ -26,7 +26,7 @@ namespace BansheeEngine
 
 
 		GLchar* attributeName = (GLchar*)bs_alloc<ScratchAlloc>(sizeof(GLchar)* maxNameSize);
 		GLchar* attributeName = (GLchar*)bs_alloc<ScratchAlloc>(sizeof(GLchar)* maxNameSize);
 
 
-		VertexDeclaration::VertexElementList elementList;
+		List<VertexElement> elementList;
 		for (GLint i = 0; i < numAttributes; i++)
 		for (GLint i = 0; i < numAttributes; i++)
 		{
 		{
 			GLint attribSize = 0;
 			GLint attribSize = 0;

+ 3 - 3
BansheeGLRenderSystem/Source/BsGLVertexArrayObjectManager.cpp

@@ -75,10 +75,10 @@ namespace BansheeEngine
 	}
 	}
 
 
 	const GLVertexArrayObject& GLVertexArrayObjectManager::getVAO(const SPtr<GLSLGpuProgramCore>& vertexProgram,
 	const GLVertexArrayObject& GLVertexArrayObjectManager::getVAO(const SPtr<GLSLGpuProgramCore>& vertexProgram,
-		const VertexDeclarationPtr& vertexDecl, const Vector<SPtr<VertexBufferCore>>& boundBuffers)
+		const SPtr<VertexDeclarationCore>& vertexDecl, const Vector<SPtr<VertexBufferCore>>& boundBuffers)
 	{
 	{
 		UINT16 maxStreamIdx = 0;
 		UINT16 maxStreamIdx = 0;
-		const VertexDeclaration::VertexElementList& decl = vertexDecl->getElements();
+		const List<VertexElement>& decl = vertexDecl->getProperties().getElements();
 		for (auto& elem : decl)
 		for (auto& elem : decl)
 			maxStreamIdx = std::max(maxStreamIdx, elem.getStreamIdx());
 			maxStreamIdx = std::max(maxStreamIdx, elem.getStreamIdx());
 
 
@@ -124,7 +124,7 @@ namespace BansheeEngine
 		}
 		}
 
 
 		// Need to create new VAO
 		// Need to create new VAO
-		const VertexDeclaration::VertexElementList& inputAttributes = vertexProgram->getInputAttributes().getElements();
+		const List<VertexElement>& inputAttributes = vertexProgram->getInputAttributes().getProperties().getElements();
 
 
 		glGenVertexArrays(1, &wantedVAO.mHandle);
 		glGenVertexArrays(1, &wantedVAO.mHandle);
 		glBindVertexArray(wantedVAO.mHandle);
 		glBindVertexArray(wantedVAO.mHandle);

+ 2 - 2
BansheeGLRenderSystem/Source/GLSL/include/BsGLSLGpuProgram.h

@@ -23,7 +23,7 @@ namespace BansheeEngine
 		 *			program expect (and which attributes will it retrieve from the bound vertex buffer). 
 		 *			program expect (and which attributes will it retrieve from the bound vertex buffer). 
 		 *			Only valid for vertex programs.
 		 *			Only valid for vertex programs.
 		 */
 		 */
-		const VertexDeclaration& getInputAttributes() const { return *mVertexDeclaration; }
+		const VertexDeclarationCore& getInputAttributes() const { return *mVertexDeclaration; }
 
 
 		/**
 		/**
 		 * @brief	Gets internal OpenGL handle to the program.
 		 * @brief	Gets internal OpenGL handle to the program.
@@ -61,7 +61,7 @@ namespace BansheeEngine
 		UINT32 mProgramID;
 		UINT32 mProgramID;
 		GLuint mGLHandle;
 		GLuint mGLHandle;
 
 
-		VertexDeclarationPtr mVertexDeclaration;
+		SPtr<VertexDeclarationCore> mVertexDeclaration;
 		
 		
 		static UINT32 mVertexShaderCount;
 		static UINT32 mVertexShaderCount;
 		static UINT32 mFragmentShaderCount;
 		static UINT32 mFragmentShaderCount;

+ 1 - 1
BansheeGLRenderSystem/Source/GLSL/include/BsGLSLParamParser.h

@@ -62,7 +62,7 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @param	glProgram	OpenGL handle to the GPU program.
 		 * @param	glProgram	OpenGL handle to the GPU program.
 		 */
 		 */
-		VertexDeclaration::VertexElementList buildVertexDeclaration(GLuint glProgram);
+		List<VertexElement> buildVertexDeclaration(GLuint glProgram);
 
 
 	private:
 	private:
 		/**
 		/**

+ 2 - 2
BansheeGLRenderSystem/Source/GLSL/src/BsGLSLGpuProgram.cpp

@@ -182,8 +182,8 @@ namespace BansheeEngine
 
 
 			if (mProperties.getType() == GPT_VERTEX_PROGRAM)
 			if (mProperties.getType() == GPT_VERTEX_PROGRAM)
 			{
 			{
-				VertexDeclaration::VertexElementList elementList = paramParser.buildVertexDeclaration(mGLHandle);
-				mVertexDeclaration = HardwareBufferManager::instance().createVertexDeclaration(elementList);
+				List<VertexElement> elementList = paramParser.buildVertexDeclaration(mGLHandle);
+				mVertexDeclaration = HardwareBufferCoreManager::instance().createVertexDeclaration(elementList);
 			}
 			}
 		}
 		}
 		else
 		else

+ 0 - 2
TODO.txt

@@ -4,8 +4,6 @@ TODO - CoreObject refactor:
 Resource
 Resource
  - Material -> Remove MaterialProxy
  - Material -> Remove MaterialProxy
  - Shader -> Remove ShaderProxy
  - Shader -> Remove ShaderProxy
-MeshHeap
-TextureView
 VertexDeclaration
 VertexDeclaration
 GpuBuffer
 GpuBuffer
 GpuParamBlockBuffer
 GpuParamBlockBuffer