Просмотр исходного кода

CoreGpuObject -> CoreObject
Made render thread initialization optional so Material/Font can be initialize without waiting for render thread

Marko Pintera 13 лет назад
Родитель
Сommit
5a64dff9db
36 измененных файлов с 163 добавлено и 134 удалено
  1. 0 2
      CamelotClient/CamelotClient.cpp
  2. 4 4
      CamelotCore/CamelotCore.vcxproj
  3. 12 12
      CamelotCore/CamelotCore.vcxproj.filters
  4. 16 14
      CamelotCore/Include/CmCoreObject.h
  5. 3 3
      CamelotCore/Include/CmCoreObjectManager.h
  6. 2 2
      CamelotCore/Include/CmGpuBuffer.h
  7. 2 2
      CamelotCore/Include/CmGpuParamBlock.h
  8. 2 2
      CamelotCore/Include/CmIndexBuffer.h
  9. 1 1
      CamelotCore/Include/CmMaterialManager.cpp
  10. 1 1
      CamelotCore/Include/CmPrerequisites.h
  11. 2 2
      CamelotCore/Include/CmRenderTarget.h
  12. 3 3
      CamelotCore/Include/CmResource.h
  13. 2 2
      CamelotCore/Include/CmTextureView.h
  14. 2 2
      CamelotCore/Include/CmVertexBuffer.h
  15. 2 2
      CamelotCore/Include/CmVertexDeclaration.h
  16. 1 1
      CamelotCore/Source/CmApplication.cpp
  17. 66 37
      CamelotCore/Source/CmCoreObject.cpp
  18. 4 4
      CamelotCore/Source/CmCoreObjectManager.cpp
  19. 2 2
      CamelotCore/Source/CmFontManager.cpp
  20. 1 1
      CamelotCore/Source/CmGpuBuffer.cpp
  21. 3 3
      CamelotCore/Source/CmGpuParamBlock.cpp
  22. 2 2
      CamelotCore/Source/CmGpuProgInclude.cpp
  23. 0 1
      CamelotCore/Source/CmGpuProgIncludeImporter.cpp
  24. 1 1
      CamelotCore/Source/CmGpuProgramManager.cpp
  25. 5 5
      CamelotCore/Source/CmHardwareBufferManager.cpp
  26. 3 3
      CamelotCore/Source/CmHighLevelGpuProgramManager.cpp
  27. 1 0
      CamelotCore/Source/CmMaterial.cpp
  28. 1 1
      CamelotCore/Source/CmMeshManager.cpp
  29. 8 8
      CamelotCore/Source/CmRenderStateManager.cpp
  30. 1 1
      CamelotCore/Source/CmRenderWindowManager.cpp
  31. 2 2
      CamelotCore/Source/CmResource.cpp
  32. 1 1
      CamelotCore/Source/CmShader.cpp
  33. 1 1
      CamelotCore/Source/CmTexture.cpp
  34. 4 4
      CamelotCore/Source/CmTextureManager.cpp
  35. 1 1
      CamelotCore/Source/CmTextureView.cpp
  36. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

+ 0 - 2
CamelotClient/CamelotClient.cpp

@@ -195,8 +195,6 @@ int CALLBACK WinMain(
 	newPassDX11->setFragmentProgram(fragProgRef);
 	newPassDX11->setFragmentProgram(fragProgRef);
 
 
 	MaterialHandle testMaterial = Material::create();
 	MaterialHandle testMaterial = Material::create();
-	testMaterial.waitUntilLoaded(); // TODO - Material doesn't do anything GPU specific, so technically it should be possible to initialize on the spot
-	// but is that a good idea?
 	testMaterial->setShader(testShader);
 	testMaterial->setShader(testShader);
 
 
 	testMaterial->setMat4("matViewProjection", Matrix4::IDENTITY);
 	testMaterial->setMat4("matViewProjection", Matrix4::IDENTITY);

+ 4 - 4
CamelotCore/CamelotCore.vcxproj

@@ -187,8 +187,8 @@
     <ClInclude Include="Include\CmCommonEnums.h" />
     <ClInclude Include="Include\CmCommonEnums.h" />
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
-    <ClInclude Include="Include\CmCoreGpuObject.h" />
-    <ClInclude Include="Include\CmCoreGpuObjectManager.h" />
+    <ClInclude Include="Include\CmCoreObject.h" />
+    <ClInclude Include="Include\CmCoreObjectManager.h" />
     <ClInclude Include="Include\CmDeferredRenderContext.h" />
     <ClInclude Include="Include\CmDeferredRenderContext.h" />
     <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
     <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
     <ClInclude Include="Include\CmDepthStencilState.h" />
     <ClInclude Include="Include\CmDepthStencilState.h" />
@@ -294,8 +294,8 @@
     <ClCompile Include="Source\CmCgProgram.cpp" />
     <ClCompile Include="Source\CmCgProgram.cpp" />
     <ClCompile Include="Source\CmCgProgramFactory.cpp" />
     <ClCompile Include="Source\CmCgProgramFactory.cpp" />
     <ClCompile Include="Source\CmCommandQueue.cpp" />
     <ClCompile Include="Source\CmCommandQueue.cpp" />
-    <ClCompile Include="Source\CmCoreGpuObject.cpp" />
-    <ClCompile Include="Source\CmCoreGpuObjectManager.cpp" />
+    <ClCompile Include="Source\CmCoreObject.cpp" />
+    <ClCompile Include="Source\CmCoreObjectManager.cpp" />
     <ClCompile Include="Source\CmDeferredRenderContext.cpp" />
     <ClCompile Include="Source\CmDeferredRenderContext.cpp" />
     <ClCompile Include="Source\CmDepthStencilState.cpp" />
     <ClCompile Include="Source\CmDepthStencilState.cpp" />
     <ClCompile Include="Source\CmFont.cpp" />
     <ClCompile Include="Source\CmFont.cpp" />

+ 12 - 12
CamelotCore/CamelotCore.vcxproj.filters

@@ -366,12 +366,6 @@
     <ClInclude Include="Include\CmGpuParamBlock.h">
     <ClInclude Include="Include\CmGpuParamBlock.h">
       <Filter>Header Files\RenderSystem</Filter>
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmCoreGpuObject.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCoreGpuObjectManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmMeshManager.h">
     <ClInclude Include="Include\CmMeshManager.h">
       <Filter>Header Files\RenderSystem</Filter>
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
     </ClInclude>
@@ -414,6 +408,12 @@
     <ClInclude Include="Include\CmFontManager.h">
     <ClInclude Include="Include\CmFontManager.h">
       <Filter>Header Files\Text</Filter>
       <Filter>Header Files\Text</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\CmCoreObject.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCoreObjectManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -602,12 +602,6 @@
     <ClCompile Include="Source\CmGpuParamBlock.cpp">
     <ClCompile Include="Source\CmGpuParamBlock.cpp">
       <Filter>Source Files\RenderSystem</Filter>
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\CmCoreGpuObject.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCoreGpuObjectManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmMeshManager.cpp">
     <ClCompile Include="Source\CmMeshManager.cpp">
       <Filter>Source Files\RenderSystem</Filter>
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
     </ClCompile>
@@ -635,5 +629,11 @@
     <ClCompile Include="Source\CmFontManager.cpp">
     <ClCompile Include="Source\CmFontManager.cpp">
       <Filter>Source Files\Text</Filter>
       <Filter>Source Files\Text</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\CmCoreObject.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCoreObjectManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 16 - 14
CamelotCore/Include/CmCoreGpuObject.h → CamelotCore/Include/CmCoreObject.h

@@ -14,19 +14,20 @@ namespace CamelotEngine
 	 * 			All core GPU objects are initialized on the render thread, and destroyed on the render thread,
 	 * 			All core GPU objects are initialized on the render thread, and destroyed on the render thread,
 	 * 			so majority of these methods will just schedule object initialization/destruction.
 	 * 			so majority of these methods will just schedule object initialization/destruction.
 	 */
 	 */
-	class CM_EXPORT CoreGpuObject
+	class CM_EXPORT CoreObject
 	{
 	{
 	protected:
 	protected:
 		enum Flags
 		enum Flags
 		{
 		{
 			CGO_INITIALIZED = 0x01,
 			CGO_INITIALIZED = 0x01,
-			CGO_SCHEDULED_FOR_INIT = 0x02,
-			CGO_SCHEDULED_FOR_DELETE = 0x04
+			CGO_REQUIRES_GPU_INIT = 0x02,
+			CGO_SCHEDULED_FOR_INIT = 0x04,
+			CGO_SCHEDULED_FOR_DELETE = 0x08
 		};
 		};
 
 
 	public:
 	public:
-		CoreGpuObject();
-		virtual ~CoreGpuObject();
+		CoreObject(bool requiresGpuInit = true);
+		virtual ~CoreObject();
 
 
 		/**
 		/**
 		 * @brief	Destroys all GPU resources of this object.
 		 * @brief	Destroys all GPU resources of this object.
@@ -62,14 +63,14 @@ o		 *
 		 *
 		 *
 		 * @note	Called automatically by the factory creation methods so user should not call this manually.
 		 * @note	Called automatically by the factory creation methods so user should not call this manually.
 		 */
 		 */
-		void setThisPtr(std::shared_ptr<CoreGpuObject> ptrThis);
+		void setThisPtr(std::shared_ptr<CoreObject> ptrThis);
 
 
 		/**
 		/**
 		 * @brief	Schedules the object to be destroyed, and then deleted.
 		 * @brief	Schedules the object to be destroyed, and then deleted.
 		 *
 		 *
 		 * @note	You should never call this manually. It's meant for internal use only.
 		 * @note	You should never call this manually. It's meant for internal use only.
 		 */
 		 */
-		static void _deleteDelayed(CoreGpuObject* obj);
+		static void _deleteDelayed(CoreObject* obj);
 
 
 	protected:
 	protected:
 		/**
 		/**
@@ -91,7 +92,7 @@ o		 *
 		/**
 		/**
 		 * @brief	Returns a shared_ptr version of "this" pointer.
 		 * @brief	Returns a shared_ptr version of "this" pointer.
 		 */
 		 */
-		std::shared_ptr<CoreGpuObject> getThisPtr() const { return mThis.lock(); }
+		std::shared_ptr<CoreObject> getThisPtr() const { return mThis.lock(); }
 
 
 		/**
 		/**
 		 * @brief	Queues a command to be executed on the render thread, without a return value.
 		 * @brief	Queues a command to be executed on the render thread, without a return value.
@@ -100,7 +101,7 @@ o		 *
 		 * 			make sure the object is not deleted before the command executes. Can be null if the 
 		 * 			make sure the object is not deleted before the command executes. Can be null if the 
 		 * 			function is static or global.
 		 * 			function is static or global.
 		 */
 		 */
-		static void queueGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void()> func);
+		static void queueGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void()> func);
 
 
 		/**
 		/**
 		 * @brief	Queues a command to be executed on the render thread, with a return value in the form of AsyncOp.
 		 * @brief	Queues a command to be executed on the render thread, with a return value in the form of AsyncOp.
@@ -111,7 +112,7 @@ o		 *
 		 * 			make sure the object is not deleted before the command executes. Can be null if the
 		 * 			make sure the object is not deleted before the command executes. Can be null if the
 		 * 			function is static or global.
 		 * 			function is static or global.
 		 */
 		 */
-		static AsyncOp queueReturnGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void(AsyncOp&)> func);
+		static AsyncOp queueReturnGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void(AsyncOp&)> func);
 
 
 		/**
 		/**
 		 * @brief	Returns an unique identifier for this object.
 		 * @brief	Returns an unique identifier for this object.
@@ -120,7 +121,8 @@ o		 *
 
 
 		bool isScheduledToBeInitialized() const { return (mFlags & CGO_SCHEDULED_FOR_INIT) != 0; }
 		bool isScheduledToBeInitialized() const { return (mFlags & CGO_SCHEDULED_FOR_INIT) != 0; }
 		bool isScheduledToBeDeleted() const { return (mFlags & CGO_SCHEDULED_FOR_DELETE) != 0; }
 		bool isScheduledToBeDeleted() const { return (mFlags & CGO_SCHEDULED_FOR_DELETE) != 0; }
-		
+		bool requiresGpuInitialization() const { return (mFlags & CGO_REQUIRES_GPU_INIT) != 0; }
+
 		void setIsInitialized(bool initialized) { mFlags = initialized ? mFlags | CGO_INITIALIZED : mFlags & ~CGO_INITIALIZED; }
 		void setIsInitialized(bool initialized) { mFlags = initialized ? mFlags | CGO_INITIALIZED : mFlags & ~CGO_INITIALIZED; }
 		void setScheduledToBeInitialized(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_INIT : mFlags & ~CGO_SCHEDULED_FOR_INIT; }
 		void setScheduledToBeInitialized(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_INIT : mFlags & ~CGO_SCHEDULED_FOR_INIT; }
 		void setScheduledToBeDeleted(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_DELETE : mFlags & ~CGO_SCHEDULED_FOR_DELETE; }
 		void setScheduledToBeDeleted(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_DELETE : mFlags & ~CGO_SCHEDULED_FOR_DELETE; }
@@ -129,12 +131,12 @@ o		 *
 
 
 		UINT8 mFlags;
 		UINT8 mFlags;
 		UINT64 mInternalID; // ID == 0 is not a valid ID
 		UINT64 mInternalID; // ID == 0 is not a valid ID
-		std::weak_ptr<CoreGpuObject> mThis;
+		std::weak_ptr<CoreObject> mThis;
 
 
 		CM_STATIC_THREAD_SYNCHRONISER(mCoreGpuObjectLoadedCondition)
 		CM_STATIC_THREAD_SYNCHRONISER(mCoreGpuObjectLoadedCondition)
 		CM_STATIC_MUTEX(mCoreGpuObjectLoadedMutex)
 		CM_STATIC_MUTEX(mCoreGpuObjectLoadedMutex)
 
 
-		static void executeGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void()> func);
-		static void executeReturnGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void(AsyncOp&)> func, AsyncOp& op); 
+		static void executeGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void()> func);
+		static void executeReturnGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void(AsyncOp&)> func, AsyncOp& op); 
 	};
 	};
 }
 }

+ 3 - 3
CamelotCore/Include/CmCoreGpuObjectManager.h → CamelotCore/Include/CmCoreObjectManager.h

@@ -13,12 +13,12 @@ namespace CamelotEngine
 		CoreGpuObjectManager();
 		CoreGpuObjectManager();
 		~CoreGpuObjectManager();
 		~CoreGpuObjectManager();
 
 
-		UINT64 registerObject(CoreGpuObject* object);
-		void unregisterObject(CoreGpuObject* object);
+		UINT64 registerObject(CoreObject* object);
+		void unregisterObject(CoreObject* object);
 	private:
 	private:
 		// Keeps a list of ALL loaded core GPU objects
 		// Keeps a list of ALL loaded core GPU objects
 		UINT64 mNextAvailableID;
 		UINT64 mNextAvailableID;
-		map<UINT64, CoreGpuObject*>::type mObjects;
+		map<UINT64, CoreObject*>::type mObjects;
 		CM_MUTEX(mObjectsMutex);
 		CM_MUTEX(mObjectsMutex);
 	};
 	};
 }
 }

+ 2 - 2
CamelotCore/Include/CmGpuBuffer.h

@@ -3,11 +3,11 @@
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmCommonEnums.h"
 #include "CmCommonEnums.h"
 #include "CmGpuBufferView.h"
 #include "CmGpuBufferView.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 
 
 namespace CamelotEngine 
 namespace CamelotEngine 
 {
 {
-	class CM_EXPORT GpuBuffer : public CoreGpuObject
+	class CM_EXPORT GpuBuffer : public CoreObject
     {
     {
     public:
     public:
         virtual ~GpuBuffer();
         virtual ~GpuBuffer();

+ 2 - 2
CamelotCore/Include/CmGpuParamBlock.h

@@ -2,7 +2,7 @@
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmCommonEnums.h"
 #include "CmCommonEnums.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -31,7 +31,7 @@ namespace CamelotEngine
 		UINT32 mSize;
 		UINT32 mSize;
 	};
 	};
 
 
-	class CM_EXPORT GpuParamBlock : public CoreGpuObject
+	class CM_EXPORT GpuParamBlock : public CoreObject
 	{
 	{
 	public:
 	public:
 		GpuParamBlock();
 		GpuParamBlock();

+ 2 - 2
CamelotCore/Include/CmIndexBuffer.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 // Precompiler options
 // Precompiler options
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
 #include "CmHardwareBuffer.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 
 
 namespace CamelotEngine 
 namespace CamelotEngine 
 {
 {
@@ -42,7 +42,7 @@ namespace CamelotEngine
 	*  @{
 	*  @{
 	*/
 	*/
 	/** Specialisation of HardwareBuffer for vertex index buffers, still abstract. */
 	/** Specialisation of HardwareBuffer for vertex index buffers, still abstract. */
-    class CM_EXPORT IndexBuffer : public HardwareBuffer, public CoreGpuObject
+    class CM_EXPORT IndexBuffer : public HardwareBuffer, public CoreObject
     {
     {
 	public:
 	public:
 		enum IndexType {
 		enum IndexType {

+ 1 - 1
CamelotCore/Include/CmMaterialManager.cpp

@@ -5,7 +5,7 @@ namespace CamelotEngine
 {
 {
 	MaterialPtr MaterialManager::create() const
 	MaterialPtr MaterialManager::create() const
 	{
 	{
-		MaterialPtr newMat(new Material(), &CoreGpuObject::_deleteDelayed);
+		MaterialPtr newMat(new Material(), &CoreObject::_deleteDelayed);
 		newMat->setThisPtr(newMat);
 		newMat->setThisPtr(newMat);
 		newMat->initialize();
 		newMat->initialize();
 
 

+ 1 - 1
CamelotCore/Include/CmPrerequisites.h

@@ -144,7 +144,7 @@ namespace CamelotEngine {
 	struct GpuParamBlockDesc;
 	struct GpuParamBlockDesc;
 	class GpuProgInclude;
 	class GpuProgInclude;
 	class TextureView;
 	class TextureView;
-	class CoreGpuObject;
+	class CoreObject;
 	class ImportOptions;
 	class ImportOptions;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;

+ 2 - 2
CamelotCore/Include/CmRenderTarget.h

@@ -33,7 +33,7 @@ THE SOFTWARE.
 #include "CmString.h"
 #include "CmString.h"
 #include "CmPixelUtil.h"
 #include "CmPixelUtil.h"
 #include "CmViewport.h"
 #include "CmViewport.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 
 
 /* Define the number of priority groups for the render system's render targets. */
 /* Define the number of priority groups for the render system's render targets. */
 #ifndef CM_NUM_RENDERTARGET_GROUPS
 #ifndef CM_NUM_RENDERTARGET_GROUPS
@@ -69,7 +69,7 @@ namespace CamelotEngine
         @version
         @version
             1.0
             1.0
      */
      */
-    class CM_EXPORT RenderTarget : public CoreGpuObject
+    class CM_EXPORT RenderTarget : public CoreObject
     {
     {
     public:
     public:
 		enum FrameBuffer
 		enum FrameBuffer

+ 3 - 3
CamelotCore/Include/CmResource.h

@@ -2,17 +2,17 @@
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmIReflectable.h"
 #include "CmIReflectable.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
 	/**
 	/**
 	 * @brief	Base class for all resources used in the engine.
 	 * @brief	Base class for all resources used in the engine.
 	 */
 	 */
-	class CM_EXPORT Resource : public IReflectable, public CoreGpuObject
+	class CM_EXPORT Resource : public IReflectable, public CoreObject
 	{
 	{
 	public:
 	public:
-		Resource();
+		Resource(bool requiresGpuInitialization = true);
 		virtual ~Resource() {};
 		virtual ~Resource() {};
 
 
 		const String& getUUID() const { return mUUID; }
 		const String& getUUID() const { return mUUID; }

+ 2 - 2
CamelotCore/Include/CmTextureView.h

@@ -1,7 +1,7 @@
 #pragma once
 #pragma once
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 #include "CmCommonEnums.h"
 #include "CmCommonEnums.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
@@ -15,7 +15,7 @@ namespace CamelotEngine
 		GpuViewUsage usage;
 		GpuViewUsage usage;
 	};
 	};
 
 
-	class CM_EXPORT TextureView : public CoreGpuObject
+	class CM_EXPORT TextureView : public CoreObject
 	{
 	{
 	public:
 	public:
 		class HashFunction
 		class HashFunction

+ 2 - 2
CamelotCore/Include/CmVertexBuffer.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 // Precompiler options
 // Precompiler options
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
 #include "CmHardwareBuffer.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 #include "CmColor.h"
 #include "CmColor.h"
 
 
 namespace CamelotEngine 
 namespace CamelotEngine 
@@ -43,7 +43,7 @@ namespace CamelotEngine
 	*  @{
 	*  @{
 	*/
 	*/
 	/** Specialisation of HardwareBuffer for a vertex buffer. */
 	/** Specialisation of HardwareBuffer for a vertex buffer. */
-    class CM_EXPORT VertexBuffer : public HardwareBuffer, public CoreGpuObject
+    class CM_EXPORT VertexBuffer : public HardwareBuffer, public CoreObject
     {
     {
 	public:
 	public:
         ~VertexBuffer();
         ~VertexBuffer();

+ 2 - 2
CamelotCore/Include/CmVertexDeclaration.h

@@ -2,7 +2,7 @@
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmColor.h"
 #include "CmColor.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -242,7 +242,7 @@ namespace CamelotEngine
 	Like the other classes in this functional area, these declarations should be created and
 	Like the other classes in this functional area, these declarations should be created and
 	destroyed using the HardwareBufferManager.
 	destroyed using the HardwareBufferManager.
     */
     */
-	class CM_EXPORT VertexDeclaration : public IReflectable, public CoreGpuObject
+	class CM_EXPORT VertexDeclaration : public IReflectable, public CoreObject
     {
     {
     public:
     public:
 		/// Defines the list of vertex elements that makes up this declaration
 		/// Defines the list of vertex elements that makes up this declaration

+ 1 - 1
CamelotCore/Source/CmApplication.cpp

@@ -11,7 +11,7 @@
 #include "CmVector2.h"
 #include "CmVector2.h"
 #include "CmHighLevelGpuProgram.h"
 #include "CmHighLevelGpuProgram.h"
 #include "CmHighLevelGpuProgramManager.h"
 #include "CmHighLevelGpuProgramManager.h"
-#include "CmCoreGpuObjectManager.h"
+#include "CmCoreObjectManager.h"
 #include "CmDynLib.h"
 #include "CmDynLib.h"
 #include "CmDynLibManager.h"
 #include "CmDynLibManager.h"
 #include "CmSceneManager.h"
 #include "CmSceneManager.h"

+ 66 - 37
CamelotCore/Source/CmCoreGpuObject.cpp → CamelotCore/Source/CmCoreObject.cpp

@@ -1,20 +1,21 @@
-#include "CmCoreGpuObject.h"
+#include "CmCoreObject.h"
 #include "CmRenderSystem.h"
 #include "CmRenderSystem.h"
-#include "CmCoreGpuObjectManager.h"
+#include "CmCoreObjectManager.h"
 #include "CmDebug.h"
 #include "CmDebug.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	CM_STATIC_THREAD_SYNCHRONISER_CLASS_INSTANCE(mCoreGpuObjectLoadedCondition, CoreGpuObject)
-	CM_STATIC_MUTEX_CLASS_INSTANCE(mCoreGpuObjectLoadedMutex, CoreGpuObject)
+	CM_STATIC_THREAD_SYNCHRONISER_CLASS_INSTANCE(mCoreGpuObjectLoadedCondition, CoreObject)
+	CM_STATIC_MUTEX_CLASS_INSTANCE(mCoreGpuObjectLoadedMutex, CoreObject)
 
 
-	CoreGpuObject::CoreGpuObject()
+	CoreObject::CoreObject(bool requiresGpuInit)
 		: mFlags(0), mInternalID(0)
 		: mFlags(0), mInternalID(0)
 	{
 	{
 		mInternalID = CoreGpuObjectManager::instance().registerObject(this);
 		mInternalID = CoreGpuObjectManager::instance().registerObject(this);
+		mFlags = requiresGpuInit ? mFlags | CGO_REQUIRES_GPU_INIT : mFlags;
 	}
 	}
 
 
-	CoreGpuObject::~CoreGpuObject() 
+	CoreObject::~CoreObject() 
 	{
 	{
 		if(isInitialized())
 		if(isInitialized())
 		{
 		{
@@ -34,14 +35,21 @@ namespace CamelotEngine
 		CoreGpuObjectManager::instance().unregisterObject(this);
 		CoreGpuObjectManager::instance().unregisterObject(this);
 	}
 	}
 
 
-	void CoreGpuObject::destroy()
+	void CoreObject::destroy()
 	{
 	{
-		setScheduledToBeDeleted(true);
+		if(requiresGpuInitialization())
+		{
+			setScheduledToBeDeleted(true);
 
 
-		queueGpuCommand(mThis.lock(), boost::bind(&CoreGpuObject::destroy_internal, this));
+			queueGpuCommand(mThis.lock(), boost::bind(&CoreObject::destroy_internal, this));
+		}
+		else
+		{
+			destroy_internal();
+		}
 	}
 	}
 
 
-	void CoreGpuObject::destroy_internal()
+	void CoreObject::destroy_internal()
 	{
 	{
 #if CM_DEBUG_MODE
 #if CM_DEBUG_MODE
 		if(!isInitialized())
 		if(!isInitialized())
@@ -51,31 +59,45 @@ namespace CamelotEngine
 		setIsInitialized(false);
 		setIsInitialized(false);
 	}
 	}
 
 
-	void CoreGpuObject::initialize()
+	void CoreObject::initialize()
 	{
 	{
 #if CM_DEBUG_MODE
 #if CM_DEBUG_MODE
 		if(isInitialized() || isScheduledToBeInitialized())
 		if(isInitialized() || isScheduledToBeInitialized())
 			CM_EXCEPT(InternalErrorException, "Trying to initialize an object that is already initialized.");
 			CM_EXCEPT(InternalErrorException, "Trying to initialize an object that is already initialized.");
 #endif
 #endif
 
 
-		setScheduledToBeInitialized(true);
+		if(requiresGpuInitialization())
+		{
+			setScheduledToBeInitialized(true);
 
 
-		queueGpuCommand(mThis.lock(), boost::bind(&CoreGpuObject::initialize_internal, this));
+			queueGpuCommand(mThis.lock(), boost::bind(&CoreObject::initialize_internal, this));
+		}
+		else
+		{
+			initialize_internal();
+		}
 	}
 	}
 
 
-	void CoreGpuObject::initialize_internal()
+	void CoreObject::initialize_internal()
 	{
 	{
+		if(requiresGpuInitialization())
 		{
 		{
-			CM_LOCK_MUTEX(mCoreGpuObjectLoadedMutex);
-			setIsInitialized(true);
-		}	
+			{
+				CM_LOCK_MUTEX(mCoreGpuObjectLoadedMutex);
+				setIsInitialized(true);
+			}	
 
 
-		setScheduledToBeInitialized(false);
+			setScheduledToBeInitialized(false);
 
 
-		CM_THREAD_NOTIFY_ALL(mCoreGpuObjectLoadedCondition);
+			CM_THREAD_NOTIFY_ALL(mCoreGpuObjectLoadedCondition);
+		}
+		else
+		{
+			setIsInitialized(true);
+		}
 	}
 	}
 
 
-	void CoreGpuObject::waitUntilInitialized()
+	void CoreObject::waitUntilInitialized()
 	{
 	{
 #if CM_DEBUG_MODE
 #if CM_DEBUG_MODE
 		if(CM_THREAD_CURRENT_ID == RenderSystem::instancePtr()->getRenderThreadId())
 		if(CM_THREAD_CURRENT_ID == RenderSystem::instancePtr()->getRenderThreadId())
@@ -84,23 +106,30 @@ namespace CamelotEngine
 
 
 		if(!isInitialized())
 		if(!isInitialized())
 		{
 		{
-			CM_LOCK_MUTEX_NAMED(mCoreGpuObjectLoadedMutex, lock);
-			while(!isInitialized())
+			if(requiresGpuInitialization())
 			{
 			{
-				if(!isScheduledToBeInitialized())
-					CM_EXCEPT(InternalErrorException, "Attempting to wait until initialization finishes but object is not scheduled to be initialized.");
-
-				CM_THREAD_WAIT(mCoreGpuObjectLoadedCondition, mCoreGpuObjectLoadedMutex, lock);
+				CM_LOCK_MUTEX_NAMED(mCoreGpuObjectLoadedMutex, lock);
+				while(!isInitialized())
+				{
+					if(!isScheduledToBeInitialized())
+						CM_EXCEPT(InternalErrorException, "Attempting to wait until initialization finishes but object is not scheduled to be initialized.");
+
+					CM_THREAD_WAIT(mCoreGpuObjectLoadedCondition, mCoreGpuObjectLoadedMutex, lock);
+				}
+			}
+			else
+			{
+				CM_EXCEPT(InternalErrorException, "Attempting to wait until initialization finishes but object is not scheduled to be initialized.");
 			}
 			}
 		}
 		}
 	}
 	}
 
 
-	void CoreGpuObject::setThisPtr(std::shared_ptr<CoreGpuObject> ptrThis)
+	void CoreObject::setThisPtr(std::shared_ptr<CoreObject> ptrThis)
 	{
 	{
 		mThis = ptrThis;
 		mThis = ptrThis;
 	}
 	}
 
 
-	void CoreGpuObject::_deleteDelayed(CoreGpuObject* obj)
+	void CoreObject::_deleteDelayed(CoreObject* obj)
 	{
 	{
 		assert(obj != nullptr);
 		assert(obj != nullptr);
 
 
@@ -123,7 +152,7 @@ namespace CamelotEngine
 
 
 		if(obj->isInitialized())
 		if(obj->isInitialized())
 		{
 		{
-			std::shared_ptr<CoreGpuObject> thisPtr(obj);
+			std::shared_ptr<CoreObject> thisPtr(obj);
 			obj->setThisPtr(thisPtr);
 			obj->setThisPtr(thisPtr);
 			obj->destroy();
 			obj->destroy();
 		}
 		}
@@ -133,31 +162,31 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
-	void CoreGpuObject::queueGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void()> func)
+	void CoreObject::queueGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void()> func)
 	{
 	{
 		// We call another internal method and go through an additional layer of abstraction in order to keep an active
 		// We call another internal method and go through an additional layer of abstraction in order to keep an active
 		// reference to the obj (saved in the bound function).
 		// reference to the obj (saved in the bound function).
 		// We could have called the function directly using "this" pointer but then we couldn't have used a shared_ptr for the object,
 		// We could have called the function directly using "this" pointer but then we couldn't have used a shared_ptr for the object,
 		// in which case there is a possibility that the object would be released and deleted while still being in the command queue.
 		// in which case there is a possibility that the object would be released and deleted while still being in the command queue.
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&CoreGpuObject::executeGpuCommand, obj, func));
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&CoreObject::executeGpuCommand, obj, func));
 	}
 	}
 
 
-	AsyncOp CoreGpuObject::queueReturnGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void(AsyncOp&)> func)
+	AsyncOp CoreObject::queueReturnGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void(AsyncOp&)> func)
 	{
 	{
 		// See queueGpuCommand
 		// See queueGpuCommand
-		return RenderSystem::instancePtr()->queueReturnCommand(boost::bind(&CoreGpuObject::executeReturnGpuCommand, obj, func, _1));
+		return RenderSystem::instancePtr()->queueReturnCommand(boost::bind(&CoreObject::executeReturnGpuCommand, obj, func, _1));
 	}
 	}
 
 
-	void CoreGpuObject::executeGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void()> func)
+	void CoreObject::executeGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void()> func)
 	{
 	{
-		volatile std::shared_ptr<CoreGpuObject> objParam = obj; // Makes sure obj isn't optimized out?
+		volatile std::shared_ptr<CoreObject> objParam = obj; // Makes sure obj isn't optimized out?
 
 
 		func();
 		func();
 	}
 	}
 
 
-	void CoreGpuObject::executeReturnGpuCommand(std::shared_ptr<CoreGpuObject>& obj, boost::function<void(AsyncOp&)> func, AsyncOp& op)
+	void CoreObject::executeReturnGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void(AsyncOp&)> func, AsyncOp& op)
 	{
 	{
-		volatile std::shared_ptr<CoreGpuObject> objParam = obj; // Makes sure obj isn't optimized out?
+		volatile std::shared_ptr<CoreObject> objParam = obj; // Makes sure obj isn't optimized out?
 
 
 		func(op);
 		func(op);
 	}
 	}

+ 4 - 4
CamelotCore/Source/CmCoreGpuObjectManager.cpp → CamelotCore/Source/CmCoreObjectManager.cpp

@@ -1,5 +1,5 @@
-#include "CmCoreGpuObjectManager.h"
-#include "CmCoreGpuObject.h"
+#include "CmCoreObjectManager.h"
+#include "CmCoreObject.h"
 #include "CmException.h"
 #include "CmException.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
@@ -25,7 +25,7 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
-	UINT64 CoreGpuObjectManager::registerObject(CoreGpuObject* object)
+	UINT64 CoreGpuObjectManager::registerObject(CoreObject* object)
 	{
 	{
 		assert(object != nullptr);
 		assert(object != nullptr);
 
 
@@ -36,7 +36,7 @@ namespace CamelotEngine
 		return mNextAvailableID++;
 		return mNextAvailableID++;
 	}
 	}
 
 
-	void CoreGpuObjectManager::unregisterObject(CoreGpuObject* object)
+	void CoreGpuObjectManager::unregisterObject(CoreObject* object)
 	{
 	{
 		assert(object != nullptr);
 		assert(object != nullptr);
 
 

+ 2 - 2
CamelotCore/Source/CmFontManager.cpp

@@ -5,7 +5,7 @@ namespace CamelotEngine
 {
 {
 	FontPtr FontManager::create(const FONT_DESC& fontDesc, vector<TexturePtr>::type texturePages) const
 	FontPtr FontManager::create(const FONT_DESC& fontDesc, vector<TexturePtr>::type texturePages) const
 	{
 	{
-		FontPtr newFont(new Font(), &CoreGpuObject::_deleteDelayed);
+		FontPtr newFont(new Font(), &CoreObject::_deleteDelayed);
 		newFont->setThisPtr(newFont);
 		newFont->setThisPtr(newFont);
 		newFont->initialize(fontDesc, texturePages);
 		newFont->initialize(fontDesc, texturePages);
 
 
@@ -14,7 +14,7 @@ namespace CamelotEngine
 
 
 	FontPtr FontManager::createEmpty() const
 	FontPtr FontManager::createEmpty() const
 	{
 	{
-		FontPtr newFont(new Font(), &CoreGpuObject::_deleteDelayed);
+		FontPtr newFont(new Font(), &CoreObject::_deleteDelayed);
 		newFont->setThisPtr(newFont);
 		newFont->setThisPtr(newFont);
 
 
 		return newFont;
 		return newFont;

+ 1 - 1
CamelotCore/Source/CmGpuBuffer.cpp

@@ -19,7 +19,7 @@ namespace CamelotEngine
 	{
 	{
 		clearBufferViews();
 		clearBufferViews();
 
 
-		CoreGpuObject::destroy_internal();
+		CoreObject::destroy_internal();
 	}
 	}
 
 
 	void GpuBuffer::clearBufferViews()
 	void GpuBuffer::clearBufferViews()

+ 3 - 3
CamelotCore/Source/CmGpuParamBlock.cpp

@@ -55,14 +55,14 @@ namespace CamelotEngine
 
 
 		mUsage = usage;
 		mUsage = usage;
 
 
-		CoreGpuObject::initialize();
+		CoreObject::initialize();
 	}
 	}
 
 
 	void GpuParamBlock::initialize_internal()
 	void GpuParamBlock::initialize_internal()
 	{
 	{
 		mBuffer = createBuffer();
 		mBuffer = createBuffer();
 
 
-		CoreGpuObject::initialize_internal();
+		CoreObject::initialize_internal();
 	}
 	}
 
 
 	void GpuParamBlock::destroy_internal()
 	void GpuParamBlock::destroy_internal()
@@ -70,7 +70,7 @@ namespace CamelotEngine
 		if(mBuffer != nullptr)
 		if(mBuffer != nullptr)
 			delete mBuffer;
 			delete mBuffer;
 
 
-		CoreGpuObject::destroy_internal();
+		CoreObject::destroy_internal();
 	}
 	}
 
 
 	GpuParamBlockBuffer* GpuParamBlock::createBuffer() const
 	GpuParamBlockBuffer* GpuParamBlock::createBuffer() const

+ 2 - 2
CamelotCore/Source/CmGpuProgInclude.cpp

@@ -3,14 +3,14 @@
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
 	GpuProgInclude::GpuProgInclude(const String& includeString)
 	GpuProgInclude::GpuProgInclude(const String& includeString)
-		:mString(includeString)
+		:Resource(false), mString(includeString)
 	{
 	{
 
 
 	}
 	}
 
 
 	GpuProgIncludeHandle GpuProgInclude::create(const String& includeString)
 	GpuProgIncludeHandle GpuProgInclude::create(const String& includeString)
 	{
 	{
-		GpuProgIncludePtr gpuProgIncludePtr = GpuProgIncludePtr(new GpuProgInclude(includeString), &CoreGpuObject::_deleteDelayed);
+		GpuProgIncludePtr gpuProgIncludePtr = GpuProgIncludePtr(new GpuProgInclude(includeString), &CoreObject::_deleteDelayed);
 		gpuProgIncludePtr->setThisPtr(gpuProgIncludePtr);
 		gpuProgIncludePtr->setThisPtr(gpuProgIncludePtr);
 		gpuProgIncludePtr->initialize();
 		gpuProgIncludePtr->initialize();
 
 

+ 0 - 1
CamelotCore/Source/CmGpuProgIncludeImporter.cpp

@@ -35,7 +35,6 @@ namespace CamelotEngine
 		String includeString = stream->getAsString();
 		String includeString = stream->getAsString();
 
 
 		GpuProgIncludeHandle gpuProgInclude = GpuProgInclude::create(includeString);
 		GpuProgIncludeHandle gpuProgInclude = GpuProgInclude::create(includeString);
-		gpuProgInclude.waitUntilLoaded();
 
 
 		return gpuProgInclude;
 		return gpuProgInclude;
 	}
 	}

+ 1 - 1
CamelotCore/Source/CmGpuProgramManager.cpp

@@ -43,7 +43,7 @@ namespace CamelotEngine {
     //---------------------------------------------------------------------------
     //---------------------------------------------------------------------------
 	GpuProgramPtr GpuProgramManager::createProgram(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile)
 	GpuProgramPtr GpuProgramManager::createProgram(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile)
     {
     {
-		GpuProgramPtr prg = GpuProgramPtr(create(source, entryPoint, language, gptype, profile), &CoreGpuObject::_deleteDelayed);
+		GpuProgramPtr prg = GpuProgramPtr(create(source, entryPoint, language, gptype, profile), &CoreObject::_deleteDelayed);
 		prg->setThisPtr(prg);
 		prg->setThisPtr(prg);
 
 
 		// TODO: Gpu programs get initialized by their parent HighLevelGpuProgram. I might handle that more intuitively later but
 		// TODO: Gpu programs get initialized by their parent HighLevelGpuProgram. I might handle that more intuitively later but

+ 5 - 5
CamelotCore/Source/CmHardwareBufferManager.cpp

@@ -44,7 +44,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     VertexDeclarationPtr HardwareBufferManager::createVertexDeclaration(void)
     VertexDeclarationPtr HardwareBufferManager::createVertexDeclaration(void)
     {
     {
-        VertexDeclarationPtr decl = VertexDeclarationPtr(createVertexDeclarationImpl(), &CoreGpuObject::_deleteDelayed);
+        VertexDeclarationPtr decl = VertexDeclarationPtr(createVertexDeclarationImpl(), &CoreObject::_deleteDelayed);
 		decl->setThisPtr(decl);
 		decl->setThisPtr(decl);
 		decl->initialize();
 		decl->initialize();
         return decl;
         return decl;
@@ -54,7 +54,7 @@ namespace CamelotEngine {
 	{
 	{
 		assert (numVerts > 0);
 		assert (numVerts > 0);
 
 
-		VertexBufferPtr vbuf = VertexBufferPtr(createVertexBufferImpl(vertexSize, numVerts, usage, streamOut), &CoreGpuObject::_deleteDelayed);
+		VertexBufferPtr vbuf = VertexBufferPtr(createVertexBufferImpl(vertexSize, numVerts, usage, streamOut), &CoreObject::_deleteDelayed);
 		vbuf->setThisPtr(vbuf);
 		vbuf->setThisPtr(vbuf);
 		vbuf->initialize();
 		vbuf->initialize();
 		return vbuf;
 		return vbuf;
@@ -64,7 +64,7 @@ namespace CamelotEngine {
 	{
 	{
 		assert (numIndexes > 0);
 		assert (numIndexes > 0);
 
 
-		IndexBufferPtr ibuf = IndexBufferPtr(createIndexBufferImpl(itype, numIndexes, usage), &CoreGpuObject::_deleteDelayed);
+		IndexBufferPtr ibuf = IndexBufferPtr(createIndexBufferImpl(itype, numIndexes, usage), &CoreObject::_deleteDelayed);
 		ibuf->setThisPtr(ibuf);
 		ibuf->setThisPtr(ibuf);
 		ibuf->initialize();
 		ibuf->initialize();
 		return ibuf;
 		return ibuf;
@@ -73,7 +73,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	GpuParamBlockPtr HardwareBufferManager::createGpuParamBlock(const GpuParamBlockDesc& paramDesc, GpuParamBlockUsage usage)
 	GpuParamBlockPtr HardwareBufferManager::createGpuParamBlock(const GpuParamBlockDesc& paramDesc, GpuParamBlockUsage usage)
 	{
 	{
-		GpuParamBlockPtr paramBlockPtr(createGpuParamBlockImpl(), &CoreGpuObject::_deleteDelayed);
+		GpuParamBlockPtr paramBlockPtr(createGpuParamBlockImpl(), &CoreObject::_deleteDelayed);
 		paramBlockPtr->setThisPtr(paramBlockPtr);
 		paramBlockPtr->setThisPtr(paramBlockPtr);
 		paramBlockPtr->initialize(paramDesc, usage);
 		paramBlockPtr->initialize(paramDesc, usage);
 
 
@@ -84,7 +84,7 @@ namespace CamelotEngine {
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 	{
 	{
 		GpuBufferPtr gbuf = GpuBufferPtr(createGpuBufferImpl(elementCount, elementSize, type, 
 		GpuBufferPtr gbuf = GpuBufferPtr(createGpuBufferImpl(elementCount, elementSize, type, 
-			usage, randomGpuWrite, useCounter), &CoreGpuObject::_deleteDelayed);
+			usage, randomGpuWrite, useCounter), &CoreObject::_deleteDelayed);
 		gbuf->setThisPtr(gbuf);
 		gbuf->setThisPtr(gbuf);
 		gbuf->initialize();
 		gbuf->initialize();
 		return gbuf;
 		return gbuf;

+ 3 - 3
CamelotCore/Source/CmHighLevelGpuProgramManager.cpp

@@ -146,7 +146,7 @@ namespace CamelotEngine {
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<GpuProgIncludeHandle>::type* includes)
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<GpuProgIncludeHandle>::type* includes)
     {
     {
 		HighLevelGpuProgramFactory* factory = getFactory(language);
 		HighLevelGpuProgramFactory* factory = getFactory(language);
-        HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(source, entryPoint, gptype, profile, includes), &CoreGpuObject::_deleteDelayed);
+        HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(source, entryPoint, gptype, profile, includes), &CoreObject::_deleteDelayed);
 		ret->setThisPtr(ret);
 		ret->setThisPtr(ret);
 		ret->initialize();
 		ret->initialize();
 
 
@@ -156,7 +156,7 @@ namespace CamelotEngine {
 	HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& language)
 	HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& language)
 	{
 	{
 		HighLevelGpuProgramFactory* factory = getFactory(language);
 		HighLevelGpuProgramFactory* factory = getFactory(language);
-		HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(), &CoreGpuObject::_deleteDelayed);
+		HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(), &CoreObject::_deleteDelayed);
 		ret->setThisPtr(ret);
 		ret->setThisPtr(ret);
 		ret->initialize();
 		ret->initialize();
 
 
@@ -166,7 +166,7 @@ namespace CamelotEngine {
 	HighLevelGpuProgramPtr HighLevelGpuProgramManager::createEmpty(const String& language)
 	HighLevelGpuProgramPtr HighLevelGpuProgramManager::createEmpty(const String& language)
 	{
 	{
 		HighLevelGpuProgramFactory* factory = getFactory(language);
 		HighLevelGpuProgramFactory* factory = getFactory(language);
-		HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(), &CoreGpuObject::_deleteDelayed);
+		HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(), &CoreObject::_deleteDelayed);
 		ret->setThisPtr(ret);
 		ret->setThisPtr(ret);
 
 
 		return ret;
 		return ret;

+ 1 - 0
CamelotCore/Source/CmMaterial.cpp

@@ -15,6 +15,7 @@
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
 	Material::Material()
 	Material::Material()
+		:Resource(false)
 	{
 	{
 
 
 	}
 	}

+ 1 - 1
CamelotCore/Source/CmMeshManager.cpp

@@ -36,7 +36,7 @@ namespace CamelotEngine
 
 
 	MeshPtr MeshManager::create()
 	MeshPtr MeshManager::create()
 	{
 	{
-		MeshPtr mesh = MeshPtr(new Mesh(), &CoreGpuObject::_deleteDelayed);
+		MeshPtr mesh = MeshPtr(new Mesh(), &CoreObject::_deleteDelayed);
 		mesh->setThisPtr(mesh);
 		mesh->setThisPtr(mesh);
 		mesh->initialize();
 		mesh->initialize();
 
 

+ 8 - 8
CamelotCore/Source/CmRenderStateManager.cpp

@@ -8,7 +8,7 @@ namespace CamelotEngine
 {
 {
 	SamplerStatePtr RenderStateManager::createSamplerState(const SAMPLER_STATE_DESC& desc) const
 	SamplerStatePtr RenderStateManager::createSamplerState(const SAMPLER_STATE_DESC& desc) const
 	{
 	{
-		SamplerStatePtr samplerState = SamplerStatePtr(createSamplerStateImpl(), &CoreGpuObject::_deleteDelayed);
+		SamplerStatePtr samplerState = SamplerStatePtr(createSamplerStateImpl(), &CoreObject::_deleteDelayed);
 		samplerState->setThisPtr(samplerState);
 		samplerState->setThisPtr(samplerState);
 		samplerState->initialize(desc);
 		samplerState->initialize(desc);
 
 
@@ -17,7 +17,7 @@ namespace CamelotEngine
 
 
 	DepthStencilStatePtr RenderStateManager::createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const
 	DepthStencilStatePtr RenderStateManager::createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const
 	{
 	{
-		DepthStencilStatePtr depthStencilState = DepthStencilStatePtr(createDepthStencilStateImpl(), &CoreGpuObject::_deleteDelayed);
+		DepthStencilStatePtr depthStencilState = DepthStencilStatePtr(createDepthStencilStateImpl(), &CoreObject::_deleteDelayed);
 		depthStencilState->setThisPtr(depthStencilState);
 		depthStencilState->setThisPtr(depthStencilState);
 		depthStencilState->initialize(desc);
 		depthStencilState->initialize(desc);
 
 
@@ -26,7 +26,7 @@ namespace CamelotEngine
 
 
 	RasterizerStatePtr RenderStateManager::createRasterizerState(const RASTERIZER_STATE_DESC& desc) const
 	RasterizerStatePtr RenderStateManager::createRasterizerState(const RASTERIZER_STATE_DESC& desc) const
 	{
 	{
-		RasterizerStatePtr rasterizerState = RasterizerStatePtr(createRasterizerStateImpl(), &CoreGpuObject::_deleteDelayed);
+		RasterizerStatePtr rasterizerState = RasterizerStatePtr(createRasterizerStateImpl(), &CoreObject::_deleteDelayed);
 		rasterizerState->setThisPtr(rasterizerState);
 		rasterizerState->setThisPtr(rasterizerState);
 		rasterizerState->initialize(desc);
 		rasterizerState->initialize(desc);
 
 
@@ -35,7 +35,7 @@ namespace CamelotEngine
 
 
 	BlendStatePtr RenderStateManager::createBlendState(const BLEND_STATE_DESC& desc) const
 	BlendStatePtr RenderStateManager::createBlendState(const BLEND_STATE_DESC& desc) const
 	{
 	{
-		BlendStatePtr blendState = BlendStatePtr(createBlendStateImpl(), &CoreGpuObject::_deleteDelayed);
+		BlendStatePtr blendState = BlendStatePtr(createBlendStateImpl(), &CoreObject::_deleteDelayed);
 		blendState->setThisPtr(blendState);
 		blendState->setThisPtr(blendState);
 		blendState->initialize(desc);
 		blendState->initialize(desc);
 
 
@@ -44,7 +44,7 @@ namespace CamelotEngine
 
 
 	SamplerStatePtr RenderStateManager::createEmptySamplerState() const
 	SamplerStatePtr RenderStateManager::createEmptySamplerState() const
 	{
 	{
-		SamplerStatePtr samplerState = SamplerStatePtr(createSamplerStateImpl(), &CoreGpuObject::_deleteDelayed);
+		SamplerStatePtr samplerState = SamplerStatePtr(createSamplerStateImpl(), &CoreObject::_deleteDelayed);
 		samplerState->setThisPtr(samplerState);
 		samplerState->setThisPtr(samplerState);
 
 
 		return samplerState;
 		return samplerState;
@@ -52,7 +52,7 @@ namespace CamelotEngine
 
 
 	DepthStencilStatePtr RenderStateManager::createEmptyDepthStencilState() const
 	DepthStencilStatePtr RenderStateManager::createEmptyDepthStencilState() const
 	{
 	{
-		DepthStencilStatePtr depthStencilState = DepthStencilStatePtr(createDepthStencilStateImpl(), &CoreGpuObject::_deleteDelayed);
+		DepthStencilStatePtr depthStencilState = DepthStencilStatePtr(createDepthStencilStateImpl(), &CoreObject::_deleteDelayed);
 		depthStencilState->setThisPtr(depthStencilState);
 		depthStencilState->setThisPtr(depthStencilState);
 
 
 		return depthStencilState;
 		return depthStencilState;
@@ -60,7 +60,7 @@ namespace CamelotEngine
 
 
 	RasterizerStatePtr RenderStateManager::createEmptyRasterizerState() const
 	RasterizerStatePtr RenderStateManager::createEmptyRasterizerState() const
 	{
 	{
-		RasterizerStatePtr rasterizerState = RasterizerStatePtr(createRasterizerStateImpl(), &CoreGpuObject::_deleteDelayed);
+		RasterizerStatePtr rasterizerState = RasterizerStatePtr(createRasterizerStateImpl(), &CoreObject::_deleteDelayed);
 		rasterizerState->setThisPtr(rasterizerState);
 		rasterizerState->setThisPtr(rasterizerState);
 
 
 		return rasterizerState;
 		return rasterizerState;
@@ -68,7 +68,7 @@ namespace CamelotEngine
 
 
 	BlendStatePtr RenderStateManager::createEmptyBlendState() const
 	BlendStatePtr RenderStateManager::createEmptyBlendState() const
 	{
 	{
-		BlendStatePtr blendState = BlendStatePtr(createBlendStateImpl(), &CoreGpuObject::_deleteDelayed);
+		BlendStatePtr blendState = BlendStatePtr(createBlendStateImpl(), &CoreObject::_deleteDelayed);
 		blendState->setThisPtr(blendState);
 		blendState->setThisPtr(blendState);
 
 
 		return blendState;
 		return blendState;

+ 1 - 1
CamelotCore/Source/CmRenderWindowManager.cpp

@@ -4,7 +4,7 @@ namespace CamelotEngine
 {
 {
 	RenderWindowPtr RenderWindowManager::create(const RENDER_WINDOW_DESC& desc)
 	RenderWindowPtr RenderWindowManager::create(const RENDER_WINDOW_DESC& desc)
 	{
 	{
-		RenderWindowPtr renderWindow(createImpl(desc), &CoreGpuObject::_deleteDelayed);
+		RenderWindowPtr renderWindow(createImpl(desc), &CoreObject::_deleteDelayed);
 		renderWindow->setThisPtr(renderWindow);
 		renderWindow->setThisPtr(renderWindow);
 		renderWindow->initialize();
 		renderWindow->initialize();
 
 

+ 2 - 2
CamelotCore/Source/CmResource.cpp

@@ -5,8 +5,8 @@
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	Resource::Resource()
-		:mSize(0)
+	Resource::Resource(bool requiresGpuInitialization)
+		:CoreObject(requiresGpuInitialization), mSize(0)
 	{
 	{
 		// We always generate a random UUID, and then overwrite it with the actual one 
 		// We always generate a random UUID, and then overwrite it with the actual one 
 		// during loading if one was previously generated and saved.
 		// during loading if one was previously generated and saved.

+ 1 - 1
CamelotCore/Source/CmShader.cpp

@@ -206,7 +206,7 @@ namespace CamelotEngine
 
 
 	ShaderPtr Shader::create(const String& name)
 	ShaderPtr Shader::create(const String& name)
 	{
 	{
-		ShaderPtr newShader(new Shader(name), &CoreGpuObject::_deleteDelayed);
+		ShaderPtr newShader(new Shader(name), &CoreObject::_deleteDelayed);
 		newShader->setThisPtr(newShader);
 		newShader->setThisPtr(newShader);
 		newShader->initialize();
 		newShader->initialize();
 
 

+ 1 - 1
CamelotCore/Source/CmTexture.cpp

@@ -218,7 +218,7 @@ namespace CamelotEngine {
 
 
 	TextureViewPtr Texture::createView()
 	TextureViewPtr Texture::createView()
 	{
 	{
-		TextureViewPtr viewPtr(new TextureView(), &CoreGpuObject::_deleteDelayed);
+		TextureViewPtr viewPtr(new TextureView(), &CoreObject::_deleteDelayed);
 		viewPtr->setThisPtr(viewPtr);
 		viewPtr->setThisPtr(viewPtr);
 
 
 		return viewPtr;
 		return viewPtr;

+ 4 - 4
CamelotCore/Source/CmTextureManager.cpp

@@ -47,7 +47,7 @@ namespace CamelotEngine {
         PixelFormat format, int usage, bool hwGamma, 
         PixelFormat format, int usage, bool hwGamma, 
 		UINT32 fsaa, const String& fsaaHint)
 		UINT32 fsaa, const String& fsaaHint)
     {
     {
-        TexturePtr ret = TexturePtr(createTextureImpl(), &CoreGpuObject::_deleteDelayed);
+        TexturePtr ret = TexturePtr(createTextureImpl(), &CoreObject::_deleteDelayed);
 		ret->setThisPtr(ret);
 		ret->setThisPtr(ret);
 		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma, fsaa, fsaaHint);
 		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma, fsaa, fsaaHint);
 
 
@@ -56,7 +56,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	TexturePtr TextureManager::createEmpty()
 	TexturePtr TextureManager::createEmpty()
 	{
 	{
-		TexturePtr texture = TexturePtr(createTextureImpl(), &CoreGpuObject::_deleteDelayed);
+		TexturePtr texture = TexturePtr(createTextureImpl(), &CoreObject::_deleteDelayed);
 		texture->setThisPtr(texture);
 		texture->setThisPtr(texture);
 
 
 		return texture;
 		return texture;
@@ -92,7 +92,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	RenderTexturePtr TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC& desc)
 	RenderTexturePtr TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC& desc)
 	{
 	{
-		RenderTexturePtr newRT = RenderTexturePtr(createRenderTextureImpl(), &CoreGpuObject::_deleteDelayed);
+		RenderTexturePtr newRT = RenderTexturePtr(createRenderTextureImpl(), &CoreObject::_deleteDelayed);
 		newRT->setThisPtr(newRT);
 		newRT->setThisPtr(newRT);
 		newRT->initialize(desc);
 		newRT->initialize(desc);
 
 
@@ -101,7 +101,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	MultiRenderTexturePtr TextureManager::createEmptyMultiRenderTexture()
 	MultiRenderTexturePtr TextureManager::createEmptyMultiRenderTexture()
 	{
 	{
-		MultiRenderTexturePtr newRT = MultiRenderTexturePtr(createMultiRenderTextureImpl(), &CoreGpuObject::_deleteDelayed);
+		MultiRenderTexturePtr newRT = MultiRenderTexturePtr(createMultiRenderTextureImpl(), &CoreObject::_deleteDelayed);
 		newRT->setThisPtr(newRT);
 		newRT->setThisPtr(newRT);
 
 
 		return newRT;
 		return newRT;

+ 1 - 1
CamelotCore/Source/CmTextureView.cpp

@@ -34,6 +34,6 @@ namespace CamelotEngine
 		mOwnerTexture = texture;
 		mOwnerTexture = texture;
 		mDesc = _desc;
 		mDesc = _desc;
 
 
-		CoreGpuObject::initialize();
+		CoreObject::initialize();
 	}
 	}
 }
 }

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -590,7 +590,7 @@ namespace CamelotEngine
 
 
 	TextureViewPtr D3D11Texture::createView()
 	TextureViewPtr D3D11Texture::createView()
 	{
 	{
-		TextureViewPtr viewPtr(new D3D11TextureView(), &CoreGpuObject::_deleteDelayed);
+		TextureViewPtr viewPtr(new D3D11TextureView(), &CoreObject::_deleteDelayed);
 		viewPtr->setThisPtr(viewPtr);
 		viewPtr->setThisPtr(viewPtr);
 
 
 		return viewPtr;
 		return viewPtr;