Browse Source

Merged Depth stencil surface into Texture class for DX9

Marko Pintera 13 years ago
parent
commit
570e911896
42 changed files with 308 additions and 487 deletions
  1. 34 34
      CamelotClient/CamelotClient.cpp
  2. 1 4
      CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h
  3. 1 81
      CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp
  4. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11MultiRenderTexture.cpp
  5. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11RenderTexture.cpp
  6. 1 21
      CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp
  7. 0 2
      CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj
  8. 0 6
      CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters
  9. 0 18
      CamelotD3D9Renderer/Include/CmD3D9DepthStencilBuffer.h
  10. 1 0
      CamelotD3D9Renderer/Include/CmD3D9Device.h
  11. 0 2
      CamelotD3D9Renderer/Include/CmD3D9Mappings.h
  12. 3 3
      CamelotD3D9Renderer/Include/CmD3D9MultiRenderTexture.h
  13. 2 2
      CamelotD3D9Renderer/Include/CmD3D9RenderTexture.h
  14. 3 5
      CamelotD3D9Renderer/Include/CmD3D9Texture.h
  15. 0 6
      CamelotD3D9Renderer/Include/CmD3D9TextureManager.h
  16. 0 41
      CamelotD3D9Renderer/Source/CmD3D9DepthStencilBuffer.cpp
  17. 11 0
      CamelotD3D9Renderer/Source/CmD3D9Device.cpp
  18. 19 21
      CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp
  19. 13 13
      CamelotD3D9Renderer/Source/CmD3D9MultiRenderTexture.cpp
  20. 0 3
      CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp
  21. 4 2
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  22. 7 7
      CamelotD3D9Renderer/Source/CmD3D9RenderTexture.cpp
  23. 87 49
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  24. 5 7
      CamelotD3D9Renderer/Source/CmD3D9TextureManager.cpp
  25. 1 1
      CamelotGLRenderer/Source/CmGLMultiRenderTexture.cpp
  26. 1 1
      CamelotGLRenderer/Source/CmGLRenderTexture.cpp
  27. 0 2
      CamelotRenderer.sln
  28. 0 2
      CamelotRenderer/CamelotRenderer.vcxproj
  29. 0 6
      CamelotRenderer/CamelotRenderer.vcxproj.filters
  30. 0 37
      CamelotRenderer/Include/CmDepthStencilBuffer.h
  31. 4 4
      CamelotRenderer/Include/CmMultiRenderTexture.h
  32. 0 2
      CamelotRenderer/Include/CmPrerequisites.h
  33. 3 4
      CamelotRenderer/Include/CmRenderTexture.h
  34. 1 0
      CamelotRenderer/Include/CmTexture.h
  35. 1 7
      CamelotRenderer/Include/CmTextureManager.h
  36. 0 32
      CamelotRenderer/Source/CmDepthStencilBuffer.cpp
  37. 18 13
      CamelotRenderer/Source/CmMultiRenderTexture.cpp
  38. 20 15
      CamelotRenderer/Source/CmRenderTexture.cpp
  39. 4 4
      CamelotRenderer/Source/CmTextureManager.cpp
  40. 0 15
      CamelotRenderer/TODO.txt
  41. 9 12
      CamelotUtility/Include/CmPixelData.h
  42. 52 1
      CamelotUtility/Source/CmPixelUtil.cpp

+ 34 - 34
CamelotClient/CamelotClient.cpp

@@ -27,8 +27,8 @@ using namespace CamelotEngine;
 int _tmain(int argc, _TCHAR* argv[])
 int _tmain(int argc, _TCHAR* argv[])
 {
 {
 	//gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
 	//gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
-	//gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
-	gApplication().startUp("CamelotD3D11RenderSystem", "CamelotForwardRenderer");
+	gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
+	//gApplication().startUp("CamelotD3D11RenderSystem", "CamelotForwardRenderer");
 
 
 	RenderSystem* renderSystem = RenderSystem::instancePtr();
 	RenderSystem* renderSystem = RenderSystem::instancePtr();
 	RenderWindowPtr renderWindow = gApplication().getPrimaryRenderWindow();
 	RenderWindowPtr renderWindow = gApplication().getPrimaryRenderWindow();
@@ -51,51 +51,51 @@ int _tmain(int argc, _TCHAR* argv[])
 	HighLevelGpuProgramPtr vertProg;
 	HighLevelGpuProgramPtr vertProg;
 
 
 	/////////////////// HLSL 9 SHADERS //////////////////////////
 	/////////////////// HLSL 9 SHADERS //////////////////////////
-	//String fragShaderCode = "sampler2D tex;			\
-	//						float4 ps_main(float2 uv : TEXCOORD0) : COLOR0		\
-	//						{														\
-	//						float4 color = tex2D(tex, uv);				\
-	//						return color;										\
-	//						}";
-
-	//fragProg =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
-
-	//String vertShaderCode = "float4x4 matViewProjection;	\
-	//						void vs_main(										\
-	//						float4 inPos : POSITION,							\
-	//						float2 uv : TEXCOORD0,								\
-	//						out float4 oPosition : POSITION,					\
-	//						out float2 oUv : TEXCOORD0)							\
-	//						{														\
-	//						oPosition = mul(matViewProjection, inPos);			\
-	//						oUv = uv;											\
-	//						}";
-
-	//vertProg =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
-
-	/////////////////// HLSL 11 SHADERS //////////////////////////
-	String fragShaderCode = "SamplerState samp : register(s0);			\
-							Texture2D tex : register(t0); \
-							float4 ps_main(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target		\
+	String fragShaderCode = "sampler2D tex;			\
+							float4 ps_main(float2 uv : TEXCOORD0) : COLOR0		\
 							{														\
 							{														\
-							float4 color = tex.Sample(samp, uv);				\
+							float4 color = tex2D(tex, uv);				\
 							return color;										\
 							return color;										\
 							}";
 							}";
 
 
-	fragProg =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+	fragProg =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
 
 
 	String vertShaderCode = "float4x4 matViewProjection;	\
 	String vertShaderCode = "float4x4 matViewProjection;	\
 							void vs_main(										\
 							void vs_main(										\
-							in float4 inPos : POSITION,							\
-							in float2 uv : TEXCOORD0,								\
-							out float4 oPosition : SV_Position,					\
+							float4 inPos : POSITION,							\
+							float2 uv : TEXCOORD0,								\
+							out float4 oPosition : POSITION,					\
 							out float2 oUv : TEXCOORD0)							\
 							out float2 oUv : TEXCOORD0)							\
 							{														\
 							{														\
 							oPosition = mul(matViewProjection, inPos);			\
 							oPosition = mul(matViewProjection, inPos);			\
 							oUv = uv;											\
 							oUv = uv;											\
 							}";
 							}";
 
 
-	vertProg =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
+	vertProg =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
+
+	/////////////////// HLSL 11 SHADERS //////////////////////////
+	//String fragShaderCode = "SamplerState samp : register(s0);			\
+	//						Texture2D tex : register(t0); \
+	//						float4 ps_main(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target		\
+	//						{														\
+	//						float4 color = tex.Sample(samp, uv);				\
+	//						return color;										\
+	//						}";
+
+	//fragProg =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+
+	//String vertShaderCode = "float4x4 matViewProjection;	\
+	//						void vs_main(										\
+	//						in float4 inPos : POSITION,							\
+	//						in float2 uv : TEXCOORD0,								\
+	//						out float4 oPosition : SV_Position,					\
+	//						out float2 oUv : TEXCOORD0)							\
+	//						{														\
+	//						oPosition = mul(matViewProjection, inPos);			\
+	//						oUv = uv;											\
+	//						}";
+
+	//vertProg =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
 
 
 	/////////////////// CG SHADERS //////////////////////////
 	/////////////////// CG SHADERS //////////////////////////
 	//String fragShaderCode = "sampler2D tex;					\
 	//String fragShaderCode = "sampler2D tex;					\

+ 1 - 4
CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h

@@ -83,9 +83,6 @@ namespace CamelotEngine
 
 
 		static UINT32 _getSizeInBytes(PixelFormat pf, UINT32 xcount = 1, UINT32 ycount = 1);
 		static UINT32 _getSizeInBytes(PixelFormat pf, UINT32 xcount = 1, UINT32 ycount = 1);
 
 
-		static UINT _getTextureBindFlags(DXGI_FORMAT format, bool isdynamic);
-		static UINT _getTextureMiscFlags(UINT bindflags, TextureType textype, bool isdynamic);
-
-		static D3D11_MAP _getLockOptions(GpuLockOptions lockOptions);
+		static D3D11_MAP getLockOptions(GpuLockOptions lockOptions);
 	};
 	};
 }
 }

+ 1 - 81
CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp

@@ -853,87 +853,7 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
-	UINT D3D11Mappings::_getTextureBindFlags(DXGI_FORMAT format, bool isdynamic)
-	{
-		if(isdynamic)
-			return D3D11_BIND_SHADER_RESOURCE; 
-
-		switch(format)
-		{
-		case DXGI_FORMAT_R32G32B32A32_TYPELESS:
-		case DXGI_FORMAT_R32G32B32_TYPELESS:
-		case DXGI_FORMAT_R32G32B32_FLOAT:
-		case DXGI_FORMAT_R32G32B32_UINT:
-		case DXGI_FORMAT_R32G32B32_SINT:
-		case DXGI_FORMAT_R16G16B16A16_TYPELESS:
-		case DXGI_FORMAT_R32G32_TYPELESS:
-		case DXGI_FORMAT_R32G8X24_TYPELESS:
-		case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
-		case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
-		case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
-		case DXGI_FORMAT_R10G10B10A2_TYPELESS:
-		case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
-		case DXGI_FORMAT_R8G8B8A8_TYPELESS:
-		case DXGI_FORMAT_R16G16_TYPELESS:
-		case DXGI_FORMAT_R32_TYPELESS:
-		case DXGI_FORMAT_D32_FLOAT:
-		case DXGI_FORMAT_R24G8_TYPELESS:
-		case DXGI_FORMAT_D24_UNORM_S8_UINT:
-		case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
-		case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
-		case DXGI_FORMAT_R8G8_TYPELESS:
-		case DXGI_FORMAT_R16_TYPELESS:
-		case DXGI_FORMAT_D16_UNORM:
-		case DXGI_FORMAT_R8_TYPELESS:
-		case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
-		case DXGI_FORMAT_R8G8_B8G8_UNORM:
-		case DXGI_FORMAT_G8R8_G8B8_UNORM:
-		case DXGI_FORMAT_BC1_TYPELESS:
-		case DXGI_FORMAT_BC1_UNORM:
-		case DXGI_FORMAT_BC1_UNORM_SRGB:
-		case DXGI_FORMAT_BC2_TYPELESS:
-		case DXGI_FORMAT_BC2_UNORM:
-		case DXGI_FORMAT_BC2_UNORM_SRGB:
-		case DXGI_FORMAT_BC3_TYPELESS:
-		case DXGI_FORMAT_BC3_UNORM:
-		case DXGI_FORMAT_BC3_UNORM_SRGB:
-		case DXGI_FORMAT_BC4_TYPELESS:
-		case DXGI_FORMAT_BC4_UNORM:
-		case DXGI_FORMAT_BC4_SNORM:
-		case DXGI_FORMAT_BC5_TYPELESS:
-		case DXGI_FORMAT_BC5_UNORM:
-		case DXGI_FORMAT_BC5_SNORM:
-		case DXGI_FORMAT_B8G8R8A8_TYPELESS:
-		case DXGI_FORMAT_B8G8R8X8_TYPELESS:
-		case DXGI_FORMAT_BC6H_TYPELESS:
-		case DXGI_FORMAT_BC6H_UF16:
-		case DXGI_FORMAT_BC6H_SF16:
-		case DXGI_FORMAT_BC7_TYPELESS:
-		case DXGI_FORMAT_BC7_UNORM:
-		case DXGI_FORMAT_BC7_UNORM_SRGB:
-			return D3D11_BIND_SHADER_RESOURCE;
-		default:
-			return D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
-		}
-	}
-
-	UINT D3D11Mappings::_getTextureMiscFlags(UINT bindflags, TextureType textype, bool isdynamic)
-	{
-		if(isdynamic)
-			return 0;
-
-		UINT flags = 0;
-
-		if(bindflags & D3D11_BIND_RENDER_TARGET)
-			flags |= D3D11_RESOURCE_MISC_GENERATE_MIPS;
-
-		if(textype == TEX_TYPE_CUBE_MAP)
-			flags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
-
-		return flags;
-	}
-
-	D3D11_MAP D3D11Mappings::_getLockOptions(GpuLockOptions lockOptions)
+	D3D11_MAP D3D11Mappings::getLockOptions(GpuLockOptions lockOptions)
 	{
 	{
 		switch(lockOptions)
 		switch(lockOptions)
 		{
 		{

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11MultiRenderTexture.cpp

@@ -44,7 +44,7 @@ namespace CamelotEngine
 		else if(name == "DSV")
 		else if(name == "DSV")
 		{
 		{
 			ID3D11DepthStencilView** pDSV = (ID3D11DepthStencilView **)pData;
 			ID3D11DepthStencilView** pDSV = (ID3D11DepthStencilView **)pData;
-			D3D11DepthStencilBuffer* d3d11depthStencilBuffer = static_cast<D3D11DepthStencilBuffer*>(mDepthStencilBuffer.get());
+			D3D11DepthStencilBuffer* d3d11depthStencilBuffer = static_cast<D3D11DepthStencilBuffer*>(mDepthStencilSurface.get());
 
 
 			*pDSV = d3d11depthStencilBuffer->getDepthStencilView();
 			*pDSV = d3d11depthStencilBuffer->getDepthStencilView();
 			return;
 			return;

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderTexture.cpp

@@ -112,7 +112,7 @@ namespace CamelotEngine
 		else if(name == "DSV")
 		else if(name == "DSV")
 		{
 		{
 			ID3D11DepthStencilView** pDSV = (ID3D11DepthStencilView **)pData;
 			ID3D11DepthStencilView** pDSV = (ID3D11DepthStencilView **)pData;
-			D3D11DepthStencilBuffer* d3d11depthStencilBuffer = static_cast<D3D11DepthStencilBuffer*>(mDepthStencilBuffer.get());
+			D3D11DepthStencilBuffer* d3d11depthStencilBuffer = static_cast<D3D11DepthStencilBuffer*>(mDepthStencilSurface.get());
 
 
 			*pDSV = d3d11depthStencilBuffer->getDepthStencilView();
 			*pDSV = d3d11depthStencilBuffer->getDepthStencilView();
 			return;
 			return;

+ 1 - 21
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -57,27 +57,7 @@ namespace CamelotEngine
 
 
 		PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
 		PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
 
 
-		D3D11_MAP flags = D3D11Mappings::_getLockOptions(options);
-		switch(options)
-		{
-		case GBL_WRITE_ONLY_NO_OVERWRITE:
-			flags = D3D11_MAP_WRITE_NO_OVERWRITE;
-			break;
-		case GBL_READ_WRITE:
-			flags = D3D11_MAP_READ_WRITE;
-			break;
-		case GBL_WRITE_ONLY_DISCARD:
-			flags = D3D11_MAP_WRITE_DISCARD;
-			break;
-		case GBL_READ_ONLY:
-			flags = D3D11_MAP_READ;
-			break;
-		case GBL_WRITE_ONLY:
-			flags = D3D11_MAP_WRITE;
-			break;
-		default: 
-			break;
-		};
+		D3D11_MAP flags = D3D11Mappings::getLockOptions(options);
 
 
 		if(flags == D3D11_MAP_READ || flags == D3D11_MAP_READ_WRITE)
 		if(flags == D3D11_MAP_READ || flags == D3D11_MAP_READ_WRITE)
 		{
 		{

+ 0 - 2
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj

@@ -147,7 +147,6 @@
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
-    <ClInclude Include="Include\CmD3D9DepthStencilBuffer.h" />
     <ClInclude Include="Include\CmD3D9Device.h" />
     <ClInclude Include="Include\CmD3D9Device.h" />
     <ClInclude Include="Include\CmD3D9DeviceManager.h" />
     <ClInclude Include="Include\CmD3D9DeviceManager.h" />
     <ClInclude Include="Include\CmD3D9Driver.h" />
     <ClInclude Include="Include\CmD3D9Driver.h" />
@@ -181,7 +180,6 @@
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="CmD3D9Plugin.cpp" />
     <ClCompile Include="CmD3D9Plugin.cpp" />
-    <ClCompile Include="Source\CmD3D9DepthStencilBuffer.cpp" />
     <ClCompile Include="Source\CmD3D9Device.cpp" />
     <ClCompile Include="Source\CmD3D9Device.cpp" />
     <ClCompile Include="Source\CmD3D9DeviceManager.cpp" />
     <ClCompile Include="Source\CmD3D9DeviceManager.cpp" />
     <ClCompile Include="Source\CmD3D9Driver.cpp" />
     <ClCompile Include="Source\CmD3D9Driver.cpp" />

+ 0 - 6
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters

@@ -87,9 +87,6 @@
     <ClInclude Include="Include\CmD3D9RenderWindowManager.h">
     <ClInclude Include="Include\CmD3D9RenderWindowManager.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D9DepthStencilBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D9RenderTexture.h">
     <ClInclude Include="Include\CmD3D9RenderTexture.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
@@ -179,9 +176,6 @@
     <ClCompile Include="Source\CmD3D9RenderWindowManager.cpp">
     <ClCompile Include="Source\CmD3D9RenderWindowManager.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\CmD3D9DepthStencilBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmD3D9RenderTexture.cpp">
     <ClCompile Include="Source\CmD3D9RenderTexture.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>

+ 0 - 18
CamelotD3D9Renderer/Include/CmD3D9DepthStencilBuffer.h

@@ -1,18 +0,0 @@
-#pragma once
-
-#include "CmD3D9Prerequisites.h"
-#include "CmDepthStencilBuffer.h"
-
-namespace CamelotEngine
-{
-	class CM_D3D9_EXPORT D3D9DepthStencilBuffer : public DepthStencilBuffer
-	{
-	public:
-		D3D9DepthStencilBuffer(DepthStencilFormat format, UINT32 width, UINT32 height, UINT32 fsaa, const String &fsaaHint);
-		~D3D9DepthStencilBuffer();
-
-		IDirect3DSurface9* getSurface() const { return mSurface; }
-	protected:
-		IDirect3DSurface9* mSurface;
-	};
-}

+ 1 - 0
CamelotD3D9Renderer/Include/CmD3D9Device.h

@@ -62,6 +62,7 @@ namespace CamelotEngine {
 		
 		
 		const D3DCAPS9&			getD3D9DeviceCaps		() const;
 		const D3DCAPS9&			getD3D9DeviceCaps		() const;
 		D3DFORMAT				getBackBufferFormat		() const;
 		D3DFORMAT				getBackBufferFormat		() const;
+		D3DFORMAT				getDepthStencilFormat	() const;
 
 
 		bool					validate				(D3D9RenderWindow* renderWindow);
 		bool					validate				(D3D9RenderWindow* renderWindow);
 		void					invalidate				(D3D9RenderWindow* renderWindow);
 		void					invalidate				(D3D9RenderWindow* renderWindow);

+ 0 - 2
CamelotD3D9Renderer/Include/CmD3D9Mappings.h

@@ -93,8 +93,6 @@ namespace CamelotEngine
 		static D3DDECLTYPE get(VertexElementType vType);
 		static D3DDECLTYPE get(VertexElementType vType);
 		/// Get vertex semantic
 		/// Get vertex semantic
 		static D3DDECLUSAGE get(VertexElementSemantic sem);
 		static D3DDECLUSAGE get(VertexElementSemantic sem);
-		/// return a D3D11 equivalent for an engine DepthStencilFormat
-		static D3DFORMAT get(DepthStencilFormat format);
         // Convert matrix to D3D style
         // Convert matrix to D3D style
         static 	D3DXMATRIX makeD3DXMatrix( const Matrix4& mat );
         static 	D3DXMATRIX makeD3DXMatrix( const Matrix4& mat );
         // Convert matrix from D3D style
         // Convert matrix from D3D style

+ 3 - 3
CamelotD3D9Renderer/Include/CmD3D9MultiRenderTexture.h

@@ -20,9 +20,9 @@ namespace CamelotEngine
 		void initialize();
 		void initialize();
 
 
 		void setColorSurfaceImpl(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0);
 		void setColorSurfaceImpl(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0);
-		void setDepthStencilImpl(DepthStencilBufferPtr depthStencilbuffer);
+		void setDepthStencilImpl(TexturePtr depthStencilSurface);
 
 
-		vector<IDirect3DSurface9*>::type mColorSurfaces;
-		IDirect3DSurface9* mDepthStencilSurface;
+		vector<IDirect3DSurface9*>::type mDX9ColorSurfaces;
+		IDirect3DSurface9* mDX9DepthStencilSurface;
 	};
 	};
 }
 }

+ 2 - 2
CamelotD3D9Renderer/Include/CmD3D9RenderTexture.h

@@ -19,8 +19,8 @@ namespace CamelotEngine
 
 
 		D3D9RenderTexture();
 		D3D9RenderTexture();
 
 
-		IDirect3DSurface9* mColorSurface;
-		IDirect3DSurface9* mDepthStencilSurface;
+		IDirect3DSurface9* mDX9ColorSurface;
+		IDirect3DSurface9* mDX9DepthStencilSurface;
 
 
 		void createInternalResourcesImpl();
 		void createInternalResourcesImpl();
 	};
 	};

+ 3 - 5
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -102,7 +102,9 @@ namespace CamelotEngine {
 			/// actual texture pointer
 			/// actual texture pointer
 			IDirect3DBaseTexture9* pBaseTex;
 			IDirect3DBaseTexture9* pBaseTex;
 			/// Optional FSAA surface
 			/// Optional FSAA surface
-			IDirect3DSurface9* pFSAASurface;			
+			IDirect3DSurface9* pFSAASurface;	
+			/// Optional depth stencil surface
+			IDirect3DSurface9* pDepthStencilSurface;	
 		};
 		};
 		
 		
 		typedef map<IDirect3DDevice9*, TextureResources*>::type	DeviceToTextureResourcesMap;
 		typedef map<IDirect3DDevice9*, TextureResources*>::type	DeviceToTextureResourcesMap;
@@ -170,10 +172,6 @@ namespace CamelotEngine {
 		bool _canAutoGenMipmaps(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat);
 		bool _canAutoGenMipmaps(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat);
 		/// internal method, return true if the device/texture combination can use hardware gamma
 		/// internal method, return true if the device/texture combination can use hardware gamma
 		bool _canUseHardwareGammaCorrection(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat, bool forwriting);
 		bool _canUseHardwareGammaCorrection(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat, bool forwriting);
-		
-		/// internal method, the cube map face name for the spec. face index
-		String _getCubeFaceName(unsigned char face) const
-		{ assert(face < 6); return mCubeFaceNames[face]; }
 
 
 		/// internal method, create D3D9HardwarePixelBuffers for every face and
 		/// internal method, create D3D9HardwarePixelBuffers for every face and
 		/// mipmap level. This method must be called after the D3D texture object was created
 		/// mipmap level. This method must be called after the D3D texture object was created

+ 0 - 6
CamelotD3D9Renderer/Include/CmD3D9TextureManager.h

@@ -47,12 +47,6 @@ namespace CamelotEngine
         bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
         bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
             bool preciseFormatOnly = false);		
             bool preciseFormatOnly = false);		
 
 
-		/**
-		 * @copydoc TextureManager::createDepthStencilBuffer()
-		 */
-		DepthStencilBufferPtr createDepthStencilBuffer(DepthStencilFormat format, UINT32 width, 
-			UINT32 height, UINT32 fsaa, const String& fsaaHint);
-
 		/**
 		/**
 		 * @copydoc TextureManager::createMultiRenderTexture()
 		 * @copydoc TextureManager::createMultiRenderTexture()
 		 */
 		 */

+ 0 - 41
CamelotD3D9Renderer/Source/CmD3D9DepthStencilBuffer.cpp

@@ -1,41 +0,0 @@
-#include "CmD3D9DepthStencilBuffer.h"
-#include "CmD3D9RenderSystem.h"
-#include "CmD3D9Mappings.h"
-
-namespace CamelotEngine
-{
-	D3D9DepthStencilBuffer::D3D9DepthStencilBuffer(DepthStencilFormat format, UINT32 width, UINT32 height, UINT32 fsaa, const String &fsaaHint)
-		:DepthStencilBuffer(format, width, height, fsaa, fsaaHint), mSurface(nullptr)
-	{
-		D3D9RenderSystem* rs = static_cast<D3D9RenderSystem*>(RenderSystem::instancePtr());
-
-		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
-
-		D3DFORMAT d3dFormat = D3D9Mappings::get(format);
-		D3DMULTISAMPLE_TYPE msType = D3DMULTISAMPLE_NONE;
-		DWORD msQuality = 0;
-		rs->determineFSAASettings(d3d9Device, fsaa, fsaaHint, d3dFormat, false, &msType, &msQuality);
-
-		/// If not, create the depthstencil surface
-		HRESULT hr = d3d9Device->CreateDepthStencilSurface( 
-			static_cast<UINT>(width), 
-			static_cast<UINT>(height), 
-			d3dFormat, 
-			msType, 
-			msQuality, 
-			TRUE,  // discard true or false?
-			&mSurface, 
-			NULL);
-
-		if(FAILED(hr))
-		{
-			String msg = DXGetErrorDescription(hr);
-			CM_EXCEPT(InvalidParametersException, "Error CreateDepthStencilSurface : " + msg);
-		}
-	}
-
-	D3D9DepthStencilBuffer::~D3D9DepthStencilBuffer()
-	{
-		SAFE_RELEASE(mSurface);
-	}
-}

+ 11 - 0
CamelotD3D9Renderer/Source/CmD3D9Device.cpp

@@ -443,6 +443,17 @@ namespace CamelotEngine
 		return mPresentationParams[0].BackBufferFormat;
 		return mPresentationParams[0].BackBufferFormat;
 	}
 	}
 
 
+	//---------------------------------------------------------------------
+	D3DFORMAT D3D9Device::getDepthStencilFormat() const
+	{		
+		if (mPresentationParams == NULL || mPresentationParamsCount == 0)
+		{
+			CM_EXCEPT(RenderingAPIException, "Presentation parameters are invalid!");
+		}
+
+		return mPresentationParams[0].AutoDepthStencilFormat;
+	}
+
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	IDirect3DDevice9* D3D9Device::getD3D9Device()
 	IDirect3DDevice9* D3D9Device::getD3D9Device()
 	{
 	{

+ 19 - 21
CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp

@@ -443,23 +443,6 @@ namespace CamelotEngine
 		return D3DDECLUSAGE_POSITION;
 		return D3DDECLUSAGE_POSITION;
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
-	D3DFORMAT D3D9Mappings::get(DepthStencilFormat format)
-	{
-		switch(format)
-		{
-		case DFMT_D24S8:
-			return D3DFMT_D24S8;
-		case DFMT_D32:
-			return D3DFMT_D32F_LOCKABLE;
-		case DFMT_D16:
-			return D3DFMT_D16;
-		}
-
-		LOGWRN("Requesting unsupported DepthStencilFormat. Using D24S8 format instead.");
-
-		return D3DFMT_D24S8;
-	}
-	//---------------------------------------------------------------------
 	D3DXMATRIX D3D9Mappings::makeD3DXMatrix( const Matrix4& mat )
 	D3DXMATRIX D3D9Mappings::makeD3DXMatrix( const Matrix4& mat )
 	{
 	{
 		// Transpose matrix
 		// Transpose matrix
@@ -543,6 +526,12 @@ namespace CamelotEngine
 			return PF_DXT4;
 			return PF_DXT4;
 		case D3DFMT_DXT5:
 		case D3DFMT_DXT5:
 			return PF_DXT5;
 			return PF_DXT5;
+		case D3DFMT_D24S8:
+			return PF_D24S8;
+		case D3DFMT_D32F_LOCKABLE:
+			return PF_D32;
+		case D3DFMT_D16:
+			return PF_D16;
 		default:
 		default:
 			return PF_UNKNOWN;
 			return PF_UNKNOWN;
 		}
 		}
@@ -610,19 +599,26 @@ namespace CamelotEngine
 			return D3DFMT_DXT4;
 			return D3DFMT_DXT4;
 		case PF_DXT5:
 		case PF_DXT5:
 			return D3DFMT_DXT5;
 			return D3DFMT_DXT5;
+		case PF_D24S8:
+			return D3DFMT_D24S8;
+		case PF_D32:
+			return D3DFMT_D32F_LOCKABLE;
+		case PF_D16:
+			return D3DFMT_D16;
 		case PF_UNKNOWN:
 		case PF_UNKNOWN:
 		default:
 		default:
 			return D3DFMT_UNKNOWN;
 			return D3DFMT_UNKNOWN;
 		}
 		}
 	}
 	}
 	/****************************************************************************************/
 	/****************************************************************************************/
-	PixelFormat D3D9Mappings::_getClosestSupportedPF(PixelFormat ogrePF)
+	PixelFormat D3D9Mappings::_getClosestSupportedPF(PixelFormat enginePF)
 	{
 	{
-		if (_getPF(ogrePF) != D3DFMT_UNKNOWN)
+		if (_getPF(enginePF) != D3DFMT_UNKNOWN)
 		{
 		{
-			return ogrePF;
+			return enginePF;
 		}
 		}
-		switch(ogrePF)
+
+		switch(enginePF)
 		{
 		{
 		case PF_B5G6R5:
 		case PF_B5G6R5:
 			return PF_R5G6B5;
 			return PF_R5G6B5;
@@ -636,6 +632,8 @@ namespace CamelotEngine
 			return PF_FLOAT16_RGBA;
 			return PF_FLOAT16_RGBA;
 		case PF_FLOAT32_RGB:
 		case PF_FLOAT32_RGB:
 			return PF_FLOAT32_RGBA;
 			return PF_FLOAT32_RGBA;
+		case PF_D32_S8X24:
+			return PF_D24S8;
 		case PF_UNKNOWN:
 		case PF_UNKNOWN:
 		default:
 		default:
 			return PF_A8R8G8B8;
 			return PF_A8R8G8B8;

+ 13 - 13
CamelotD3D9Renderer/Source/CmD3D9MultiRenderTexture.cpp

@@ -1,12 +1,11 @@
 #include "CmD3D9MultiRenderTexture.h"
 #include "CmD3D9MultiRenderTexture.h"
-#include "CmD3D9DepthStencilBuffer.h"
 #include "CmD3D9Texture.h"
 #include "CmD3D9Texture.h"
 #include "CmD3D9RenderSystem.h"
 #include "CmD3D9RenderSystem.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
 	D3D9MultiRenderTexture::D3D9MultiRenderTexture()
 	D3D9MultiRenderTexture::D3D9MultiRenderTexture()
-		:MultiRenderTexture(), mDepthStencilSurface(nullptr)
+		:MultiRenderTexture(), mDX9DepthStencilSurface(nullptr)
 	{
 	{
 
 
 	}
 	}
@@ -22,24 +21,25 @@ namespace CamelotEngine
 		{
 		{
 			D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(texture.get());
 			D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(texture.get());
 			D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9texture->getBuffer(face, mipLevel).get());
 			D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9texture->getBuffer(face, mipLevel).get());
-			mColorSurfaces[surfaceIdx] = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
+			mDX9ColorSurfaces[surfaceIdx] = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
 		}
 		}
 		else
 		else
 		{
 		{
-			mColorSurfaces[surfaceIdx] = nullptr;
+			mDX9ColorSurfaces[surfaceIdx] = nullptr;
 		}
 		}
 	}
 	}
 
 
-	void D3D9MultiRenderTexture::setDepthStencilImpl(DepthStencilBufferPtr depthStencilBuffer)
+	void D3D9MultiRenderTexture::setDepthStencilImpl(TexturePtr depthStencilSurface)
 	{
 	{
-		if(depthStencilBuffer != nullptr)
+		if(depthStencilSurface != nullptr)
 		{
 		{
-			D3D9DepthStencilBuffer* d3d9DepthStencil = static_cast<D3D9DepthStencilBuffer*>(mDepthStencilBuffer.get());
-			mDepthStencilSurface = d3d9DepthStencil->getSurface();
+			D3D9Texture* d3d9DepthStencil = static_cast<D3D9Texture*>(mDepthStencilSurface.get());
+			D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9DepthStencil->getBuffer(0, 0).get());
+			mDX9DepthStencilSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
 		}
 		}
 		else
 		else
 		{
 		{
-			mDepthStencilSurface = nullptr;
+			mDX9DepthStencilSurface = nullptr;
 		}
 		}
 	}
 	}
 
 
@@ -49,15 +49,15 @@ namespace CamelotEngine
 		{
 		{
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
 
 
-			for(size_t x = 0; x < mColorSurfaces.size(); ++x)							
-				pSurf[x] = mColorSurfaces[x];			
+			for(size_t x = 0; x < mDX9ColorSurfaces.size(); ++x)							
+				pSurf[x] = mDX9ColorSurfaces[x];			
 
 
 			return;
 			return;
 		}
 		}
 		else if(name == "D3DZBUFFER")
 		else if(name == "D3DZBUFFER")
 		{
 		{
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
-			*pSurf = mDepthStencilSurface;
+			*pSurf = mDX9DepthStencilSurface;
 			return;
 			return;
 		}
 		}
 		else if(name == "HWND")
 		else if(name == "HWND")
@@ -70,6 +70,6 @@ namespace CamelotEngine
 
 
 	void D3D9MultiRenderTexture::initialize()
 	void D3D9MultiRenderTexture::initialize()
 	{
 	{
-		mColorSurfaces.resize(CM_MAX_MULTIPLE_RENDER_TARGETS);
+		mDX9ColorSurfaces.resize(CM_MAX_MULTIPLE_RENDER_TARGETS);
 	}
 	}
 }
 }

+ 0 - 3
CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp

@@ -321,9 +321,6 @@ namespace CamelotEngine
 	{	
 	{	
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 
-		// Check for misuse
-		if(mUsage & TU_RENDERTARGET)
-			CM_EXCEPT(RenderingAPIException, "DirectX does not allow locking of or directly writing to RenderTargets. Use blitFromMemory if you need the contents.");		
 		// Set locking flags according to options
 		// Set locking flags according to options
 		DWORD flags = 0;
 		DWORD flags = 0;
 		switch(options)
 		switch(options)

+ 4 - 2
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -1087,8 +1087,8 @@ namespace CamelotEngine
 		// Retrieve render surfaces
 		// Retrieve render surfaces
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 		IDirect3DSurface9** pBack = new IDirect3DSurface9*[maxRenderTargets];
 		IDirect3DSurface9** pBack = new IDirect3DSurface9*[maxRenderTargets];
-		memset(pBack, 0, sizeof(pBack));
-		target->getCustomAttribute( "DDBACKBUFFER", &pBack );
+		memset(pBack, 0, sizeof(IDirect3DSurface9*) * maxRenderTargets);
+		target->getCustomAttribute( "DDBACKBUFFER", pBack );
 		if (!pBack[0])
 		if (!pBack[0])
 		{
 		{
 			delete[] pBack;
 			delete[] pBack;
@@ -2293,6 +2293,8 @@ namespace CamelotEngine
 			DWORD d3dusage = D3DUSAGE_QUERY_FILTER;
 			DWORD d3dusage = D3DUSAGE_QUERY_FILTER;
 			if (usage & TU_RENDERTARGET) 
 			if (usage & TU_RENDERTARGET) 
 				d3dusage |= D3DUSAGE_RENDERTARGET;
 				d3dusage |= D3DUSAGE_RENDERTARGET;
+			if (usage & TU_DEPTHSTENCIL) 
+				d3dusage |= D3DUSAGE_DEPTHSTENCIL;
 			if (usage & TU_DYNAMIC)
 			if (usage & TU_DYNAMIC)
 				d3dusage |= D3DUSAGE_DYNAMIC;
 				d3dusage |= D3DUSAGE_DYNAMIC;
 
 

+ 7 - 7
CamelotD3D9Renderer/Source/CmD3D9RenderTexture.cpp

@@ -2,12 +2,11 @@
 #include "CmD3D9Texture.h"
 #include "CmD3D9Texture.h"
 #include "CmD3D9PixelBuffer.h"
 #include "CmD3D9PixelBuffer.h"
 #include "CmD3D9RenderSystem.h"
 #include "CmD3D9RenderSystem.h"
-#include "CmD3D9DepthStencilBuffer.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
 	D3D9RenderTexture::D3D9RenderTexture()
 	D3D9RenderTexture::D3D9RenderTexture()
-		:mColorSurface(nullptr), mDepthStencilSurface(nullptr)
+		:mDX9ColorSurface(nullptr), mDX9DepthStencilSurface(nullptr)
 	{
 	{
 
 
 	}
 	}
@@ -22,13 +21,13 @@ namespace CamelotEngine
 		if(name == "DDBACKBUFFER")
 		if(name == "DDBACKBUFFER")
 		{
 		{
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
-			*pSurf = mColorSurface;
+			*pSurf = mDX9ColorSurface;
 			return;
 			return;
 		}
 		}
 		else if(name == "D3DZBUFFER")
 		else if(name == "D3DZBUFFER")
 		{
 		{
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
 			IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
-			*pSurf = mDepthStencilSurface;
+			*pSurf = mDX9DepthStencilSurface;
 			return;
 			return;
 		}
 		}
 		else if(name == "HWND")
 		else if(name == "HWND")
@@ -43,9 +42,10 @@ namespace CamelotEngine
 	{
 	{
 		D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(mSurface.texture.get());
 		D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(mSurface.texture.get());
 		D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9texture->getBuffer(mSurface.face, mSurface.mipLevel).get());
 		D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9texture->getBuffer(mSurface.face, mSurface.mipLevel).get());
-		mColorSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
+		mDX9ColorSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
 
 
-		D3D9DepthStencilBuffer* d3d9DepthStencil = static_cast<D3D9DepthStencilBuffer*>(mDepthStencilBuffer.get());
-		mDepthStencilSurface = d3d9DepthStencil->getSurface();
+		D3D9Texture* d3d9DepthStencil = static_cast<D3D9Texture*>(mDepthStencilSurface.get());
+		D3D9PixelBuffer* depthStencilBuffer = static_cast<D3D9PixelBuffer*>(d3d9DepthStencil->getBuffer(0, 0).get());
+		mDX9DepthStencilSurface = depthStencilBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
 	}
 	}
 }
 }

+ 87 - 49
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -85,6 +85,9 @@ namespace CamelotEngine
 		if(mLockedBuffer != nullptr)
 		if(mLockedBuffer != nullptr)
 			CM_EXCEPT(InternalErrorException, "Trying to lock a buffer that's already locked.");
 			CM_EXCEPT(InternalErrorException, "Trying to lock a buffer that's already locked.");
 
 
+		if(getUsage() == TU_DEPTHSTENCIL)
+			CM_EXCEPT(InternalErrorException, "Cannot lock a depth stencil texture.");
+
 		UINT32 mipWidth = mipLevel >> mWidth;
 		UINT32 mipWidth = mipLevel >> mWidth;
 		UINT32 mipHeight = mipLevel >> mHeight;
 		UINT32 mipHeight = mipLevel >> mHeight;
 		UINT32 mipDepth = mipLevel >> mDepth;
 		UINT32 mipDepth = mipLevel >> mDepth;
@@ -221,19 +224,6 @@ namespace CamelotEngine
 
 
 		createInternalResources();
 		createInternalResources();
 
 
-		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
-
-		for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
-		{
-			IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
-
-			if (mUsage & TU_RENDERTARGET)
-			{
-				createInternalResourcesImpl(d3d9Device);
-				return;
-			}	
-		}	
-
 		Resource::initialize_internal();
 		Resource::initialize_internal();
 	}
 	}
 	/****************************************************************************************/
 	/****************************************************************************************/
@@ -275,6 +265,7 @@ namespace CamelotEngine
 		textureResources->pVolumeTex	= NULL;
 		textureResources->pVolumeTex	= NULL;
 		textureResources->pBaseTex		= NULL;
 		textureResources->pBaseTex		= NULL;
 		textureResources->pFSAASurface	= NULL;
 		textureResources->pFSAASurface	= NULL;
+		textureResources->pDepthStencilSurface = NULL;
 
 
 		mMapDeviceToTextureResources[d3d9Device] = textureResources;
 		mMapDeviceToTextureResources[d3d9Device] = textureResources;
 
 
@@ -312,6 +303,7 @@ namespace CamelotEngine
 		SAFE_RELEASE(textureResources->pCubeTex);
 		SAFE_RELEASE(textureResources->pCubeTex);
 		SAFE_RELEASE(textureResources->pVolumeTex);
 		SAFE_RELEASE(textureResources->pVolumeTex);
 		SAFE_RELEASE(textureResources->pFSAASurface);
 		SAFE_RELEASE(textureResources->pFSAASurface);
+		SAFE_RELEASE(textureResources->pDepthStencilSurface);
 	}
 	}
 	/****************************************************************************************/
 	/****************************************************************************************/
 	UINT32 D3D9Texture::calculateSize(void) const
 	UINT32 D3D9Texture::calculateSize(void) const
@@ -389,7 +381,12 @@ namespace CamelotEngine
 		hr = D3DXCheckTextureRequirements(d3d9Device, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckTextureRequirements(d3d9Device, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
-		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
+		DWORD usage = 0;
+		if((mUsage & TU_RENDERTARGET) != 0)
+			usage = D3DUSAGE_RENDERTARGET;
+		else if((mUsage & TU_DEPTHSTENCIL) != 0)
+			usage = D3DUSAGE_DEPTHSTENCIL;
+
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 				D3DX_DEFAULT : mNumMipmaps + 1;
 				D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
 		// Check dynamic textures
@@ -449,63 +446,85 @@ namespace CamelotEngine
 		else
 		else
 			textureResources = allocateTextureResources(d3d9Device);
 			textureResources = allocateTextureResources(d3d9Device);
 
 
-		if ((mUsage & TU_RENDERTARGET) == 0)
+		if ((mUsage & TU_RENDERTARGET) != 0)
 		{
 		{
-			// create the texture
-			hr = D3DXCreateTexture(	
-					d3d9Device,								// device
-					static_cast<UINT>(mWidth),				// width
-					static_cast<UINT>(mHeight),				// height
-					numMips,								// number of mip map levels
-					usage,									// usage
-					d3dPF,									// pixel format
-					mD3DPool,
-					&textureResources->pNormTex);			// data pointer
+			// create AA surface
+			HRESULT hr = d3d9Device->CreateRenderTarget(mWidth, mHeight, d3dPF, 
+				mFSAAType, 
+				mFSAAQuality,
+				TRUE, // TODO - Possible performance issues? Need to check
+				&textureResources->pFSAASurface, NULL);
 
 
-			// check result and except if failed
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				freeInternalResources();
-				CM_EXCEPT(RenderingAPIException, "Error creating texture: " + String(DXGetErrorDescription(hr)));
+				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 
 
-			// set the base texture we'll use in the render system
-			hr = textureResources->pNormTex->QueryInterface(IID_IDirect3DBaseTexture9, (void **)&textureResources->pBaseTex);
+			D3DSURFACE_DESC desc;
+			hr = textureResources->pFSAASurface->GetDesc(&desc);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				freeInternalResources();
 				freeInternalResources();
-				CM_EXCEPT(RenderingAPIException, "Can't get base texture: " + String(DXGetErrorDescription(hr)));
+				CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 
 
-			// set final tex. attributes from tex. description
-			// they may differ from the source image !!!
+			_setFinalAttributes(d3d9Device, textureResources, 
+				desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
+		}
+		else if ((mUsage & TU_DEPTHSTENCIL) != 0)
+		{
+			// create depth stencil surface
+			HRESULT hr = d3d9Device->CreateDepthStencilSurface(mWidth, mHeight, d3dPF, 
+				mFSAAType, 
+				mFSAAQuality,
+				TRUE, // TODO - Possible performance issues? Need to check
+				&textureResources->pDepthStencilSurface, NULL);
+
+			if (FAILED(hr))
+				CM_EXCEPT(RenderingAPIException, "Unable to create depth stencil render target: " + String(DXGetErrorDescription(hr)));
+
 			D3DSURFACE_DESC desc;
 			D3DSURFACE_DESC desc;
-			hr = textureResources->pNormTex->GetLevelDesc(0, &desc);
+			hr = textureResources->pDepthStencilSurface->GetDesc(&desc);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				freeInternalResources();
 				freeInternalResources();
 				CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 				CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 
 
-			_setFinalAttributes(d3d9Device, textureResources, 
-				desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
+			_setFinalAttributes(d3d9Device, textureResources, desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 		}
 		}
 		else
 		else
 		{
 		{
-			// create AA surface
-			HRESULT hr = d3d9Device->CreateRenderTarget(mWidth, mHeight, d3dPF, 
-				mFSAAType, 
-				mFSAAQuality,
-				FALSE, // not lockable
-				&textureResources->pFSAASurface, NULL);
+			// create the texture
+			hr = D3DXCreateTexture(	
+				d3d9Device,								// device
+				static_cast<UINT>(mWidth),				// width
+				static_cast<UINT>(mHeight),				// height
+				numMips,								// number of mip map levels
+				usage,									// usage
+				d3dPF,									// pixel format
+				mD3DPool,
+				&textureResources->pNormTex);			// data pointer
 
 
+			// check result and except if failed
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
+				freeInternalResources();
+				CM_EXCEPT(RenderingAPIException, "Error creating texture: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 
 
+			// set the base texture we'll use in the render system
+			hr = textureResources->pNormTex->QueryInterface(IID_IDirect3DBaseTexture9, (void **)&textureResources->pBaseTex);
+			if (FAILED(hr))
+			{
+				freeInternalResources();
+				CM_EXCEPT(RenderingAPIException, "Can't get base texture: " + String(DXGetErrorDescription(hr)));
+			}
+
+			// set final tex. attributes from tex. description
+			// they may differ from the source image !!!
 			D3DSURFACE_DESC desc;
 			D3DSURFACE_DESC desc;
-			hr = textureResources->pFSAASurface->GetDesc(&desc);
+			hr = textureResources->pNormTex->GetLevelDesc(0, &desc);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				freeInternalResources();
 				freeInternalResources();
@@ -523,9 +542,10 @@ namespace CamelotEngine
 		assert(mWidth > 0 || mHeight > 0);
 		assert(mWidth > 0 || mHeight > 0);
 
 
 		if (mUsage & TU_RENDERTARGET)
 		if (mUsage & TU_RENDERTARGET)
-		{
 			CM_EXCEPT(RenderingAPIException, "D3D9 Cube texture can not be created as render target !!");
 			CM_EXCEPT(RenderingAPIException, "D3D9 Cube texture can not be created as render target !!");
-		}
+
+		if (mUsage & TU_DEPTHSTENCIL)
+			CM_EXCEPT(RenderingAPIException, "D3D9 Cube texture can not be created as a depth stencil target !!");
 
 
 		// determine wich D3D9 pixel format we'll use
 		// determine wich D3D9 pixel format we'll use
 		HRESULT hr;
 		HRESULT hr;
@@ -628,9 +648,10 @@ namespace CamelotEngine
 		assert(mWidth > 0 && mHeight > 0 && mDepth>0);
 		assert(mWidth > 0 && mHeight > 0 && mDepth>0);
 
 
 		if (mUsage & TU_RENDERTARGET)
 		if (mUsage & TU_RENDERTARGET)
-		{
 			CM_EXCEPT(RenderingAPIException, "D3D9 Volume texture can not be created as render target !!");
 			CM_EXCEPT(RenderingAPIException, "D3D9 Volume texture can not be created as render target !!");
-		}
+
+		if (mUsage & TU_DEPTHSTENCIL)
+			CM_EXCEPT(RenderingAPIException, "D3D9 Cube texture can not be created as a depth stencil target !!");
 
 
 		// determine which D3D9 pixel format we'll use
 		// determine which D3D9 pixel format we'll use
 		HRESULT hr;
 		HRESULT hr;
@@ -918,7 +939,10 @@ namespace CamelotEngine
 		{	
 		{	
 			D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 			D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 			
 			
-			return device->getBackBufferFormat();		
+			if((mUsage & TU_DEPTHSTENCIL) != 0)
+				return device->getDepthStencilFormat();
+			else
+				return device->getBackBufferFormat();		
 		}
 		}
 
 
 		// Choose closest supported D3D format as a D3D format
 		// Choose closest supported D3D format as a D3D format
@@ -961,6 +985,10 @@ namespace CamelotEngine
 		{
 		{
 			bufusage |= TU_RENDERTARGET;
 			bufusage |= TU_RENDERTARGET;
 		}
 		}
+		else if(mUsage & TU_DEPTHSTENCIL)
+		{
+			bufusage |= TU_RENDERTARGET;
+		}
 		
 		
 		UINT32 surfaceCount  = static_cast<UINT32>((getNumFaces() * (mNumMipmaps + 1)));
 		UINT32 surfaceCount  = static_cast<UINT32>((getNumFaces() * (mNumMipmaps + 1)));
 		bool updateOldList = mSurfaceList.size() == surfaceCount;
 		bool updateOldList = mSurfaceList.size() == surfaceCount;
@@ -988,6 +1016,16 @@ namespace CamelotEngine
 			currPixelBuffer->bind(d3d9Device, textureResources->pFSAASurface,
 			currPixelBuffer->bind(d3d9Device, textureResources->pFSAASurface,
 				mHwGammaWriteSupported, mFSAA, "PortNoName", textureResources->pBaseTex);
 				mHwGammaWriteSupported, mFSAA, "PortNoName", textureResources->pBaseTex);
 		}
 		}
+		else if((mUsage & TU_DEPTHSTENCIL) != 0)
+		{
+			assert(textureResources->pFSAASurface);
+			assert(getTextureType() == TEX_TYPE_2D);
+
+			D3D9PixelBuffer* currPixelBuffer = GETLEVEL(0, 0);
+
+			currPixelBuffer->bind(d3d9Device, textureResources->pDepthStencilSurface,
+				mHwGammaWriteSupported, mFSAA, "PortNoName", textureResources->pBaseTex);
+		}
 		else
 		else
 		{
 		{
 			switch(getTextureType()) 
 			switch(getTextureType()) 

+ 5 - 7
CamelotD3D9Renderer/Source/CmD3D9TextureManager.cpp

@@ -31,7 +31,6 @@ THE SOFTWARE.
 #include "CmException.h"
 #include "CmException.h"
 #include "CmD3D9Mappings.h"
 #include "CmD3D9Mappings.h"
 #include "CmD3D9RenderSystem.h"
 #include "CmD3D9RenderSystem.h"
-#include "CmD3D9DepthStencilBuffer.h"
 #include "CmD3D9MultiRenderTexture.h"
 #include "CmD3D9MultiRenderTexture.h"
 
 
 namespace CamelotEngine 
 namespace CamelotEngine 
@@ -56,12 +55,6 @@ namespace CamelotEngine
 		return new D3D9RenderTexture();
 		return new D3D9RenderTexture();
 	}
 	}
 
 
-	DepthStencilBufferPtr D3D9TextureManager::createDepthStencilBuffer(DepthStencilFormat format, UINT32 width, 
-		UINT32 height, UINT32 fsaa, const String& fsaaHint)
-	{
-		return DepthStencilBufferPtr(new D3D9DepthStencilBuffer(format, width, height, fsaa, fsaaHint));
-	}
-
 	MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTexture()
 	MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTexture()
 	{
 	{
 		D3D9MultiRenderTexture* newMRT = new D3D9MultiRenderTexture();
 		D3D9MultiRenderTexture* newMRT = new D3D9MultiRenderTexture();
@@ -81,6 +74,11 @@ namespace CamelotEngine
 		if (usage & TU_RENDERTARGET) 
 		if (usage & TU_RENDERTARGET) 
 		{
 		{
 			d3dusage |= D3DUSAGE_RENDERTARGET;
 			d3dusage |= D3DUSAGE_RENDERTARGET;
+			pool = D3DPOOL_DEFAULT; 
+		}
+		if(usage & TU_DEPTHSTENCIL)
+		{
+			d3dusage |= D3DUSAGE_DEPTHSTENCIL;
 			pool = D3DPOOL_DEFAULT;
 			pool = D3DPOOL_DEFAULT;
 		}
 		}
 		if (usage & TU_DYNAMIC)
 		if (usage & TU_DYNAMIC)

+ 1 - 1
CamelotGLRenderer/Source/CmGLMultiRenderTexture.cpp

@@ -39,7 +39,7 @@ namespace CamelotEngine
 	{
 	{
 		if(depthStencilBuffer != nullptr)
 		if(depthStencilBuffer != nullptr)
 		{
 		{
-			GLDepthStencilBuffer* glDepthStencilBuffer = static_cast<GLDepthStencilBuffer*>(mDepthStencilBuffer.get());
+			GLDepthStencilBuffer* glDepthStencilBuffer = static_cast<GLDepthStencilBuffer*>(mDepthStencilSurface.get());
 
 
 			mFB->bindDepthStencil(glDepthStencilBuffer->getGLRenderBuffer());
 			mFB->bindDepthStencil(glDepthStencilBuffer->getGLRenderBuffer());
 		}
 		}

+ 1 - 1
CamelotGLRenderer/Source/CmGLRenderTexture.cpp

@@ -59,7 +59,7 @@ namespace CamelotEngine
 
 
 		mFB->bindSurface(0, surfaceDesc);
 		mFB->bindSurface(0, surfaceDesc);
 
 
-		GLDepthStencilBuffer* glDepthStencilBuffer = static_cast<GLDepthStencilBuffer*>(mDepthStencilBuffer.get());
+		GLDepthStencilBuffer* glDepthStencilBuffer = static_cast<GLDepthStencilBuffer*>(mDepthStencilSurface.get());
 
 
 		mFB->bindDepthStencil(glDepthStencilBuffer->getGLRenderBuffer());
 		mFB->bindDepthStencil(glDepthStencilBuffer->getGLRenderBuffer());
 	}
 	}

+ 0 - 2
CamelotRenderer.sln

@@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotClient", "CamelotCli
 	ProjectSection(ProjectDependencies) = postProject
 	ProjectSection(ProjectDependencies) = postProject
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79} = {122B7A22-0C62-4B35-B661-EBF3F394EA79}
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79} = {122B7A22-0C62-4B35-B661-EBF3F394EA79}
-		{1437BB4E-DDB3-4307-AA41-8C035DA3014B} = {1437BB4E-DDB3-4307-AA41-8C035DA3014B}
-		{F58FF869-2EA6-4FFF-AB84-328C531BA9D9} = {F58FF869-2EA6-4FFF-AB84-328C531BA9D9}
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC} = {08975177-4A13-4EE7-BB21-3BB92FB3F3CC}
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC} = {08975177-4A13-4EE7-BB21-3BB92FB3F3CC}
 		{7F449698-73DF-4203-9F31-0877DBF01695} = {7F449698-73DF-4203-9F31-0877DBF01695}
 		{7F449698-73DF-4203-9F31-0877DBF01695} = {7F449698-73DF-4203-9F31-0877DBF01695}
 		{BFEBBAF8-8A84-4899-8899-D0D7196AF9A1} = {BFEBBAF8-8A84-4899-8899-D0D7196AF9A1}
 		{BFEBBAF8-8A84-4899-8899-D0D7196AF9A1} = {BFEBBAF8-8A84-4899-8899-D0D7196AF9A1}

+ 0 - 2
CamelotRenderer/CamelotRenderer.vcxproj

@@ -188,7 +188,6 @@
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
     <ClInclude Include="Include\CmDeferredRenderContext.h" />
     <ClInclude Include="Include\CmDeferredRenderContext.h" />
-    <ClInclude Include="Include\CmDepthStencilBuffer.h" />
     <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
     <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
     <ClInclude Include="Include\CmDepthStencilState.h" />
     <ClInclude Include="Include\CmDepthStencilState.h" />
     <ClInclude Include="Include\CmGenericBuffer.h" />
     <ClInclude Include="Include\CmGenericBuffer.h" />
@@ -277,7 +276,6 @@
     <ClCompile Include="Source\CmCgProgramFactory.cpp" />
     <ClCompile Include="Source\CmCgProgramFactory.cpp" />
     <ClCompile Include="Source\CmCommandQueue.cpp" />
     <ClCompile Include="Source\CmCommandQueue.cpp" />
     <ClCompile Include="Source\CmDeferredRenderContext.cpp" />
     <ClCompile Include="Source\CmDeferredRenderContext.cpp" />
-    <ClCompile Include="Source\CmDepthStencilBuffer.cpp" />
     <ClCompile Include="Source\CmDepthStencilState.cpp" />
     <ClCompile Include="Source\CmDepthStencilState.cpp" />
     <ClCompile Include="Source\CmGenericBuffer.cpp" />
     <ClCompile Include="Source\CmGenericBuffer.cpp" />
     <ClCompile Include="Source\CmGenericBufferView.cpp" />
     <ClCompile Include="Source\CmGenericBufferView.cpp" />

+ 0 - 6
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -323,9 +323,6 @@
     <ClInclude Include="Include\CmRenderWindowManager.h">
     <ClInclude Include="Include\CmRenderWindowManager.h">
       <Filter>Header Files\RenderSystem</Filter>
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmDepthStencilBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmMultiRenderTexture.h">
     <ClInclude Include="Include\CmMultiRenderTexture.h">
       <Filter>Header Files\RenderSystem</Filter>
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
     </ClInclude>
@@ -514,9 +511,6 @@
     <ClCompile Include="Source\CmRenderWindowManager.cpp">
     <ClCompile Include="Source\CmRenderWindowManager.cpp">
       <Filter>Source Files\RenderSystem</Filter>
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\CmDepthStencilBuffer.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmMultiRenderTexture.cpp">
     <ClCompile Include="Source\CmMultiRenderTexture.cpp">
       <Filter>Source Files\RenderSystem</Filter>
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
     </ClCompile>

+ 0 - 37
CamelotRenderer/Include/CmDepthStencilBuffer.h

@@ -1,37 +0,0 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmPixelData.h"
-
-namespace CamelotEngine
-{
-	class CM_EXPORT DepthStencilBuffer
-	{
-	public:
-		DepthStencilBuffer(DepthStencilFormat format, UINT32 width, UINT32 height, UINT32 fsaa, const String &fsaaHint);
-		virtual ~DepthStencilBuffer();
-
-		DepthStencilFormat getFormat() const { return mFormat; }
-		UINT32 getWidth() const { return mWidth; }
-		UINT32 getHeight() const { return mHeight; }
-		UINT32 getFsaa() const { return mFsaa; }
-		const String& getFsaaHint() const { return mFsaaHint; }
-
-		/** Returns whether the specified RenderTarget is compatible with this DepthBuffer
-			That is, this DepthBuffer can be attached to that RenderTarget
-            @note
-                Most APIs impose the following restrictions:
-				Width & height must be equal or higher than the render target's
-				They must be of the same bit depth.
-				They need to have the same FSAA setting
-        */
-		virtual bool isCompatible(RenderTarget *renderTarget) const;
-
-	protected:
-		DepthStencilFormat			mFormat;
-		UINT32						mWidth;
-		UINT32						mHeight;
-		UINT32						mFsaa;
-		String						mFsaaHint;
-	};
-}

+ 4 - 4
CamelotRenderer/Include/CmMultiRenderTexture.h

@@ -11,22 +11,22 @@ namespace CamelotEngine
 		virtual ~MultiRenderTexture() {}
 		virtual ~MultiRenderTexture() {}
 
 
 		void setColorSurface(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0);
 		void setColorSurface(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0);
-		void setDepthStencil(DepthStencilBufferPtr depthStencilbuffer);
+		void setDepthStencilSurface(TexturePtr depthStencilbuffer);
 
 
 		SurfaceDesc getSurfaceDesc(UINT32 surfaceIdx) const { return mSurfaces.at(surfaceIdx); }
 		SurfaceDesc getSurfaceDesc(UINT32 surfaceIdx) const { return mSurfaces.at(surfaceIdx); }
-		DepthStencilBufferPtr getDepthStencilBuffer() const { return mDepthStencilBuffer; }
+		TexturePtr getDepthStencilSurface() const { return mDepthStencilSurface; }
 
 
 		bool requiresTextureFlipping() const { return false; }
 		bool requiresTextureFlipping() const { return false; }
 
 
 	protected:
 	protected:
 		vector<SurfaceDesc>::type mSurfaces;
 		vector<SurfaceDesc>::type mSurfaces;
-		DepthStencilBufferPtr mDepthStencilBuffer;
+		TexturePtr mDepthStencilSurface;
 
 
 		MultiRenderTexture();
 		MultiRenderTexture();
 		virtual void initialize() {}
 		virtual void initialize() {}
 
 
 		virtual void setColorSurfaceImpl(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0) = 0;
 		virtual void setColorSurfaceImpl(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0) = 0;
-		virtual void setDepthStencilImpl(DepthStencilBufferPtr depthStencilbuffer) = 0;
+		virtual void setDepthStencilImpl(TexturePtr depthStencilstencil) = 0;
 	private:
 	private:
 		void throwIfBuffersDontMatch() const;
 		void throwIfBuffersDontMatch() const;
 
 

+ 0 - 2
CamelotRenderer/Include/CmPrerequisites.h

@@ -112,7 +112,6 @@ namespace CamelotEngine {
     class RenderTexture;
     class RenderTexture;
 	class MultiRenderTexture;
 	class MultiRenderTexture;
     class RenderWindow;
     class RenderWindow;
-	class DepthStencilBuffer;
     class RenderOperation;
     class RenderOperation;
     class StringInterface;
     class StringInterface;
     class SamplerState;
     class SamplerState;
@@ -196,7 +195,6 @@ namespace CamelotEngine
 	typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
 	typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
 	typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
 	typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
 	typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
 	typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
-	typedef std::shared_ptr<DepthStencilBuffer> DepthStencilBufferPtr;
 	typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
 	typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
 	typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
 	typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
 	typedef std::shared_ptr<GpuParams> GpuParamsPtr;
 	typedef std::shared_ptr<GpuParams> GpuParamsPtr;

+ 3 - 4
CamelotRenderer/Include/CmRenderTexture.h

@@ -30,7 +30,6 @@ THE SOFTWARE.
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmTexture.h"
 #include "CmTexture.h"
-#include "CmDepthStencilBuffer.h"
 #include "CmRenderTarget.h"
 #include "CmRenderTarget.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
@@ -52,16 +51,16 @@ namespace CamelotEngine
 		virtual ~RenderTexture() {}
 		virtual ~RenderTexture() {}
 
 
 		void setColorSurface(TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0);
 		void setColorSurface(TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 0, UINT32 mipLevel = 0);
-		void setDepthStencil(DepthStencilBufferPtr depthStencilbuffer);
+		void setDepthStencilSurface(TexturePtr depthStencil);
 
 
 		SurfaceDesc getSurfaceDesc() const { return mSurface; }
 		SurfaceDesc getSurfaceDesc() const { return mSurface; }
-		DepthStencilBufferPtr getDepthStencilBuffer() const { return mDepthStencilBuffer; }
+		TexturePtr getDepthStencilSurface() const { return mDepthStencilSurface; }
 
 
 		bool requiresTextureFlipping() const { return false; }
 		bool requiresTextureFlipping() const { return false; }
 
 
 	protected:
 	protected:
 		SurfaceDesc mSurface;
 		SurfaceDesc mSurface;
-		DepthStencilBufferPtr mDepthStencilBuffer;
+		TexturePtr mDepthStencilSurface;
 
 
 		RenderTexture();
 		RenderTexture();
 
 

+ 1 - 0
CamelotRenderer/Include/CmTexture.h

@@ -49,6 +49,7 @@ namespace CamelotEngine {
 		TU_STATIC = GBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
 		TU_STATIC = GBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
 		TU_DYNAMIC = GBU_DYNAMIC, // Optimal if the texture is updated by CPU often (e.g. every frame)
 		TU_DYNAMIC = GBU_DYNAMIC, // Optimal if the texture is updated by CPU often (e.g. every frame)
 		TU_RENDERTARGET = 0x200, // Used for rendering by the GPU
 		TU_RENDERTARGET = 0x200, // Used for rendering by the GPU
+		TU_DEPTHSTENCIL = 0x400,
 		TU_DEFAULT = TU_STATIC
 		TU_DEFAULT = TU_STATIC
     };
     };
 
 

+ 1 - 7
CamelotRenderer/Include/CmTextureManager.h

@@ -172,19 +172,13 @@ namespace CamelotEngine {
 		 */
 		 */
 		TexturePtr createEmpty();
 		TexturePtr createEmpty();
 
 
-		/**
-		 * @brief	Creates a new depth/stencil buffer.
-		 */
-		virtual DepthStencilBufferPtr createDepthStencilBuffer(DepthStencilFormat format, UINT32 width, 
-			UINT32 height, UINT32 fsaa, const String& fsaaHint) = 0;
-
 		/**
 		/**
 		 * @brief	Creates a new RenderTexture and automatically generates a color surface
 		 * @brief	Creates a new RenderTexture and automatically generates a color surface
 		 * 			and (optionally) a depth/stencil surface
 		 * 			and (optionally) a depth/stencil surface
 		 */
 		 */
 		virtual RenderTexturePtr createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
 		virtual RenderTexturePtr createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
 			PixelFormat format, bool hwGamma, UINT32 fsaa, const String& fsaaHint, 
 			PixelFormat format, bool hwGamma, UINT32 fsaa, const String& fsaaHint, 
-			bool createDepth = true, DepthStencilFormat depthStencilFormat = DFMT_D24S8);
+			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
 
 
 		/**
 		/**
 		 * @brief	Creates an empty RenderTexture. You need to assign color and depth/stencil buffers to
 		 * @brief	Creates an empty RenderTexture. You need to assign color and depth/stencil buffers to

+ 0 - 32
CamelotRenderer/Source/CmDepthStencilBuffer.cpp

@@ -1,32 +0,0 @@
-#include "CmDepthStencilBuffer.h"
-#include "CmRenderTarget.h"
-
-namespace CamelotEngine
-{
-	DepthStencilBuffer::DepthStencilBuffer(DepthStencilFormat format, UINT32 width, UINT32 height, UINT32 fsaa, const String &fsaaHint)
-		: mFormat(format)
-		, mWidth(width)
-		, mHeight(height)
-		, mFsaa(fsaa)
-		, mFsaaHint(fsaaHint)
-	{
-
-	}
-
-	DepthStencilBuffer::~DepthStencilBuffer()
-	{
-
-	}
-
-	bool DepthStencilBuffer::isCompatible(RenderTarget *renderTarget) const
-	{
-		if( this->getWidth() >= renderTarget->getWidth() &&
-			this->getHeight() >= renderTarget->getHeight() &&
-			this->getFsaa() == renderTarget->getFSAA() )
-		{
-			return true;
-		}
-
-		return false;
-	}
-}

+ 18 - 13
CamelotRenderer/Source/CmMultiRenderTexture.cpp

@@ -1,6 +1,5 @@
 #include "CmMultiRenderTexture.h"
 #include "CmMultiRenderTexture.h"
 #include "CmTexture.h"
 #include "CmTexture.h"
-#include "CmDepthStencilBuffer.h"
 #include "CmException.h"
 #include "CmException.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
@@ -15,6 +14,9 @@ namespace CamelotEngine
 		if(surfaceIdx < 0 || surfaceIdx >= CM_MAX_MULTIPLE_RENDER_TARGETS)
 		if(surfaceIdx < 0 || surfaceIdx >= CM_MAX_MULTIPLE_RENDER_TARGETS)
 			CM_EXCEPT(InvalidParametersException, "Invalid surface index. 0 <= " + toString(surfaceIdx) + " < CM_MAX_MULTIPLE_RENDER_TARGETS");
 			CM_EXCEPT(InvalidParametersException, "Invalid surface index. 0 <= " + toString(surfaceIdx) + " < CM_MAX_MULTIPLE_RENDER_TARGETS");
 
 
+		if(texture != nullptr && texture->getUsage() != TU_RENDERTARGET)
+			CM_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
+
 		mSurfaces[surfaceIdx].texture = texture;
 		mSurfaces[surfaceIdx].texture = texture;
 
 
 		if(texture == nullptr)
 		if(texture == nullptr)
@@ -43,13 +45,16 @@ namespace CamelotEngine
 		setColorSurfaceImpl(surfaceIdx, texture, face, numFaces, mipLevel);
 		setColorSurfaceImpl(surfaceIdx, texture, face, numFaces, mipLevel);
 	}
 	}
 
 
-	void MultiRenderTexture::setDepthStencil(DepthStencilBufferPtr depthStencilBuffer)
+	void MultiRenderTexture::setDepthStencilSurface(TexturePtr depthStencilSurface)
 	{
 	{
-		mDepthStencilBuffer = depthStencilBuffer;
+		if(depthStencilSurface != nullptr && depthStencilSurface->getUsage() != TU_DEPTHSTENCIL)
+			CM_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
+
+		mDepthStencilSurface = depthStencilSurface;
 
 
 		throwIfBuffersDontMatch();
 		throwIfBuffersDontMatch();
 
 
-		setDepthStencilImpl(depthStencilBuffer);
+		setDepthStencilImpl(depthStencilSurface);
 	}
 	}
 
 
 	void MultiRenderTexture::throwIfBuffersDontMatch() const
 	void MultiRenderTexture::throwIfBuffersDontMatch() const
@@ -98,18 +103,18 @@ namespace CamelotEngine
 				toString(firstSurfaceDesc->mipLevel) + ". Max num mipmaps: " + toString(firstSurfaceDesc->texture->getNumMipmaps()));
 				toString(firstSurfaceDesc->mipLevel) + ". Max num mipmaps: " + toString(firstSurfaceDesc->texture->getNumMipmaps()));
 		}
 		}
 
 
-		if(mDepthStencilBuffer == nullptr)
+		if(mDepthStencilSurface == nullptr)
 			return;
 			return;
 
 
-		if(mDepthStencilBuffer->getWidth() != firstSurfaceDesc->texture->getWidth() ||
-			mDepthStencilBuffer->getHeight() != firstSurfaceDesc->texture->getHeight() ||
-			mDepthStencilBuffer->getFsaa() != firstSurfaceDesc->texture->getFSAA() ||
-			mDepthStencilBuffer->getFsaaHint() != firstSurfaceDesc->texture->getFSAAHint())
+		if(mDepthStencilSurface->getWidth() != firstSurfaceDesc->texture->getWidth() ||
+			mDepthStencilSurface->getHeight() != firstSurfaceDesc->texture->getHeight() ||
+			mDepthStencilSurface->getFSAA() != firstSurfaceDesc->texture->getFSAA() ||
+			mDepthStencilSurface->getFSAAHint() != firstSurfaceDesc->texture->getFSAAHint())
 		{
 		{
-			String errorInfo = "\nWidth: " + toString(mDepthStencilBuffer->getWidth()) + "/" + toString(firstSurfaceDesc->texture->getWidth());
-			errorInfo += "\nHeight: " + toString(mDepthStencilBuffer->getHeight()) + "/" + toString(firstSurfaceDesc->texture->getHeight());
-			errorInfo += "\nFSAA: " + toString(mDepthStencilBuffer->getFsaa()) + "/" + toString(firstSurfaceDesc->texture->getFSAA());
-			errorInfo += "\nFSAAHint: " + mDepthStencilBuffer->getFsaaHint() + "/" + firstSurfaceDesc->texture->getFSAAHint();
+			String errorInfo = "\nWidth: " + toString(mDepthStencilSurface->getWidth()) + "/" + toString(firstSurfaceDesc->texture->getWidth());
+			errorInfo += "\nHeight: " + toString(mDepthStencilSurface->getHeight()) + "/" + toString(firstSurfaceDesc->texture->getHeight());
+			errorInfo += "\nFSAA: " + toString(mDepthStencilSurface->getFSAA()) + "/" + toString(firstSurfaceDesc->texture->getFSAA());
+			errorInfo += "\nFSAAHint: " + mDepthStencilSurface->getFSAAHint() + "/" + firstSurfaceDesc->texture->getFSAAHint();
 
 
 			CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
 			CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
 		}
 		}

+ 20 - 15
CamelotRenderer/Source/CmRenderTexture.cpp

@@ -31,7 +31,6 @@ THE SOFTWARE.
 #include "CmPixelBuffer.h"
 #include "CmPixelBuffer.h"
 #include "CmTexture.h"
 #include "CmTexture.h"
 #include "CmTextureManager.h"
 #include "CmTextureManager.h"
-#include "CmDepthStencilBuffer.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -64,6 +63,9 @@ namespace CamelotEngine
 
 
 	void RenderTexture::setColorSurface(TexturePtr texture, UINT32 face, UINT32 numFaces, UINT32 mipLevel)
 	void RenderTexture::setColorSurface(TexturePtr texture, UINT32 face, UINT32 numFaces, UINT32 mipLevel)
 	{
 	{
+		if(texture != nullptr && texture->getUsage() != TU_RENDERTARGET)
+			CM_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
+
 		mSurface.texture = texture;
 		mSurface.texture = texture;
 
 
 		if(mSurface.texture == nullptr)
 		if(mSurface.texture == nullptr)
@@ -86,37 +88,40 @@ namespace CamelotEngine
 		
 		
 		throwIfBuffersDontMatch();
 		throwIfBuffersDontMatch();
 
 
-		if(mDepthStencilBuffer != nullptr && mSurface.texture != nullptr)
+		if(mDepthStencilSurface != nullptr && mSurface.texture != nullptr)
 			createInternalResourcesImpl();
 			createInternalResourcesImpl();
 	}
 	}
 
 
-	void RenderTexture::setDepthStencil(DepthStencilBufferPtr depthStencilBuffer)
+	void RenderTexture::setDepthStencilSurface(TexturePtr depthStencilSurface)
 	{
 	{
-		mDepthStencilBuffer = depthStencilBuffer;
+		if(depthStencilSurface != nullptr && depthStencilSurface->getUsage() != TU_DEPTHSTENCIL)
+			CM_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
+
+		mDepthStencilSurface = depthStencilSurface;
 
 
-		if(mDepthStencilBuffer == nullptr)
+		if(mDepthStencilSurface == nullptr)
 			return;
 			return;
 
 
 		throwIfBuffersDontMatch();
 		throwIfBuffersDontMatch();
 
 
-		if(mDepthStencilBuffer != nullptr && mSurface.texture != nullptr)
+		if(mDepthStencilSurface != nullptr && mSurface.texture != nullptr)
 			createInternalResourcesImpl();
 			createInternalResourcesImpl();
 	}
 	}
 
 
 	void RenderTexture::throwIfBuffersDontMatch() const
 	void RenderTexture::throwIfBuffersDontMatch() const
 	{
 	{
-		if(mSurface.texture == nullptr || mDepthStencilBuffer == nullptr)
+		if(mSurface.texture == nullptr || mDepthStencilSurface == nullptr)
 			return;
 			return;
 
 
-		if(mSurface.texture->getWidth() != mDepthStencilBuffer->getWidth() ||
-			mSurface.texture->getHeight() != mDepthStencilBuffer->getHeight() ||
-			mSurface.texture->getFSAA() != mDepthStencilBuffer->getFsaa() ||
-			mSurface.texture->getFSAAHint() != mDepthStencilBuffer->getFsaaHint())
+		if(mSurface.texture->getWidth() != mDepthStencilSurface->getWidth() ||
+			mSurface.texture->getHeight() != mDepthStencilSurface->getHeight() ||
+			mSurface.texture->getFSAA() != mDepthStencilSurface->getFSAA() ||
+			mSurface.texture->getFSAAHint() != mDepthStencilSurface->getFSAAHint())
 		{
 		{
-			String errorInfo = "\nWidth: " + toString(mSurface.texture->getWidth()) + "/" + toString(mDepthStencilBuffer->getWidth());
-			errorInfo += "\nHeight: " + toString(mSurface.texture->getHeight()) + "/" + toString(mDepthStencilBuffer->getHeight());
-			errorInfo += "\nFSAA: " + toString(mSurface.texture->getFSAA()) + "/" + toString(mDepthStencilBuffer->getFsaa());
-			errorInfo += "\nFSAAHint: " + mSurface.texture->getFSAAHint() + "/" + mDepthStencilBuffer->getFsaaHint();
+			String errorInfo = "\nWidth: " + toString(mSurface.texture->getWidth()) + "/" + toString(mDepthStencilSurface->getWidth());
+			errorInfo += "\nHeight: " + toString(mSurface.texture->getHeight()) + "/" + toString(mDepthStencilSurface->getHeight());
+			errorInfo += "\nFSAA: " + toString(mSurface.texture->getFSAA()) + "/" + toString(mDepthStencilSurface->getFSAA());
+			errorInfo += "\nFSAAHint: " + mSurface.texture->getFSAAHint() + "/" + mDepthStencilSurface->getFSAAHint();
 
 
 			CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
 			CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
 		}
 		}

+ 4 - 4
CamelotRenderer/Source/CmTextureManager.cpp

@@ -71,17 +71,17 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	RenderTexturePtr TextureManager::createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
 	RenderTexturePtr TextureManager::createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
 			PixelFormat format, bool hwGamma, UINT32 fsaa, const String& fsaaHint, 
 			PixelFormat format, bool hwGamma, UINT32 fsaa, const String& fsaaHint, 
-			bool createDepth, DepthStencilFormat depthStencilFormat)
+			bool createDepth, PixelFormat depthStencilFormat)
 	{
 	{
 		TexturePtr texture = createTexture(textureType, width, height, 0, format, TU_RENDERTARGET, hwGamma, fsaa, fsaaHint);
 		TexturePtr texture = createTexture(textureType, width, height, 0, format, TU_RENDERTARGET, hwGamma, fsaa, fsaaHint);
 
 
-		DepthStencilBufferPtr depthStencilBuffer = nullptr;
+		TexturePtr depthStencil = nullptr;
 		if(createDepth)
 		if(createDepth)
-			depthStencilBuffer = TextureManager::instance().createDepthStencilBuffer(depthStencilFormat, width, height, fsaa, fsaaHint);
+			depthStencil = createTexture(TEX_TYPE_2D, width, height, 0, depthStencilFormat, TU_DEPTHSTENCIL, false, fsaa, fsaaHint);
 
 
 		RenderTexturePtr newRT = RenderTexturePtr(createRenderTextureImpl());
 		RenderTexturePtr newRT = RenderTexturePtr(createRenderTextureImpl());
 		newRT->setColorSurface(texture, 0, 1, 0);
 		newRT->setColorSurface(texture, 0, 1, 0);
-		newRT->setDepthStencil(depthStencilBuffer);
+		newRT->setDepthStencilSurface(depthStencil);
 
 
 		return newRT;
 		return newRT;
 	}
 	}

+ 0 - 15
CamelotRenderer/TODO.txt

@@ -14,14 +14,10 @@
 
 
 
 
 >>>>>>>>>>FINAL SPRINT BEFORE EDITOR WORK
 >>>>>>>>>>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
 Once I get DX11 running make sure to test if driver complains about missing shader attributes or invalid size ones
 delete d3d11 vertex declaration
 delete d3d11 vertex declaration
  Working generic buffers
  Working generic buffers
  A way to bind buffers to a Pass, while specifying buffer range
  A way to bind buffers to a Pass, while specifying buffer range
- Fully implement DX11
  Better creation of PrimaryWindow
  Better creation of PrimaryWindow
   - RENDERWINDOWDESC accepts a "externalWindow" flag and an "externalHandle" so when creating the primary window with RenderSystem::initialize we don't always need to create a new window
   - RENDERWINDOWDESC accepts a "externalWindow" flag and an "externalHandle" so when creating the primary window with RenderSystem::initialize we don't always need to create a new window
   - Actually new OpenGL seems to support creating context without a window with the help of wglCreateContextAttribsARB and wglMakeCurrent:
   - Actually new OpenGL seems to support creating context without a window with the help of wglCreateContextAttribsARB and wglMakeCurrent:
@@ -64,17 +60,6 @@ delete d3d11 vertex declaration
     - Actually destroys the resource and sets isDestroyed flag to true
     - Actually destroys the resource and sets isDestroyed flag to true
     - Reference to the empty texture continues to exist but render system need to check if its destroyed before it tries to use it
     - Reference to the empty texture continues to exist but render system need to check if its destroyed before it tries to use it
 
 
-<<<<Binding input layout:>>>
- Upon call to draw()
- Create or retrieve existing layout based on current set vertex shader and vertex buffer
-  (combine their input declarations into a new one, matching their semantics)
-  Use hash from input declarations to quickly find the combined one
- Vertex buffer is almost certainly allowed to have more values than the input layout specifies
- What about less values? If shader requests a field that isn't available?
-  - Test if DX11 supplies default values for the missing field
-  - If not, then throw an error if a value is missing
-    - And adjust DX9 and GL implementations accordingly
-
 <<<<Handle multithreaded object management>>>:
 <<<<Handle multithreaded object management>>>:
  - Make everything that is possible immutable. Once created it cant be changed.
  - Make everything that is possible immutable. Once created it cant be changed.
   - Example are shaders, state objects and similar
   - Example are shaders, state objects and similar

+ 9 - 12
CamelotUtility/Include/CmPixelData.h

@@ -117,8 +117,16 @@ namespace CamelotEngine
         PF_PVRTC_RGB4 = 40,
         PF_PVRTC_RGB4 = 40,
         /// PVRTC (PowerVR) RGBA 4 bpp
         /// PVRTC (PowerVR) RGBA 4 bpp
         PF_PVRTC_RGBA4 = 41,
         PF_PVRTC_RGBA4 = 41,
+		// Depth stencil, 32bit depth, 8bit stencil + 24 unused
+		PF_D32_S8X24 = 42,
+		// Depth stencil, 24bit depth + 8bit stencil
+		PF_D24S8 = 43,
+		// Depth, 32bits
+		PF_D32 = 44,
+		// Depth, 16bits
+		PF_D16 = 45,
 		// Number of pixel formats currently defined
 		// Number of pixel formats currently defined
-        PF_COUNT = 42
+        PF_COUNT = 46
     };
     };
 	typedef vector<PixelFormat>::type PixelFormatList;
 	typedef vector<PixelFormat>::type PixelFormatList;
 
 
@@ -152,17 +160,6 @@ namespace CamelotEngine
         PCT_FLOAT32 = 3, /// 32 bit float per component
         PCT_FLOAT32 = 3, /// 32 bit float per component
         PCT_COUNT = 4    /// Number of pixel types
         PCT_COUNT = 4    /// Number of pixel types
     };
     };
-
-	/**
-	 * @brief	Available formats for depth/stencil buffer
-	 */
-	enum DepthStencilFormat
-	{
-		DFMT_D32_S8X24,
-		DFMT_D24S8,
-		DFMT_D32,
-		DFMT_D16
-	};
     
     
 	/** A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
 	/** A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
      	In case of a rectangle, depth must be 1. 
      	In case of a rectangle, depth must be 1. 

+ 52 - 1
CamelotUtility/Source/CmPixelUtil.cpp

@@ -933,7 +933,58 @@ namespace CamelotEngine {
         /* Masks and shifts */
         /* Masks and shifts */
         0, 0, 0, 0, 0, 0, 0, 0
         0, 0, 0, 0, 0, 0, 0, 0
         },
         },
-        
+	//-----------------------------------------------------------------------
+		{"PF_D32_S8X24",
+		/* Bytes per element */
+		4,
+		/* Flags */
+		PFF_DEPTH | PFF_FLOAT,
+		/* Component type and count */
+		PCT_FLOAT32, 1,
+		/* rbits, gbits, bbits, abits */
+		0, 0, 0, 0,
+		/* Masks and shifts */
+		0, 0, 0, 0, 0, 0, 0, 0
+		}, 
+	//-----------------------------------------------------------------------
+		{"PF_D24_S8",
+		/* Bytes per element */
+		8,
+		/* Flags */
+		PFF_DEPTH | PFF_FLOAT,
+		/* Component type and count */
+		PCT_FLOAT32, 2,
+		/* rbits, gbits, bbits, abits */
+		0, 0, 0, 0,
+		/* Masks and shifts */
+		0, 0, 0, 0, 0, 0, 0, 0
+		}, 
+	//-----------------------------------------------------------------------
+		{"PF_D32",
+		/* Bytes per element */
+		4,
+		/* Flags */
+		PFF_DEPTH | PFF_FLOAT,
+		/* Component type and count */
+		PCT_FLOAT32, 1,
+		/* rbits, gbits, bbits, abits */
+		0, 0, 0, 0,
+		/* Masks and shifts */
+		0, 0, 0, 0, 0, 0, 0, 0
+		}, 
+	//-----------------------------------------------------------------------
+		{"PF_D16",
+		/* Bytes per element */
+		2,
+		/* Flags */
+		PFF_DEPTH | PFF_FLOAT,
+		/* Component type and count */
+		PCT_FLOAT16, 1,
+		/* rbits, gbits, bbits, abits */
+		0, 0, 0, 0,
+		/* Masks and shifts */
+		0, 0, 0, 0, 0, 0, 0, 0
+		}, 
     };
     };
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	UINT32 PixelData::getConsecutiveSize() const
 	UINT32 PixelData::getConsecutiveSize() const