Marko Pintera пре 13 година
родитељ
комит
36c37b43ff
26 измењених фајлова са 221 додато и 360 уклоњено
  1. 1 1
      CamelotClient/CamelotClient.cpp
  2. 0 2
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj
  3. 0 6
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters
  4. 1 2
      CamelotD3D11RenderSystem/Include/CmD3D11HLSLParamParser.h
  5. 4 7
      CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgram.h
  6. 1 0
      CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h
  7. 1 0
      CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h
  8. 2 0
      CamelotD3D11RenderSystem/Include/CmD3D11RenderSystem.h
  9. 0 1
      CamelotD3D11RenderSystem/Include/CmD3D11RenderWindow.h
  10. 0 61
      CamelotD3D11RenderSystem/Include/CmD3D11VertexDeclaration.h
  11. 12 18
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLParamParser.cpp
  12. 15 3
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp
  13. 3 3
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp
  14. 48 49
      CamelotD3D11RenderSystem/Source/CmD3D11InputLayoutManager.cpp
  15. 22 1
      CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp
  16. 39 20
      CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp
  17. 5 33
      CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp
  18. 2 0
      CamelotD3D11RenderSystem/Source/CmD3D11RenderWindowManager.cpp
  19. 0 137
      CamelotD3D11RenderSystem/Source/CmD3D11VertexDeclaration.cpp
  20. 1 0
      CamelotRenderer/Include/CmCommandQueue.h
  21. 24 0
      CamelotRenderer/Include/CmPrerequisites.h
  22. 3 1
      CamelotRenderer/Include/CmVertexDeclaration.h
  23. 10 0
      CamelotRenderer/Source/CmCommandQueue.cpp
  24. 12 12
      CamelotRenderer/Source/CmGpuParams.cpp
  25. 12 3
      CamelotRenderer/Source/CmRenderSystem.cpp
  26. 3 0
      CamelotRenderer/TODO.txt

+ 1 - 1
CamelotClient/CamelotClient.cpp

@@ -76,7 +76,7 @@ int _tmain(int argc, _TCHAR* argv[])
 	/////////////////// HLSL 11 SHADERS //////////////////////////
 	String fragShaderCode = "SamplerState samp : register(s0);			\
 							Texture2D tex : register(t0); \
-							float4 ps_main(float2 uv : TEXCOORD0) : SV_Target		\
+							float4 ps_main(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target		\
 							{														\
 							float4 color = tex.Sample(samp, uv);				\
 							return color;										\

+ 0 - 2
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj

@@ -178,7 +178,6 @@
     <ClInclude Include="Include\CmD3D11SamplerState.h" />
     <ClInclude Include="Include\CmD3D11Texture.h" />
     <ClInclude Include="Include\CmD3D11TextureManager.h" />
-    <ClInclude Include="Include\CmD3D11VertexDeclaration.h" />
     <ClInclude Include="Include\CmD3D11VideoMode.h" />
     <ClInclude Include="Include\CmD3D11VideoModeList.h" />
     <ClInclude Include="Include\CmD3D11InputLayoutManager.h" />
@@ -216,7 +215,6 @@
     <ClCompile Include="Source\CmD3D11SamplerState.cpp" />
     <ClCompile Include="Source\CmD3D11Texture.cpp" />
     <ClCompile Include="Source\CmD3D11TextureManager.cpp" />
-    <ClCompile Include="Source\CmD3D11VertexDeclaration.cpp" />
     <ClCompile Include="Source\CmD3D11VideoMode.cpp" />
     <ClCompile Include="Source\CmD3D11VideoModeList.cpp" />
   </ItemGroup>

+ 0 - 6
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters

@@ -54,9 +54,6 @@
     <ClInclude Include="Include\CmD3D11HardwareBufferManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D11VertexDeclaration.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D11RenderSystem.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -161,9 +158,6 @@
     <ClCompile Include="Source\CmD3D11HardwareBufferManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmD3D11VertexDeclaration.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmD3D11RenderSystem.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 1 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HLSLParamParser.h

@@ -7,8 +7,7 @@ namespace CamelotEngine
 	class D3D11HLSLParamParser
 	{
 	public:
-		void parse(ID3DBlob* microcode, GpuParamDesc& desc, 
-			vector<D3D11_SIGNATURE_PARAMETER_DESC>::type& inputParams, vector<D3D11_SIGNATURE_PARAMETER_DESC>::type& outputParams);
+		void parse(ID3DBlob* microcode, GpuParamDesc& desc, VertexDeclarationPtr& inputParams);
 
 	private:
 		void parseBuffer(ID3D11ShaderReflectionConstantBuffer* bufferReflection, GpuParamDesc& desc);

+ 4 - 7
CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgram.h

@@ -13,6 +13,8 @@ namespace CamelotEngine
 		const String& getLanguage() const;
 		bool isSupported() const;
 
+		GpuParamsPtr createParameters();
+
 		/** Sets whether matrix packing in column-major order. */ 
 		void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
 		/** Gets whether matrix packed in column-major order. */
@@ -23,11 +25,8 @@ namespace CamelotEngine
 		bool getEnableBackwardsCompatibility() const { return mEnableBackwardsCompatibility; }
 
 		const HLSLMicroCode& getMicroCode() const { return mMicrocode; }
-		UINT32 getNumInputs() const { return (UINT32)mInputParameters.size(); }
-		UINT32 getNumOutputs() const { return (UINT32)mOutputParameters.size(); }
 
-		const D3D11_SIGNATURE_PARAMETER_DESC& getInputParamDesc(unsigned int index) const { return mInputParameters.at(index); }
-		const D3D11_SIGNATURE_PARAMETER_DESC& getOutputParamDesc(unsigned int index) const { return mOutputParameters.at(index); }
+		VertexDeclarationPtr getInputDeclaration() const { return mInputDeclaration; }
 
 	protected:
 		friend class D3D11HLSLProgramFactory;
@@ -50,9 +49,7 @@ namespace CamelotEngine
 		bool mEnableBackwardsCompatibility;
 
 		HLSLMicroCode mMicrocode;
-
-		vector<D3D11_SIGNATURE_PARAMETER_DESC>::type mInputParameters;
-		vector<D3D11_SIGNATURE_PARAMETER_DESC>::type mOutputParameters;
+		VertexDeclarationPtr mInputDeclaration;
 
 		/**
 		 * @brief	Compiles the shader from source and generates the microcode.

+ 1 - 0
CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h

@@ -55,6 +55,7 @@ namespace CamelotEngine
 		/// Get vertex semantic
 		static LPCSTR get(VertexElementSemantic sem);
 		static VertexElementSemantic get(LPCSTR sem);
+		static VertexElementType getInputType(D3D_REGISTER_COMPONENT_TYPE type);
 		static D3D11_PRIMITIVE_TOPOLOGY getPrimitiveType(DrawOperationType type);
 		/// Get dx11 color
 		static void get(const Color& inColour, float * outColour );

+ 1 - 0
CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h

@@ -52,6 +52,7 @@ namespace CamelotEngine
 	class D3D11RasterizerState;
 	class D3D11SamplerState;
 	class D3D11DepthStencilState;
+	class D3D11InputLayoutManager;
 
 	enum TypeID_D3D11
 	{

+ 2 - 0
CamelotD3D11RenderSystem/Include/CmD3D11RenderSystem.h

@@ -102,6 +102,7 @@ namespace CamelotEngine
 		D3D_FEATURE_LEVEL	mFeatureLevel;
 
 		D3D11HLSLProgramFactory* mHLSLFactory;
+		D3D11InputLayoutManager* mIAManager;
 
 		// State variables
 		UINT32				mStencilRef;
@@ -109,6 +110,7 @@ namespace CamelotEngine
 		D3D11_RECT			mScissorRect;
 
 		VertexDeclarationPtr mActiveVertexDeclaration;
+		D3D11HLSLProgram*	 mActiveVertexShader;
 
 		/**
 		 * @brief	Creates or retrieves a proper input layout depending on the currently set vertex shader

+ 0 - 1
CamelotD3D11RenderSystem/Include/CmD3D11RenderWindow.h

@@ -70,7 +70,6 @@ namespace CamelotEngine
 		// Window size depended resources - must be released before swapchain resize and recreated later
 		ID3D11Texture2D*			mBackBuffer;
 		ID3D11RenderTargetView*		mRenderTargetView;
-		ID3D11DepthStencilView*		mDepthStencilView;
 		DepthStencilBufferPtr		mDepthStencilBuffer;
 
 		IDXGISwapChain*				mSwapChain;

+ 0 - 61
CamelotD3D11RenderSystem/Include/CmD3D11VertexDeclaration.h

@@ -1,61 +0,0 @@
-#pragma once
-
-#include "CmD3D11Prerequisites.h"
-#include "CmVertexDeclaration.h"
-
-namespace CamelotEngine
-{
-	class D3D11VertexDeclaration : public VertexDeclaration
-	{
-	protected:
-		mutable bool mNeedsRebuild;
-
-		map<D3D11Device*, ID3D11InputLayout*>::type mLayoutPerDevice;
-	public:
-		D3D11VertexDeclaration();
-		~D3D11VertexDeclaration();
-
-		/**
-		 * @copydoc VertexDeclaration::addElement
-		 */
-		const VertexElement& addElement(unsigned short source, UINT32 offset, VertexElementType theType,
-			VertexElementSemantic semantic, unsigned short index = 0);
-
-		/**
-		 * @copydoc VertexDeclaration::insertElement
-		 */
-		const VertexElement& insertElement(unsigned short atPosition,
-			unsigned short source, UINT32 offset, VertexElementType theType,
-			VertexElementSemantic semantic, unsigned short index = 0);
-
-		/**
-		 * @copydoc VertexDeclaration::removeElement(unsigned short)
-		 */
-		void removeElement(unsigned short elem_index);
-
-		/**
-		 * @copydoc VertexDeclaration::removeElement(VertexElementSemantic, unsigned short)
-		 */
-		void removeElement(VertexElementSemantic semantic, unsigned short index = 0);
-
-		/**
-		 * @copydoc VertexDeclaration::removeAllElements
-		 */
-		void removeAllElements(void);
-
-		/**
-		 * @copydoc VertexDeclaration::modifyElement
-		 */
-		void modifyElement(unsigned short elem_index, unsigned short source, UINT32 offset, VertexElementType theType,
-			VertexElementSemantic semantic, unsigned short index = 0);
-
-		/**
-		 * @brief	Gets the D3D11 input layout.
-		 * 			
-		 * @note	Recreates the layout if it way previously modified or if this is the first time
-		 * 			this method is called.
-		 */
-		ID3D11InputLayout* getD3DLayout(D3D11Device& device, D3D11HLSLProgram& programToBindTo);
-	};
-
-}

+ 12 - 18
CamelotD3D11RenderSystem/Source/CmD3D11HLSLParamParser.cpp

@@ -1,16 +1,13 @@
 #include "CmD3D11HLSLParamParser.h"
+#include "CmD3D11Mappings.h"
 #include "CmGpuParamDesc.h"
 #include "CmException.h"
 #include "CmDebug.h"
 
 namespace CamelotEngine
 {
-	void D3D11HLSLParamParser::parse(ID3DBlob* microcode, GpuParamDesc& desc, 
-		vector<D3D11_SIGNATURE_PARAMETER_DESC>::type& inputParams, vector<D3D11_SIGNATURE_PARAMETER_DESC>::type& outputParams)
+	void D3D11HLSLParamParser::parse(ID3DBlob* microcode, GpuParamDesc& desc, VertexDeclarationPtr& inputParams)
 	{
-		inputParams.clear();
-		outputParams.clear();
-
 		const char* commentString = nullptr;
 		ID3DBlob* pIDisassembly = nullptr;
 		char* pDisassembly = nullptr;
@@ -36,22 +33,19 @@ namespace CamelotEngine
 		if (FAILED(hr))
 			CM_EXCEPT(RenderingAPIException, "Cannot reflect D3D11 high-level shader.");
 
-		inputParams.resize(shaderDesc.InputParameters);
-		for (UINT32 i = 0; i < shaderDesc.InputParameters; i++)
+		if(inputParams != nullptr)
 		{
-			hr = shaderReflection->GetInputParameterDesc(i, &(inputParams[i]));
-
-			if (FAILED(hr))
-				CM_EXCEPT(RenderingAPIException, "Cannot get input param desc with index: " + toString(i));
-		}
+			D3D11_SIGNATURE_PARAMETER_DESC inputParamDesc;
+			for (UINT32 i = 0; i < shaderDesc.InputParameters; i++)
+			{
+				hr = shaderReflection->GetInputParameterDesc(i, &inputParamDesc);
 
-		outputParams.resize(shaderDesc.OutputParameters);
-		for (UINT32 i = 0; i < shaderDesc.OutputParameters; i++)
-		{
-			hr = shaderReflection->GetOutputParameterDesc(i, &(outputParams[i]));
+				if (FAILED(hr))
+					CM_EXCEPT(RenderingAPIException, "Cannot get input param desc with index: " + toString(i));
 
-			if (FAILED(hr))
-				CM_EXCEPT(RenderingAPIException, "Cannot get output param desc with index: " + toString(i));
+				inputParams->addElement(inputParamDesc.Stream, inputParamDesc.Register, 
+					D3D11Mappings::getInputType(inputParamDesc.ComponentType), D3D11Mappings::get(inputParamDesc.SemanticName), inputParamDesc.SemanticIndex);
+			}
 		}
 
 		for(UINT32 i = 0; i < shaderDesc.BoundResources; i++)

+ 15 - 3
CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp

@@ -6,6 +6,8 @@
 #include "CmHardwareBufferManager.h"
 #include "CmD3D11RenderSystem.h"
 #include "CmD3D11HLSLParamParser.h"
+#include "CmD3D11Mappings.h"
+#include "CmGpuParams.h"
 #include "CmException.h"
 #include "CmDebug.h"
 
@@ -77,8 +79,6 @@ namespace CamelotEngine
     void D3D11HLSLProgram::unload_internal()
 	{
 		mAssemblerProgram = nullptr;
-		mInputParameters.clear();
-		mOutputParameters.clear();
 		mMicrocode.clear();
 	}
 
@@ -150,7 +150,19 @@ namespace CamelotEngine
 		assert(microcode != nullptr);
 
 		D3D11HLSLParamParser parser;
-		parser.parse(microcode, mParametersDesc, mInputParameters, mOutputParameters);
+
+		if(mType == GPT_VERTEX_PROGRAM)
+			mInputDeclaration = HardwareBufferManager::instance().createVertexDeclaration();
+
+		parser.parse(microcode, mParametersDesc, mInputDeclaration);
+	}
+
+	GpuParamsPtr D3D11HLSLProgram::createParameters()
+	{
+		GpuParamsPtr params(new GpuParams(mParametersDesc));
+		params->setTransposeMatrices(mColumnMajorMatrices);
+
+		return params;
 	}
 
 	/************************************************************************/

+ 3 - 3
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp

@@ -1,8 +1,8 @@
 #include "CmD3D11HardwareBufferManager.h"
 #include "CmD3D11VertexBuffer.h"
 #include "CmD3D11IndexBuffer.h"
-#include "CmD3D11VertexDeclaration.h"
 #include "CmD3D11GenericBuffer.h"
+#include "CmD3D11GpuParamBlock.h"
 #include "CmGpuParamDesc.h"
 
 namespace CamelotEngine
@@ -46,7 +46,7 @@ namespace CamelotEngine
 
 	GpuParamBlockPtr D3D11HardwareBufferManager::createGpuParamBlock(const GpuParamBlockDesc& blockDesc)
 	{
-		return GpuParamBlockPtr(new GpuParamBlock(blockDesc));
+		return GpuParamBlockPtr(new D3D11GpuParamBlock(blockDesc));
 	}
 
 	GenericBufferPtr D3D11HardwareBufferManager::createGenericBuffer(UINT32 elementCount, UINT32 elementSize, 
@@ -57,7 +57,7 @@ namespace CamelotEngine
 
 	VertexDeclarationPtr D3D11HardwareBufferManager::createVertexDeclarationImpl(void)
 	{
-		return VertexDeclarationPtr(new D3D11VertexDeclaration());
+		return VertexDeclarationPtr(new VertexDeclaration());
 	}
 
 	void D3D11HardwareBufferManager::destroyVertexDeclarationImpl(VertexDeclaration* decl)

+ 48 - 49
CamelotD3D11RenderSystem/Source/CmD3D11InputLayoutManager.cpp

@@ -110,21 +110,21 @@ namespace CamelotEngine
 			return;
 
 		UINT32 numElements = newDecl->getElementCount();
-		D3D11_INPUT_ELEMENT_DESC* declElements = new D3D11_INPUT_ELEMENT_DESC[numElements];
-		ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
-
-		unsigned int idx;
+		D3D11_INPUT_ELEMENT_DESC* declElements = new D3D11_INPUT_ELEMENT_DESC[numElements];
+		ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
+
+		unsigned int idx = 0;
 		for(auto iter = newDecl->getElements().begin(); iter != newDecl->getElements().end(); ++iter)
-		{
-			declElements[idx].SemanticName			= D3D11Mappings::get(iter->getSemantic());
-			declElements[idx].SemanticIndex			= iter->getIndex();
-			declElements[idx].Format				= D3D11Mappings::get(iter->getType());
-			declElements[idx].InputSlot				= iter->getSource();
-			declElements[idx].AlignedByteOffset		= static_cast<WORD>(iter->getOffset());
-			declElements[idx].InputSlotClass		= D3D11_INPUT_PER_VERTEX_DATA;
-			declElements[idx].InstanceDataStepRate	= 0;
-
-			idx++;
+		{
+			declElements[idx].SemanticName			= D3D11Mappings::get(iter->getSemantic());
+			declElements[idx].SemanticIndex			= iter->getIndex();
+			declElements[idx].Format				= D3D11Mappings::get(iter->getType());
+			declElements[idx].InputSlot				= iter->getSource();
+			declElements[idx].AlignedByteOffset		= static_cast<WORD>(iter->getOffset());
+			declElements[idx].InputSlotClass		= D3D11_INPUT_PER_VERTEX_DATA;
+			declElements[idx].InstanceDataStepRate	= 0;
+
+			idx++;
 		}
 
 		D3D11RenderSystem* d3d11rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
@@ -132,15 +132,15 @@ namespace CamelotEngine
 
 		InputLayoutEntry* newEntry = new InputLayoutEntry();
 		newEntry->lastUsedIdx = ++mLastUsedCounter;
-		newEntry->inputLayout = nullptr; 
-		HRESULT hr = device.getD3D11Device()->CreateInputLayout( 
-			declElements, 
-			numElements, 
-			&microCode[0], 
-			microCode.size(),
-			&newEntry->inputLayout);
-
-		if (FAILED(hr)|| device.hasError())
+		newEntry->inputLayout = nullptr; 
+		HRESULT hr = device.getD3D11Device()->CreateInputLayout( 
+			declElements, 
+			numElements, 
+			&microCode[0], 
+			microCode.size(),
+			&newEntry->inputLayout);
+
+		if (FAILED(hr)|| device.hasError())
 			CM_EXCEPT(RenderingAPIException, "Unable to set D3D11 vertex declaration" + device.getErrorDescription());
 
 		// Create key and add to the layout map
@@ -200,34 +200,33 @@ namespace CamelotEngine
 	{
 		VertexDeclarationPtr newDecl = HardwareBufferManager::instance().createVertexDeclaration();
 
-		for(auto shaderIter = vertexShaderDecl->getElements().begin(); shaderIter != vertexShaderDecl->getElements().end(); ++shaderIter)
+		//for(auto shaderIter = vertexShaderDecl->getElements().begin(); shaderIter != vertexShaderDecl->getElements().end(); ++shaderIter)
+		//{
+		//	const VertexElement* foundElement = nullptr;
+		//	for(auto bufferIter = vertexBufferDecl->getElements().begin(); bufferIter != vertexBufferDecl->getElements().end(); ++bufferIter)
+		//	{
+		//		if(shaderIter->getSemantic() == bufferIter->getSemantic() && shaderIter->getIndex() == bufferIter->getIndex())
+		//		{
+		//			foundElement = &(*bufferIter);
+		//			break;
+		//		}
+		//	}
+
+		//	if(foundElement == nullptr)
+		//	{
+		//		// TODO - It's possible I can just skip this attribute and driver won't complain?
+		//		LOGWRN("Provided vertex buffer doesn't have a required input attribute: " + toString(shaderIter->getSemantic()) + toString(shaderIter->getIndex()));
+		//		return nullptr;
+		//	}
+
+		//	newDecl->addElement(foundElement->getSource(), foundElement->getOffset(), foundElement->getType(), foundElement->getSemantic(), foundElement->getIndex());
+		//}
+
+		const VertexElement* foundElement = nullptr;
+		for(auto bufferIter = vertexBufferDecl->getElements().begin(); bufferIter != vertexBufferDecl->getElements().end(); ++bufferIter)
 		{
-			const VertexElement* foundElement = nullptr;
-			for(auto bufferIter = vertexBufferDecl->getElements().begin(); bufferIter != vertexBufferDecl->getElements().end(); ++bufferIter)
-			{
-				if(shaderIter->getSemantic() == bufferIter->getSemantic() && shaderIter->getIndex() == bufferIter->getSemantic())
-				{
-					foundElement = &(*bufferIter);
-					break;
-				}
-			}
-
-			if(foundElement == nullptr)
-			{
-				// TODO - It's possible I can just skip this attribute and driver won't complain?
-				LOGWRN("Provided vertex buffer doesn't have a required input attribute: " + toString(shaderIter->getSemantic()) + toString(shaderIter->getIndex()));
-				return nullptr;
-			}
-
-			if(foundElement->getType() != shaderIter->getType())
-			{
-				// TODO - It's possible I can just cast to the smaller size and driver won't complain?
-				LOGWRN("Shader input and vertex buffer types don't match for element with semantic: " + toString(shaderIter->getSemantic()) + toString(shaderIter->getIndex()) + ". " \
-					"Buffer type is " + toString(foundElement->getType()) + " and shader type is " + toString(shaderIter->getType()));
-				return nullptr;
-			}
 
-			newDecl->addElement(foundElement->getSource(), foundElement->getOffset(), foundElement->getType(), foundElement->getSemantic(), foundElement->getIndex());
+			newDecl->addElement(bufferIter->getSource(), bufferIter->getOffset(), bufferIter->getType(), bufferIter->getSemantic(), bufferIter->getIndex());
 		}
 
 		return newDecl;

+ 22 - 1
CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp

@@ -336,9 +336,15 @@ namespace CamelotEngine
 		case VET_UBYTE4:
 			return DXGI_FORMAT_R8G8B8A8_UINT;
 			break;
+		case VET_UINT4:
+			return DXGI_FORMAT_R32G32B32A32_UINT;
+			break;
+		case VET_SINT4:
+			return DXGI_FORMAT_R32G32B32A32_SINT;
+			break;
 		}
 		// to keep compiler happy
-		return DXGI_FORMAT_R32G32B32_FLOAT;
+		return DXGI_FORMAT_R32G32B32A32_FLOAT;
 	}
 
 	VertexElementSemantic D3D11Mappings::get(LPCSTR sem)
@@ -414,6 +420,21 @@ namespace CamelotEngine
 		return "";
 	}
 
+	VertexElementType D3D11Mappings::getInputType(D3D_REGISTER_COMPONENT_TYPE type)
+	{
+		switch(type)
+		{
+		case D3D_REGISTER_COMPONENT_FLOAT32:
+			return VET_FLOAT4;
+		case D3D_REGISTER_COMPONENT_SINT32:
+			return VET_SINT4;
+		case D3D_REGISTER_COMPONENT_UINT32:
+			return VET_UINT4;
+		default:
+			return VET_FLOAT4;
+		}
+	}
+
 	void D3D11Mappings::get(const Color& inColour, float * outColour )
 	{
 		outColour[0] = inColour.r;

+ 39 - 20
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -13,12 +13,13 @@
 #include "CmD3D11DepthStencilState.h"
 #include "CmD3D11SamplerState.h"
 #include "CmD3D11GpuProgram.h"
-#include "CmD3D11VertexDeclaration.h"
 #include "CmD3D11Mappings.h"
 #include "CmD3D11VertexBuffer.h"
 #include "CmD3D11IndexBuffer.h"
 #include "CmD3D11RenderStateManager.h"
 #include "CmD3D11GpuParamBlock.h"
+#include "CmD3D11InputLayoutManager.h"
+#include "CmD3D11HLSLProgram.h"
 #include "CmGpuParams.h"
 #include "CmDebug.h"
 #include "CmException.h"
@@ -34,10 +35,10 @@ namespace CamelotEngine
 	D3D11RenderSystem::D3D11RenderSystem()
 		: mDXGIFactory(nullptr), mDevice(nullptr), mDriverList(nullptr)
 		, mActiveD3DDriver(nullptr), mFeatureLevel(D3D_FEATURE_LEVEL_9_1)
-		, mHLSLFactory(nullptr)
-		, mStencilRef(0)
+		, mHLSLFactory(nullptr), mIAManager(nullptr)
+		, mStencilRef(0), mActiveVertexShader(nullptr)
 	{
-
+		mClipPlanesDirty = false; // DX11 handles clip planes through shaders
 	}
 
 	D3D11RenderSystem::~D3D11RenderSystem()
@@ -128,6 +129,8 @@ namespace CamelotEngine
 		mCurrentCapabilities->addShaderProfile("hlsl");
 		HighLevelGpuProgramManager::instance().addFactory(mHLSLFactory);
 
+		mIAManager = new D3D11InputLayoutManager();
+
 		RenderSystem::initialize_internal();
 	}
 
@@ -135,6 +138,7 @@ namespace CamelotEngine
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 
+		SAFE_DELETE(mIAManager);
 		SAFE_DELETE(mHLSLFactory);
 
 		RenderStateManager::shutDown();
@@ -274,6 +278,12 @@ namespace CamelotEngine
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 
+		mActiveViewport = vp;
+
+		// Set render target
+		RenderTargetPtr target = vp.getTarget();
+		setRenderTarget(target.get());
+
 		// set viewport dimensions
 		mViewport.TopLeftX = (FLOAT)vp.getActualLeft();
 		mViewport.TopLeftY = (FLOAT)vp.getActualTop();
@@ -352,6 +362,7 @@ namespace CamelotEngine
 			{
 				D3D11GpuVertexProgram* d3d11GpuProgram = static_cast<D3D11GpuVertexProgram*>(prg->getBindingDelegate());
 				mDevice->getImmediateContext()->VSSetShader(d3d11GpuProgram->getVertexShader(), nullptr, 0);
+				mActiveVertexShader = static_cast<D3D11HLSLProgram*>(prg.get());
 				break;
 			}
 		case GPT_FRAGMENT_PROGRAM:
@@ -397,22 +408,23 @@ namespace CamelotEngine
 		{
 		case GPT_VERTEX_PROGRAM:
 			mDevice->getImmediateContext()->VSSetShader(nullptr, nullptr, 0);
+			mActiveVertexShader = nullptr;
 			break;
 		case GPT_FRAGMENT_PROGRAM:
-				mDevice->getImmediateContext()->PSSetShader(nullptr, nullptr, 0);
-				break;
+			mDevice->getImmediateContext()->PSSetShader(nullptr, nullptr, 0);
+			break;
 		case GPT_GEOMETRY_PROGRAM:
-				mDevice->getImmediateContext()->GSSetShader(nullptr, nullptr, 0);
-				break;
+			mDevice->getImmediateContext()->GSSetShader(nullptr, nullptr, 0);
+			break;
 		case GPT_DOMAIN_PROGRAM:
-				mDevice->getImmediateContext()->DSSetShader(nullptr, nullptr, 0);
-				break;
+			mDevice->getImmediateContext()->DSSetShader(nullptr, nullptr, 0);
+			break;
 		case GPT_HULL_PROGRAM:
-				mDevice->getImmediateContext()->HSSetShader(nullptr, nullptr, 0);
-				break;
+			mDevice->getImmediateContext()->HSSetShader(nullptr, nullptr, 0);
+			break;
 		case GPT_COMPUTE_PROGRAM:
-				mDevice->getImmediateContext()->CSSetShader(nullptr, nullptr, 0);
-				break;
+			mDevice->getImmediateContext()->CSSetShader(nullptr, nullptr, 0);
+			break;
 		default:
 			CM_EXCEPT(InvalidParametersException, "Unsupported gpu program type: " + toString(gptype));
 		}
@@ -422,6 +434,8 @@ namespace CamelotEngine
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 
+		params->updateIfDirty();
+
 		const GpuParamDesc& paramDesc = params->getParamDesc();
 
 		for(auto iter = paramDesc.samplers.begin(); iter != paramDesc.samplers.end(); ++iter)
@@ -488,6 +502,8 @@ namespace CamelotEngine
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 
+		applyInputLayout();
+
 		mDevice->getImmediateContext()->Draw(vertexCount, 0);
 	}
 
@@ -495,6 +511,8 @@ namespace CamelotEngine
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 
+		applyInputLayout();
+
 		mDevice->getImmediateContext()->DrawIndexed(indexCount, startIndex, 0);
 	}
 
@@ -520,9 +538,9 @@ namespace CamelotEngine
 			UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 
 			ID3D11RenderTargetView** views = new ID3D11RenderTargetView*[maxRenderTargets];
-			memset(views, 0, sizeof(views));
+			memset(views, 0, sizeof(ID3D11RenderTargetView*) * maxRenderTargets);
 
-			target->getCustomAttribute("RTV", &views);
+			target->getCustomAttribute("RTV", views);
 			if (!views[0])
 			{
 				delete[] views;
@@ -573,8 +591,8 @@ namespace CamelotEngine
 		// Retrieve render surfaces
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 		ID3D11RenderTargetView** views = new ID3D11RenderTargetView*[maxRenderTargets];
-		memset(views, 0, sizeof(views));
-		target->getCustomAttribute("RTV", &views);
+		memset(views, 0, sizeof(ID3D11RenderTargetView*) * maxRenderTargets);
+		target->getCustomAttribute("RTV", views);
 		if (!views[0])
 		{
 			delete[] views;
@@ -938,8 +956,9 @@ namespace CamelotEngine
 			return;
 		}
 
-		D3D11VertexDeclaration* vertexDeclaration = static_cast<D3D11VertexDeclaration*>(mActiveVertexDeclaration.get());
-		//mDevice->getImmediateContext()->IASetInputLayout(vertexDeclaration->get);
+		ID3D11InputLayout* ia = mIAManager->retrieveInputLayout(mActiveVertexShader->getInputDeclaration(), mActiveVertexDeclaration, *mActiveVertexShader);
+
+		mDevice->getImmediateContext()->IASetInputLayout(ia);
 	}
 }
 

+ 5 - 33
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp

@@ -2,7 +2,7 @@
 #include "CmWindowEventUtilities.h"
 #include "CmD3D11RenderSystem.h"
 #include "CmD3D11Device.h"
-#include "CmDepthStencilBuffer.h"
+#include "CmD3D11DepthStencilBuffer.h"
 #include "CmTextureManager.h"
 #include "CmException.h"
 
@@ -334,10 +334,6 @@ namespace CamelotEngine
 
 	void D3D11RenderWindow::getCustomAttribute( const String& name, void* pData )
 	{
-		// Valid attributes and their equvalent native functions:
-		// D3DDEVICE			: getD3DDevice
-		// WINDOW				: getWindowHandle
-
 		if(name == "WINDOW")
 		{
 			HWND *pWnd = (HWND*)pData;
@@ -345,39 +341,15 @@ namespace CamelotEngine
 			return;
 		}
 
-		if(name == "D3DDEVICE")
-		{
-			ID3D11Device **device = (ID3D11Device **)pData;
-			*device = mDevice.getD3D11Device();
-			return;
-		}
-		else if(name == "isTexture")
-		{
-			bool *b = reinterpret_cast< bool * >( pData );
-			*b = false;
-			return;
-		}
-		else if(name == "ID3D11RenderTargetView")
+		if(name == "RTV")
 		{
 			*static_cast<ID3D11RenderTargetView**>(pData) = mRenderTargetView;
 			return;
 		}
-		else if(name == "ID3D11Texture2D")
-		{
-			ID3D11Texture2D **pBackBuffer = (ID3D11Texture2D**)pData;
-			*pBackBuffer = mBackBuffer;
-			return;
-		}
-		else if(name == "numberOfViews")
-		{
-			unsigned int* n = reinterpret_cast<unsigned int*>(pData);
-			*n = 1;
-			return;
-		}
-		else if(name == "DDBACKBUFFER")
+		else if(name == "DSV")
 		{
-			ID3D11Texture2D **ppBackBuffer = (ID3D11Texture2D**) pData;
-			ppBackBuffer[0] = NULL;
+			D3D11DepthStencilBuffer* d3d11depthStencilBuffer = static_cast<D3D11DepthStencilBuffer*>(mDepthStencilBuffer.get());
+			*static_cast<ID3D11DepthStencilView**>(pData) = d3d11depthStencilBuffer->getDepthStencilView();
 			return;
 		}
 

+ 2 - 0
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindowManager.cpp

@@ -20,6 +20,8 @@ namespace CamelotEngine
 		D3D11RenderWindow* renderWindow = new D3D11RenderWindow(d3d11rs->getPrimaryDevice(), d3d11rs->getDXGIFactory());
 		renderWindow->initialize(desc);
 
+		d3d11rs->attachRenderTarget(*renderWindow);
+
 		D3D11RenderWindowPtr winPtr(renderWindow);
 		asyncOp.completeOperation(std::static_pointer_cast<RenderWindow>(winPtr));
 	}

+ 0 - 137
CamelotD3D11RenderSystem/Source/CmD3D11VertexDeclaration.cpp

@@ -1,137 +0,0 @@
-#include "CmD3D11VertexDeclaration.h"
-#include "CmD3D11Mappings.h"
-#include "CmD3D11Device.h"
-#include "CmD3D11HLSLProgram.h"
-#include "CmException.h"
-
-namespace CamelotEngine
-{
-	D3D11VertexDeclaration::D3D11VertexDeclaration()
-		:VertexDeclaration()
-	{
-	}
-
-	D3D11VertexDeclaration::~D3D11VertexDeclaration()
-	{
-		for(auto iter = mLayoutPerDevice.begin(); iter != mLayoutPerDevice.end(); ++iter)
-		{
-			if(iter->second != nullptr)
-				iter->second->Release();
-		}
-	}
-
-	const VertexElement& D3D11VertexDeclaration::addElement(unsigned short source, UINT32 offset, VertexElementType theType,
-		VertexElementSemantic semantic, unsigned short index)
-	{
-		mNeedsRebuild = true;
-		return VertexDeclaration::addElement(source, offset, theType, semantic, index);
-	}
-
-	const VertexElement& D3D11VertexDeclaration::insertElement(unsigned short atPosition,
-		unsigned short source, UINT32 offset, VertexElementType theType,
-		VertexElementSemantic semantic, unsigned short index)
-	{
-		mNeedsRebuild = true;
-		return VertexDeclaration::insertElement(atPosition, source, offset, theType, semantic, index);
-	}
-
-	void D3D11VertexDeclaration::removeElement(unsigned short elem_index)
-	{
-		VertexDeclaration::removeElement(elem_index);
-		mNeedsRebuild = true;
-	}
-
-	void D3D11VertexDeclaration::removeElement(VertexElementSemantic semantic, unsigned short index)
-	{
-		VertexDeclaration::removeElement(semantic, index);
-		mNeedsRebuild = true;
-	}
-
-	void D3D11VertexDeclaration::removeAllElements(void)
-	{
-		VertexDeclaration::removeAllElements();
-		mNeedsRebuild = true;
-	}
-
-	void D3D11VertexDeclaration::modifyElement(unsigned short elem_index, unsigned short source, UINT32 offset, VertexElementType theType,
-		VertexElementSemantic semantic, unsigned short index)
-	{
-		VertexDeclaration::modifyElement(elem_index, source, offset, theType, semantic, index);
-		mNeedsRebuild = true;
-	}
-
-	ID3D11InputLayout* D3D11VertexDeclaration::getD3DLayout(D3D11Device& device, D3D11HLSLProgram& programToBindTo)
-	{
-		if(!mNeedsRebuild)
-		{
-			auto iterFind = mLayoutPerDevice.find(&device);
-
-			if(iterFind == mLayoutPerDevice.end())
-				mNeedsRebuild = true;
-		}
-
-		if(mNeedsRebuild)
-		{
-			size_t numElements = programToBindTo.getNumInputs();
-
-			D3D11_INPUT_ELEMENT_DESC* declElements = new D3D11_INPUT_ELEMENT_DESC[numElements];
-			ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
-
-			unsigned int idx;
-			for (idx = 0; idx < numElements; ++idx)
-			{
-				const D3D11_SIGNATURE_PARAMETER_DESC& inputDesc = programToBindTo.getInputParamDesc(idx);
-				VertexElementList::const_iterator i, iend;
-				iend = mElementList.end();
-				bool found = false;
-				for (i = mElementList.begin(); i != iend; ++i)
-				{
-					LPCSTR semanticName			= D3D11Mappings::get(i->getSemantic());
-					UINT semanticIndex			= i->getIndex();
-					if(strcmp(semanticName, inputDesc.SemanticName) == 0
-						&& semanticIndex == inputDesc.SemanticIndex)
-					{
-						found = true;
-						break;
-					}
-				}
-
-				if(!found)
-				{
-					CM_EXCEPT(RenderingAPIException, "Shader signature doesn't match the vertex declaration!");
-				}
-
-				declElements[idx].SemanticName			= inputDesc.SemanticName;
-				declElements[idx].SemanticIndex			= inputDesc.SemanticIndex;
-				declElements[idx].Format				= D3D11Mappings::get(i->getType());
-				declElements[idx].InputSlot				= i->getSource();
-				declElements[idx].AlignedByteOffset		= static_cast<WORD>(i->getOffset());
-				declElements[idx].InputSlotClass		= D3D11_INPUT_PER_VERTEX_DATA;
-				declElements[idx].InstanceDataStepRate	= 0;
-				
-				DWORD dwShaderFlags = 0;
-				const HLSLMicroCode& microCode = programToBindTo.getMicroCode();
-
-				ID3D11InputLayout* inputLayout = nullptr; 
-				HRESULT hr = device.getD3D11Device()->CreateInputLayout( 
-					declElements, 
-					programToBindTo.getNumInputs(), 
-					&microCode[0], 
-					microCode.size(),
-					&inputLayout );
-
-				if (FAILED(hr)|| device.hasError())
-				{
-					String errorDescription = device.getErrorDescription();
-
-					CM_EXCEPT(RenderingAPIException, "Unable to set D3D11 vertex declaration" + errorDescription);
-				}
-
-				mLayoutPerDevice[&device] = inputLayout;
-
-			}
-		}
-
-		return mLayoutPerDevice[&device];
-	}
-}

+ 1 - 0
CamelotRenderer/Include/CmCommandQueue.h

@@ -42,6 +42,7 @@ namespace CamelotEngine
 		 * 							
 		 *							When you want to allow multiple threads to access it, set this to true,
 		 *							and also make sure you sync access to the queue properly.
+		 *							
 		 */
 		CommandQueue(CM_THREAD_ID_TYPE threadId, bool allowAllThreads = false);
 		~CommandQueue();

+ 24 - 0
CamelotRenderer/Include/CmPrerequisites.h

@@ -29,6 +29,7 @@ THE SOFTWARE
 #include "CmPrerequisitesUtil.h"
 
 #define CM_MAX_MULTIPLE_RENDER_TARGETS 8
+#define CM_FORCE_SINGLETHREADED_RENDERING 0
 
 //----------------------------------------------------------------------------
 // Windows Settings
@@ -60,6 +61,29 @@ THE SOFTWARE
 
 #endif // CM_PLATFORM == CM_PLATFORM_WIN32
 
+// Linux/Apple Settings
+#if CM_PLATFORM == CM_PLATFORM_LINUX || CM_PLATFORM == CM_PLATFORM_APPLE
+
+// Enable GCC symbol visibility
+#   if defined( CM_GCC_VISIBILITY )
+#       define CM_EXPORT  __attribute__ ((visibility("default")))
+#       define CM_HIDDEN __attribute__ ((visibility("hidden")))
+#   else
+#       define CM_EXPORT
+#       define CM_HIDDEN
+#   endif
+
+// A quick define to overcome different names for the same function
+#   define stricmp strcasecmp
+
+#   ifdef DEBUG
+#       define CM_DEBUG_MODE 1
+#   else
+#       define CM_DEBUG_MODE 0
+#   endif
+
+#endif
+
 namespace CamelotEngine {
 
 // Pre-declare classes

+ 3 - 1
CamelotRenderer/Include/CmVertexDeclaration.h

@@ -48,7 +48,9 @@ namespace CamelotEngine
         /// D3D style compact color
         VET_COLOR_ARGB = 10,
         /// GL style compact color
-        VET_COLOR_ABGR = 11
+        VET_COLOR_ABGR = 11,
+		VET_UINT4 = 12,
+		VET_SINT4 = 13
     };
 
     /** This class declares the usage of a single vertex buffer as a component

+ 10 - 0
CamelotRenderer/Source/CmCommandQueue.cpp

@@ -40,6 +40,11 @@ namespace CamelotEngine
 		Command newCommand(commandCallback, _notifyWhenComplete, _callbackId);
 		mCommands->push_back(newCommand);
 
+#if CM_FORCE_SINGLETHREADED_RENDERING
+		vector<CommandQueue::Command>::type* commands = flush();
+		playback(commands);
+#endif
+
 		return newCommand.asyncOp;
 	}
 
@@ -56,6 +61,11 @@ namespace CamelotEngine
 
 		Command newCommand(commandCallback, _notifyWhenComplete, _callbackId);
 		mCommands->push_back(newCommand);
+
+#if CM_FORCE_SINGLETHREADED_RENDERING
+		vector<CommandQueue::Command>::type* commands = flush();
+		playback(commands);
+#endif
 	}
 
 	vector<CommandQueue::Command>::type* CommandQueue::flush()

+ 12 - 12
CamelotRenderer/Source/CmGpuParams.cpp

@@ -10,37 +10,37 @@ namespace CamelotEngine
 	GpuParams::GpuParams(GpuParamDesc& paramDesc)
 		:mParamDesc(paramDesc), mTransposeMatrices(false)
 	{
-		UINT32 maxParamBlockSlot = 0;
+		UINT32 numParamBlockSlots = 0;
 		for(auto iter = mParamDesc.paramBlocks.begin(); iter != mParamDesc.paramBlocks.end(); ++iter)
 		{
-			if(iter->second.slot > maxParamBlockSlot)
-				maxParamBlockSlot = iter->second.slot;
+			if((iter->second.slot + 1) > numParamBlockSlots)
+				numParamBlockSlots = iter->second.slot + 1;
 		}
 
-		mParamBlocks.resize(maxParamBlockSlot + 1);
+		mParamBlocks.resize(numParamBlockSlots);
 
 		for(auto iter = mParamDesc.paramBlocks.begin(); iter != mParamDesc.paramBlocks.end(); ++iter)
 		{
 			mParamBlocks[iter->second.slot] = GpuParamBlock::create(iter->second);
 		}
 
-		UINT32 maxTextureSlot = 0;
+		UINT32 numTextureSlots = 0;
 		for(auto iter = mParamDesc.textures.begin(); iter != mParamDesc.textures.end(); ++iter)
 		{
-			if(iter->second.slot > maxTextureSlot)
-				maxTextureSlot = iter->second.slot;
+			if((iter->second.slot + 1) > numTextureSlots)
+				numTextureSlots = iter->second.slot + 1;
 		}
 
-		mTextures.resize(maxTextureSlot + 1);
+		mTextures.resize(numTextureSlots);
 
-		UINT32 maxSamplerSlot = 0;
+		UINT32 numSamplerSlots = 0;
 		for(auto iter = mParamDesc.samplers.begin(); iter != mParamDesc.samplers.end(); ++iter)
 		{
-			if(iter->second.slot > maxSamplerSlot)
-				maxSamplerSlot = iter->second.slot;
+			if((iter->second.slot + 1) > numSamplerSlots)
+				numSamplerSlots = iter->second.slot + 1;
 		}
 
-		mSamplerStates.resize(maxSamplerSlot + 1);
+		mSamplerStates.resize(numSamplerSlots);
 	}
 
 	GpuParamBlockPtr GpuParams::getParamBlock(UINT32 slot) const

+ 12 - 3
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -380,6 +380,7 @@ namespace CamelotEngine {
 
 	void RenderSystem::initRenderThread()
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
 		mRenderThreadFunc = new RenderWorkerFunc(this);
 
 #if CM_THREAD_SUPPORT
@@ -391,11 +392,13 @@ namespace CamelotEngine {
 
 #else
 		CM_EXCEPT(InternalErrorException, "Attempting to start a render thread but Camelot isn't compiled with thread support.");
+#endif
 #endif
 	}
 
 	void RenderSystem::runRenderThread()
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
 		mRenderThreadId = CM_THREAD_CURRENT_ID;
 
 		CM_THREAD_NOTIFY_ALL(mRenderThreadStartCondition)
@@ -419,11 +422,12 @@ namespace CamelotEngine {
 			// Play commands
 			mCommandQueue->playback(commands, boost::bind(&RenderSystem::commandCompletedNotify, this, _1)); 
 		}
-
+#endif
 	}
 
 	void RenderSystem::shutdownRenderThread()
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
 		mRenderThreadShutdown = true;
 
 		// Wake all threads. They will quit after they see the shutdown flag
@@ -434,6 +438,7 @@ namespace CamelotEngine {
 
 		mRenderThread = nullptr;
 		mRenderThreadId = CM_THREAD_CURRENT_ID;
+#endif
 	}
 
 	DeferredRenderContextPtr RenderSystem::createDeferredContext()
@@ -443,7 +448,7 @@ namespace CamelotEngine {
 	
 	AsyncOp RenderSystem::queueReturnCommand(boost::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete)
 	{
-#ifdef CM_DEBUG_MODE
+#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
@@ -472,7 +477,7 @@ namespace CamelotEngine {
 
 	void RenderSystem::queueCommand(boost::function<void()> commandCallback, bool blockUntilComplete)
 	{
-#ifdef CM_DEBUG_MODE
+#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
@@ -498,6 +503,7 @@ namespace CamelotEngine {
 
 	void RenderSystem::blockUntilCommandCompleted(UINT32 commandId)
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
 		CM_LOCK_MUTEX_NAMED(mCommandNotifyMutex, lock);
 
 		while(true)
@@ -518,6 +524,7 @@ namespace CamelotEngine {
 
 			CM_THREAD_WAIT(mCommandCompleteCondition, mCommandNotifyMutex, lock);
 		}
+#endif
 	}
 
 	void RenderSystem::commandCompletedNotify(UINT32 commandId)
@@ -533,8 +540,10 @@ namespace CamelotEngine {
 
 	void RenderSystem::throwIfNotRenderThread() const
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
 		if(CM_THREAD_CURRENT_ID != getRenderThreadId())
 			CM_EXCEPT(InternalErrorException, "Calling the render system from a non-render thread!");
+#endif
 	}
 
 	/************************************************************************/

+ 3 - 0
CamelotRenderer/TODO.txt

@@ -14,6 +14,9 @@
 
 
 >>>>>>>>>>FINAL SPRINT BEFORE EDITOR WORK
+Creating input layout doesn't seem to require shader/buffer decl combining
+ - Remove the extra code, and possibly keep a check to mase sure buffer provides all attributes requested by the shader
+
 Once I get DX11 running make sure to test if driver complains about missing shader attributes or invalid size ones
 delete d3d11 vertex declaration
  Working generic buffers