Prechádzať zdrojové kódy

Render queue automatically detects if its being called from render thread an executes immediately
(No more need for internalCall parameters when creating resources)

Marko Pintera 13 rokov pred
rodič
commit
f53903ed37
33 zmenil súbory, kde vykonal 122 pridanie a 225 odobranie
  1. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11BlendState.h
  2. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11DepthStencilState.h
  3. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11RasterizerState.h
  4. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11SamplerState.h
  5. 13 11
      CamelotD3D11RenderSystem/Source/CmD3D11BlendState.cpp
  6. 17 15
      CamelotD3D11RenderSystem/Source/CmD3D11DepthStencilState.cpp
  7. 12 10
      CamelotD3D11RenderSystem/Source/CmD3D11RasterizerState.cpp
  8. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp
  9. 20 18
      CamelotD3D11RenderSystem/Source/CmD3D11SamplerState.cpp
  10. 0 2
      CamelotRenderer/CamelotRenderer.vcxproj
  11. 0 6
      CamelotRenderer/CamelotRenderer.vcxproj.filters
  12. 3 3
      CamelotRenderer/Include/CmBlendState.h
  13. 3 3
      CamelotRenderer/Include/CmDepthStencilState.h
  14. 2 5
      CamelotRenderer/Include/CmGpuProgram.h
  15. 2 6
      CamelotRenderer/Include/CmHighLevelGpuProgramManager.h
  16. 1 1
      CamelotRenderer/Include/CmRasterizerState.h
  17. 0 29
      CamelotRenderer/Include/CmRasterizerStateImporter.h
  18. 2 3
      CamelotRenderer/Include/CmResource.h
  19. 3 3
      CamelotRenderer/Include/CmSamplerState.h
  20. 3 6
      CamelotRenderer/Include/CmTexture.h
  21. 3 7
      CamelotRenderer/Include/CmTextureManager.h
  22. 3 0
      CamelotRenderer/Source/CmBlendState.cpp
  23. 1 1
      CamelotRenderer/Source/CmCgProgram.cpp
  24. 3 0
      CamelotRenderer/Source/CmDepthStencilState.cpp
  25. 2 5
      CamelotRenderer/Source/CmGpuProgram.cpp
  26. 4 4
      CamelotRenderer/Source/CmHighLevelGpuProgramManager.cpp
  27. 1 2
      CamelotRenderer/Source/CmImporter.cpp
  28. 0 61
      CamelotRenderer/Source/CmRasterizerStateImporter.cpp
  29. 10 7
      CamelotRenderer/Source/CmRenderSystem.cpp
  30. 2 5
      CamelotRenderer/Source/CmResource.cpp
  31. 3 0
      CamelotRenderer/Source/CmSamplerState.cpp
  32. 2 5
      CamelotRenderer/Source/CmTexture.cpp
  33. 2 2
      CamelotRenderer/Source/CmTextureManager.cpp

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11BlendState.h

@@ -17,7 +17,7 @@ namespace CamelotEngine
 
 		D3D11BlendState();
 
-		void initialize(const BLEND_STATE_DESC& desc);
+		void initialize_internal();
 
 		ID3D11BlendState* mBlendState;
 	};

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11DepthStencilState.h

@@ -17,7 +17,7 @@ namespace CamelotEngine
 
 		D3D11DepthStencilState();
 
-		void initialize(const DEPTH_STENCIL_STATE_DESC& desc);
+		void initialize_internal();
 
 		ID3D11DepthStencilState* mDepthStencilState;
 	};

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11RasterizerState.h

@@ -16,7 +16,7 @@ namespace CamelotEngine
 
 		D3D11RasterizerState();
 
-		void initialize(const RASTERIZER_STATE_DESC& desc);
+		void initialize_internal();
 
 		ID3D11RasterizerState* mRasterizerState;
 	};

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11SamplerState.h

@@ -16,7 +16,7 @@ namespace CamelotEngine
 
 		D3D11SamplerState();
 
-		void initialize(const SAMPLER_STATE_DESC& desc);
+		void initialize_internal();
 
 		ID3D11SamplerState* mSamplerState;
 	};

+ 13 - 11
CamelotD3D11RenderSystem/Source/CmD3D11BlendState.cpp

@@ -14,24 +14,24 @@ namespace CamelotEngine
 		SAFE_RELEASE(mBlendState);
 	}
 
-	void D3D11BlendState::initialize(const BLEND_STATE_DESC& desc)
+	void D3D11BlendState::initialize_internal()
 	{
 		D3D11_BLEND_DESC blendStateDesc;
 		ZeroMemory(&blendStateDesc, sizeof(D3D11_BLEND_DESC));
 
-		blendStateDesc.AlphaToCoverageEnable = desc.alphaToCoverageEnable;
-		blendStateDesc.IndependentBlendEnable = desc.independantBlendEnable;
+		blendStateDesc.AlphaToCoverageEnable = mData.alphaToCoverageEnable;
+		blendStateDesc.IndependentBlendEnable = mData.independantBlendEnable;
 		
 		for(UINT32 i = 0; i < CM_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		{
-			blendStateDesc.RenderTarget[i].BlendEnable = desc.renderTargetDesc[i].blendEnable;
-			blendStateDesc.RenderTarget[i].BlendOp = D3D11Mappings::get(desc.renderTargetDesc[i].blendOp);
-			blendStateDesc.RenderTarget[i].BlendOpAlpha = D3D11Mappings::get(desc.renderTargetDesc[i].blendOpAlpha);
-			blendStateDesc.RenderTarget[i].DestBlend = D3D11Mappings::get(desc.renderTargetDesc[i].dstBlend);
-			blendStateDesc.RenderTarget[i].DestBlendAlpha = D3D11Mappings::get(desc.renderTargetDesc[i].dstBlendAlpha);
-			blendStateDesc.RenderTarget[i].RenderTargetWriteMask = 0xf & desc.renderTargetDesc[i].renderTargetWriteMask; // Mask out all but last 4 bits
-			blendStateDesc.RenderTarget[i].SrcBlend = D3D11Mappings::get(desc.renderTargetDesc[i].srcBlend);
-			blendStateDesc.RenderTarget[i].SrcBlendAlpha = D3D11Mappings::get(desc.renderTargetDesc[i].srcBlendAlpha);
+			blendStateDesc.RenderTarget[i].BlendEnable = mData.renderTargetDesc[i].blendEnable;
+			blendStateDesc.RenderTarget[i].BlendOp = D3D11Mappings::get(mData.renderTargetDesc[i].blendOp);
+			blendStateDesc.RenderTarget[i].BlendOpAlpha = D3D11Mappings::get(mData.renderTargetDesc[i].blendOpAlpha);
+			blendStateDesc.RenderTarget[i].DestBlend = D3D11Mappings::get(mData.renderTargetDesc[i].dstBlend);
+			blendStateDesc.RenderTarget[i].DestBlendAlpha = D3D11Mappings::get(mData.renderTargetDesc[i].dstBlendAlpha);
+			blendStateDesc.RenderTarget[i].RenderTargetWriteMask = 0xf & mData.renderTargetDesc[i].renderTargetWriteMask; // Mask out all but last 4 bits
+			blendStateDesc.RenderTarget[i].SrcBlend = D3D11Mappings::get(mData.renderTargetDesc[i].srcBlend);
+			blendStateDesc.RenderTarget[i].SrcBlendAlpha = D3D11Mappings::get(mData.renderTargetDesc[i].srcBlendAlpha);
 		}
 
 		D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
@@ -43,5 +43,7 @@ namespace CamelotEngine
 			String errorDescription = device.getErrorDescription();
 			CM_EXCEPT(RenderingAPIException, "Cannot create blend state.\nError Description:" + errorDescription);
 		}
+
+		BlendState::initialize_internal();
 	}
 }

+ 17 - 15
CamelotD3D11RenderSystem/Source/CmD3D11DepthStencilState.cpp

@@ -14,25 +14,25 @@ namespace CamelotEngine
 		SAFE_RELEASE(mDepthStencilState);
 	}
 
-	void D3D11DepthStencilState::initialize(const DEPTH_STENCIL_STATE_DESC& desc)
+	void D3D11DepthStencilState::initialize_internal()
 	{
 		D3D11_DEPTH_STENCIL_DESC depthStencilState;
 		ZeroMemory(&depthStencilState, sizeof(D3D11_DEPTH_STENCIL_DESC));
 
-		depthStencilState.BackFace.StencilPassOp = D3D11Mappings::get(desc.backStencilPassOp);
-		depthStencilState.BackFace.StencilFailOp = D3D11Mappings::get(desc.backStencilFailOp);
-		depthStencilState.BackFace.StencilDepthFailOp = D3D11Mappings::get(desc.backStencilZFailOp);
-		depthStencilState.BackFace.StencilFunc = D3D11Mappings::get(desc.backStencilComparisonFunc);
-		depthStencilState.FrontFace.StencilPassOp = D3D11Mappings::get(desc.frontStencilPassOp);
-		depthStencilState.FrontFace.StencilFailOp = D3D11Mappings::get(desc.frontStencilFailOp);
-		depthStencilState.FrontFace.StencilDepthFailOp = D3D11Mappings::get(desc.frontStencilZFailOp);
-		depthStencilState.FrontFace.StencilFunc = D3D11Mappings::get(desc.frontStencilComparisonFunc);
-		depthStencilState.DepthEnable = desc.depthReadEnable;
-		depthStencilState.DepthWriteMask = desc.depthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
-		depthStencilState.DepthFunc = D3D11Mappings::get(desc.depthComparisonFunc);
-		depthStencilState.StencilEnable = desc.stencilEnable;
-		depthStencilState.StencilReadMask = desc.stencilReadMask;
-		depthStencilState.StencilWriteMask = desc.stencilWriteMask;
+		depthStencilState.BackFace.StencilPassOp = D3D11Mappings::get(mData.backStencilPassOp);
+		depthStencilState.BackFace.StencilFailOp = D3D11Mappings::get(mData.backStencilFailOp);
+		depthStencilState.BackFace.StencilDepthFailOp = D3D11Mappings::get(mData.backStencilZFailOp);
+		depthStencilState.BackFace.StencilFunc = D3D11Mappings::get(mData.backStencilComparisonFunc);
+		depthStencilState.FrontFace.StencilPassOp = D3D11Mappings::get(mData.frontStencilPassOp);
+		depthStencilState.FrontFace.StencilFailOp = D3D11Mappings::get(mData.frontStencilFailOp);
+		depthStencilState.FrontFace.StencilDepthFailOp = D3D11Mappings::get(mData.frontStencilZFailOp);
+		depthStencilState.FrontFace.StencilFunc = D3D11Mappings::get(mData.frontStencilComparisonFunc);
+		depthStencilState.DepthEnable = mData.depthReadEnable;
+		depthStencilState.DepthWriteMask = mData.depthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
+		depthStencilState.DepthFunc = D3D11Mappings::get(mData.depthComparisonFunc);
+		depthStencilState.StencilEnable = mData.stencilEnable;
+		depthStencilState.StencilReadMask = mData.stencilReadMask;
+		depthStencilState.StencilWriteMask = mData.stencilWriteMask;
 
 		D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
 		D3D11Device& device = rs->getPrimaryDevice();
@@ -43,5 +43,7 @@ namespace CamelotEngine
 			String errorDescription = device.getErrorDescription();
 			CM_EXCEPT(RenderingAPIException, "Cannot create depth stencil state.\nError Description:" + errorDescription);
 		}
+
+		DepthStencilState::initialize_internal();
 	}
 }

+ 12 - 10
CamelotD3D11RenderSystem/Source/CmD3D11RasterizerState.cpp

@@ -14,20 +14,20 @@ namespace CamelotEngine
 		SAFE_RELEASE(mRasterizerState);
 	}
 
-	void D3D11RasterizerState::initialize(const RASTERIZER_STATE_DESC& desc)
+	void D3D11RasterizerState::initialize_internal()
 	{
 		D3D11_RASTERIZER_DESC rasterizerStateDesc;
 		ZeroMemory(&rasterizerStateDesc, sizeof(D3D11_RASTERIZER_DESC));
 
-		rasterizerStateDesc.AntialiasedLineEnable = desc.antialiasedLineEnable;
-		rasterizerStateDesc.CullMode = D3D11Mappings::get(desc.cullMode);
-		rasterizerStateDesc.DepthBias = desc.depthBias;
-		rasterizerStateDesc.DepthBiasClamp = desc.depthBiasClamp;
-		rasterizerStateDesc.DepthClipEnable = desc.depthClipEnable;
-		rasterizerStateDesc.FillMode = D3D11Mappings::get(desc.polygonMode);
-		rasterizerStateDesc.MultisampleEnable = desc.multisampleEnable;
-		rasterizerStateDesc.ScissorEnable = desc.scissorEnable;
-		rasterizerStateDesc.SlopeScaledDepthBias = desc.slopeScaledDepthBias;
+		rasterizerStateDesc.AntialiasedLineEnable = mData.antialiasedLineEnable;
+		rasterizerStateDesc.CullMode = D3D11Mappings::get(mData.cullMode);
+		rasterizerStateDesc.DepthBias = mData.depthBias;
+		rasterizerStateDesc.DepthBiasClamp = mData.depthBiasClamp;
+		rasterizerStateDesc.DepthClipEnable = mData.depthClipEnable;
+		rasterizerStateDesc.FillMode = D3D11Mappings::get(mData.polygonMode);
+		rasterizerStateDesc.MultisampleEnable = mData.multisampleEnable;
+		rasterizerStateDesc.ScissorEnable = mData.scissorEnable;
+		rasterizerStateDesc.SlopeScaledDepthBias = mData.slopeScaledDepthBias;
 
 		D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
 		D3D11Device& device = rs->getPrimaryDevice();
@@ -38,5 +38,7 @@ namespace CamelotEngine
 			String errorDescription = device.getErrorDescription();
 			CM_EXCEPT(RenderingAPIException, "Cannot create rasterizer state.\nError Description:" + errorDescription);
 		}
+
+		RasterizerState::initialize_internal();
 	}
 }

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp

@@ -521,7 +521,7 @@ namespace CamelotEngine
 		}
 
 		mDepthStencilBuffer = TextureManager::instance().createTexture(TEX_TYPE_2D, 
-			BBDesc.Width, BBDesc.Height, 0, PF_D24S8, TU_DEPTHSTENCIL, false, mFSAA, mFSAAHint, true);
+			BBDesc.Width, BBDesc.Height, 0, PF_D24S8, TU_DEPTHSTENCIL, false, mFSAA, mFSAAHint);
 
 		if(mDepthStencilView != nullptr)
 		{

+ 20 - 18
CamelotD3D11RenderSystem/Source/CmD3D11SamplerState.cpp

@@ -14,31 +14,31 @@ namespace CamelotEngine
 		SAFE_RELEASE(mSamplerState);
 	}
 
-	void D3D11SamplerState::initialize(const SAMPLER_STATE_DESC& desc)
+	void D3D11SamplerState::initialize_internal()
 	{
 		D3D11_SAMPLER_DESC samplerState;
 		ZeroMemory(&samplerState, sizeof(D3D11_SAMPLER_DESC));
 
-		samplerState.AddressU = D3D11Mappings::get(desc.addressMode.u);
-		samplerState.AddressV = D3D11Mappings::get(desc.addressMode.v);
-		samplerState.AddressW = D3D11Mappings::get(desc.addressMode.w);
-		samplerState.BorderColor[0] = desc.borderColor[0];
-		samplerState.BorderColor[1] = desc.borderColor[1];
-		samplerState.BorderColor[2] = desc.borderColor[2];
-		samplerState.BorderColor[3] = desc.borderColor[3];
-		samplerState.ComparisonFunc = D3D11Mappings::get(desc.comparisonFunc);
-		samplerState.MaxAnisotropy = desc.maxAniso;
-		samplerState.MaxLOD = desc.mipMax;
-		samplerState.MinLOD = desc.mipMin;
-		samplerState.MipLODBias =desc.mipmapBias;
+		samplerState.AddressU = D3D11Mappings::get(mData.addressMode.u);
+		samplerState.AddressV = D3D11Mappings::get(mData.addressMode.v);
+		samplerState.AddressW = D3D11Mappings::get(mData.addressMode.w);
+		samplerState.BorderColor[0] = mData.borderColor[0];
+		samplerState.BorderColor[1] = mData.borderColor[1];
+		samplerState.BorderColor[2] = mData.borderColor[2];
+		samplerState.BorderColor[3] = mData.borderColor[3];
+		samplerState.ComparisonFunc = D3D11Mappings::get(mData.comparisonFunc);
+		samplerState.MaxAnisotropy = mData.maxAniso;
+		samplerState.MaxLOD = mData.mipMax;
+		samplerState.MinLOD = mData.mipMin;
+		samplerState.MipLODBias =mData.mipmapBias;
 
-		bool isComparison = ((desc.minFilter & FO_USE_COMPARISON) & (desc.magFilter & FO_USE_COMPARISON) & (desc.mipFilter & FO_USE_COMPARISON)) != 0;
+		bool isComparison = ((mData.minFilter & FO_USE_COMPARISON) & (mData.magFilter & FO_USE_COMPARISON) & (mData.mipFilter & FO_USE_COMPARISON)) != 0;
 
-		FilterOptions minFilter = (FilterOptions)(desc.minFilter & ~FO_USE_COMPARISON);
-		FilterOptions magFilter = (FilterOptions)(desc.magFilter & ~FO_USE_COMPARISON);
-		FilterOptions mipFilter = (FilterOptions)(desc.mipFilter & ~FO_USE_COMPARISON);
+		FilterOptions minFilter = (FilterOptions)(mData.minFilter & ~FO_USE_COMPARISON);
+		FilterOptions magFilter = (FilterOptions)(mData.magFilter & ~FO_USE_COMPARISON);
+		FilterOptions mipFilter = (FilterOptions)(mData.mipFilter & ~FO_USE_COMPARISON);
 
-		if(minFilter == FO_ANISOTROPIC && desc.magFilter == FO_ANISOTROPIC && desc.mipFilter == FO_ANISOTROPIC)
+		if(minFilter == FO_ANISOTROPIC && mData.magFilter == FO_ANISOTROPIC && mData.mipFilter == FO_ANISOTROPIC)
 		{
 			samplerState.Filter = D3D11_FILTER_ANISOTROPIC;
 		}
@@ -96,5 +96,7 @@ namespace CamelotEngine
 			String errorDescription = device.getErrorDescription();
 			CM_EXCEPT(RenderingAPIException, "Cannot create sampler state.\nError Description:" + errorDescription);
 		}
+
+		SamplerState::initialize_internal();
 	}
 }

+ 0 - 2
CamelotRenderer/CamelotRenderer.vcxproj

@@ -204,7 +204,6 @@
     <ClInclude Include="Include\CmIndexBuffer.h" />
     <ClInclude Include="Include\CmOcclusionQuery.h" />
     <ClInclude Include="Include\CmPixelBuffer.h" />
-    <ClInclude Include="Include\CmRasterizerStateImporter.h" />
     <ClInclude Include="Include\CmTextureView.h" />
     <ClInclude Include="Include\CmVertexBuffer.h" />
     <ClInclude Include="Include\CmHighLevelGpuProgram.h" />
@@ -292,7 +291,6 @@
     <ClCompile Include="Source\CmIndexData.cpp" />
     <ClCompile Include="Source\CmOcclusionQuery.cpp" />
     <ClCompile Include="Source\CmPixelBuffer.cpp" />
-    <ClCompile Include="Source\CmRasterizerStateImporter.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
     <ClCompile Include="Source\CmVertexBuffer.cpp" />
     <ClCompile Include="Source\CmHighLevelGpuProgram.cpp" />

+ 0 - 6
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -365,9 +365,6 @@
     <ClInclude Include="Include\CmVertexData.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmRasterizerStateImporter.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -556,8 +553,5 @@
     <ClCompile Include="Source\CmVertexData.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmRasterizerStateImporter.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
   </ItemGroup>
 </Project>

+ 3 - 3
CamelotRenderer/Include/CmBlendState.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmPrerequisites.h"
-#include "CmIReflectable.h"
+#include "CmResource.h"
 #include "CmCommonEnums.h"
 
 namespace CamelotEngine
@@ -43,7 +43,7 @@ namespace CamelotEngine
 	};
 
 	// TODO Low priority - Write doc explaining various states
-	class CM_EXPORT BlendState : public IReflectable
+	class CM_EXPORT BlendState : public Resource
 	{
 	public:
 		virtual ~BlendState() {}
@@ -67,7 +67,7 @@ namespace CamelotEngine
 		 */
 		static const BlendStatePtr& getDefault();
 
-	private:
+	protected:
 		friend class RenderStateManager;
 
 		virtual void initialize(const BLEND_STATE_DESC& desc);

+ 3 - 3
CamelotRenderer/Include/CmDepthStencilState.h

@@ -2,7 +2,7 @@
 
 #include "CmPrerequisites.h"
 #include "CmCommonEnums.h"
-#include "CmIReflectable.h"
+#include "CmResource.h"
 
 namespace CamelotEngine
 {
@@ -45,7 +45,7 @@ namespace CamelotEngine
 	};
 
 	// TODO Low priority - Write doc explaining various states
-	class CM_EXPORT DepthStencilState : public IReflectable
+	class CM_EXPORT DepthStencilState : public Resource
 	{
 	public:
 		virtual ~DepthStencilState() {}
@@ -74,7 +74,7 @@ namespace CamelotEngine
 		 * @brief	Returns the default depth stencil state;
 		 */
 		static const DepthStencilStatePtr& getDefault();
-	private:
+	protected:
 		friend class RenderStateManager;
 
 		virtual void initialize(const DEPTH_STENCIL_STATE_DESC& desc);

+ 2 - 5
CamelotRenderer/Include/CmGpuProgram.h

@@ -171,14 +171,11 @@ namespace CamelotEngine {
 		 * 			constructed. Called by GpuManager upon creation, so usually you don't want
 		 * 			to call this manually.
 		 *		 
-		 * @param	internalCall	(optional) Set to true if initializing from within the RenderSystem.
-		 * 							Most users don't have to be concerned about this.
-		 * 							
 		 * @note	Initialization is not done immediately, and is instead just scheduled on the
-		 * 			render thread. Unless internalCall is specified, in which case it is initialized
+		 * 			render thread. Unless called from render thread, in which case it is initialized
 		 * 			right away.
 		 */
-		void initialize(bool internalCall = false);
+		void initialize();
 
 		/**
 		 * @copydoc Resource::destroy_internal.

+ 2 - 6
CamelotRenderer/Include/CmHighLevelGpuProgramManager.h

@@ -100,20 +100,16 @@ namespace CamelotEngine {
             to be a member of
 		@param language Code of the language to use (e.g. "cg")
 		@param gptype The type of program to create
-		* @param	internalCall	(optional) Set to true if calling this method from within the RenderSystem.
-		* 							Most users don't have to be concerned about this.
 		*/
-		HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile, bool internalCall = false);
+		HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile);
 
 		/** Create a new HighLevelGpuProgram. 
 		@par
 			This method creates a new program of the specified language. You need to set other 
 			properties like source, entry point, type, profile manually.
 		@param language Code of the language to use (e.g. "cg")
-		* @param	internalCall	(optional) Set to true if calling this method from within the RenderSystem.
-		* 							Most users don't have to be concerned about this.
 		*/
-		HighLevelGpuProgramPtr create(const String& language, bool internalCall = false);
+		HighLevelGpuProgramPtr create(const String& language);
 
 		/**
 		 * @brief	Creates a completely empty and uninitialized HighLevelGpuProgram.

+ 1 - 1
CamelotRenderer/Include/CmRasterizerState.h

@@ -58,7 +58,7 @@ namespace CamelotEngine
 		 */
 		static const RasterizerStatePtr& getDefault();
 
-	private:
+	protected:
 		friend class RenderStateManager;
 
 		virtual void initialize(const RASTERIZER_STATE_DESC& desc);

+ 0 - 29
CamelotRenderer/Include/CmRasterizerStateImporter.h

@@ -1,29 +0,0 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmSpecificImporter.h"
-#include "CmImporter.h"
-
-namespace CamelotEngine
-{
-	class RasterizerStateImporter : public SpecificImporter
-	{
-	public:
-		RasterizerStateImporter();
-		virtual ~RasterizerStateImporter();
-
-		/** Inherited from SpecificImporter */
-		virtual bool isExtensionSupported(const String& ext) const;
-
-		/** Inherited from SpecificImporter */
-		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
-
-		/** Inherited from SpecificImporter */
-		virtual BaseResourceHandle import(const String& filePath);
-	private:
-		vector<String>::type mExtensions;
-		std::unordered_map<String, int> mExtensionToFID;
-
-		String magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const;
-	};
-}

+ 2 - 3
CamelotRenderer/Include/CmResource.h

@@ -32,10 +32,9 @@ namespace CamelotEngine
 		 * @copydoc	IDestroyable::destroy()
 		 * 			
 		 * 	@note	Destruction is not done immediately, and is instead just scheduled on the
-		 * 			render thread. Unless internalCall is specified, in which case it is destroyed
-		 * 			right away. But you should only do this when calling from the render thread.
+		 * 			render thread. Unless called from render thread in which case it is executed right away.
 		 */
-		void destroy(bool internalCall = false);
+		void destroy();
 
 	protected:
 		friend class Resources;

+ 3 - 3
CamelotRenderer/Include/CmSamplerState.h

@@ -7,7 +7,7 @@
 #include "CmPixelUtil.h"
 #include "CmTexture.h"
 #include "CmColor.h"
-#include "CmIReflectable.h"
+#include "CmResource.h"
 
 namespace CamelotEngine 
 {
@@ -49,7 +49,7 @@ namespace CamelotEngine
 	*			be recreated internally (depending on used render system). It is better to have multiple SamplerState objects with different
 	*			configurations and re-use them.
 	*/
-	class CM_EXPORT SamplerState : public IReflectable
+	class CM_EXPORT SamplerState : public Resource
     {
     public:
 		virtual ~SamplerState() {}
@@ -99,7 +99,7 @@ namespace CamelotEngine
 		 */
 		static const SamplerStatePtr& getDefault();
 
-	private:
+	protected:
 		friend class RenderStateManager;
 
 		virtual void initialize(const SAMPLER_STATE_DESC& desc);

+ 3 - 6
CamelotRenderer/Include/CmTexture.h

@@ -246,15 +246,12 @@ namespace CamelotEngine {
 		 * @brief	Initializes the texture. This must be called right after the texture is constructed. Called by TextureManager
 		 * 			upon texture creation, so usually you don't want to call this manually.
 		 * 			
-		 * @param	internalCall	(optional) Set to true if initializing from within the RenderSystem.
-		 * 							Most users don't have to be concerned about this.
-		 * 							
 		 * @note	Initialization is not done immediately, and is instead just scheduled on the
-		 * 			render thread. Unless internalCall is specified, in which case it is initialized
-		 * 			right away. But you should only do this when calling from the render thread.
+		 * 			render thread. Unless called from render thread, in which case it is initialized
+		 * 			right away.
 		 */
 		void initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
-			PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint, bool internalCall = false);
+			PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint);
 
 		virtual PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
 		virtual void unlockImpl() = 0;

+ 3 - 7
CamelotRenderer/Include/CmTextureManager.h

@@ -110,12 +110,10 @@ namespace CamelotEngine {
 			@param fsaa The level of multisampling to use if this is a render target. Ignored
 				if usage does not include TU_RENDERTARGET or if the device does
 				not support it.
-			@param	internalCall	(optional) Set to true if calling this method from within the RenderSystem.
-										Most users don't have to be concerned about this.
         */
         TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
 			int num_mips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
-			UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK, bool internalCall = false);
+			UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
 			
         /** Create a manual texture with a depth of 1 (not loaded from a file).
             @param
@@ -158,15 +156,13 @@ namespace CamelotEngine {
 			@param fsaa The level of multisampling to use if this is a render target. Ignored
 				if usage does not include TU_RENDERTARGET or if the device does
 				not support it.
-			@param	internalCall	(optional) Set to true if calling this method from within the RenderSystem.
-				Most users don't have to be concerned about this.
         */
         TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, int num_mips,
             PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, UINT32 fsaa = 0, 
-			const String& fsaaHint = StringUtil::BLANK, bool internalCall = false)
+			const String& fsaaHint = StringUtil::BLANK)
 		{
 			return createTexture(texType, width, height, 1, 
-				num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint, internalCall);
+				num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
 		}
 
 		/**

+ 3 - 0
CamelotRenderer/Source/CmBlendState.cpp

@@ -1,5 +1,6 @@
 #include "CmBlendState.h"
 #include "CmRenderStateManager.h"
+#include "CmRenderSystem.h"
 #include "CmBlendStateRTTI.h"
 
 namespace CamelotEngine
@@ -7,6 +8,8 @@ namespace CamelotEngine
 	void BlendState::initialize(const BLEND_STATE_DESC& desc)
 	{
 		mData = desc;
+
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&BlendState::initialize_internal, this));
 	}
 
 	const BlendStatePtr& BlendState::getDefault()

+ 1 - 1
CamelotRenderer/Source/CmCgProgram.cpp

@@ -102,7 +102,7 @@ namespace CamelotEngine {
 			// Create a low-level program, give it the same name as us
 			mAssemblerProgram = 
 				HighLevelGpuProgramManager::instance().create(
-				sourceFromCg, mEntryPoint, RenderSystem::instance().getShadingLanguageName(), mType, mProfile, true);
+				sourceFromCg, mEntryPoint, RenderSystem::instance().getShadingLanguageName(), mType, mProfile);
 
 			// Shader params need to be forwarded to low level implementation
 			mAssemblerProgram->setAdjacencyInfoRequired(isAdjacencyInfoRequired());

+ 3 - 0
CamelotRenderer/Source/CmDepthStencilState.cpp

@@ -1,5 +1,6 @@
 #include "CmDepthStencilState.h"
 #include "CmRenderStateManager.h"
+#include "CmRenderSystem.h"
 #include "CmDepthStencilStateRTTI.h"
 #include "CmException.h"
 
@@ -8,6 +9,8 @@ namespace CamelotEngine
 	void DepthStencilState::initialize(const DEPTH_STENCIL_STATE_DESC& desc)
 	{
 		mData = desc;
+
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&DepthStencilState::initialize_internal, this));
 	}
 
 	const DepthStencilStatePtr& DepthStencilState::getDefault()

+ 2 - 5
CamelotRenderer/Source/CmGpuProgram.cpp

@@ -57,12 +57,9 @@ namespace CamelotEngine
 	{
 	}
 	//---------------------------------------------------------------------------
-	void GpuProgram::initialize(bool internalCall)
+	void GpuProgram::initialize()
 	{
-		if(internalCall)
-			initialize_internal();
-		else
-			RenderSystem::instancePtr()->queueCommand(boost::bind(&GpuProgram::initialize_internal, this));
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&GpuProgram::initialize_internal, this));
 	}
 	//---------------------------------------------------------------------------
     void GpuProgram::initialize_internal(void)

+ 4 - 4
CamelotRenderer/Source/CmHighLevelGpuProgramManager.cpp

@@ -147,20 +147,20 @@ namespace CamelotEngine {
 	}
     //---------------------------------------------------------------------------
     HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& source, const String& entryPoint, const String& language, 
-		GpuProgramType gptype, GpuProgramProfile profile, bool internalCall)
+		GpuProgramType gptype, GpuProgramProfile profile)
     {
 		HighLevelGpuProgramFactory* factory = getFactory(language);
         HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(source, entryPoint, gptype, profile), boost::bind(&HighLevelGpuProgramFactory::destroy, factory, _1));
-		ret->initialize(internalCall);
+		ret->initialize();
 
         return ret;
     }
 	//---------------------------------------------------------------------------
-	HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& language, bool internalCall)
+	HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& language)
 	{
 		HighLevelGpuProgramFactory* factory = getFactory(language);
 		HighLevelGpuProgramPtr ret = HighLevelGpuProgramPtr(factory->create(), boost::bind(&HighLevelGpuProgramFactory::destroy, factory, _1));
-		ret->initialize(internalCall);
+		ret->initialize();
 
 		return ret;
 	}

+ 1 - 2
CamelotRenderer/Source/CmImporter.cpp

@@ -5,14 +5,13 @@
 #include "CmSpecificImporter.h"
 #include "CmDebug.h"
 #include "CmDataStream.h"
-#include "CmRasterizerStateImporter.h"
 #include "CmException.h"
 
 namespace CamelotEngine
 {
 	Importer::Importer()
 	{
-		registerAssetImporter(new RasterizerStateImporter());
+
 	}
 
 	Importer::~Importer()

+ 0 - 61
CamelotRenderer/Source/CmRasterizerStateImporter.cpp

@@ -1,61 +0,0 @@
-#include "CmRasterizerStateImporter.h"
-#include "CmResource.h"
-#include "CmDebug.h"
-#include "CmDataStream.h"
-#include "CmPath.h"
-#include "CmFileSystem.h"
-#include "CmRasterizerState.h"
-
-namespace CamelotEngine
-{
-	RasterizerStateImporter::RasterizerStateImporter()
-		:SpecificImporter() 
-	{
-
-	}
-
-	RasterizerStateImporter::~RasterizerStateImporter() 
-	{
-
-	}
-
-	bool RasterizerStateImporter::isExtensionSupported(const String& ext) const
-	{
-		String lowerCaseExt = ext;
-		StringUtil::toLowerCase(lowerCaseExt);
-
-		return find(mExtensions.begin(), mExtensions.end(), lowerCaseExt) != mExtensions.end();
-	}
-
-	bool RasterizerStateImporter::isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const
-	{
-		String ext = magicNumToExtension(magicNumPtr, numBytes);
-
-		return isExtensionSupported(ext);
-	}
-
-	String RasterizerStateImporter::magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const
-	{
-		return StringUtil::BLANK;
-	}
-
-	BaseResourceHandle RasterizerStateImporter::import(const String& filePath)
-	{
-		DataStreamPtr fileData = FileSystem::open(filePath, true);
-
-		RASTERIZER_STATE_DESC stateDesc;// = parseStateData(fileData);
-
-
-		// TODO - Not initialized properly
-
-
-		RasterizerStateHandle newState(RasterizerState::create(stateDesc));
-
-		newState.waitUntilLoaded();
-		fileData->close();
-
-		registerLoadedResource(newState);
-
-		return newState;
-	}
-}

+ 10 - 7
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -448,12 +448,14 @@ namespace CamelotEngine {
 	
 	AsyncOp RenderSystem::queueReturnCommand(boost::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete)
 	{
-#if CM_DEBUG_MODE && !CM_FORCE_SINGLETHREADED_RENDERING
+		AsyncOp op;
+
 		if(CM_THREAD_CURRENT_ID == getRenderThreadId())
-			CM_EXCEPT(InternalErrorException, "You are not allowed to call this method on the render thread!");
-#endif
+		{
+			commandCallback(op); // Execute immediately
+			return op;
+		}
 
-		AsyncOp op;
 		UINT32 commandId = -1;
 		{
 			CM_LOCK_MUTEX(mCommandQueueMutex);
@@ -477,10 +479,11 @@ namespace CamelotEngine {
 
 	void RenderSystem::queueCommand(boost::function<void()> commandCallback, bool blockUntilComplete)
 	{
-#if CM_DEBUG_MODE && !CM_FORCE_SINGLETHREADED_RENDERING
 		if(CM_THREAD_CURRENT_ID == getRenderThreadId())
-			CM_EXCEPT(InternalErrorException, "You are not allowed to call this method on the render thread!");
-#endif
+		{
+			commandCallback(); // Execute immediately
+			return;
+		}
 
 		UINT32 commandId = -1;
 		{

+ 2 - 5
CamelotRenderer/Source/CmResource.cpp

@@ -26,12 +26,9 @@ namespace CamelotEngine
 		CM_THREAD_NOTIFY_ALL(mResourceLoadedCondition);
 	}
 
-	void Resource::destroy(bool internalCall)
+	void Resource::destroy()
 	{
-		if(internalCall)
-			destroy_internal();
-		else
-			RenderSystem::instancePtr()->queueCommand(boost::bind(&Texture::destroy_internal, this));
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&Texture::destroy_internal, this));
 	}
 
 	void Resource::waitUntilInitialized()

+ 3 - 0
CamelotRenderer/Source/CmSamplerState.cpp

@@ -1,6 +1,7 @@
 #include "CmSamplerState.h"
 #include "CmSamplerStateRTTI.h"
 #include "CmRenderStateManager.h"
+#include "CmRenderSystem.h"
 #include "CmException.h"
 
 namespace CamelotEngine 
@@ -8,6 +9,8 @@ namespace CamelotEngine
 	void SamplerState::initialize(const SAMPLER_STATE_DESC& desc)
 	{
 		mData = desc;
+
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&SamplerState::initialize_internal, this));
 	}
 
 	const SamplerStatePtr& SamplerState::getDefault()

+ 2 - 5
CamelotRenderer/Source/CmTexture.cpp

@@ -58,7 +58,7 @@ namespace CamelotEngine {
     }
 	//-------------------------------------------------------------------------
 	void Texture::initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
-		PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint, bool internalCall)
+		PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint)
 	{
 		mTextureType = textureType;
 		mWidth = width;
@@ -73,10 +73,7 @@ namespace CamelotEngine {
 
 		mSize = getNumFaces() * PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
 
-		if(internalCall)
-			initialize_internal();
-		else
-			RenderSystem::instancePtr()->queueCommand(boost::bind(&Texture::initialize_internal, this));
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&Texture::initialize_internal, this));
 	}
     //--------------------------------------------------------------------------
     bool Texture::hasAlpha(void) const

+ 2 - 2
CamelotRenderer/Source/CmTextureManager.cpp

@@ -54,10 +54,10 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     TexturePtr TextureManager::createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, int numMipmaps,
         PixelFormat format, int usage, bool hwGamma, 
-		UINT32 fsaa, const String& fsaaHint, bool internalCall)
+		UINT32 fsaa, const String& fsaaHint)
     {
         TexturePtr ret = TexturePtr(createTextureImpl(), boost::bind(&TextureManager::destroy, this, _1));
-		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma, fsaa, fsaaHint, internalCall);
+		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma, fsaa, fsaaHint);
 
 		return ret;
     }