Browse Source

Removed the old way of RenderTexture handling

Marko Pintera 13 years ago
parent
commit
356b07673e

+ 0 - 15
CamelotD3D9Renderer/Include/CmD3D9HardwarePixelBuffer.h

@@ -63,19 +63,12 @@ namespace CamelotEngine {
 		/// Function to set mipmap generation
 		void _setMipmapping(bool doMipmapGen, bool HWMipmaps);
 
-
-		/// Get rendertarget for z slice
-		RenderTexture *getRenderTarget(UINT32 zoffset);
-
 		/// Accessor for surface
 		IDirect3DSurface9 *getSurface(IDirect3DDevice9* d3d9Device);
 
 		/// Accessor for AA surface
 		IDirect3DSurface9 *getFSAASurface(IDirect3DDevice9* d3d9Device);
 
-		/// Notify TextureBuffer of destruction of render target
-		virtual void _clearSliceRTT(UINT32 zoffset);
-
 		/// Release surfaces held by this pixel buffer.
 		void releaseSurfaces(IDirect3DDevice9* d3d9Device);
 
@@ -115,9 +108,6 @@ namespace CamelotEngine {
 		/// Mipmapping
 		bool mDoMipmapGen;
 		bool mHWMipmaps;
-		
-		/// Render target
-		D3D9RenderTexture* mRenderTexture;
 
 		// The owner texture if exists.
 		D3D9Texture* mOwnerTexture;
@@ -138,11 +128,6 @@ namespace CamelotEngine {
 
 		BufferResources* getBufferResources(IDirect3DDevice9* d3d9Device);
 		BufferResources* createBufferResources();
-	
-		/// updates render texture.
-		void updateRenderTexture(bool writeGamma, UINT32 fsaa, const String& srcName);
-		/// destroy render texture.
-		void destroyRenderTexture();
 
 		void blit(IDirect3DDevice9* d3d9Device, const HardwarePixelBufferPtr &src,
 				const Box &srcBox, const Box &dstBox, 

+ 1 - 9
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -86,9 +86,7 @@ namespace CamelotEngine {
 			/// Volume texture
 			IDirect3DVolumeTexture9* pVolumeTex;
 			/// actual texture pointer
-			IDirect3DBaseTexture9* pBaseTex;
-			/// Optional FSAA surface
-			IDirect3DSurface9* pFSAASurface;			
+			IDirect3DBaseTexture9* pBaseTex;		
 		};
 		
 		typedef map<IDirect3DDevice9*, TextureResources*>::type	DeviceToTextureResourcesMap;
@@ -111,10 +109,6 @@ namespace CamelotEngine {
 
 		/// Is hardware gamma supported (read)?
 		bool mHwGammaReadSupported;
-		/// Is hardware gamma supported (write)?
-		bool mHwGammaWriteSupported;
-		D3DMULTISAMPLE_TYPE mFSAAType;
-		DWORD mFSAAQuality;
 
 		D3D9Texture();
 
@@ -211,9 +205,7 @@ namespace CamelotEngine {
 
 		/// Override needed to deal with FSAA
 		void swapBuffers(bool waitForVSync = true);
-
 	};
-
 }
 
 #endif

+ 714 - 761
CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp

@@ -32,926 +32,879 @@ THE SOFTWARE.
 #include "CmBitwise.h"
 #include "CmRenderSystem.h"
 
-namespace CamelotEngine {
-
-CM_STATIC_MUTEX_INSTANCE(D3D9HardwarePixelBuffer::msDeviceAccessMutex)
-//-----------------------------------------------------------------------------  
-
-D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
-												 D3D9Texture* ownerTexture):
-	HardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage, false),
-	mDoMipmapGen(0), mHWMipmaps(0), mOwnerTexture(ownerTexture), 
-	mRenderTexture(NULL)
-{	
-}
-D3D9HardwarePixelBuffer::~D3D9HardwarePixelBuffer()
+namespace CamelotEngine 
 {
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+	CM_STATIC_MUTEX_INSTANCE(D3D9HardwarePixelBuffer::msDeviceAccessMutex)
+	//-----------------------------------------------------------------------------  
 
-	destroyRenderTexture();
-	
-	DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
-
-	while (it != mMapDeviceToBufferResources.end())
-	{
-		SAFE_RELEASE(it->second->surface);
-		SAFE_RELEASE(it->second->volume);
-		SAFE_DELETE(it->second);
-		DeviceToBufferResourcesIterator deadi = it++;
-		mMapDeviceToBufferResources.erase(deadi);
+	D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
+													 D3D9Texture* ownerTexture):
+		HardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage, false),
+		mDoMipmapGen(0), mHWMipmaps(0), mOwnerTexture(ownerTexture)
+	{	
 	}
-}
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *surface, 
-								   IDirect3DSurface9* fsaaSurface,
-								   bool writeGamma, UINT32 fsaa, const String& srcName,
-								   IDirect3DBaseTexture9 *mipTex)
-{
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
-
-	BufferResources* bufferResources = getBufferResources(dev);
-	bool isNewBuffer = false;
-
-	if (bufferResources == NULL)
+	D3D9HardwarePixelBuffer::~D3D9HardwarePixelBuffer()
 	{
-		bufferResources = createBufferResources();		
-		mMapDeviceToBufferResources[dev] = bufferResources;
-		isNewBuffer = true;
-	}
-		
-	bufferResources->mipTex = mipTex;
-	bufferResources->surface = surface;
-	bufferResources->surface->AddRef();
-	bufferResources->fSAASurface = fsaaSurface;
-
-	D3DSURFACE_DESC desc;
-	if(surface->GetDesc(&desc) != D3D_OK)
-		CM_EXCEPT(RenderingAPIException, "Could not get surface information");
-
-	mWidth = desc.Width;
-	mHeight = desc.Height;
-	mDepth = 1;
-	mFormat = D3D9Mappings::_getPF(desc.Format);
-	// Default
-	mRowPitch = mWidth;
-	mSlicePitch = mHeight*mWidth;
-	mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);	
-	
-	if(mUsage & TU_RENDERTARGET)
-		updateRenderTexture(writeGamma, fsaa, srcName);
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-	// TODO PORT - My Texture doesn't inherit from Resource and doesn't have that method. Not sure why it needs to call it,
-	// but since we're not there's potential for trouble here.
-	if (isNewBuffer /*&& mOwnerTexture->isManuallyLoaded()*/)
-	{
 		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 
 		while (it != mMapDeviceToBufferResources.end())
 		{
-			if (it->second != bufferResources && 
-				it->second->surface != NULL &&
-				it->first->TestCooperativeLevel() == D3D_OK &&
-				dev->TestCooperativeLevel() == D3D_OK)
-			{
-				Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
-				PixelData dstBox(fullBufferBox, mFormat);
-
-				dstBox.data = new char[getSizeInBytes()];
-				blitToMemory(fullBufferBox, dstBox, it->second, it->first);
-				blitFromMemory(dstBox, fullBufferBox, bufferResources);
-				SAFE_DELETE_ARRAY(dstBox.data);
-				break;
-			}
-			++it;			
-		}				
+			SAFE_RELEASE(it->second->surface);
+			SAFE_RELEASE(it->second->volume);
+			SAFE_DELETE(it->second);
+			DeviceToBufferResourcesIterator deadi = it++;
+			mMapDeviceToBufferResources.erase(deadi);
+		}
 	}
-}
-//-----------------------------------------------------------------------------
-void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *volume, IDirect3DBaseTexture9 *mipTex)
-{
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *surface, 
+									   IDirect3DSurface9* fsaaSurface,
+									   bool writeGamma, UINT32 fsaa, const String& srcName,
+									   IDirect3DBaseTexture9 *mipTex)
+	{
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-	BufferResources* bufferResources = getBufferResources(dev);
-	bool isNewBuffer = false;
+		BufferResources* bufferResources = getBufferResources(dev);
+		bool isNewBuffer = false;
 
-	if (bufferResources == NULL)
-	{
-		bufferResources = createBufferResources();
-		mMapDeviceToBufferResources[dev] = bufferResources;
-		isNewBuffer = true;
-	}
+		if (bufferResources == NULL)
+		{
+			bufferResources = createBufferResources();		
+			mMapDeviceToBufferResources[dev] = bufferResources;
+			isNewBuffer = true;
+		}
+		
+		bufferResources->mipTex = mipTex;
+		bufferResources->surface = surface;
+		bufferResources->surface->AddRef();
+		bufferResources->fSAASurface = fsaaSurface;
+
+		D3DSURFACE_DESC desc;
+		if(surface->GetDesc(&desc) != D3D_OK)
+			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
 
-	bufferResources->mipTex = mipTex;
-	bufferResources->volume = volume;
-	bufferResources->volume->AddRef();
+		mWidth = desc.Width;
+		mHeight = desc.Height;
+		mDepth = 1;
+		mFormat = D3D9Mappings::_getPF(desc.Format);
+		// Default
+		mRowPitch = mWidth;
+		mSlicePitch = mHeight*mWidth;
+		mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);	
 	
-	D3DVOLUME_DESC desc;
-	if(volume->GetDesc(&desc) != D3D_OK)
-		CM_EXCEPT(RenderingAPIException, "Could not get volume information");
-	mWidth = desc.Width;
-	mHeight = desc.Height;
-	mDepth = desc.Depth;
-	mFormat = D3D9Mappings::_getPF(desc.Format);
-	// Default
-	mRowPitch = mWidth;
-	mSlicePitch = mHeight*mWidth;
-	mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
-
-	// TODO PORT - My Texture doesn't inherit from Resource and doesn't have that method. Not sure why it needs to call it,
-	// but since we're not there's potential for trouble here.
-	if (isNewBuffer /*&& mOwnerTexture->isManuallyLoaded()*/)
-	{
-		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
-		
-		while (it != mMapDeviceToBufferResources.end())
+		if (isNewBuffer)
 		{
-			if (it->second != bufferResources &&
-				it->second->volume != NULL &&
-				it->first->TestCooperativeLevel() == D3D_OK &&
-				dev->TestCooperativeLevel() == D3D_OK)
+			DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
+
+			while (it != mMapDeviceToBufferResources.end())
 			{
-				Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
-				PixelData dstBox(fullBufferBox, mFormat);
-
-				dstBox.data = new char[getSizeInBytes()];
-				blitToMemory(fullBufferBox, dstBox, it->second, it->first);
-				blitFromMemory(dstBox, fullBufferBox, bufferResources);
-				SAFE_DELETE(dstBox.data);
-				break;
-			}
-			++it;			
-		}				
+				if (it->second != bufferResources && 
+					it->second->surface != NULL &&
+					it->first->TestCooperativeLevel() == D3D_OK &&
+					dev->TestCooperativeLevel() == D3D_OK)
+				{
+					Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
+					PixelData dstBox(fullBufferBox, mFormat);
+
+					dstBox.data = new char[getSizeInBytes()];
+					blitToMemory(fullBufferBox, dstBox, it->second, it->first);
+					blitFromMemory(dstBox, fullBufferBox, bufferResources);
+					SAFE_DELETE_ARRAY(dstBox.data);
+					break;
+				}
+				++it;			
+			}				
+		}
 	}
-}
+	//-----------------------------------------------------------------------------
+	void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *volume, IDirect3DBaseTexture9 *mipTex)
+	{
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-//-----------------------------------------------------------------------------  
-D3D9HardwarePixelBuffer::BufferResources* D3D9HardwarePixelBuffer::getBufferResources(IDirect3DDevice9* d3d9Device)
-{
-	DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.find(d3d9Device);
+		BufferResources* bufferResources = getBufferResources(dev);
+		bool isNewBuffer = false;
 
-	if (it != mMapDeviceToBufferResources.end())	
-		return it->second;
-	
-	return NULL;
-}
+		if (bufferResources == NULL)
+		{
+			bufferResources = createBufferResources();
+			mMapDeviceToBufferResources[dev] = bufferResources;
+			isNewBuffer = true;
+		}
 
-//-----------------------------------------------------------------------------  
-D3D9HardwarePixelBuffer::BufferResources* D3D9HardwarePixelBuffer::createBufferResources()
-{
-	BufferResources* newResources = new BufferResources;
+		bufferResources->mipTex = mipTex;
+		bufferResources->volume = volume;
+		bufferResources->volume->AddRef();
+	
+		D3DVOLUME_DESC desc;
+		if(volume->GetDesc(&desc) != D3D_OK)
+			CM_EXCEPT(RenderingAPIException, "Could not get volume information");
+		mWidth = desc.Width;
+		mHeight = desc.Height;
+		mDepth = desc.Depth;
+		mFormat = D3D9Mappings::_getPF(desc.Format);
+		// Default
+		mRowPitch = mWidth;
+		mSlicePitch = mHeight*mWidth;
+		mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
+
+		// TODO PORT - My Texture doesn't inherit from Resource and doesn't have that method. Not sure why it needs to call it,
+		// but since we're not there's potential for trouble here.
+		if (isNewBuffer /*&& mOwnerTexture->isManuallyLoaded()*/)
+		{
+			DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
+		
+			while (it != mMapDeviceToBufferResources.end())
+			{
+				if (it->second != bufferResources &&
+					it->second->volume != NULL &&
+					it->first->TestCooperativeLevel() == D3D_OK &&
+					dev->TestCooperativeLevel() == D3D_OK)
+				{
+					Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
+					PixelData dstBox(fullBufferBox, mFormat);
+
+					dstBox.data = new char[getSizeInBytes()];
+					blitToMemory(fullBufferBox, dstBox, it->second, it->first);
+					blitFromMemory(dstBox, fullBufferBox, bufferResources);
+					SAFE_DELETE(dstBox.data);
+					break;
+				}
+				++it;			
+			}				
+		}
+	}
 
-	memset(newResources, 0, sizeof(BufferResources));
+	//-----------------------------------------------------------------------------  
+	D3D9HardwarePixelBuffer::BufferResources* D3D9HardwarePixelBuffer::getBufferResources(IDirect3DDevice9* d3d9Device)
+	{
+		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.find(d3d9Device);
 
-	return newResources;
-}
+		if (it != mMapDeviceToBufferResources.end())	
+			return it->second;
+	
+		return NULL;
+	}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::destroyBufferResources(IDirect3DDevice9* d3d9Device)
-{
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+	//-----------------------------------------------------------------------------  
+	D3D9HardwarePixelBuffer::BufferResources* D3D9HardwarePixelBuffer::createBufferResources()
+	{
+		BufferResources* newResources = new BufferResources;
 
-	DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.find(d3d9Device);
+		memset(newResources, 0, sizeof(BufferResources));
 
-	if (it != mMapDeviceToBufferResources.end())
-	{
-		SAFE_RELEASE(it->second->surface);
-		SAFE_RELEASE(it->second->volume);	
-		SAFE_DELETE(it->second);
-		mMapDeviceToBufferResources.erase(it);
+		return newResources;
 	}
-}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::lockDeviceAccess()
-{
-	D3D9_DEVICE_ACCESS_LOCK;			
-}
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::destroyBufferResources(IDirect3DDevice9* d3d9Device)
+	{
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::unlockDeviceAccess()
-{
-	D3D9_DEVICE_ACCESS_UNLOCK;								
-}
+		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.find(d3d9Device);
 
-//-----------------------------------------------------------------------------  
-// Util functions to convert a D3D locked box to a pixel box
-void fromD3DLock(PixelData &rval, const D3DLOCKED_RECT &lrect)
-{
-	UINT32 bpp = PixelUtil::getNumElemBytes(rval.format);
-	if (bpp != 0)
-	{
-		rval.rowPitch = lrect.Pitch / bpp;
-		rval.slicePitch = rval.rowPitch * rval.getHeight();
-		assert((lrect.Pitch % bpp)==0);
+		if (it != mMapDeviceToBufferResources.end())
+		{
+			SAFE_RELEASE(it->second->surface);
+			SAFE_RELEASE(it->second->volume);	
+			SAFE_DELETE(it->second);
+			mMapDeviceToBufferResources.erase(it);
+		}
 	}
-	else if (PixelUtil::isCompressed(rval.format))
+
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::lockDeviceAccess()
 	{
-		rval.rowPitch = rval.getWidth();
-		rval.slicePitch = rval.getWidth() * rval.getHeight();
+		D3D9_DEVICE_ACCESS_LOCK;			
 	}
-	else
+
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::unlockDeviceAccess()
 	{
-		CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
+		D3D9_DEVICE_ACCESS_UNLOCK;								
 	}
 
-	rval.data = lrect.pBits;
-}
-void fromD3DLock(PixelData &rval, const D3DLOCKED_BOX &lbox)
-{
-	UINT32 bpp = PixelUtil::getNumElemBytes(rval.format);
-	if (bpp != 0)
+	//-----------------------------------------------------------------------------  
+	// Util functions to convert a D3D locked box to a pixel box
+	void fromD3DLock(PixelData &rval, const D3DLOCKED_RECT &lrect)
 	{
-		rval.rowPitch = lbox.RowPitch / bpp;
-		rval.slicePitch = lbox.SlicePitch / bpp;
-		assert((lbox.RowPitch % bpp)==0);
-		assert((lbox.SlicePitch % bpp)==0);
+		UINT32 bpp = PixelUtil::getNumElemBytes(rval.format);
+		if (bpp != 0)
+		{
+			rval.rowPitch = lrect.Pitch / bpp;
+			rval.slicePitch = rval.rowPitch * rval.getHeight();
+			assert((lrect.Pitch % bpp)==0);
+		}
+		else if (PixelUtil::isCompressed(rval.format))
+		{
+			rval.rowPitch = rval.getWidth();
+			rval.slicePitch = rval.getWidth() * rval.getHeight();
+		}
+		else
+		{
+			CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
+		}
+
+		rval.data = lrect.pBits;
 	}
-	else if (PixelUtil::isCompressed(rval.format))
+	void fromD3DLock(PixelData &rval, const D3DLOCKED_BOX &lbox)
 	{
-		rval.rowPitch = rval.getWidth();
-		rval.slicePitch = rval.getWidth() * rval.getHeight();
+		UINT32 bpp = PixelUtil::getNumElemBytes(rval.format);
+		if (bpp != 0)
+		{
+			rval.rowPitch = lbox.RowPitch / bpp;
+			rval.slicePitch = lbox.SlicePitch / bpp;
+			assert((lbox.RowPitch % bpp)==0);
+			assert((lbox.SlicePitch % bpp)==0);
+		}
+		else if (PixelUtil::isCompressed(rval.format))
+		{
+			rval.rowPitch = rval.getWidth();
+			rval.slicePitch = rval.getWidth() * rval.getHeight();
+		}
+		else
+		{
+			CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
+		}
+		rval.data = lbox.pBits;
 	}
-	else
+	// Convert Ogre integer Box to D3D rectangle
+	RECT toD3DRECT(const Box &lockBox)
 	{
-		CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
+		RECT prect;
+		assert(lockBox.getDepth() == 1);
+		prect.left = static_cast<LONG>(lockBox.left);
+		prect.right = static_cast<LONG>(lockBox.right);
+		prect.top = static_cast<LONG>(lockBox.top);
+		prect.bottom = static_cast<LONG>(lockBox.bottom);
+		return prect;
 	}
-	rval.data = lbox.pBits;
-}
-// Convert Ogre integer Box to D3D rectangle
-RECT toD3DRECT(const Box &lockBox)
-{
-	RECT prect;
-	assert(lockBox.getDepth() == 1);
-	prect.left = static_cast<LONG>(lockBox.left);
-	prect.right = static_cast<LONG>(lockBox.right);
-	prect.top = static_cast<LONG>(lockBox.top);
-	prect.bottom = static_cast<LONG>(lockBox.bottom);
-	return prect;
-}
-// Convert Ogre integer Box to D3D box
-D3DBOX toD3DBOX(const Box &lockBox)
-{
-	D3DBOX pbox;
-	
-	pbox.Left = static_cast<UINT>(lockBox.left);
-	pbox.Right = static_cast<UINT>(lockBox.right);
-	pbox.Top = static_cast<UINT>(lockBox.top);
-	pbox.Bottom = static_cast<UINT>(lockBox.bottom);
-	pbox.Front = static_cast<UINT>(lockBox.front);
-	pbox.Back = static_cast<UINT>(lockBox.back);
-	return pbox;
-}
-// Convert Ogre pixelbox extent to D3D rectangle
-RECT toD3DRECTExtent(const PixelData &lockBox)
-{
-	RECT prect;
-	assert(lockBox.getDepth() == 1);
-	prect.left = 0;
-	prect.right = static_cast<LONG>(lockBox.getWidth());
-	prect.top = 0;
-	prect.bottom = static_cast<LONG>(lockBox.getHeight());
-	return prect;
-}
-// Convert Ogre pixelbox extent to D3D box
-D3DBOX toD3DBOXExtent(const PixelData &lockBox)
-{
-	D3DBOX pbox;
-	pbox.Left = 0;
-	pbox.Right = static_cast<UINT>(lockBox.getWidth());
-	pbox.Top = 0;
-	pbox.Bottom = static_cast<UINT>(lockBox.getHeight());
-	pbox.Front = 0;
-	pbox.Back = static_cast<UINT>(lockBox.getDepth());
-	return pbox;
-}
-//-----------------------------------------------------------------------------  
-PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
-{	
-	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
-	DWORD flags = 0;
-	switch(options)
+	// Convert Ogre integer Box to D3D box
+	D3DBOX toD3DBOX(const Box &lockBox)
 	{
-	case HBL_WRITE_ONLY_DISCARD:
-		// D3D only likes D3DLOCK_DISCARD if you created the texture with D3DUSAGE_DYNAMIC
-		// debug runtime flags this up, could cause problems on some drivers
-		if (mUsage & HBU_DYNAMIC)
-			flags |= D3DLOCK_DISCARD;
-		break;
-	case HBL_READ_ONLY:
-		flags |= D3DLOCK_READONLY;
-		break;
-	default: 
-		break;
-	};
-
-	if (mMapDeviceToBufferResources.size() == 0)
-	{
-		CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");	
-	}
+		D3DBOX pbox;
 	
-	mLockedBox = lockBox;
-	mLockFlags = flags;
-
-	BufferResources* bufferResources = mMapDeviceToBufferResources.begin()->second;
+		pbox.Left = static_cast<UINT>(lockBox.left);
+		pbox.Right = static_cast<UINT>(lockBox.right);
+		pbox.Top = static_cast<UINT>(lockBox.top);
+		pbox.Bottom = static_cast<UINT>(lockBox.bottom);
+		pbox.Front = static_cast<UINT>(lockBox.front);
+		pbox.Back = static_cast<UINT>(lockBox.back);
+		return pbox;
+	}
+	// Convert Ogre pixelbox extent to D3D rectangle
+	RECT toD3DRECTExtent(const PixelData &lockBox)
+	{
+		RECT prect;
+		assert(lockBox.getDepth() == 1);
+		prect.left = 0;
+		prect.right = static_cast<LONG>(lockBox.getWidth());
+		prect.top = 0;
+		prect.bottom = static_cast<LONG>(lockBox.getHeight());
+		return prect;
+	}
+	// Convert Ogre pixelbox extent to D3D box
+	D3DBOX toD3DBOXExtent(const PixelData &lockBox)
+	{
+		D3DBOX pbox;
+		pbox.Left = 0;
+		pbox.Right = static_cast<UINT>(lockBox.getWidth());
+		pbox.Top = 0;
+		pbox.Bottom = static_cast<UINT>(lockBox.getHeight());
+		pbox.Front = 0;
+		pbox.Back = static_cast<UINT>(lockBox.getDepth());
+		return pbox;
+	}
+	//-----------------------------------------------------------------------------  
+	PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
+	{	
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 	
-	// Lock the source buffer.
-	return lockBuffer(bufferResources, lockBox, flags);
-}
-
-//-----------------------------------------------------------------------------  
-CamelotEngine::PixelData D3D9HardwarePixelBuffer::lockBuffer(BufferResources* bufferResources, 
-												   const Box &lockBox, 
-												   DWORD flags)
-{
-	// Set extents and format
-	// Note that we do not carry over the left/top/front here, since the returned
-	// PixelBox will be re-based from the locking point onwards
-	PixelData rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat);
-
-
-	if (bufferResources->surface != NULL) 
-	{
-		// Surface
-		D3DLOCKED_RECT lrect; // Filled in by D3D
-		HRESULT hr;
-
-		if (lockBox.left == 0 && lockBox.top == 0 
-			&& lockBox.right == mWidth && lockBox.bottom == mHeight)
+		// Set locking flags according to options
+		DWORD flags = 0;
+		switch(options)
 		{
-			// Lock whole surface
-			hr = bufferResources->surface->LockRect(&lrect, NULL, flags);
-		}
-		else
+		case HBL_WRITE_ONLY_DISCARD:
+			// D3D only likes D3DLOCK_DISCARD if you created the texture with D3DUSAGE_DYNAMIC
+			// debug runtime flags this up, could cause problems on some drivers
+			if (mUsage & HBU_DYNAMIC)
+				flags |= D3DLOCK_DISCARD;
+			break;
+		case HBL_READ_ONLY:
+			flags |= D3DLOCK_READONLY;
+			break;
+		default: 
+			break;
+		};
+
+		if (mMapDeviceToBufferResources.size() == 0)
 		{
-			RECT prect = toD3DRECT(lockBox); // specify range to lock
-			hr = bufferResources->surface->LockRect(&lrect, &prect, flags);
+			CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");	
 		}
-		if (FAILED(hr))		
-			CM_EXCEPT(RenderingAPIException, "Surface locking failed");
-		fromD3DLock(rval, lrect);
-	} 
-	else if(bufferResources->volume) 
-	{
-		// Volume
-		D3DBOX pbox = toD3DBOX(lockBox); // specify range to lock
-		D3DLOCKED_BOX lbox; // Filled in by D3D
+	
+		mLockedBox = lockBox;
+		mLockFlags = flags;
 
-		if(bufferResources->volume->LockBox(&lbox, &pbox, flags) != D3D_OK)
-			CM_EXCEPT(RenderingAPIException, "Volume locking failed");
-		fromD3DLock(rval, lbox);
+		BufferResources* bufferResources = mMapDeviceToBufferResources.begin()->second;
+	
+		// Lock the source buffer.
+		return lockBuffer(bufferResources, lockBox, flags);
 	}
 
+	//-----------------------------------------------------------------------------  
+	CamelotEngine::PixelData D3D9HardwarePixelBuffer::lockBuffer(BufferResources* bufferResources, 
+													   const Box &lockBox, 
+													   DWORD flags)
+	{
+		// Set extents and format
+		// Note that we do not carry over the left/top/front here, since the returned
+		// PixelBox will be re-based from the locking point onwards
+		PixelData rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat);
 
-	return rval;
-}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::unlockImpl(void)
-{
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+		if (bufferResources->surface != NULL) 
+		{
+			// Surface
+			D3DLOCKED_RECT lrect; // Filled in by D3D
+			HRESULT hr;
 
-	if (mMapDeviceToBufferResources.size() == 0)
-	{
-		CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");	
-	}
+			if (lockBox.left == 0 && lockBox.top == 0 
+				&& lockBox.right == mWidth && lockBox.bottom == mHeight)
+			{
+				// Lock whole surface
+				hr = bufferResources->surface->LockRect(&lrect, NULL, flags);
+			}
+			else
+			{
+				RECT prect = toD3DRECT(lockBox); // specify range to lock
+				hr = bufferResources->surface->LockRect(&lrect, &prect, flags);
+			}
+			if (FAILED(hr))		
+				CM_EXCEPT(RenderingAPIException, "Surface locking failed");
+			fromD3DLock(rval, lrect);
+		} 
+		else if(bufferResources->volume) 
+		{
+			// Volume
+			D3DBOX pbox = toD3DBOX(lockBox); // specify range to lock
+			D3DLOCKED_BOX lbox; // Filled in by D3D
 
-	DeviceToBufferResourcesIterator it;
-	
-	// 1. Update duplicates buffers.
-	it = mMapDeviceToBufferResources.begin();
-	++it;
-	while (it != mMapDeviceToBufferResources.end())
-	{			
-		BufferResources* bufferResources = it->second;
-		
-		// Update duplicated buffer from the from the locked buffer content.					
-		blitFromMemory(mCurrentLock, mLockedBox, bufferResources);										
-		++it;			
-	}
+			if(bufferResources->volume->LockBox(&lbox, &pbox, flags) != D3D_OK)
+				CM_EXCEPT(RenderingAPIException, "Volume locking failed");
+			fromD3DLock(rval, lbox);
+		}
 
-	// 2. Unlock the locked buffer.
-	it = mMapDeviceToBufferResources.begin();							
-	unlockBuffer( it->second);		
-	if(mDoMipmapGen)
-		_genMipmaps(it->second->mipTex);	
-}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::unlockBuffer(BufferResources* bufferResources)
-{
-	if(bufferResources->surface) 
-	{
-		// Surface
-		bufferResources->surface->UnlockRect();
-	} 
-	else if(bufferResources->volume) 
-	{
-		// Volume
-		bufferResources->volume->UnlockBox();
+		return rval;
 	}
-}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blit(const HardwarePixelBufferPtr &rsrc, 
-								   const Box &srcBox, 
-								   const Box &dstBox)
-{
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
-
-	D3D9HardwarePixelBuffer *src = static_cast<D3D9HardwarePixelBuffer*>(rsrc.get());
-	DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
-
-	// Update all the buffer copies.
-	while (it != mMapDeviceToBufferResources.end())
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::unlockImpl(void)
 	{
-		BufferResources* srcBufferResources = src->getBufferResources(it->first);
-		BufferResources* dstBufferResources = it->second;
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		if (srcBufferResources == NULL)
+		if (mMapDeviceToBufferResources.size() == 0)
 		{
-			CM_EXCEPT(RenderingAPIException, "There are no matching resources attached to the source pixel buffer !!");	
+			CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");	
 		}
 
-		blit(it->first, rsrc, srcBox, dstBox, srcBufferResources, dstBufferResources);
+		DeviceToBufferResourcesIterator it;
+	
+		// 1. Update duplicates buffers.
+		it = mMapDeviceToBufferResources.begin();
 		++it;
+		while (it != mMapDeviceToBufferResources.end())
+		{			
+			BufferResources* bufferResources = it->second;
+		
+			// Update duplicated buffer from the from the locked buffer content.					
+			blitFromMemory(mCurrentLock, mLockedBox, bufferResources);										
+			++it;			
+		}
+
+		// 2. Unlock the locked buffer.
+		it = mMapDeviceToBufferResources.begin();							
+		unlockBuffer( it->second);		
+		if(mDoMipmapGen)
+			_genMipmaps(it->second->mipTex);	
 	}
-}
-
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device, 
-								   const HardwarePixelBufferPtr &rsrc, 
-								   const Box &srcBox, 
-								   const Box &dstBox,
-								   BufferResources* srcBufferResources, 
-								   BufferResources* dstBufferResources)
-{
-	if(dstBufferResources->surface && srcBufferResources->surface)
+
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::unlockBuffer(BufferResources* bufferResources)
+	{
+		if(bufferResources->surface) 
+		{
+			// Surface
+			bufferResources->surface->UnlockRect();
+		} 
+		else if(bufferResources->volume) 
+		{
+			// Volume
+			bufferResources->volume->UnlockBox();
+		}
+	}
+
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::blit(const HardwarePixelBufferPtr &rsrc, 
+									   const Box &srcBox, 
+									   const Box &dstBox)
 	{
-		// Surface-to-surface
-		RECT dsrcRect = toD3DRECT(srcBox);
-		RECT ddestRect = toD3DRECT(dstBox);
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		D3DSURFACE_DESC srcDesc;
-		if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
-			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
+		D3D9HardwarePixelBuffer *src = static_cast<D3D9HardwarePixelBuffer*>(rsrc.get());
+		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 
-		// If we're blitting from a RTT, try GetRenderTargetData
-		// if we're going to try to use GetRenderTargetData, need to use system mem pool
-		bool tryGetRenderTargetData = false;
-		if ((srcDesc.Usage & D3DUSAGE_RENDERTARGET) != 0
-			&& srcDesc.MultiSampleType == D3DMULTISAMPLE_NONE)
+		// Update all the buffer copies.
+		while (it != mMapDeviceToBufferResources.end())
 		{
+			BufferResources* srcBufferResources = src->getBufferResources(it->first);
+			BufferResources* dstBufferResources = it->second;
 
-			// Temp texture
-			IDirect3DTexture9 *tmptex;
-			IDirect3DSurface9 *tmpsurface;
-
-			if(D3DXCreateTexture(
-				d3d9Device,
-				srcDesc.Width, srcDesc.Height,
-				1, // 1 mip level ie topmost, generate no mipmaps
-				0, srcDesc.Format, D3DPOOL_SYSTEMMEM,
-				&tmptex
-				) != D3D_OK)
+			if (srcBufferResources == NULL)
 			{
-				CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
+				CM_EXCEPT(RenderingAPIException, "There are no matching resources attached to the source pixel buffer !!");	
 			}
-			if(tmptex->GetSurfaceLevel(0, &tmpsurface) != D3D_OK)
-			{
-				tmptex->Release();
-				CM_EXCEPT(RenderingAPIException, "Get surface level failed");
-			}
-			if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, tmpsurface) == D3D_OK)
+
+			blit(it->first, rsrc, srcBox, dstBox, srcBufferResources, dstBufferResources);
+			++it;
+		}
+	}
+
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device, 
+									   const HardwarePixelBufferPtr &rsrc, 
+									   const Box &srcBox, 
+									   const Box &dstBox,
+									   BufferResources* srcBufferResources, 
+									   BufferResources* dstBufferResources)
+	{
+		if(dstBufferResources->surface && srcBufferResources->surface)
+		{
+			// Surface-to-surface
+			RECT dsrcRect = toD3DRECT(srcBox);
+			RECT ddestRect = toD3DRECT(dstBox);
+
+			D3DSURFACE_DESC srcDesc;
+			if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
+				CM_EXCEPT(RenderingAPIException, "Could not get surface information");
+
+			// If we're blitting from a RTT, try GetRenderTargetData
+			// if we're going to try to use GetRenderTargetData, need to use system mem pool
+			bool tryGetRenderTargetData = false;
+			if ((srcDesc.Usage & D3DUSAGE_RENDERTARGET) != 0
+				&& srcDesc.MultiSampleType == D3DMULTISAMPLE_NONE)
 			{
-				// Hey, it worked
-				// Copy from this surface instead
-				if(D3DXLoadSurfaceFromSurface(
-					dstBufferResources->surface, NULL, &ddestRect, 
-					tmpsurface, NULL, &dsrcRect,
-					D3DX_DEFAULT, 0) != D3D_OK)
+
+				// Temp texture
+				IDirect3DTexture9 *tmptex;
+				IDirect3DSurface9 *tmpsurface;
+
+				if(D3DXCreateTexture(
+					d3d9Device,
+					srcDesc.Width, srcDesc.Height,
+					1, // 1 mip level ie topmost, generate no mipmaps
+					0, srcDesc.Format, D3DPOOL_SYSTEMMEM,
+					&tmptex
+					) != D3D_OK)
+				{
+					CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
+				}
+				if(tmptex->GetSurfaceLevel(0, &tmpsurface) != D3D_OK)
 				{
+					tmptex->Release();
+					CM_EXCEPT(RenderingAPIException, "Get surface level failed");
+				}
+				if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, tmpsurface) == D3D_OK)
+				{
+					// Hey, it worked
+					// Copy from this surface instead
+					if(D3DXLoadSurfaceFromSurface(
+						dstBufferResources->surface, NULL, &ddestRect, 
+						tmpsurface, NULL, &dsrcRect,
+						D3DX_DEFAULT, 0) != D3D_OK)
+					{
+						tmpsurface->Release();
+						tmptex->Release();
+						CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
+					}
 					tmpsurface->Release();
 					tmptex->Release();
-					CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
+					return;
 				}
-				tmpsurface->Release();
-				tmptex->Release();
-				return;
-			}
 
-		}
+			}
 
-		// Otherwise, try the normal method
+			// Otherwise, try the normal method
 
-		// D3DXLoadSurfaceFromSurface
-		if(D3DXLoadSurfaceFromSurface(
-			dstBufferResources->surface, NULL, &ddestRect, 
-			srcBufferResources->surface, NULL, &dsrcRect,
-			D3DX_DEFAULT, 0) != D3D_OK)
+			// D3DXLoadSurfaceFromSurface
+			if(D3DXLoadSurfaceFromSurface(
+				dstBufferResources->surface, NULL, &ddestRect, 
+				srcBufferResources->surface, NULL, &dsrcRect,
+				D3DX_DEFAULT, 0) != D3D_OK)
+			{
+				CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
+			}
+		}
+		else if(dstBufferResources->volume && srcBufferResources->volume)
 		{
-			CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
+			// Volume-to-volume
+			D3DBOX dsrcBox = toD3DBOX(srcBox);
+			D3DBOX ddestBox = toD3DBOX(dstBox);
+
+			// D3DXLoadVolumeFromVolume
+			if(D3DXLoadVolumeFromVolume(
+				dstBufferResources->volume, NULL, &ddestBox, 
+				srcBufferResources->volume, NULL, &dsrcBox,
+				D3DX_DEFAULT, 0) != D3D_OK)
+			{
+				CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
+			}
 		}
-	}
-	else if(dstBufferResources->volume && srcBufferResources->volume)
-	{
-		// Volume-to-volume
-		D3DBOX dsrcBox = toD3DBOX(srcBox);
-		D3DBOX ddestBox = toD3DBOX(dstBox);
-
-		// D3DXLoadVolumeFromVolume
-		if(D3DXLoadVolumeFromVolume(
-			dstBufferResources->volume, NULL, &ddestBox, 
-			srcBufferResources->volume, NULL, &dsrcBox,
-			D3DX_DEFAULT, 0) != D3D_OK)
+		else
 		{
-			CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
+			// Software fallback   
+			HardwarePixelBuffer::blit(rsrc, srcBox, dstBox);
 		}
 	}
-	else
-	{
-		// Software fallback   
-		HardwarePixelBuffer::blit(rsrc, srcBox, dstBox);
-	}
-}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
-{	
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
+	{	
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-	DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
+		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 
-	while (it != mMapDeviceToBufferResources.end())
-	{		
-		BufferResources* dstBufferResources = it->second;
+		while (it != mMapDeviceToBufferResources.end())
+		{		
+			BufferResources* dstBufferResources = it->second;
 		
-		blitFromMemory(src, dstBox, dstBufferResources);	
-		++it;
-	}
-}
-
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox, BufferResources* dstBufferResources)
-{
-	// for scoped deletion of conversion buffer
-	void* data = NULL;
-	PixelData converted = src;
-
-	// convert to pixelbuffer's native format if necessary
-	if (D3D9Mappings::_getPF(src.format) == D3DFMT_UNKNOWN)
-	{
-		data = new void*[PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat)];
-		converted = PixelData(src.getWidth(), src.getHeight(), src.getDepth(), mFormat, data);
-		PixelUtil::bulkPixelConversion(src, converted);
-	}
-
-	UINT32 rowWidth;
-	if (PixelUtil::isCompressed(converted.format))
-	{
-		// D3D wants the width of one row of cells in bytes
-		if (converted.format == PF_DXT1)
-		{
-			// 64 bits (8 bytes) per 4x4 block
-			rowWidth = (converted.rowPitch / 4) * 8;
-		}
-		else
-		{
-			// 128 bits (16 bytes) per 4x4 block
-			rowWidth = (converted.rowPitch / 4) * 16;
+			blitFromMemory(src, dstBox, dstBufferResources);	
+			++it;
 		}
-
-	}
-	else
-	{
-		rowWidth = converted.rowPitch * PixelUtil::getNumElemBytes(converted.format);
 	}
 
-	if (dstBufferResources->surface)
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox, BufferResources* dstBufferResources)
 	{
-		RECT destRect, srcRect;
-		srcRect = toD3DRECT(converted);
-		destRect = toD3DRECT(dstBox);
+		// for scoped deletion of conversion buffer
+		void* data = NULL;
+		PixelData converted = src;
 
-		if(D3DXLoadSurfaceFromMemory(dstBufferResources->surface, NULL, &destRect, 
-			converted.data, D3D9Mappings::_getPF(converted.format),
-			static_cast<UINT>(rowWidth),
-			NULL, &srcRect, D3DX_DEFAULT, 0) != D3D_OK)
+		// convert to pixelbuffer's native format if necessary
+		if (D3D9Mappings::_getPF(src.format) == D3DFMT_UNKNOWN)
 		{
-			CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
+			data = new void*[PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat)];
+			converted = PixelData(src.getWidth(), src.getHeight(), src.getDepth(), mFormat, data);
+			PixelUtil::bulkPixelConversion(src, converted);
 		}
-	}
-	else if (dstBufferResources->volume)
-	{
-		D3DBOX destBox, srcBox;
-		srcBox = toD3DBOX(converted);
-		destBox = toD3DBOX(dstBox);
-		UINT32 sliceWidth;
+
+		UINT32 rowWidth;
 		if (PixelUtil::isCompressed(converted.format))
 		{
-			// D3D wants the width of one slice of cells in bytes
+			// D3D wants the width of one row of cells in bytes
 			if (converted.format == PF_DXT1)
 			{
 				// 64 bits (8 bytes) per 4x4 block
-				sliceWidth = (converted.slicePitch / 16) * 8;
+				rowWidth = (converted.rowPitch / 4) * 8;
 			}
 			else
 			{
 				// 128 bits (16 bytes) per 4x4 block
-				sliceWidth = (converted.slicePitch / 16) * 16;
+				rowWidth = (converted.rowPitch / 4) * 16;
 			}
 
 		}
 		else
 		{
-			sliceWidth = converted.slicePitch * PixelUtil::getNumElemBytes(converted.format);
+			rowWidth = converted.rowPitch * PixelUtil::getNumElemBytes(converted.format);
 		}
 
-		if(D3DXLoadVolumeFromMemory(dstBufferResources->volume, NULL, &destBox, 
-			converted.data, D3D9Mappings::_getPF(converted.format),
-			static_cast<UINT>(rowWidth), static_cast<UINT>(sliceWidth),
-			NULL, &srcBox, D3DX_DEFAULT, 0) != D3D_OK)
+		if (dstBufferResources->surface)
 		{
-			CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
+			RECT destRect, srcRect;
+			srcRect = toD3DRECT(converted);
+			destRect = toD3DRECT(dstBox);
+
+			if(D3DXLoadSurfaceFromMemory(dstBufferResources->surface, NULL, &destRect, 
+				converted.data, D3D9Mappings::_getPF(converted.format),
+				static_cast<UINT>(rowWidth),
+				NULL, &srcRect, D3DX_DEFAULT, 0) != D3D_OK)
+			{
+				CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
+			}
 		}
-	}
-
-	if(mDoMipmapGen)
-		_genMipmaps(dstBufferResources->mipTex);
-
-	if(data != NULL)
-		delete[] data;
-}
+		else if (dstBufferResources->volume)
+		{
+			D3DBOX destBox, srcBox;
+			srcBox = toD3DBOX(converted);
+			destBox = toD3DBOX(dstBox);
+			UINT32 sliceWidth;
+			if (PixelUtil::isCompressed(converted.format))
+			{
+				// D3D wants the width of one slice of cells in bytes
+				if (converted.format == PF_DXT1)
+				{
+					// 64 bits (8 bytes) per 4x4 block
+					sliceWidth = (converted.slicePitch / 16) * 8;
+				}
+				else
+				{
+					// 128 bits (16 bytes) per 4x4 block
+					sliceWidth = (converted.slicePitch / 16) * 16;
+				}
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
-{
-	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+			}
+			else
+			{
+				sliceWidth = converted.slicePitch * PixelUtil::getNumElemBytes(converted.format);
+			}
 
-	DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
-	BufferResources* bufferResources = it->second;
+			if(D3DXLoadVolumeFromMemory(dstBufferResources->volume, NULL, &destBox, 
+				converted.data, D3D9Mappings::_getPF(converted.format),
+				static_cast<UINT>(rowWidth), static_cast<UINT>(sliceWidth),
+				NULL, &srcBox, D3DX_DEFAULT, 0) != D3D_OK)
+			{
+				CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
+			}
+		}
 
-	blitToMemory(srcBox, dst, bufferResources, it->first);
-}
+		if(mDoMipmapGen)
+			_genMipmaps(dstBufferResources->mipTex);
 
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst, 
-										   BufferResources* srcBufferResources,
-										   IDirect3DDevice9* d3d9Device)
-{
-	// Decide on pixel format of temp surface
-	PixelFormat tmpFormat = mFormat; 
-	if(D3D9Mappings::_getPF(dst.format) != D3DFMT_UNKNOWN)
-	{
-		tmpFormat = dst.format;
+		if(data != NULL)
+			delete[] data;
 	}
 
-	if (srcBufferResources->surface)
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 	{
-		assert(srcBox.getDepth() == 1 && dst.getDepth() == 1);
-		// Create temp texture
-		IDirect3DTexture9 *tmp;
-		IDirect3DSurface9 *surface;
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		D3DSURFACE_DESC srcDesc;
-		if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
-			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
+		DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
+		BufferResources* bufferResources = it->second;
 
-		D3DPOOL temppool = D3DPOOL_SCRATCH;
-		// if we're going to try to use GetRenderTargetData, need to use system mem pool
-		bool tryGetRenderTargetData = false;
-		if (((srcDesc.Usage & D3DUSAGE_RENDERTARGET) != 0) &&
-			(srcBox.getWidth() == dst.getWidth()) && (srcBox.getHeight() == dst.getHeight()) &&
-			(srcBox.getWidth() == getWidth()) && (srcBox.getHeight() == getHeight()) &&
-			(mFormat == tmpFormat))
-		{
-			tryGetRenderTargetData = true;
-			temppool = D3DPOOL_SYSTEMMEM;
-		}
+		blitToMemory(srcBox, dst, bufferResources, it->first);
+	}
 
-		if(D3DXCreateTexture(
-			d3d9Device,
-			static_cast<UINT>(dst.getWidth()), static_cast<UINT>(dst.getHeight()), 
-			1, // 1 mip level ie topmost, generate no mipmaps
-			0, D3D9Mappings::_getPF(tmpFormat), temppool,
-			&tmp
-			) != D3D_OK)
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst, 
+											   BufferResources* srcBufferResources,
+											   IDirect3DDevice9* d3d9Device)
+	{
+		// Decide on pixel format of temp surface
+		PixelFormat tmpFormat = mFormat; 
+		if(D3D9Mappings::_getPF(dst.format) != D3DFMT_UNKNOWN)
 		{
-			CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
+			tmpFormat = dst.format;
 		}
-		if(tmp->GetSurfaceLevel(0, &surface) != D3D_OK)
+
+		if (srcBufferResources->surface)
 		{
-			tmp->Release();
-			CM_EXCEPT(RenderingAPIException, "Get surface level failed");
-		}
-		// Copy texture to this temp surface
-		RECT destRect, srcRect;
-		srcRect = toD3DRECT(srcBox);
-		destRect = toD3DRECTExtent(dst);
+			assert(srcBox.getDepth() == 1 && dst.getDepth() == 1);
+			// Create temp texture
+			IDirect3DTexture9 *tmp;
+			IDirect3DSurface9 *surface;
+
+			D3DSURFACE_DESC srcDesc;
+			if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
+				CM_EXCEPT(RenderingAPIException, "Could not get surface information");
+
+			D3DPOOL temppool = D3DPOOL_SCRATCH;
+			// if we're going to try to use GetRenderTargetData, need to use system mem pool
+			bool tryGetRenderTargetData = false;
+			if (((srcDesc.Usage & D3DUSAGE_RENDERTARGET) != 0) &&
+				(srcBox.getWidth() == dst.getWidth()) && (srcBox.getHeight() == dst.getHeight()) &&
+				(srcBox.getWidth() == getWidth()) && (srcBox.getHeight() == getHeight()) &&
+				(mFormat == tmpFormat))
+			{
+				tryGetRenderTargetData = true;
+				temppool = D3DPOOL_SYSTEMMEM;
+			}
 
-		// Get the real temp surface format
-		D3DSURFACE_DESC dstDesc;
-		if(surface->GetDesc(&dstDesc) != D3D_OK)
-			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
-		tmpFormat = D3D9Mappings::_getPF(dstDesc.Format);
+			if(D3DXCreateTexture(
+				d3d9Device,
+				static_cast<UINT>(dst.getWidth()), static_cast<UINT>(dst.getHeight()), 
+				1, // 1 mip level ie topmost, generate no mipmaps
+				0, D3D9Mappings::_getPF(tmpFormat), temppool,
+				&tmp
+				) != D3D_OK)
+			{
+				CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
+			}
+			if(tmp->GetSurfaceLevel(0, &surface) != D3D_OK)
+			{
+				tmp->Release();
+				CM_EXCEPT(RenderingAPIException, "Get surface level failed");
+			}
+			// Copy texture to this temp surface
+			RECT destRect, srcRect;
+			srcRect = toD3DRECT(srcBox);
+			destRect = toD3DRECTExtent(dst);
+
+			// Get the real temp surface format
+			D3DSURFACE_DESC dstDesc;
+			if(surface->GetDesc(&dstDesc) != D3D_OK)
+				CM_EXCEPT(RenderingAPIException, "Could not get surface information");
+			tmpFormat = D3D9Mappings::_getPF(dstDesc.Format);
+
+			// Use fast GetRenderTargetData if we are in its usage conditions
+			bool fastLoadSuccess = false;
+			if (tryGetRenderTargetData)
+			{
+				if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, surface) == D3D_OK)
+				{
+					fastLoadSuccess = true;
+				}
+			}
+			if (!fastLoadSuccess)
+			{
+				if(D3DXLoadSurfaceFromSurface(
+					surface, NULL, &destRect, 
+					srcBufferResources->surface, NULL, &srcRect,
+					D3DX_DEFAULT, 0) != D3D_OK)
+				{
+					surface->Release();
+					tmp->Release();
+					CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
+				}
+			}
 
-		// Use fast GetRenderTargetData if we are in its usage conditions
-		bool fastLoadSuccess = false;
-		if (tryGetRenderTargetData)
-		{
-			if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, surface) == D3D_OK)
+			// Lock temp surface and copy it to memory
+			D3DLOCKED_RECT lrect; // Filled in by D3D
+			if(surface->LockRect(&lrect, NULL,  D3DLOCK_READONLY) != D3D_OK)
 			{
-				fastLoadSuccess = true;
+				surface->Release();
+				tmp->Release();
+				CM_EXCEPT(RenderingAPIException, "surface->LockRect");
 			}
+			// Copy it
+			PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
+			fromD3DLock(locked, lrect);
+			PixelUtil::bulkPixelConversion(locked, dst);
+			surface->UnlockRect();
+			// Release temporary surface and texture
+			surface->Release();
+			tmp->Release();
 		}
-		if (!fastLoadSuccess)
+		else if (srcBufferResources->volume)
 		{
-			if(D3DXLoadSurfaceFromSurface(
-				surface, NULL, &destRect, 
-				srcBufferResources->surface, NULL, &srcRect,
+			// Create temp texture
+			IDirect3DVolumeTexture9 *tmp;
+			IDirect3DVolume9 *surface;
+
+			if(D3DXCreateVolumeTexture(
+				d3d9Device,
+				static_cast<UINT>(dst.getWidth()), 
+				static_cast<UINT>(dst.getHeight()), 
+				static_cast<UINT>(dst.getDepth()), 0,
+				0, D3D9Mappings::_getPF(tmpFormat), D3DPOOL_SCRATCH,
+				&tmp
+				) != D3D_OK)
+			{
+				CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
+			}
+			if(tmp->GetVolumeLevel(0, &surface) != D3D_OK)
+			{
+				tmp->Release();
+				CM_EXCEPT(RenderingAPIException, "Get volume level failed");
+			}
+			// Volume
+			D3DBOX ddestBox, dsrcBox;
+			ddestBox = toD3DBOXExtent(dst);
+			dsrcBox = toD3DBOX(srcBox);
+
+			if(D3DXLoadVolumeFromVolume(
+				surface, NULL, &ddestBox, 
+				srcBufferResources->volume, NULL, &dsrcBox,
 				D3DX_DEFAULT, 0) != D3D_OK)
 			{
 				surface->Release();
 				tmp->Release();
-				CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
+				CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
 			}
-		}
-
-		// Lock temp surface and copy it to memory
-		D3DLOCKED_RECT lrect; // Filled in by D3D
-		if(surface->LockRect(&lrect, NULL,  D3DLOCK_READONLY) != D3D_OK)
-		{
+			// Lock temp surface and copy it to memory
+			D3DLOCKED_BOX lbox; // Filled in by D3D
+			if(surface->LockBox(&lbox, NULL,  D3DLOCK_READONLY) != D3D_OK)
+			{
+				surface->Release();
+				tmp->Release();
+				CM_EXCEPT(RenderingAPIException, "surface->LockBox");
+			}
+			// Copy it
+			PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
+			fromD3DLock(locked, lbox);
+			PixelUtil::bulkPixelConversion(locked, dst);
+			surface->UnlockBox();
+			// Release temporary surface and texture
 			surface->Release();
 			tmp->Release();
-			CM_EXCEPT(RenderingAPIException, "surface->LockRect");
-		}
-		// Copy it
-		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
-		fromD3DLock(locked, lrect);
-		PixelUtil::bulkPixelConversion(locked, dst);
-		surface->UnlockRect();
-		// Release temporary surface and texture
-		surface->Release();
-		tmp->Release();
+		}
 	}
-	else if (srcBufferResources->volume)
+
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::_genMipmaps(IDirect3DBaseTexture9* mipTex)
 	{
-		// Create temp texture
-		IDirect3DVolumeTexture9 *tmp;
-		IDirect3DVolume9 *surface;
+		assert(mipTex);
 
-		if(D3DXCreateVolumeTexture(
-			d3d9Device,
-			static_cast<UINT>(dst.getWidth()), 
-			static_cast<UINT>(dst.getHeight()), 
-			static_cast<UINT>(dst.getDepth()), 0,
-			0, D3D9Mappings::_getPF(tmpFormat), D3DPOOL_SCRATCH,
-			&tmp
-			) != D3D_OK)
+		// Mipmapping
+		if (mHWMipmaps)
 		{
-			CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
+			// Hardware mipmaps
+			mipTex->GenerateMipSubLevels();
 		}
-		if(tmp->GetVolumeLevel(0, &surface) != D3D_OK)
+		else
 		{
-			tmp->Release();
-			CM_EXCEPT(RenderingAPIException, "Get volume level failed");
+			// Software mipmaps
+			if( D3DXFilterTexture( mipTex, NULL, D3DX_DEFAULT, D3DX_DEFAULT ) != D3D_OK )
+			{
+				CM_EXCEPT(RenderingAPIException, "Failed to filter texture (generate mipmaps)");
+			}
 		}
-		// Volume
-		D3DBOX ddestBox, dsrcBox;
-		ddestBox = toD3DBOXExtent(dst);
-		dsrcBox = toD3DBOX(srcBox);
 
-		if(D3DXLoadVolumeFromVolume(
-			surface, NULL, &ddestBox, 
-			srcBufferResources->volume, NULL, &dsrcBox,
-			D3DX_DEFAULT, 0) != D3D_OK)
-		{
-			surface->Release();
-			tmp->Release();
-			CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
-		}
-		// Lock temp surface and copy it to memory
-		D3DLOCKED_BOX lbox; // Filled in by D3D
-		if(surface->LockBox(&lbox, NULL,  D3DLOCK_READONLY) != D3D_OK)
-		{
-			surface->Release();
-			tmp->Release();
-			CM_EXCEPT(RenderingAPIException, "surface->LockBox");
-		}
-		// Copy it
-		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
-		fromD3DLock(locked, lbox);
-		PixelUtil::bulkPixelConversion(locked, dst);
-		surface->UnlockBox();
-		// Release temporary surface and texture
-		surface->Release();
-		tmp->Release();
 	}
-}
-
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::_genMipmaps(IDirect3DBaseTexture9* mipTex)
-{
-	assert(mipTex);
-
-	// Mipmapping
-	if (mHWMipmaps)
-	{
-		// Hardware mipmaps
-		mipTex->GenerateMipSubLevels();
+	//----------------------------------------------------------------------------- 
+	void D3D9HardwarePixelBuffer::_setMipmapping(bool doMipmapGen, 
+												 bool HWMipmaps)
+	{	
+		mDoMipmapGen = doMipmapGen;
+		mHWMipmaps = HWMipmaps;	
 	}
-	else
+	//-----------------------------------------------------------------------------  
+	void D3D9HardwarePixelBuffer::releaseSurfaces(IDirect3DDevice9* d3d9Device)
 	{
-		// Software mipmaps
-		if( D3DXFilterTexture( mipTex, NULL, D3DX_DEFAULT, D3DX_DEFAULT ) != D3D_OK )
+		BufferResources* bufferResources = getBufferResources(d3d9Device);
+
+		if (bufferResources != NULL)
 		{
-			CM_EXCEPT(RenderingAPIException, "Failed to filter texture (generate mipmaps)");
+			SAFE_RELEASE(bufferResources->surface);
+			SAFE_RELEASE(bufferResources->volume);
 		}
 	}
-
-}
-//----------------------------------------------------------------------------- 
-void D3D9HardwarePixelBuffer::_setMipmapping(bool doMipmapGen, 
-											 bool HWMipmaps)
-{	
-	mDoMipmapGen = doMipmapGen;
-	mHWMipmaps = HWMipmaps;	
-}
-//-----------------------------------------------------------------------------   
-void D3D9HardwarePixelBuffer::_clearSliceRTT(UINT32 zoffset)
-{
-	mRenderTexture = NULL;
-}
-
-//-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::releaseSurfaces(IDirect3DDevice9* d3d9Device)
-{
-	BufferResources* bufferResources = getBufferResources(d3d9Device);
-
-	if (bufferResources != NULL)
-	{
-		SAFE_RELEASE(bufferResources->surface);
-		SAFE_RELEASE(bufferResources->volume);
-	}
-}
-//-----------------------------------------------------------------------------   
-IDirect3DSurface9* D3D9HardwarePixelBuffer::getSurface(IDirect3DDevice9* d3d9Device)
-{
-	BufferResources* bufferResources = getBufferResources(d3d9Device);
-
-	if (bufferResources	== NULL)
+	//-----------------------------------------------------------------------------   
+	IDirect3DSurface9* D3D9HardwarePixelBuffer::getSurface(IDirect3DDevice9* d3d9Device)
 	{
-		mOwnerTexture->createTextureResources(d3d9Device);
-		bufferResources = getBufferResources(d3d9Device);
-	}
+		BufferResources* bufferResources = getBufferResources(d3d9Device);
 
-	return bufferResources->surface;
-}
-//-----------------------------------------------------------------------------   
-IDirect3DSurface9* D3D9HardwarePixelBuffer::getFSAASurface(IDirect3DDevice9* d3d9Device)
-{
-	BufferResources* bufferResources = getBufferResources(d3d9Device);
+		if (bufferResources	== NULL)
+		{
+			mOwnerTexture->createTextureResources(d3d9Device);
+			bufferResources = getBufferResources(d3d9Device);
+		}
 
-	if (bufferResources	== NULL)
-	{
-		mOwnerTexture->createTextureResources(d3d9Device);
-		bufferResources = getBufferResources(d3d9Device);
+		return bufferResources->surface;
 	}
-	
-	return bufferResources->fSAASurface;
-}
-//-----------------------------------------------------------------------------    
-RenderTexture *D3D9HardwarePixelBuffer::getRenderTarget(UINT32 zoffset)
-{
-    assert(mUsage & TU_RENDERTARGET);
-	assert(mRenderTexture != NULL);   
-	return mRenderTexture;
-}
-//-----------------------------------------------------------------------------    
-void D3D9HardwarePixelBuffer::updateRenderTexture(bool writeGamma, UINT32 fsaa, const String& srcName)
-{
-	if (mRenderTexture == NULL)
+	//-----------------------------------------------------------------------------   
+	IDirect3DSurface9* D3D9HardwarePixelBuffer::getFSAASurface(IDirect3DDevice9* d3d9Device)
 	{
-		String name;
-		name = "rtt/" +CamelotEngine::toString((size_t)this) + "/" + srcName;
-
-		mRenderTexture = new D3D9RenderTexture(name, this, writeGamma, fsaa);		
+		BufferResources* bufferResources = getBufferResources(d3d9Device);
 
-		CamelotEngine::RenderSystem::instancePtr()->attachRenderTarget(*mRenderTexture);
-	}
-}
-//-----------------------------------------------------------------------------    
-void D3D9HardwarePixelBuffer::destroyRenderTexture()
-{
-	if (mRenderTexture != NULL)
-	{
-		CamelotEngine::RenderSystem::instancePtr()->destroyRenderTarget(mRenderTexture);
-		mRenderTexture = NULL;
+		if (bufferResources	== NULL)
+		{
+			mOwnerTexture->createTextureResources(d3d9Device);
+			bufferResources = getBufferResources(d3d9Device);
+		}
+	
+		return bufferResources->fSAASurface;
 	}
-}
-
 };

+ 0 - 2
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -2502,8 +2502,6 @@ namespace CamelotEngine
 
 			// Calculate usage
 			DWORD d3dusage = D3DUSAGE_QUERY_FILTER;
-			if (usage & TU_RENDERTARGET) 
-				d3dusage |= D3DUSAGE_RENDERTARGET;
 			if (usage & TU_DYNAMIC)
 				d3dusage |= D3DUSAGE_DYNAMIC;
 

+ 8 - 103
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -49,10 +49,7 @@ namespace CamelotEngine
         :Texture(),              
         mD3DPool(D3DPOOL_MANAGED),
 		mDynamicTextures(false),
-		mHwGammaReadSupported(false),
-		mHwGammaWriteSupported(false),	
-		mFSAAType(D3DMULTISAMPLE_NONE),
-		mFSAAQuality(0)
+		mHwGammaReadSupported(false)
 	{
        
 	}
@@ -221,19 +218,6 @@ namespace CamelotEngine
 
 		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();
 	}
 	/****************************************************************************************/
@@ -274,7 +258,6 @@ namespace CamelotEngine
 		textureResources->pCubeTex		= NULL;
 		textureResources->pVolumeTex	= NULL;
 		textureResources->pBaseTex		= NULL;
-		textureResources->pFSAASurface	= NULL;
 
 		mMapDeviceToTextureResources[d3d9Device] = textureResources;
 
@@ -311,7 +294,6 @@ namespace CamelotEngine
 		SAFE_RELEASE(textureResources->pNormTex);
 		SAFE_RELEASE(textureResources->pCubeTex);
 		SAFE_RELEASE(textureResources->pVolumeTex);
-		SAFE_RELEASE(textureResources->pFSAASurface);
 	}
 	/****************************************************************************************/
 	UINT32 D3D9Texture::calculateSize(void) const
@@ -389,7 +371,7 @@ namespace CamelotEngine
 		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
-		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
+		DWORD usage = 0;
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 				D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
@@ -409,20 +391,6 @@ namespace CamelotEngine
 		if (mHwGamma)
 		{
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_TEXTURE, d3dPF, false);
-			if (mUsage & TU_RENDERTARGET)
-				mHwGammaWriteSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_TEXTURE, d3dPF, true);
-		}
-		// Check FSAA level
-		if (mUsage & TU_RENDERTARGET)
-		{
-			D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystem::instancePtr());
-			rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
-				&mFSAAType, &mFSAAQuality);
-		}
-		else
-		{
-			mFSAAType = D3DMULTISAMPLE_NONE;
-			mFSAAQuality = 0;
 		}
 
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
@@ -484,22 +452,6 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 
-		if (mFSAAType)
-		{
-			// create AA surface
-			HRESULT hr = d3d9Device->CreateRenderTarget(desc.Width, desc.Height, d3dPF, 
-				mFSAAType, 
-				mFSAAQuality,
-				FALSE, // not lockable
-				&textureResources->pFSAASurface, NULL);
-
-			if (FAILED(hr))
-			{
-				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
-			}
-
-		}
-
 		_setFinalAttributes(d3d9Device, textureResources, 
 			desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 	}
@@ -517,7 +469,7 @@ namespace CamelotEngine
 		hr = D3DXCheckCubeTextureRequirements(d3d9Device, NULL, NULL, 0, &d3dPF, mD3DPool);
 
 		// 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;
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 			D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
@@ -537,20 +489,6 @@ namespace CamelotEngine
 		if (mHwGamma)
 		{
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_CUBETEXTURE, d3dPF, false);
-			if (mUsage & TU_RENDERTARGET)
-				mHwGammaWriteSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_CUBETEXTURE, d3dPF, true);
-		}
-		// Check FSAA level
-		if (mUsage & TU_RENDERTARGET)
-		{
-			D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystem::instancePtr());
-			rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
-				&mFSAAType, &mFSAAQuality);
-		}
-		else
-		{
-			mFSAAType = D3DMULTISAMPLE_NONE;
-			mFSAAQuality = 0;
 		}
 
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
@@ -610,21 +548,6 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 
-		if (mFSAAType)
-		{
-			// create AA surface
-			HRESULT hr = d3d9Device->CreateRenderTarget(desc.Width, desc.Height, d3dPF, 
-				mFSAAType, 
-				mFSAAQuality,
-				FALSE, // not lockable
-				&textureResources->pFSAASurface, NULL);
-
-			if (FAILED(hr))
-			{
-				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
-			}
-		}
-
 		_setFinalAttributes(d3d9Device, textureResources, 
 			desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 	}
@@ -634,11 +557,6 @@ namespace CamelotEngine
 		// we must have those defined here
 		assert(mWidth > 0 && mHeight > 0 && mDepth>0);
 
-		if (mUsage & TU_RENDERTARGET)
-		{
-			CM_EXCEPT(RenderingAPIException, "D3D9 Volume texture can not be created as render target !!");
-		}
-
 		// determine which D3D9 pixel format we'll use
 		HRESULT hr;
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
@@ -646,7 +564,7 @@ namespace CamelotEngine
 		hr = D3DXCheckVolumeTextureRequirements(d3d9Device, NULL, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 
 		// 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;
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 			D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
@@ -664,16 +582,11 @@ namespace CamelotEngine
 		}
 		// Check sRGB support
 		if (mHwGamma)
-		{
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_VOLUMETEXTURE, d3dPF, false);
-			if (mUsage & TU_RENDERTARGET)
-				mHwGammaWriteSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_VOLUMETEXTURE, d3dPF, true);
-		}
 
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 		const D3DCAPS9& rkCurCaps = device->getD3D9DeviceCaps();			
 
-
 		// check if mip map volume textures are supported
 		if (!(rkCurCaps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP))
 		{
@@ -965,10 +878,6 @@ namespace CamelotEngine
 		{
 			bufusage = HardwareBuffer::HBU_STATIC;
 		}
-		if (mUsage & TU_RENDERTARGET)
-		{
-			bufusage |= TU_RENDERTARGET;
-		}
 		
 		UINT32 surfaceCount  = static_cast<UINT32>((getNumFaces() * (mNumMipmaps + 1)));
 		bool updateOldList = mSurfaceList.size() == surfaceCount;
@@ -986,8 +895,6 @@ namespace CamelotEngine
 			}
 		}
 
-		
-
 		switch(getTextureType()) {
 		case TEX_TYPE_2D:
 		case TEX_TYPE_1D:
@@ -1000,8 +907,7 @@ namespace CamelotEngine
 
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 								
-				currPixelBuffer->bind(d3d9Device, surface, textureResources->pFSAASurface,
-					mHwGammaWriteSupported, mFSAA, "PortNoName", textureResources->pBaseTex);
+				currPixelBuffer->bind(d3d9Device, surface, nullptr, false, 0, "PortNoName", textureResources->pBaseTex);
 
 				// decrement reference count, the GetSurfaceLevel call increments this
 				// this is safe because the pixel buffer keeps a reference as well
@@ -1021,8 +927,7 @@ namespace CamelotEngine
 
 					D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(face, mip);
 
-					currPixelBuffer->bind(d3d9Device, surface, textureResources->pFSAASurface,
-						mHwGammaWriteSupported, mFSAA, "NoNamePort", textureResources->pBaseTex);
+					currPixelBuffer->bind(d3d9Device, surface, nullptr, false, 0, "NoNamePort", textureResources->pBaseTex);
 
 					// decrement reference count, the GetSurfaceLevel call increments this
 					// this is safe because the pixel buffer keeps a reference as well
@@ -1077,10 +982,10 @@ namespace CamelotEngine
 	bool D3D9Texture::useDefaultPool()
 	{
 		// Determine D3D pool to use
-		// Use managed unless we're a render target or user has asked for 
+		// Use managed unless user has asked for 
 		// a dynamic texture, and device supports D3DUSAGE_DYNAMIC (because default pool
 		// resources without the dynamic flag are not lockable)
-		return (mUsage & TU_RENDERTARGET) || ((mUsage & TU_DYNAMIC) && mDynamicTextures);
+		return ((mUsage & TU_DYNAMIC) && mDynamicTextures);
 	}
 	
 	//---------------------------------------------------------------------

+ 0 - 5
CamelotD3D9Renderer/Source/CmD3D9TextureManager.cpp

@@ -63,11 +63,6 @@ namespace CamelotEngine
 		// Calculate usage
 		DWORD d3dusage = 0;
 		D3DPOOL pool = D3DPOOL_MANAGED;
-		if (usage & TU_RENDERTARGET) 
-		{
-			d3dusage |= D3DUSAGE_RENDERTARGET;
-			pool = D3DPOOL_DEFAULT;
-		}
 		if (usage & TU_DYNAMIC)
 		{
 			d3dusage |= D3DUSAGE_DYNAMIC;

+ 0 - 10
CamelotGLRenderer/Include/CmGLHardwarePixelBuffer.h

@@ -86,8 +86,6 @@ namespace CamelotEngine {
         
         /// @copydoc HardwarePixelBuffer::bindToFramebuffer
         virtual void bindToFramebuffer(GLenum attachment, UINT32 zoffset);
-        /// @copydoc HardwarePixelBuffer::getRenderTarget
-        RenderTexture* getRenderTarget(UINT32);
         /// Upload a box of pixels to this buffer on the card
 		virtual void upload(const PixelData &data, const Box &dest);
 		// Download a box of pixels from the card
@@ -96,11 +94,6 @@ namespace CamelotEngine {
         /// Hardware implementation of blitFromMemory
         virtual void blitFromMemory(const PixelData &src_orig, const Box &dstBox);
         
-        /// Notify TextureBuffer of destruction of render target
-        void _clearSliceRTT(UINT32 zoffset)
-        {
-            mSliceTRT[zoffset] = 0;
-        }
         /// Copy from framebuffer
         void copyFromFramebuffer(UINT32 zoffset);
         /// @copydoc HardwarePixelBuffer::blit
@@ -115,9 +108,6 @@ namespace CamelotEngine {
 		GLint mFace;
 		GLint mLevel;
 		bool mSoftwareMipmap;		// Use GLU for mip mapping
-        
-        typedef vector<RenderTexture*>::type SliceTRT;
-        SliceTRT mSliceTRT;
     };
      /** Renderbuffer surface.  Needs FBO extension.
      */

+ 0 - 2
CamelotGLRenderer/Include/CmGLTexture.h

@@ -74,8 +74,6 @@ namespace CamelotEngine {
 		*/
 		void createSurfaceList();
 
-		void createRenderTexture();
-
 		/** Return hardware pixel buffer for a surface. This buffer can then
 			be used to copy data from and to a particular level of the texture.
 			@param face 	Face number, in case of a cubemap texture. Must be 0

+ 3 - 42
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -191,7 +191,7 @@ GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint i
 								 bool writeGamma, UINT32 fsaa):
 	GLHardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage),
 	mTarget(target), mFaceTarget(0), mTextureID(id), mFace(face), mLevel(level),
-    mSoftwareMipmap(crappyCard), mSliceTRT(0)
+    mSoftwareMipmap(crappyCard)
 {
 	// devise mWidth, mHeight and mDepth and mFormat
 	GLint value = 0;
@@ -237,38 +237,10 @@ GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint i
     if(mWidth==0 || mHeight==0 || mDepth==0)
         /// We are invalid, do not allocate a buffer
         return;
-	// Allocate buffer
-	//if(mUsage & HBU_STATIC)
-	//	allocateBuffer();
-    // Is this a render target?
-    if(mUsage & TU_RENDERTARGET)
-    {
-        // Create render target for each slice
-        mSliceTRT.reserve(mDepth);
-        for(UINT32 zoffset=0; zoffset<mDepth; ++zoffset)
-        {
-            String name;
-			name = "rtt/" + toString((UINT32)this) + "/" + baseName;
-            GLSurfaceDesc surface;
-            surface.buffer = this;
-            surface.zoffset = zoffset;
-            RenderTexture *trt = GLRTTManager::instance().createRenderTexture(name, surface, writeGamma, fsaa);
-            mSliceTRT.push_back(trt);
-            CamelotEngine::RenderSystem::instancePtr()->attachRenderTarget(*mSliceTRT[zoffset]);
-        }
-	}
 }
 GLTextureBuffer::~GLTextureBuffer()
 {
-    if(mUsage & TU_RENDERTARGET)
-    {
-        // Delete all render targets that are not yet deleted via _clearSliceRTT because the rendertarget
-        // was deleted by the user.
-        for (SliceTRT::const_iterator it = mSliceTRT.begin(); it != mSliceTRT.end(); ++it)
-        {
-			CamelotEngine::RenderSystem::instancePtr()->destroyRenderTarget(*it);
-        }
-	}
+
 }
 //-----------------------------------------------------------------------------
 void GLTextureBuffer::upload(const PixelData &data, const Box &dest)
@@ -530,10 +502,7 @@ void GLTextureBuffer::blit(const HardwarePixelBufferPtr &src, const Box &srcBox,
     /// Destination texture must be 1D, 2D, 3D, or Cube
     /// Source texture must be 1D, 2D or 3D
 	
-	// This does not sem to work for RTTs after the first update
-	// I have no idea why! For the moment, disable 
-    if(GLEW_EXT_framebuffer_object && (src->getUsage() & TU_RENDERTARGET) == 0 &&
-        (srct->mTarget==GL_TEXTURE_1D||srct->mTarget==GL_TEXTURE_2D||srct->mTarget==GL_TEXTURE_3D))
+    if(GLEW_EXT_framebuffer_object && (srct->mTarget==GL_TEXTURE_1D||srct->mTarget==GL_TEXTURE_2D||srct->mTarget==GL_TEXTURE_3D))
     {
         blitFromTexture(srct, srcBox, dstBox);
     }
@@ -811,14 +780,6 @@ void GLTextureBuffer::blitFromMemory(const PixelData &src_orig, const Box &dstBo
 	if(data != NULL)
 		delete[] data;
 }
-//-----------------------------------------------------------------------------    
-
-RenderTexture *GLTextureBuffer::getRenderTarget(UINT32 zoffset)
-{
-    assert(mUsage & TU_RENDERTARGET);
-    assert(zoffset < mDepth);
-    return mSliceTRT[zoffset];
-}
 //********* GLRenderBuffer
 //----------------------------------------------------------------------------- 
 GLRenderBuffer::GLRenderBuffer(GLenum format, UINT32 width, UINT32 height, GLsizei numSamples):

+ 1 - 17
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -74,11 +74,6 @@ namespace CamelotEngine {
 	{
 		createInternalResources();
 
-		if( mUsage & TU_RENDERTARGET )
-		{
-			createRenderTexture();
-		}
-
 		Resource::initialize_internal();
 	}
 
@@ -278,22 +273,12 @@ namespace CamelotEngine {
 		// Get final internal format
 		mFormat = getBuffer(0,0)->getFormat();
 	}
-	
-    void GLTexture::createRenderTexture(void)
-    {
-        // Create the GL texture
-		// This already does everything neccessary
-        createInternalResources();
-    }
 	//*************************************************************************
-    
     void GLTexture::freeInternalResourcesImpl()
     {
 		mSurfaceList.clear();
         glDeleteTextures( 1, &mTextureID );
     }
-
-	
 	//---------------------------------------------------------------------------------------------
 	void GLTexture::createSurfaceList()
 	{
@@ -304,7 +289,7 @@ namespace CamelotEngine {
 			for(UINT32 mip=0; mip<=getNumMipmaps(); mip++)
 			{
                 GLHardwarePixelBuffer *buf = new GLTextureBuffer("", getGLTextureTarget_internal(), mTextureID, face, mip,
-						static_cast<HardwareBuffer::Usage>(mUsage), false, mHwGamma, mFSAA);
+						static_cast<HardwareBuffer::Usage>(mUsage), false, mHwGamma, 0);
 				mSurfaceList.push_back(HardwarePixelBufferPtr(buf));
                 
                 /// Check for error
@@ -319,7 +304,6 @@ namespace CamelotEngine {
 			}
 		}
 	}
-	
 	//---------------------------------------------------------------------------------------------
 	HardwarePixelBufferPtr GLTexture::getBuffer(UINT32 face, UINT32 mipmap)
 	{

+ 0 - 10
CamelotGLRenderer/Source/CmGLTextureManager.cpp

@@ -104,19 +104,9 @@ namespace CamelotEngine {
 		{
 			return PF_A8R8G8B8;
 		}
-        
-        // Check if this is a valid rendertarget format
-		if( usage & TU_RENDERTARGET )
-        {
-            /// Get closest supported alternative
-            /// If mFormat is supported it's returned
-            return GLRTTManager::instance().getSupportedAlternative(format);
-        }
 
 		// Supported
 		return format;
-
-		
 	}
 	//-----------------------------------------------------------------------------
     bool GLTextureManager::isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,

+ 0 - 16
CamelotRenderer/Include/CmHardwarePixelBuffer.h

@@ -68,13 +68,6 @@ namespace CamelotEngine {
         /// for HardwarePixelBuffer implementations, but override the previous method
         virtual void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
 
-        /// Internal implementation of unlock(), must be overridden in subclasses
-        // virtual void unlockImpl(void) = 0;
-
-		/** Notify TextureBuffer of destruction of render target.
-			Called by RenderTexture when destroyed.
-		*/
-		virtual void _clearSliceRTT(UINT32 zoffset);
 		friend class RenderTexture;
     public:
         /// Should be called by HardwareBufferManager
@@ -169,15 +162,6 @@ namespace CamelotEngine {
 			blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
 		}
         
-        /** Get a render target for this PixelBuffer, or a slice of it. The texture this
-            was acquired from must have TU_RENDERTARGET set, otherwise it is possible to
-            render to it and this method will throw an ERR_RENDERSYSTEM exception.
-            @param slice    Which slice
-            @returns A pointer to the render target. This pointer has the lifespan of this
-            PixelBuffer.
-        */
-        virtual RenderTexture *getRenderTarget(UINT32 slice=0);
-        
         /// Gets the width of this buffer
         UINT32 getWidth() const { return mWidth; }
         /// Gets the height of this buffer

+ 4 - 19
CamelotRenderer/Include/CmTexture.h

@@ -47,9 +47,7 @@ namespace CamelotEngine {
     {
 		/// @copydoc HardwareBuffer::Usage
 		TU_STATIC = HardwareBuffer::HBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
-		TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC, // Optimal if the texture is updated by CPU often (e.g. every frame)
-		TU_RENDERTARGET = 0x200, // Used for rendering by the GPU
-		TU_DEFAULT = TU_STATIC
+		TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC // Optimal if the texture is updated by CPU often (e.g. every frame)
     };
 
     /** Enum identifying the texture type
@@ -101,15 +99,6 @@ namespace CamelotEngine {
 		*/
 		virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
 
-		/** Get the level of multisample AA to be used if this texture is a 
-		rendertarget.
-		*/
-		virtual UINT32 getFSAA() const { return mFSAA; }
-
-		/** Get the multisample AA hint if this texture is a rendertarget.
-		*/
-		virtual const String& getFSAAHint() const { return mFSAAHint; }
-
 		/** Returns the height of the texture.
         */
         virtual UINT32 getHeight(void) const { return mHeight; }
@@ -215,8 +204,6 @@ namespace CamelotEngine {
 
 		UINT32 mNumMipmaps;
 		bool mHwGamma;
-		UINT32 mFSAA;
-		String mFSAAHint;
 
         TextureType mTextureType;
 		PixelFormat mFormat;
@@ -231,7 +218,7 @@ namespace CamelotEngine {
 		 * @note	Initialization is not done immediately, and is instead just scheduled on the render thread.
 		 */
 		void initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
-			PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint);
+			PixelFormat format, int usage, bool hwGamma);
 		
 		/**
 		 * @brief	Performs GpuProgram initialization. Only callable from the render thread.
@@ -289,12 +276,10 @@ namespace CamelotEngine {
 		/************************************************************************/
 	public:
 		static TexturePtr create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-			int num_mips, PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
+			int num_mips, PixelFormat format, int usage = TU_STATIC, bool hwGammaCorrection = false);
 
 		static TexturePtr create(TextureType texType, UINT32 width, UINT32 height, int num_mips,
-			PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
+			PixelFormat format, int usage = TU_STATIC, bool hwGammaCorrection = false);
     };
 	/** @} */
 }

+ 15 - 53
CamelotRenderer/Include/CmTextureManager.h

@@ -70,10 +70,6 @@ namespace CamelotEngine {
         virtual ~TextureManager();
 
 		/** Create a manual texture with specified width, height and depth (not loaded from a file).
-            @param
-                name The name to give the resulting texture
-            @param
-                group The name of the resource group to assign the texture to
             @param
                 texType The type of texture to load/create, defaults to normal 2D textures
             @param
@@ -88,38 +84,20 @@ namespace CamelotEngine {
                 the right to create a different format if the one you select is
                 not available in this context.
 			@param 
-				usage The kind of usage this texture is intended for. It 
-				is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY, 
-				TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are
-            	strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to 
-            	update regularly, consider HBU_DYNAMIC_WRITE_ONLY.
-            @param
-                loader If you intend the contents of the manual texture to be 
-                regularly updated, to the extent that you don't need to recover 
-                the contents if the texture content is lost somehow, you can leave
-                this parameter as 0. However, if you intend to populate the
-                texture only once, then you should implement ManualResourceLoader
-                and pass a pointer to it in this parameter; this means that if the
-                manual texture ever needs to be reloaded, the ManualResourceLoader
-                will be called to do it.
+				usage The kind of usage this texture is intended for. You are
+				strongly advised to use TU_STATIC wherever possible, if you need to 
+				update regularly, consider TU_DYNAMIC.
 			@param hwGammaCorrection Pass 'true' to enable hardware gamma correction
 				(sRGB) on this texture. The hardware will convert from gamma space
 				to linear space when reading from this texture. Only applicable for 
 				8-bits per channel textures, will be ignored for other types. Has the advantage
 				over pre-applied gamma that the texture precision is maintained.
-			@param fsaa The level of multisampling to use if this is a render target. Ignored
-				if usage does not include TU_RENDERTARGET or if the device does
-				not support it.
         */
         TexturePtr create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-			int num_mips, PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
+			int num_mips, PixelFormat format, int usage = TU_STATIC,
+			bool hwGammaCorrection = false);
 			
         /** Create a manual texture with a depth of 1 (not loaded from a file).
-            @param
-                name The name to give the resulting texture
-            @param
-                group The name of the resource group to assign the texture to
             @param
                 texType The type of texture to load/create, defaults to normal 2D textures
             @param
@@ -134,35 +112,21 @@ namespace CamelotEngine {
                 the right to create a different format if the one you select is
                 not available in this context.
 			@param 
-				usage The kind of usage this texture is intended for. It 
-				is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY, 
-				TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are
-            	strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to 
-            	update regularly, consider HBU_DYNAMIC_WRITE_ONLY.
-            @param
-                loader If you intend the contents of the manual texture to be 
-                regularly updated, to the extent that you don't need to recover 
-                the contents if the texture content is lost somehow, you can leave
-                this parameter as 0. However, if you intend to populate the
-                texture only once, then you should implement ManualResourceLoader
-                and pass a pointer to it in this parameter; this means that if the
-                manual texture ever needs to be reloaded, the ManualResourceLoader
-                will be called to do it.
-			 @param hwGammaCorrection Pass 'true' to enable hardware gamma correction
+				usage The kind of usage this texture is intended for. You are
+            	strongly advised to use TU_STATIC wherever possible, if you need to 
+            	update regularly, consider TU_DYNAMIC.
+			@param hwGammaCorrection Pass 'true' to enable hardware gamma correction
 				 (sRGB) on this texture. The hardware will convert from gamma space
 				 to linear space when reading from this texture. Only applicable for 
 				 8-bits per channel textures, will be ignored for other types. Has the advantage
 				 over pre-applied gamma that the texture precision is maintained.
-			@param fsaa The level of multisampling to use if this is a render target. Ignored
-				if usage does not include TU_RENDERTARGET or if the device does
-				not support it.
         */
         TexturePtr create(TextureType texType, UINT32 width, UINT32 height, int num_mips,
-            PixelFormat format, int usage = TU_DEFAULT,
-			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK)
+            PixelFormat format, int usage = TU_STATIC,
+			bool hwGammaCorrection = false)
 		{
 			return create(texType, width, height, 1, 
-				num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
+				num_mips, format, usage, hwGammaCorrection);
 		}
 
 		/**
@@ -175,9 +139,8 @@ namespace CamelotEngine {
 		/**
 		 * @brief	Creates a new depth/stencil buffer.
 		 */
-		virtual DepthStencilBufferPtr createDepthStencilBuffer(UINT32 bitDepth, UINT32 width, 
-			UINT32 height, UINT32 fsaa, const String& fsaaHint) = 0;
-
+		virtual DepthStencilBufferPtr createDepthStencilBuffer(UINT32 bitDepth, UINT32 width, UINT32 height, 
+			UINT32 fsaa, const String& fsaaHint) = 0;
 
 		/** Returns whether this render system can natively support the precise texture 
 			format requested with the given usage options.
@@ -246,8 +209,7 @@ namespace CamelotEngine {
             check if in fallback mode.
 		@returns true if the texture filtering is supported.
         */
-        virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
-            bool preciseFormatOnly = false) = 0;
+        virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage, bool preciseFormatOnly = false) = 0;
 
     protected:
 

+ 4 - 9
CamelotRenderer/Include/CmTextureRTTI.h

@@ -21,8 +21,6 @@ namespace CamelotEngine
 		CM_SETGET_MEMBER(mDepth, UINT32, Texture)
 		CM_SETGET_MEMBER(mNumMipmaps, UINT32, Texture)
 		CM_SETGET_MEMBER(mHwGamma, bool, Texture)
-		CM_SETGET_MEMBER(mFSAA, UINT32, Texture)
-		CM_SETGET_MEMBER(mFSAAHint, String, Texture)
 		CM_SETGET_MEMBER(mTextureType, TextureType, Texture)
 		CM_SETGET_MEMBER(mFormat, PixelFormat, Texture)
 		CM_SETGET_MEMBER(mUsage, INT32, Texture)
@@ -64,11 +62,9 @@ namespace CamelotEngine
 			CM_ADD_PLAINFIELD(mDepth, 4, TextureRTTI)
 			CM_ADD_PLAINFIELD(mNumMipmaps, 5, TextureRTTI)
 			CM_ADD_PLAINFIELD(mHwGamma, 6, TextureRTTI)
-			CM_ADD_PLAINFIELD(mFSAA, 7, TextureRTTI)
-			CM_ADD_PLAINFIELD(mFSAAHint, 8, TextureRTTI)
-			CM_ADD_PLAINFIELD(mTextureType, 9, TextureRTTI)
-			CM_ADD_PLAINFIELD(mFormat, 10, TextureRTTI)
-			CM_ADD_PLAINFIELD(mUsage, 11, TextureRTTI)
+			CM_ADD_PLAINFIELD(mTextureType, 7, TextureRTTI)
+			CM_ADD_PLAINFIELD(mFormat, 8, TextureRTTI)
+			CM_ADD_PLAINFIELD(mUsage, 9, TextureRTTI)
 
 			addReflectablePtrArrayField("mPixelData", 12, &TextureRTTI::getPixelData, &TextureRTTI::getPixelDataArraySize, 
 				&TextureRTTI::setPixelData, &TextureRTTI::setPixelDataArraySize);
@@ -91,8 +87,7 @@ namespace CamelotEngine
 			// A bit clumsy initializing with already set values, but I feel its better than complicating things and storing the values
 			// in mRTTIData.
 			texture->initialize(texture->getTextureType(), texture->getWidth(), texture->getHeight(), texture->getDepth(), 
-				texture->getNumMipmaps(), texture->getFormat(), texture->getUsage(), texture->isHardwareGammaEnabled(), 
-				texture->getFSAA(), texture->getFSAAHint());
+				texture->getNumMipmaps(), texture->getFormat(), texture->getUsage(), texture->isHardwareGammaEnabled());
 
 			vector<PixelDataPtr>::type* pixelData = boost::any_cast<vector<PixelDataPtr>::type*>(texture->mRTTIData);
 			for(size_t i = 0; i < pixelData->size(); i++)

+ 0 - 14
CamelotRenderer/Source/CmHardwarePixelBuffer.cpp

@@ -150,18 +150,4 @@ namespace CamelotEngine
 		CM_EXCEPT(NotImplementedException,
 				"Writing a byte range is not implemented. Use blitFromMemory.");
 	}
-    //-----------------------------------------------------------------------------    
-    
-    RenderTexture *HardwarePixelBuffer::getRenderTarget(UINT32)
-    {
-        CM_EXCEPT(NotImplementedException,
-				"Not yet implemented for this rendersystem.");
-    }
-
-	//-----------------------------------------------------------------------------    
-
-	void HardwarePixelBuffer::_clearSliceRTT(UINT32 zoffset)
-	{
-	}
-
 }

+ 0 - 1
CamelotRenderer/Source/CmRenderTexture.cpp

@@ -45,7 +45,6 @@ namespace CamelotEngine
     }
     RenderTexture::~RenderTexture()
     {
-		mBuffer->_clearSliceRTT(0);
     }
 
 	void RenderTexture::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)

+ 6 - 9
CamelotRenderer/Source/CmTexture.cpp

@@ -49,16 +49,15 @@ namespace CamelotEngine {
             mDepth(1),
             mNumMipmaps(0),
 			mHwGamma(false),
-			mFSAA(0),
             mTextureType(TEX_TYPE_2D),            
             mFormat(PF_UNKNOWN),
-            mUsage(TU_DEFAULT)
+            mUsage(TU_STATIC)
     {
         
     }
 	//-------------------------------------------------------------------------
 	void Texture::initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
-		PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint)
+		PixelFormat format, int usage, bool hwGamma)
 	{
 		mTextureType = textureType;
 		mWidth = width;
@@ -68,8 +67,6 @@ namespace CamelotEngine {
 		mFormat = format;
 		mUsage = usage;
 		mHwGamma = hwGamma;
-		mFSAA = fsaa;
-		mFSAAHint = fsaaHint;
 
 		mSize = getNumFaces() * PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
 
@@ -252,17 +249,17 @@ namespace CamelotEngine {
 	/* 								STATICS	                      			*/
 	/************************************************************************/
 	TexturePtr Texture::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 fsaa, const String& fsaaHint)
+		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection)
 	{
 		return TextureManager::instance().create(texType, 
-			width, height, depth, num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
+			width, height, depth, num_mips, format, usage, hwGammaCorrection);
 	}
 	
 	TexturePtr Texture::create(TextureType texType, UINT32 width, UINT32 height, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 fsaa, const String& fsaaHint)
+		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection)
 	{
 		return TextureManager::instance().create(texType, 
-			width, height, num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
+			width, height, num_mips, format, usage, hwGammaCorrection);
 	}
 }
 

+ 2 - 3
CamelotRenderer/Source/CmTextureManager.cpp

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