Browse Source

More documentation

Marko Pintera 11 years ago
parent
commit
2b84371fe6

+ 162 - 13
BansheeD3D9RenderSystem/Include/BsD3D9Device.h

@@ -5,21 +5,25 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
-	/** High level interface of Direct3D9 Device.
-	Provide useful methods for device handling.
-	*/
+	/**
+	 * @brief	High level interface for a DX9 device. Each device represents
+	 *			a hardware adapter or a software emulation device.
+	 */
 	class BS_D3D9_EXPORT D3D9Device
 	class BS_D3D9_EXPORT D3D9Device
 	{
 	{
 	protected:
 	protected:
+		/**
+		 * @brief	Holds device specific render window resources.
+		 */
 		struct RenderWindowResources
 		struct RenderWindowResources
 		{
 		{
-			IDirect3DSwapChain9* swapChain;	// Swap chain interface.
-			UINT32 adapterOrdinalInGroupIndex; // Relative index of the render window in the group.
-			UINT32 presentParametersIndex; // Index of present parameter in the shared array of the device.
-			IDirect3DSurface9* backBuffer; // The back buffer of the render window.
-			IDirect3DSurface9* depthBuffer;	// The depth buffer of the render window.
-			D3DPRESENT_PARAMETERS presentParameters; // Present parameters of the render window.
-			bool acquired; // True if resources acquired.			
+			IDirect3DSwapChain9* swapChain;	/**< Swap chain interface. */
+			UINT32 adapterOrdinalInGroupIndex; /**< Relative index of the render window in the group. */
+			UINT32 presentParametersIndex; /**< Index of present parameter in the shared array of the device. */
+			IDirect3DSurface9* backBuffer; /**< The back buffer of the render window. */
+			IDirect3DSurface9* depthBuffer;	/**< The depth buffer of the render window. */
+			D3DPRESENT_PARAMETERS presentParameters; /**< Present parameters of the render window. */
+			bool acquired; /**< True if resources acquired. */	
 		};
 		};
 
 
 	public:
 	public:
@@ -27,36 +31,116 @@ namespace BansheeEngine
 			D3DDEVTYPE devType, DWORD behaviorFlags);
 			D3DDEVTYPE devType, DWORD behaviorFlags);
 		~D3D9Device();
 		~D3D9Device();
 
 
+		/**
+		 * @brief	Attaches a new render window to this device. Caller must ensure
+		 *			the window is not attached to multiple devices.
+		 */
 		void attachRenderWindow(const D3D9RenderWindow* renderWindow);
 		void attachRenderWindow(const D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Detaches the render window from this device.
+		 */
 		void detachRenderWindow(const D3D9RenderWindow* renderWindow);
 		void detachRenderWindow(const D3D9RenderWindow* renderWindow);
 	
 	
+		/**
+		 * @brief	Acquires the device. This will cause a device reset in case present parameters changed.
+		 */
 		bool acquire();
 		bool acquire();
 		
 		
-		void release();		
+		/**
+		 * @brief	Release the device and all resources directly managed by it.
+		 */
+		void release();
+
+		/**
+		 * @brief	Destroys the device and all resources directly managed by it.
+		 */
 		void destroy();		
 		void destroy();		
 		
 		
+		/**
+		 * @brief	Checks is the device lost. If lost you will need to "acquire" the device.
+		 */
 		bool isDeviceLost();				
 		bool isDeviceLost();				
+		
+		/**
+		 * @brief	Return internal DX9 device object.
+		 */
 		IDirect3DDevice9* getD3D9Device() const;
 		IDirect3DDevice9* getD3D9Device() const;
-					
+
+		/**
+		 * @brief	Returns adapter number this device is tied to. This number corresponds to the
+		 *			adapter index returned by DX9 API.
+		 */
 		UINT getAdapterNumber() const;
 		UINT getAdapterNumber() const;
+
+		/**
+		 * @brief	Returns type of the device.
+		 */
 		D3DDEVTYPE getDeviceType() const;
 		D3DDEVTYPE getDeviceType() const;
+
+		/**
+		 * @brief	Checks is the device multihead (manages multiple full-screen outputs).
+		 */
 		bool isMultihead() const;					
 		bool isMultihead() const;					
+
+		/**
+		 * @brief	Returns true if depth/stencil format can be automatically determined.
+		 */
 		bool isAutoDepthStencil() const;
 		bool isAutoDepthStencil() const;
 		
 		
+		/**
+		 * @brief	Returns DX9 device capabilities.
+		 */
 		const D3DCAPS9& getD3D9DeviceCaps() const;
 		const D3DCAPS9& getD3D9DeviceCaps() const;
+
+		/**
+		 * @brief	Returns DX9 format of the back buffer used by the primary window for this device.
+		 */
 		D3DFORMAT getBackBufferFormat() const;
 		D3DFORMAT getBackBufferFormat() const;
+
+		/**
+		 * @brief	Returns DX9 format of the depth stencil buffer used by the primary window for this device.
+		 */
 		D3DFORMAT getDepthStencilFormat() const;
 		D3DFORMAT getDepthStencilFormat() const;
 
 
+		/**
+		 * @brief	Validates that the window is valid for this device. Will reset device if needed.
+		 */
 		bool validate(D3D9RenderWindow* renderWindow);
 		bool validate(D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Invalidates the window so on the next call to validate, the device will be re-acquired.
+		 */
 		void invalidate(const D3D9RenderWindow* renderWindow);
 		void invalidate(const D3D9RenderWindow* renderWindow);
 
 
+		/**
+		 * @brief	Swap back and front buffers for the specified window.
+		 */
 		void present(const D3D9RenderWindow* renderWindow);
 		void present(const D3D9RenderWindow* renderWindow);
 		
 		
+		/**
+		 * @brief	Returns internal DX9 represention of the depth/stencil buffer.
+		 */
 		IDirect3DSurface9* getDepthBuffer(const D3D9RenderWindow* renderWindow);
 		IDirect3DSurface9* getDepthBuffer(const D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Returns internal DX9 represention of the backbuffer.
+		 */
 		IDirect3DSurface9* getBackBuffer(const D3D9RenderWindow* renderWindow);
 		IDirect3DSurface9* getBackBuffer(const D3D9RenderWindow* renderWindow);
 
 
+		/**
+		 * @brief	Sets adapter index for the specified window.
+		 */
 		void setAdapterOrdinalIndex(const D3D9RenderWindow* renderWindow, UINT32 adapterOrdinalInGroupIndex);
 		void setAdapterOrdinalIndex(const D3D9RenderWindow* renderWindow, UINT32 adapterOrdinalInGroupIndex);
+
+		/**
+		 * @brief	Copies contents of the back or depth/stencil buffer in to the provided object.
+		 */
 		void copyContentsToMemory(const D3D9RenderWindow* window, const PixelData &dst, RenderTarget::FrameBuffer buffer);
 		void copyContentsToMemory(const D3D9RenderWindow* window, const PixelData &dst, RenderTarget::FrameBuffer buffer);
+
+		/**
+		 * @brief	Resets bound pipeline states/streams to null.
+		 */
 		void clearDeviceStreams();
 		void clearDeviceStreams();
 	
 	
 	protected:
 	protected:
@@ -66,25 +150,90 @@ namespace BansheeEngine
 		typedef Map<const D3D9RenderWindow*, RenderWindowResources*> RenderWindowToResorucesMap;
 		typedef Map<const D3D9RenderWindow*, RenderWindowResources*> RenderWindowToResorucesMap;
 		typedef RenderWindowToResorucesMap::iterator				 RenderWindowToResorucesIterator;
 		typedef RenderWindowToResorucesMap::iterator				 RenderWindowToResorucesIterator;
 
 
+		/**
+		 * @brief	Find iterator for the specified window in the render window resource list.
+		 */
 		RenderWindowToResorucesIterator getRenderWindowIterator(const D3D9RenderWindow* renderWindow);
 		RenderWindowToResorucesIterator getRenderWindowIterator(const D3D9RenderWindow* renderWindow);
 
 
+		/**
+		 * @brief	Acquires the device for the provided render window.
+		 */
 		bool acquire(const D3D9RenderWindow* renderWindow);
 		bool acquire(const D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Forcibly reset the device.
+		 */
 		bool reset();
 		bool reset();
+
+		/**
+		 * @brief	Update presentation parameters from the active render window.
+		 */
 		void updatePresentationParameters();
 		void updatePresentationParameters();
+
+		/**
+		 * @brief	Updates presentation parameter indices for all windows attached to this device.
+		 */
 		void updateRenderWindowsIndices();
 		void updateRenderWindowsIndices();
 
 
+		/**
+		 * @brief	Creates a new DX9 device object.
+		 */
 		void createD3D9Device();
 		void createD3D9Device();
+
+		/**
+		 * @brief	Releases the DX9 device object.
+		 */
 		void releaseD3D9Device();
 		void releaseD3D9Device();
+
+		/**
+		 * @brief	Releases all render window resources in the provided object.
+		 */
 		void releaseRenderWindowResources(RenderWindowResources* renderWindowResources);
 		void releaseRenderWindowResources(RenderWindowResources* renderWindowResources);
+
+		/**
+		 * @brief	Acquires all render window resources from the provided render window,
+		 *			and stores them in the provided render window resources object.
+		 */
 		void acquireRenderWindowResources(RenderWindowToResorucesIterator it);
 		void acquireRenderWindowResources(RenderWindowToResorucesIterator it);
+
+		/**
+		 * @brief	Called when it has been detected that device has been lost.
+		 */
 		void notifyDeviceLost();
 		void notifyDeviceLost();
 
 
+		/**
+		 * @brief	Checks if focus window changed and should device be reacquired.
+		 */
 		void validateFocusWindow();
 		void validateFocusWindow();
+
+		/**
+		 * @brief	Checks if back buffer size has changed and invalidates the window if it has.
+		 */
 		void validateBackBufferSize(const D3D9RenderWindow* renderWindow);
 		void validateBackBufferSize(const D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Checks if window monitor changed and re-links the window if needed.
+		 */
 		bool validateDisplayMonitor(D3D9RenderWindow* renderWindow);
 		bool validateDisplayMonitor(D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Checks if device has been lost or active window invalidated and acquires the device if needed.
+		 */
 		bool validateDeviceState(const D3D9RenderWindow* renderWindow);
 		bool validateDeviceState(const D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Checks if the render window contains a custom swap chain.
+		 */
 		bool isSwapChainWindow(const D3D9RenderWindow* renderWindow);
 		bool isSwapChainWindow(const D3D9RenderWindow* renderWindow);
+
+		/**
+		 * @brief	Returns primary window for this device.
+		 */
 		const D3D9RenderWindow*	getPrimaryWindow();
 		const D3D9RenderWindow*	getPrimaryWindow();
+
+		/**
+		 * @brief	Sets the shared window handle.
+		 */
 		void setSharedWindowHandle(HWND hSharedHWND);
 		void setSharedWindowHandle(HWND hSharedHWND);
 
 
 	protected:			
 	protected:			
@@ -107,7 +256,7 @@ namespace BansheeEngine
 		D3DDEVICE_CREATION_PARAMETERS mCreationParams; /**< Creation parameters. */
 		D3DDEVICE_CREATION_PARAMETERS mCreationParams; /**< Creation parameters. */
 		bool mDeviceLost; /**< True if device entered lost state. */
 		bool mDeviceLost; /**< True if device entered lost state. */
 	
 	
-		RenderWindowToResorucesMap mMapRenderWindowToResoruces;		// Map between render window to resources.
+		RenderWindowToResorucesMap mMapRenderWindowToResoruces;	/**< Map between render window to resources. */
 	
 	
 	};
 	};
 }
 }

+ 23 - 1
BansheeD3D9RenderSystem/Include/BsD3D9Driver.h

@@ -8,6 +8,9 @@ namespace BansheeEngine
 	class D3D9VideoModeList;
 	class D3D9VideoModeList;
 	class D3D9VideoMode;
 	class D3D9VideoMode;
 
 
+	/**
+	 * @brief	Holds data about a DX9 driver (adapter).
+	 */
 	class BS_D3D9_EXPORT D3D9Driver
 	class BS_D3D9_EXPORT D3D9Driver
 	{
 	{
 	public:
 	public:
@@ -16,11 +19,30 @@ namespace BansheeEngine
 		D3D9Driver(UINT32 adapterNumber, const D3DCAPS9& deviceCaps, const D3DADAPTER_IDENTIFIER9& adapterIdentifer);
 		D3D9Driver(UINT32 adapterNumber, const D3DCAPS9& deviceCaps, const D3DADAPTER_IDENTIFIER9& adapterIdentifer);
 		~D3D9Driver();
 		~D3D9Driver();
 
 
+		/**
+		 * @brief	Returns hardware capabilities for this driver.
+		 */
 		const D3DCAPS9&	getD3D9DeviceCaps() const { return mD3D9DeviceCaps; }
 		const D3DCAPS9&	getD3D9DeviceCaps() const { return mD3D9DeviceCaps; }
+
+		/**
+		 * @brief	Returns name of the driver.
+		 */
 		String getDriverName() const;
 		String getDriverName() const;
+
+		/**
+		 * @brief	Returns description of the driver.
+		 */
 		String getDriverDescription() const;
 		String getDriverDescription() const;
-				
+
+		/**
+		 * @brief	Returns adapter number which corresponds to adapter number returned by
+		 *			DX9 API.
+		 */
 		UINT32 getAdapterNumber() const { return mAdapterNumber; }
 		UINT32 getAdapterNumber() const { return mAdapterNumber; }
+
+		/**
+		 * @brief	Returns DX9 adapter identifier.
+		 */
 		const D3DADAPTER_IDENTIFIER9& getAdapterIdentifier() const { return mAdapterIdentifier; }
 		const D3DADAPTER_IDENTIFIER9& getAdapterIdentifier() const { return mAdapterIdentifier; }
 
 
 	private:				
 	private:				

+ 16 - 0
BansheeD3D9RenderSystem/Include/BsD3D9DriverList.h

@@ -5,17 +5,33 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
+	/**
+	 * @brief	Holds a list of all drivers (adapters) and video modes.
+	 */
 	class BS_D3D9_EXPORT D3D9DriverList
 	class BS_D3D9_EXPORT D3D9DriverList
 	{
 	{
 	public:
 	public:
 		D3D9DriverList();
 		D3D9DriverList();
 		~D3D9DriverList();
 		~D3D9DriverList();
 
 
+		/**
+		 * @brief	Returns the number of drivers (adapters) available.
+		 */
 		UINT32 count() const;
 		UINT32 count() const;
 
 
+		/**
+		 * @brief	Returns driver with the specified index.
+		 */
 		D3D9Driver* item(UINT32 index);
 		D3D9Driver* item(UINT32 index);
+
+		/**
+		 * @brief	Returns drivers with the specified name or null if it cannot be found.
+		 */
 		D3D9Driver* item(const String &name);
 		D3D9Driver* item(const String &name);
 
 
+		/**
+		 * @brief	Returns available video modes for all drivers and output devices.
+		 */
 		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
 		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
 
 
 	private:
 	private:

+ 12 - 0
BansheeD3D9RenderSystem/Include/BsD3D9GpuBuffer.h

@@ -5,6 +5,11 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/**
+	 * @brief	Represents a generic GPU buffer in DX9. This class
+	 *			is just a dummy in order to conform to the interface
+	 *			as DX9 supports no such buffers.
+	 */
 	class BS_D3D9_EXPORT D3D9GpuBuffer : public GpuBuffer
 	class BS_D3D9_EXPORT D3D9GpuBuffer : public GpuBuffer
 	{
 	{
 	public:
 	public:
@@ -42,7 +47,14 @@ namespace BansheeEngine
 
 
 		D3D9GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
 		D3D9GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
 
 
+		/**
+		 * @copydoc	GpuBuffer::createView
+		 */
 		virtual GpuBufferView* createView();
 		virtual GpuBufferView* createView();
+
+		/**
+		 * @copydoc	GpuBuffer::destroyView
+		 */
 		virtual void destroyView(GpuBufferView* view);
 		virtual void destroyView(GpuBufferView* view);
 
 
 		/**
 		/**

+ 57 - 36
BansheeD3D9RenderSystem/Include/BsD3D9GpuProgram.h

@@ -7,6 +7,9 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
+	/**
+	 * @brief	Available optimization levels when compiling a GPU program.
+	 */
 	enum OptimizationLevel
 	enum OptimizationLevel
 	{
 	{
 		OPT_DEFAULT,
 		OPT_DEFAULT,
@@ -17,38 +20,42 @@ namespace BansheeEngine
 		OPT_3
 		OPT_3
 	};
 	};
 
 
-    /** Direct3D implementation of a few things common to low-level vertex & fragment programs. */
+	/**
+	 * @brief	DirectX 9 implementation of a GPU program.
+	 */
     class BS_D3D9_EXPORT D3D9GpuProgram : public GpuProgram, public D3D9Resource
     class BS_D3D9_EXPORT D3D9GpuProgram : public GpuProgram, public D3D9Resource
     {   
     {   
     public:
     public:
-        ~D3D9GpuProgram();
+        virtual ~D3D9GpuProgram();
 
 
 		/**
 		/**
 		 * @copydoc	GpuProgram::requiresMatrixTranspose
 		 * @copydoc	GpuProgram::requiresMatrixTranspose
 		 */
 		 */
 		virtual bool requiresMatrixTranspose() const { return mColumnMajorMatrices; }
 		virtual bool requiresMatrixTranspose() const { return mColumnMajorMatrices; }
 
 
-		/** Sets the preprocessor defines use to compile the program. */
+		/**
+		 * @brief	Sets the preprocessor defines use to compile the program.
+		 */
 		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
 		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
-		/** Sets the preprocessor defines use to compile the program. */
-		const String& getPreprocessorDefines() const { return mPreprocessorDefines; }
 
 
-        /** Sets whether matrix packing in column-major order. */ 
+		/**
+		 * @brief	Sets whether matrix packing in column-major order.
+		 */
         void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
         void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
-        /** Gets whether matrix packed in column-major order. */
-        bool getColumnMajorMatrices() const { return mColumnMajorMatrices; }
 
 
-		/** Sets the optimisation level to use.
-		@param opt Optimisation level
-		*/
+		/**
+		 * @brief	Sets optimization level to use when compiling the shader.
+		 */
 		void setOptimizationLevel(OptimizationLevel opt) { mOptimisationLevel = opt; }
 		void setOptimizationLevel(OptimizationLevel opt) { mOptimisationLevel = opt; }
 
 
-		/** Gets the optimisation level to use. */
-		OptimizationLevel getOptimizationLevel() const { return mOptimisationLevel; }
-
-		/// Overridden from GpuProgram
+		/**
+		 * @copydoc	GpuProgram::createParameters
+		 */
 		GpuParamsPtr createParameters();
 		GpuParamsPtr createParameters();
-		/// Overridden from GpuProgram
+
+		/**
+		 * @copydoc	GpuProgram::getLanguage
+		 */
 		const String& getLanguage() const;
 		const String& getLanguage() const;
 
 
     protected:
     protected:
@@ -58,19 +65,19 @@ namespace BansheeEngine
 			GpuProgramType gptype, GpuProgramProfile profile, 
 			GpuProgramType gptype, GpuProgramProfile profile, 
 			const Vector<HGpuProgInclude>* includes);
 			const Vector<HGpuProgInclude>* includes);
 
 
-		void createInternalResources(IDirect3DDevice9* d3d9Device);
-
 		/**
 		/**
-		 * @copydoc GpuProgram::initialize_internal().
+		 * @copydoc GpuProgram::initialize_internal
 		 */
 		 */
 		void initialize_internal();
 		void initialize_internal();
 
 
 		/**
 		/**
-		 * @copydoc GpuProgram::destroy_internal().
+		 * @copydoc GpuProgram::destroy_internal
 		 */
 		 */
 		void destroy_internal();
 		void destroy_internal();
       
       
-		/** Loads this program from microcode, must be overridden by subclasses. */
+		/**
+		 * @brief	Loads the GPU program from compiled microcode.
+		 */
         virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
         virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
 
 
 	protected:    
 	protected:    
@@ -89,19 +96,27 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 		virtual RTTITypeBase* getRTTI() const;
     };
     };
 
 
-    /** Direct3D implementation of low-level vertex programs. */
+	/**
+	 * @brief	DirectX 9 implementation of a vertex GPU program.
+	 */
     class BS_D3D9_EXPORT D3D9GpuVertexProgram : public D3D9GpuProgram
     class BS_D3D9_EXPORT D3D9GpuVertexProgram : public D3D9GpuProgram
     {  
     {  
     public:
     public:
 		~D3D9GpuVertexProgram();
 		~D3D9GpuVertexProgram();
         
         
-		/// Gets the vertex shader
+		/**
+		 * @brief	Returns internal DX9 vertex shader object.
+		 */
         IDirect3DVertexShader9* getVertexShader();
         IDirect3DVertexShader9* getVertexShader();
 
 
-		// Called immediately after the Direct3D device has been created.
+		/**
+		 * @copydoc D3D9Resource::notifyOnDeviceCreate
+		 */
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
 
 
-		// Called before the Direct3D device is going to be destroyed.
+		/**
+		 * @copydoc D3D9Resource::notifyOnDeviceDestroy
+		 */
 		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
 		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
 
 
     protected:
     protected:
@@ -115,13 +130,13 @@ namespace BansheeEngine
 		 */
 		 */
 		void destroy_internal();
 		void destroy_internal();
 
 
+		/**
+		 * @copydoc	D3D9GpuProgram::loadFromMicrocode
+		 */
         void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode);
         void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode);
 
 
 	protected:
 	protected:
-		typedef Map<IDirect3DDevice9*, IDirect3DVertexShader9*>   DeviceToVertexShaderMap;
-		typedef DeviceToVertexShaderMap::iterator						DeviceToVertexShaderIterator;
-	
-		DeviceToVertexShaderMap		mMapDeviceToVertexShader;	
+		Map<IDirect3DDevice9*, IDirect3DVertexShader9*>	mMapDeviceToVertexShader;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/* 								SERIALIZATION                      		*/
@@ -138,13 +153,19 @@ namespace BansheeEngine
     public:
     public:
 		~D3D9GpuFragmentProgram();
 		~D3D9GpuFragmentProgram();
 
 
-        /// Gets the pixel shader
+		/**
+		 * @brief	Returns internal DX9 pixel shader object.
+		 */
         IDirect3DPixelShader9* getPixelShader();
         IDirect3DPixelShader9* getPixelShader();
 
 
-		// Called immediately after the Direct3D device has been created.
+		/**
+		 * @copydoc D3D9Resource::notifyOnDeviceCreate
+		 */
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
 
 
-		// Called before the Direct3D device is going to be destroyed.
+		/**
+		 * @copydoc D3D9Resource::notifyOnDeviceDestroy
+		 */
 		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
 		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
 
 
     protected:
     protected:
@@ -158,13 +179,13 @@ namespace BansheeEngine
 		 */
 		 */
 		void destroy_internal();
 		void destroy_internal();
 
 
+		/**
+		 * @copydoc	D3D9GpuProgram::loadFromMicrocode
+		 */
         void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode);
         void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode);
 
 
 	protected:
 	protected:
-		typedef Map<IDirect3DDevice9*, IDirect3DPixelShader9*>	DeviceToPixelShaderMap;
-		typedef DeviceToPixelShaderMap::iterator						DeviceToPixelShaderIterator;
-
-		DeviceToPixelShaderMap		mMapDeviceToPixelShader;	
+		Map<IDirect3DDevice9*, IDirect3DPixelShader9*> mMapDeviceToPixelShader;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/* 								SERIALIZATION                      		*/

+ 32 - 3
BansheeD3D9RenderSystem/Include/BsD3D9HLSLParamParser.h

@@ -5,20 +5,49 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/**
+	 * @brief	Helper class that parses GPU program constant table and returns parameters used 
+	 *			by the program, as well as their type, size and other information.
+	 */
 	class D3D9HLSLParamParser
 	class D3D9HLSLParamParser
 	{
 	{
 	public:
 	public:
+		/**
+		 * @brief	Initializes the parameter parser with the specified constant table, and an optional list
+		 *			of parameter blocks. DirectX 9 does not support parameter blocks internally, but
+		 *			we can emulate the functionality by providing a list of user-defined blocks and
+		 *			the parameters they contain.
+		 */
 		D3D9HLSLParamParser(LPD3DXCONSTANTTABLE constTable, const Vector<D3D9EmulatedParamBlock>& blocks)
 		D3D9HLSLParamParser(LPD3DXCONSTANTTABLE constTable, const Vector<D3D9EmulatedParamBlock>& blocks)
 			:mpConstTable(constTable), mBlocks(blocks)
 			:mpConstTable(constTable), mBlocks(blocks)
 		{ }
 		{ }
 
 
+		/**
+		 * @brief	Builds parameter descriptions and returns an object containing all relevant information.
+		 */
 		GpuParamDescPtr buildParameterDescriptions();
 		GpuParamDescPtr buildParameterDescriptions();
 
 
 	private:
 	private:
-		void processParameter(GpuParamBlockDesc& blockDesc, const String& paramName, D3DXHANDLE constant,
-			String prefix, UINT32 index);
+		/**
+		 * @brief	Determines information about the specified parameter and places it in the provided 
+		 *			parameter block, as well as any children of the parameter.
+		 *
+		 * @param	blockDesc	Parent block into which to add the new parameter.
+		 * @param	paramName	Name of the parameter.
+		 * @param	constant	Parameter handle in the constant table.
+		 * @param	prefix		Prefix to append to the parameter and any child parameters.	
+		 */
+		void processParameter(GpuParamBlockDesc& blockDesc, const String& paramName, D3DXHANDLE constant, String prefix);
+
+		/**
+		 * @brief	Populates information about the parameter in "memberDesc" from the data in d3dDesc. Esentially converts
+		 *			DX9 parameter data to engine data.
+		 */
 		void populateParamMemberDesc(GpuParamDataDesc& memberDesc, D3DXCONSTANT_DESC& d3dDesc);
 		void populateParamMemberDesc(GpuParamDataDesc& memberDesc, D3DXCONSTANT_DESC& d3dDesc);
 
 
+		/**
+		 * @brief	Returns the name of the parameter with the specified constant table handle.
+		 */
 		String getParamName(D3DXHANDLE constant);
 		String getParamName(D3DXHANDLE constant);
 
 
 	private:
 	private:
@@ -106,7 +135,7 @@ namespace BansheeEngine
 		return mParamDesc;
 		return mParamDesc;
 	}
 	}
 
 
-	void D3D9HLSLParamParser::processParameter(GpuParamBlockDesc& blockDesc, const String& paramName, D3DXHANDLE constant, String prefix, UINT32 index)
+	void D3D9HLSLParamParser::processParameter(GpuParamBlockDesc& blockDesc, const String& paramName, D3DXHANDLE constant, String prefix)
 	{
 	{
 		// Since D3D HLSL doesn't deal with naming of array and struct parameters
 		// Since D3D HLSL doesn't deal with naming of array and struct parameters
 		// automatically, we have to do it by hand
 		// automatically, we have to do it by hand

+ 13 - 1
BansheeD3D9RenderSystem/Include/BsD3D9HLSLProgramFactory.h

@@ -5,18 +5,30 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-    /** Factory class for D3D9 HLSL programs. */
+	/**
+	 * @brief	Handles creation of HLSL GPU programs.
+	 */
     class BS_D3D9_EXPORT D3D9HLSLProgramFactory : public GpuProgramFactory
     class BS_D3D9_EXPORT D3D9HLSLProgramFactory : public GpuProgramFactory
     {
     {
     public:
     public:
         D3D9HLSLProgramFactory();
         D3D9HLSLProgramFactory();
         ~D3D9HLSLProgramFactory();
         ~D3D9HLSLProgramFactory();
 
 
+		/**
+		 * @copydoc	GpuProgramFactory::getLanguage
+		 */
 		const String& getLanguage() const;
 		const String& getLanguage() const;
 
 
+		/**
+		 * @copydoc	GpuProgramFactory::getLanguage(const String&, const String&, GpuProgramType,
+		 *			GpuProgramProfile, const Vector<HGpuProgInclude>*, bool)
+		 */
         GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
         GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency);
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency);
 
 
+		/**
+		 * @copydoc	GpuProgramFactory::create(GpuProgramType)
+		 */
 		GpuProgramPtr create(GpuProgramType type);
 		GpuProgramPtr create(GpuProgramType type);
 
 
 	protected:
 	protected:

+ 8 - 6
BansheeD3D9RenderSystem/Include/BsD3D9HardwareBufferManager.h

@@ -3,9 +3,11 @@
 #include "BsD3D9Prerequisites.h"
 #include "BsD3D9Prerequisites.h"
 #include "BsHardwareBufferManager.h"
 #include "BsHardwareBufferManager.h"
 
 
-namespace BansheeEngine {
-
-    /** Implementation of HardwareBufferManager for D3D9. */
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Manages creation of DX9 hardware buffers.
+	 */
     class BS_D3D9_EXPORT D3D9HardwareBufferManager : public HardwareBufferManager
     class BS_D3D9_EXPORT D3D9HardwareBufferManager : public HardwareBufferManager
     {
     {
     public:
     public:
@@ -13,7 +15,9 @@ namespace BansheeEngine {
         ~D3D9HardwareBufferManager();
         ~D3D9HardwareBufferManager();
 
 
 	protected:     
 	protected:     
-		/// Internal method for creates a new vertex declaration, may be overridden by certain rendering APIs
+		/**
+		 * @copydoc	HardwareBufferManager::createVertexDeclarationImpl
+		 */
 		VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
 		VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
 
 
 		/**
 		/**
@@ -31,8 +35,6 @@ namespace BansheeEngine {
 
 
 		/**
 		/**
 		 * @copydoc HardwareBufferManager::createGenericBufferImpl
 		 * @copydoc HardwareBufferManager::createGenericBufferImpl
-		 *
-		 * DirectX 9 does not support generic buffers so this method will return a dummy instance.
 		 */
 		 */
 		GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 		GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
 			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);

+ 36 - 13
BansheeD3D9RenderSystem/Include/BsD3D9IndexBuffer.h

@@ -6,9 +6,15 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 { 
 { 
+	/**
+	 * @brief	DirectX 9 implementation of an index buffer.
+	 */
     class BS_D3D9_EXPORT D3D9IndexBuffer : public IndexBuffer, public D3D9Resource
     class BS_D3D9_EXPORT D3D9IndexBuffer : public IndexBuffer, public D3D9Resource
     {
     {
 	protected:
 	protected:
+		/**
+		 * @brief	Container for internal buffer resources.
+		 */
 		struct BufferResources
 		struct BufferResources
 		{
 		{
 			IDirect3DIndexBuffer9* mBuffer;
 			IDirect3DIndexBuffer9* mBuffer;
@@ -21,9 +27,14 @@ namespace BansheeEngine
     public:
     public:
         ~D3D9IndexBuffer();
         ~D3D9IndexBuffer();
 
 
-        /** See HardwareBuffer. */
+		/**
+		 * @copydoc	IndexBuffer::readData
+		 */
         void readData(UINT32 offset, UINT32 length, void* dest);
         void readData(UINT32 offset, UINT32 length, void* dest);
-        /** See HardwareBuffer. */
+
+		/**
+		 * @copydoc	IndexBuffer::writeData
+		 */
 		void writeData(UINT32 offset, UINT32 length, const void* source, BufferWriteType writeFlags = BufferWriteType::Normal);
 		void writeData(UINT32 offset, UINT32 length, const void* source, BufferWriteType writeFlags = BufferWriteType::Normal);
 
 
 		/**
 		/**
@@ -46,37 +57,49 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
 		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
 
 
-		// Create the actual index buffer.
+		/**
+		 * @brief	Creates a DX9 index buffer object in the provided memory pool.
+		 */
 		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
 		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
 	
 	
-		/// Get the D3D-specific index buffer
+		/**
+		 * @brief	Returns the DX9 index buffer object.
+		 */
         IDirect3DIndexBuffer9* getD3DIndexBuffer();		
         IDirect3DIndexBuffer9* getD3DIndexBuffer();		
 
 
 	protected:
 	protected:
 		friend class D3D9HardwareBufferManager;
 		friend class D3D9HardwareBufferManager;
 
 
 		D3D9IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMem);
 		D3D9IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMem);
-
-		/** See HardwareBuffer. */
+		
+		/**
+		 * @copydoc	IndexBuffer::lockImpl
+		 */
 		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-		/** See HardwareBuffer. */
+
+		/**
+		 * @copydoc	IndexBuffer::unlockImpl
+		 */
 		void unlockImpl();
 		void unlockImpl();
-		// updates buffer resources from system memory buffer.
+
+		/**
+		 * @brief	Updates buffer resources from cached system memory buffer.
+		 */
 		bool updateBufferResources(const UINT8* systemMemoryBuffer, BufferResources* bufferResources);
 		bool updateBufferResources(const UINT8* systemMemoryBuffer, BufferResources* bufferResources);
 
 
 		/**
 		/**
-		 * @copydoc IndexBuffer::initialize_internal()
+		 * @copydoc IndexBuffer::initialize_internal
 		 */
 		 */
 		void initialize_internal();	
 		void initialize_internal();	
 		
 		
 		/**
 		/**
-		 * @copydoc IndexBuffer::destroy_internal()
+		 * @copydoc IndexBuffer::destroy_internal
 		 */
 		 */
 		void destroy_internal();
 		void destroy_internal();
 
 
 	protected:		
 	protected:		
-		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;	// Map between device to buffer resources.	
-		D3DINDEXBUFFER_DESC	mBufferDesc;					// Buffer description.		
-		UINT8* mSystemMemoryBuffer;			// Consistent system memory buffer for multiple devices support.
+		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
+		D3DINDEXBUFFER_DESC	mBufferDesc;	
+		UINT8* mSystemMemoryBuffer;
     };
     };
 }
 }

+ 104 - 45
BansheeD3D9RenderSystem/Include/BsD3D9Mappings.h

@@ -1,4 +1,3 @@
-
 #pragma once
 #pragma once
 
 
 #include "BsD3D9Prerequisites.h"
 #include "BsD3D9Prerequisites.h"
@@ -8,75 +7,135 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
+	/**
+	 * @brief	Provides helper methods for mapping between engine and DirectX 9 types.
+	 */
 	class BS_D3D9_EXPORT D3D9Mappings
 	class BS_D3D9_EXPORT D3D9Mappings
 	{
 	{
 	public:
 	public:
-		/// enum identifying D3D9 tex. types
-		enum eD3DTexType
+		/**
+		 * @brief	DirectX 9 texture types.
+		 */
+		enum D3DTexType
 		{
 		{
-			/// standard texture
 			D3D_TEX_TYPE_NORMAL,
 			D3D_TEX_TYPE_NORMAL,
-			/// cube texture
 			D3D_TEX_TYPE_CUBE,
 			D3D_TEX_TYPE_CUBE,
-			/// volume texture
 			D3D_TEX_TYPE_VOLUME,
 			D3D_TEX_TYPE_VOLUME,
-			/// just to have it...
 			D3D_TEX_TYPE_NONE
 			D3D_TEX_TYPE_NONE
 		};
 		};
 
 
-		/// enum identifying D3D9 filter usage type
-		enum eD3DFilterUsage
-		{
-			/// min filter
-			D3D_FUSAGE_MIN,
-			/// mag filter
-			D3D_FUSAGE_MAG,
-			/// mip filter
-			D3D_FUSAGE_MIP
-		};
-
-		/// return a D3D9 equivalent for a Ogre TextureAddressingMode value
+		/**
+		 * @brief	Returns DirectX 9 texture addressing mode. Returns exact mode if supported, or
+		 *			nearest available if not.
+		 */
 		static D3DTEXTUREADDRESS get(TextureAddressingMode tam, const D3DCAPS9& devCaps);
 		static D3DTEXTUREADDRESS get(TextureAddressingMode tam, const D3DCAPS9& devCaps);
-		/// return a D3D9 equivalent for a Ogre SceneBlendFactor value
+
+		/**
+		 * @brief	Returns DirectX 9 blend factor.
+		 */
 		static D3DBLEND get(BlendFactor sbf);
 		static D3DBLEND get(BlendFactor sbf);
-		/// return a D3D9 equivlalent for a Ogre SceneBlendOperation value
+
+		/**
+		 * @brief	Returns DirectX 9 blend operation
+		 */
 		static D3DBLENDOP get(BlendOperation sbo);
 		static D3DBLENDOP get(BlendOperation sbo);
-		/// return a D3D9 equivalent for a Ogre CompareFunction value
+
+		/**
+		 * @brief	Return DirectX 9 compare function.
+		 */
 		static DWORD get(CompareFunction cf);
 		static DWORD get(CompareFunction cf);
-		/// return a D3D9 equivalent for a Ogre CillingMode value
+
+		/**
+		 * @brief	Returns DirectX 9 culling mode. Optionally flip the mode so that
+		 *			engine CCW is DX9 CW and reverse.
+		 */
 		static DWORD get(CullingMode cm, bool flip);
 		static DWORD get(CullingMode cm, bool flip);
-		/// return a D3D9 equivalent for a Ogre PolygonMode value
+
+		/**
+		 * @brief	Return DirectX 9 fill mode depending on provided polygon mode.
+		 */
 		static D3DFILLMODE get(PolygonMode level);
 		static D3DFILLMODE get(PolygonMode level);
-		/// return a D3D9 equivalent for a Ogre StencilOperation value
+
+		/**
+		 * @brief	Return DirectX 9 stencil operation and optionally 
+		 *			invert it (greater than becomes less than, etc.)
+		 */
 		static DWORD get(StencilOperation op, bool invert = false);
 		static DWORD get(StencilOperation op, bool invert = false);
-		/// return a D3D9 state type for Ogre FilterType value
+
+		/**
+		 * @brief	Returns DirectX 9 sampler state based on provided filter type.
+		 */
 		static D3DSAMPLERSTATETYPE get(FilterType ft);
 		static D3DSAMPLERSTATETYPE get(FilterType ft);
-		/// return a D3D9 filter option for Ogre FilterType & FilterOption value
-		static DWORD get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, eD3DTexType texType);
-		/// return the D3DtexType equivalent of a Ogre tex. type
-		static eD3DTexType get(TextureType ogreTexType);
-        /// return the combination of D3DUSAGE values for Ogre buffer usage
+
+		/**
+		 * @brief	Returns a DirectX 9 texture filter type based on provided filter type, options and texture type.
+		 *			If wanted filter type is not available closest type will be returned.
+		 */
+		static DWORD get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, D3DTexType texType);
+		
+		/**
+		 * @brief	Returns DirectX 9 texture type.
+		 */
+		static D3DTexType get(TextureType textype);
+        
+		/**
+		 * @brief	Return DirectX 9 buffer usage.
+		 */
         static DWORD get(GpuBufferUsage usage);
         static DWORD get(GpuBufferUsage usage);
-        /// Get lock options
+        
+		/**
+		 * @brief	Returns DirectX 9 lock options, constrained by the provided usage.
+		 */
         static DWORD get(GpuLockOptions options, GpuBufferUsage usage);
         static DWORD get(GpuLockOptions options, GpuBufferUsage usage);
-        /// Get index type
+        
+		/**
+		 * @brief	Returns DirectX 9 index buffer type.
+		 */
         static D3DFORMAT get(IndexBuffer::IndexType itype);
         static D3DFORMAT get(IndexBuffer::IndexType itype);
-		/// Get vertex data type
+		
+		/**
+		 * @brief	Returns DirectX 9 vertex element type.
+		 */
 		static D3DDECLTYPE get(VertexElementType vType);
 		static D3DDECLTYPE get(VertexElementType vType);
-		/// Get vertex semantic
+
+		/**
+		 * @brief	Returns DirectX9 vertex element semantic.
+		 */
 		static D3DDECLUSAGE get(VertexElementSemantic sem);
 		static D3DDECLUSAGE get(VertexElementSemantic sem);
-        // Convert matrix to D3D style
-        static 	D3DXMATRIX makeD3DXMatrix( const Matrix4& mat );
-        // Convert matrix from D3D style
-        static Matrix4 convertD3DXMatrix( const D3DXMATRIX& mat );
+        
+		/**
+		 * @brief	Converts a matrix to one usable by DirectX 9 API.
+		 */
+        static 	D3DXMATRIX makeD3DXMatrix(const Matrix4& mat);
+        
+		/**
+		 * @brief	Converts matrix returned by DirectX 9 API to engine matrix.
+		 */
+        static Matrix4 convertD3DXMatrix(const D3DXMATRIX& mat);
 
 
-		/// utility method, convert D3D9 pixel format to engine pixel format
+		/**
+		 * @brief	Converts DirectX 9 pixel format to engine pixel format.
+		 */
 		static PixelFormat _getPF(D3DFORMAT d3dPF);
 		static PixelFormat _getPF(D3DFORMAT d3dPF);
-		/// utility method, convert engine pixel format to D3D9 pixel format
-		static D3DFORMAT _getPF(PixelFormat ogrePF);
+		
+		/**
+		 * @brief	Converts engine pixel format to DirectX 9 pixel format.
+		 */
+		static D3DFORMAT _getPF(PixelFormat pf);
+
+		/**
+		 * @brief	Returns closest pixel format supported by DirectX 9.
+		 */
+		static PixelFormat _getClosestSupportedPF(PixelFormat pf);
+
+		/**
+		 * @brief	Returns closest color render target pixel format supported by DirectX 9.
+		 */
+		static PixelFormat _getClosestSupportedRenderTargetPF(PixelFormat pf);
 
 
-		static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF);
-		static PixelFormat _getClosestSupportedRenderTargetPF(PixelFormat enginePF);
-		static PixelFormat _getClosestSupportedDepthStencilPF(PixelFormat enginePF);
+		/**
+		 * @brief	Returns closest depth/stencil format supported by DirectX 9.
+		 */
+		static PixelFormat _getClosestSupportedDepthStencilPF(PixelFormat pf);
 	};
 	};
 }
 }

+ 10 - 3
BansheeD3D9RenderSystem/Include/BsD3D9MultiRenderTexture.h

@@ -5,12 +5,22 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/**
+	 * @brief	DirectX 9 implementation of a multi-render texture.
+	 */
 	class BS_D3D9_EXPORT D3D9MultiRenderTexture : public MultiRenderTexture
 	class BS_D3D9_EXPORT D3D9MultiRenderTexture : public MultiRenderTexture
 	{
 	{
 	public:
 	public:
 		virtual ~D3D9MultiRenderTexture();
 		virtual ~D3D9MultiRenderTexture();
 
 
+		/**
+		 * @copydoc	MultiRenderTexture::requiresTextureFlipping
+		 */
 		bool requiresTextureFlipping() const { return false; }
 		bool requiresTextureFlipping() const { return false; }
+
+		/**
+		 * @copydoc	MultiRenderTexture::getCustomAttribute
+		 */
 		void getCustomAttribute(const String& name, void* pData) const;
 		void getCustomAttribute(const String& name, void* pData) const;
 
 
 	protected:
 	protected:
@@ -23,9 +33,6 @@ namespace BansheeEngine
 		 */
 		 */
 		void initialize_internal();
 		void initialize_internal();
 
 
-		void setColorSurfaceImpl(UINT32 surfaceIdx, TexturePtr texture, UINT32 face = 0, UINT32 numFaces = 1, UINT32 mipLevel = 0);
-		void setDepthStencilImpl(TexturePtr depthStencilSurface, UINT32 face = 0, UINT32 numFaces = 1, UINT32 mipLevel = 0);
-
 		Vector<IDirect3DSurface9*> mDX9ColorSurfaces;
 		Vector<IDirect3DSurface9*> mDX9ColorSurfaces;
 		IDirect3DSurface9* mDX9DepthStencilSurface;
 		IDirect3DSurface9* mDX9DepthStencilSurface;
 	};
 	};

+ 1 - 1
BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h

@@ -176,7 +176,7 @@ namespace BansheeEngine
 		struct sD3DTextureStageDesc
 		struct sD3DTextureStageDesc
 		{
 		{
 			/// the type of the texture
 			/// the type of the texture
-			D3D9Mappings::eD3DTexType texType;
+			D3D9Mappings::D3DTexType texType;
 			/// which texCoordIndex to use
 			/// which texCoordIndex to use
 			size_t coordIndex;
 			size_t coordIndex;
 			/// texture 
 			/// texture 

+ 0 - 1
BansheeD3D9RenderSystem/Source/BsD3D9Device.cpp

@@ -764,7 +764,6 @@ namespace BansheeEngine
 		RenderWindowToResorucesIterator it = getRenderWindowIterator(renderWindow);
 		RenderWindowToResorucesIterator it = getRenderWindowIterator(renderWindow);
 		RenderWindowResources*	renderWindowResources = it->second;
 		RenderWindowResources*	renderWindowResources = it->second;
 	
 	
-
 		// Case size has been changed.
 		// Case size has been changed.
 		if (renderWindow->getWidth() != renderWindowResources->presentParameters.BackBufferWidth ||
 		if (renderWindow->getWidth() != renderWindowResources->presentParameters.BackBufferWidth ||
 			renderWindow->getHeight() != renderWindowResources->presentParameters.BackBufferHeight)
 			renderWindow->getHeight() != renderWindowResources->presentParameters.BackBufferHeight)

+ 11 - 16
BansheeD3D9RenderSystem/Source/BsD3D9GpuProgram.cpp

@@ -183,7 +183,7 @@ namespace BansheeEngine
 			for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
 			for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
 			{
 			{
 				IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
 				IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
-				createInternalResources(d3d9Device);
+				loadFromMicrocode(d3d9Device, mMicrocode);
 			}
 			}
 
 
 			D3D9HLSLParamParser paramParser(constTable, mBlocks);
 			D3D9HLSLParamParser paramParser(constTable, mBlocks);
@@ -212,11 +212,6 @@ namespace BansheeEngine
 		return params;
 		return params;
 	}
 	}
 
 
-	void D3D9GpuProgram::createInternalResources(IDirect3DDevice9* d3d9Device)
-	{
-		loadFromMicrocode(d3d9Device, mMicrocode);
-	}
-
 	const String& D3D9GpuProgram::getLanguage() const
 	const String& D3D9GpuProgram::getLanguage() const
 	{
 	{
 		static const String language = "hlsl";
 		static const String language = "hlsl";
@@ -250,7 +245,7 @@ namespace BansheeEngine
 
 
 	void D3D9GpuVertexProgram::destroy_internal(void)
 	void D3D9GpuVertexProgram::destroy_internal(void)
 	{
 	{
-		DeviceToVertexShaderIterator it = mMapDeviceToVertexShader.begin();
+		auto it = mMapDeviceToVertexShader.begin();
 
 
 		while (it != mMapDeviceToVertexShader.end())
 		while (it != mMapDeviceToVertexShader.end())
 		{
 		{
@@ -264,7 +259,7 @@ namespace BansheeEngine
 
 
     void D3D9GpuVertexProgram::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
     void D3D9GpuVertexProgram::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
     {		 
     {		 
-		DeviceToVertexShaderIterator it = mMapDeviceToVertexShader.find(d3d9Device);
+		auto it = mMapDeviceToVertexShader.find(d3d9Device);
 
 
 		if (it != mMapDeviceToVertexShader.end())
 		if (it != mMapDeviceToVertexShader.end())
 			SAFE_RELEASE(it->second);
 			SAFE_RELEASE(it->second);
@@ -292,7 +287,7 @@ namespace BansheeEngine
 
 
 	void D3D9GpuVertexProgram::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	void D3D9GpuVertexProgram::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	{
 	{
-		DeviceToVertexShaderIterator it;
+		auto it;
 
 
 		// Find the shader of this device.
 		// Find the shader of this device.
 		it = mMapDeviceToVertexShader.find(d3d9Device);
 		it = mMapDeviceToVertexShader.find(d3d9Device);
@@ -311,7 +306,7 @@ namespace BansheeEngine
 			return nullptr;
 			return nullptr;
 
 
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
-		DeviceToVertexShaderIterator it;
+		auto it;
 
 
 		// Find the shader of this device.
 		// Find the shader of this device.
 		it = mMapDeviceToVertexShader.find(d3d9Device);
 		it = mMapDeviceToVertexShader.find(d3d9Device);
@@ -319,7 +314,7 @@ namespace BansheeEngine
 		// Shader was not found -> load it.
 		// Shader was not found -> load it.
 		if (it == mMapDeviceToVertexShader.end())		
 		if (it == mMapDeviceToVertexShader.end())		
 		{
 		{
-			createInternalResources(d3d9Device);		
+			loadFromMicrocode(d3d9Device, mMicrocode);
 			it = mMapDeviceToVertexShader.find(d3d9Device);
 			it = mMapDeviceToVertexShader.find(d3d9Device);
 		}
 		}
 	
 	
@@ -352,7 +347,7 @@ namespace BansheeEngine
 
 
 	void D3D9GpuFragmentProgram::destroy_internal()
 	void D3D9GpuFragmentProgram::destroy_internal()
 	{
 	{
-		DeviceToPixelShaderIterator it = mMapDeviceToPixelShader.begin();
+		auto it = mMapDeviceToPixelShader.begin();
 
 
 		while (it != mMapDeviceToPixelShader.end())
 		while (it != mMapDeviceToPixelShader.end())
 		{
 		{
@@ -366,7 +361,7 @@ namespace BansheeEngine
 
 
     void D3D9GpuFragmentProgram::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
     void D3D9GpuFragmentProgram::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
     {
     {
-		DeviceToPixelShaderIterator it = mMapDeviceToPixelShader.find(d3d9Device);
+		auto it = mMapDeviceToPixelShader.find(d3d9Device);
 
 
 		if (it != mMapDeviceToPixelShader.end())
 		if (it != mMapDeviceToPixelShader.end())
 			SAFE_RELEASE(it->second);
 			SAFE_RELEASE(it->second);
@@ -390,7 +385,7 @@ namespace BansheeEngine
 
 
 	void D3D9GpuFragmentProgram::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	void D3D9GpuFragmentProgram::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	{
 	{
-		DeviceToPixelShaderIterator it;
+		auto it;
 
 
 		// Find the shader of this device.
 		// Find the shader of this device.
 		it = mMapDeviceToPixelShader.find(d3d9Device);
 		it = mMapDeviceToPixelShader.find(d3d9Device);
@@ -409,7 +404,7 @@ namespace BansheeEngine
 			return nullptr;
 			return nullptr;
 
 
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
-		DeviceToPixelShaderIterator it;
+		auto it;
 
 
 		// Find the shader of this device.
 		// Find the shader of this device.
 		it = mMapDeviceToPixelShader.find(d3d9Device);
 		it = mMapDeviceToPixelShader.find(d3d9Device);
@@ -417,7 +412,7 @@ namespace BansheeEngine
 		// Shader was not found -> load it.
 		// Shader was not found -> load it.
 		if (it == mMapDeviceToPixelShader.end())		
 		if (it == mMapDeviceToPixelShader.end())		
 		{
 		{
-			createInternalResources(d3d9Device);			
+			loadFromMicrocode(d3d9Device, mMicrocode);
 			it = mMapDeviceToPixelShader.find(d3d9Device);
 			it = mMapDeviceToPixelShader.find(d3d9Device);
 		}
 		}
 
 

+ 1 - 3
BansheeD3D9RenderSystem/Source/BsD3D9IndexBuffer.cpp

@@ -10,9 +10,7 @@ namespace BansheeEngine
 {
 {
     D3D9IndexBuffer::D3D9IndexBuffer(IndexBuffer::IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory)
     D3D9IndexBuffer::D3D9IndexBuffer(IndexBuffer::IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory)
         : IndexBuffer(idxType, numIndexes, usage, useSystemMemory)
         : IndexBuffer(idxType, numIndexes, usage, useSystemMemory)
-    {
-			
-    }
+    { }
 
 
     D3D9IndexBuffer::~D3D9IndexBuffer()
     D3D9IndexBuffer::~D3D9IndexBuffer()
     { }
     { }

+ 26 - 27
BansheeD3D9RenderSystem/Source/BsD3D9Mappings.cpp

@@ -7,7 +7,7 @@ namespace BansheeEngine
 {
 {
 	D3DTEXTUREADDRESS D3D9Mappings::get(TextureAddressingMode tam, const D3DCAPS9& devCaps)
 	D3DTEXTUREADDRESS D3D9Mappings::get(TextureAddressingMode tam, const D3DCAPS9& devCaps)
 	{
 	{
-		switch( tam )
+		switch(tam)
 		{
 		{
 		case TAM_WRAP:
 		case TAM_WRAP:
 			return D3DTADDRESS_WRAP;
 			return D3DTADDRESS_WRAP;
@@ -21,12 +21,13 @@ namespace BansheeEngine
             else
             else
                 return D3DTADDRESS_CLAMP;
                 return D3DTADDRESS_CLAMP;
 		}
 		}
+
 		return D3DTADDRESS_FORCE_DWORD;
 		return D3DTADDRESS_FORCE_DWORD;
 	}
 	}
 
 
 	D3DBLEND D3D9Mappings::get(BlendFactor sbf)
 	D3DBLEND D3D9Mappings::get(BlendFactor sbf)
 	{
 	{
-		switch( sbf )
+		switch(sbf)
 		{
 		{
 		case BF_ONE:
 		case BF_ONE:
 			return D3DBLEND_ONE;
 			return D3DBLEND_ONE;
@@ -49,10 +50,11 @@ namespace BansheeEngine
 		case BF_INV_SOURCE_ALPHA:
 		case BF_INV_SOURCE_ALPHA:
 			return D3DBLEND_INVSRCALPHA;
 			return D3DBLEND_INVSRCALPHA;
 		}
 		}
+
 		return D3DBLEND_FORCE_DWORD;
 		return D3DBLEND_FORCE_DWORD;
 	}
 	}
 
 
-	D3DBLENDOP D3D9Mappings::get(BansheeEngine::BlendOperation sbo)
+	D3DBLENDOP D3D9Mappings::get(BlendOperation sbo)
 	{
 	{
 		switch(sbo)
 		switch(sbo)
 		{
 		{
@@ -73,7 +75,7 @@ namespace BansheeEngine
 
 
 	DWORD D3D9Mappings::get(CompareFunction cf)
 	DWORD D3D9Mappings::get(CompareFunction cf)
 	{
 	{
-		switch( cf )
+		switch(cf)
 		{
 		{
 		case CMPF_ALWAYS_FAIL:
 		case CMPF_ALWAYS_FAIL:
 			return D3DCMP_NEVER;
 			return D3DCMP_NEVER;
@@ -92,26 +94,28 @@ namespace BansheeEngine
 		case CMPF_GREATER:
 		case CMPF_GREATER:
 			return D3DCMP_GREATER;
 			return D3DCMP_GREATER;
 		};
 		};
+
 		return 0;
 		return 0;
 	}
 	}
 
 
 	DWORD D3D9Mappings::get(CullingMode cm, bool flip)
 	DWORD D3D9Mappings::get(CullingMode cm, bool flip)
 	{
 	{
-		switch( cm )
+		switch(cm)
 		{
 		{
 		case CULL_NONE:
 		case CULL_NONE:
 			return D3DCULL_NONE;
 			return D3DCULL_NONE;
 		case CULL_CLOCKWISE:
 		case CULL_CLOCKWISE:
-			if( flip )
+			if(flip)
 				return D3DCULL_CCW;
 				return D3DCULL_CCW;
 			else
 			else
 				return D3DCULL_CW;
 				return D3DCULL_CW;
 		case CULL_COUNTERCLOCKWISE:
 		case CULL_COUNTERCLOCKWISE:
-			if( flip )
+			if(flip)
 				return D3DCULL_CW;
 				return D3DCULL_CW;
 			else
 			else
 				return D3DCULL_CCW;
 				return D3DCULL_CCW;
 		}
 		}
+
 		return 0;
 		return 0;
 	}
 	}
 
 
@@ -124,6 +128,7 @@ namespace BansheeEngine
 		case PM_SOLID:
 		case PM_SOLID:
 			return D3DFILL_SOLID;
 			return D3DFILL_SOLID;
 		}
 		}
+
 		return D3DFILL_FORCE_DWORD;
 		return D3DFILL_FORCE_DWORD;
 	}
 	}
 
 
@@ -138,16 +143,17 @@ namespace BansheeEngine
 		case SOP_REPLACE:
 		case SOP_REPLACE:
 			return D3DSTENCILOP_REPLACE;
 			return D3DSTENCILOP_REPLACE;
 		case SOP_INCREMENT:
 		case SOP_INCREMENT:
-            return invert? D3DSTENCILOP_DECRSAT : D3DSTENCILOP_INCRSAT;
+            return invert ? D3DSTENCILOP_DECRSAT : D3DSTENCILOP_INCRSAT;
 		case SOP_DECREMENT:
 		case SOP_DECREMENT:
-            return invert? D3DSTENCILOP_INCRSAT : D3DSTENCILOP_DECRSAT;
+            return invert ? D3DSTENCILOP_INCRSAT : D3DSTENCILOP_DECRSAT;
 		case SOP_INCREMENT_WRAP:
 		case SOP_INCREMENT_WRAP:
-            return invert? D3DSTENCILOP_DECR : D3DSTENCILOP_INCR;
+            return invert ? D3DSTENCILOP_DECR : D3DSTENCILOP_INCR;
 		case SOP_DECREMENT_WRAP:
 		case SOP_DECREMENT_WRAP:
-            return invert? D3DSTENCILOP_INCR : D3DSTENCILOP_DECR;
+            return invert ? D3DSTENCILOP_INCR : D3DSTENCILOP_DECR;
 		case SOP_INVERT:
 		case SOP_INVERT:
 			return D3DSTENCILOP_INVERT;
 			return D3DSTENCILOP_INVERT;
 		}
 		}
+
 		return 0;
 		return 0;
 	}
 	}
 
 
@@ -166,12 +172,10 @@ namespace BansheeEngine
             break;
             break;
         }
         }
 
 
-        // to keep compiler happy
         return D3DSAMP_MINFILTER;
         return D3DSAMP_MINFILTER;
     }
     }
 
 
-	DWORD D3D9Mappings::get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, 
-        eD3DTexType texType)
+	DWORD D3D9Mappings::get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, D3DTexType texType)
 	{
 	{
 		// Assume normal
 		// Assume normal
 		DWORD capsType = devCaps.TextureFilterCaps;
 		DWORD capsType = devCaps.TextureFilterCaps;
@@ -192,17 +196,17 @@ namespace BansheeEngine
         switch (ft)
         switch (ft)
         {
         {
         case FT_MIN:
         case FT_MIN:
-            switch( fo )
+            switch(fo)
             {
             {
                 // NOTE: Fall through if device doesn't support requested type
                 // NOTE: Fall through if device doesn't support requested type
             case FO_ANISOTROPIC:
             case FO_ANISOTROPIC:
-                if( capsType & D3DPTFILTERCAPS_MINFANISOTROPIC )
+                if(capsType & D3DPTFILTERCAPS_MINFANISOTROPIC)
                 {
                 {
                     return D3DTEXF_ANISOTROPIC;
                     return D3DTEXF_ANISOTROPIC;
                     break;
                     break;
                 }
                 }
             case FO_LINEAR:
             case FO_LINEAR:
-                if( capsType & D3DPTFILTERCAPS_MINFLINEAR )
+                if(capsType & D3DPTFILTERCAPS_MINFLINEAR)
                 {
                 {
                     return D3DTEXF_LINEAR;
                     return D3DTEXF_LINEAR;
                     break;
                     break;
@@ -218,13 +222,13 @@ namespace BansheeEngine
             {
             {
             // NOTE: Fall through if device doesn't support requested type
             // NOTE: Fall through if device doesn't support requested type
             case FO_ANISOTROPIC:
             case FO_ANISOTROPIC:
-                if( capsType & D3DPTFILTERCAPS_MAGFANISOTROPIC )
+                if(capsType & D3DPTFILTERCAPS_MAGFANISOTROPIC)
                 {
                 {
                     return D3DTEXF_ANISOTROPIC;
                     return D3DTEXF_ANISOTROPIC;
                     break;
                     break;
                 }
                 }
             case FO_LINEAR:
             case FO_LINEAR:
-                if( capsType & D3DPTFILTERCAPS_MAGFLINEAR )
+                if(capsType & D3DPTFILTERCAPS_MAGFLINEAR)
                 {
                 {
                     return D3DTEXF_LINEAR;
                     return D3DTEXF_LINEAR;
                     break;
                     break;
@@ -240,13 +244,13 @@ namespace BansheeEngine
             {
             {
             case FO_ANISOTROPIC:
             case FO_ANISOTROPIC:
             case FO_LINEAR:
             case FO_LINEAR:
-                if( capsType & D3DPTFILTERCAPS_MIPFLINEAR )
+                if(capsType & D3DPTFILTERCAPS_MIPFLINEAR)
                 {
                 {
                     return D3DTEXF_LINEAR;
                     return D3DTEXF_LINEAR;
                     break;
                     break;
                 }
                 }
             case FO_POINT:
             case FO_POINT:
-                if( capsType & D3DPTFILTERCAPS_MIPFPOINT )
+                if(capsType & D3DPTFILTERCAPS_MIPFPOINT)
                 {
                 {
                     return D3DTEXF_POINT;
                     return D3DTEXF_POINT;
                     break;
                     break;
@@ -258,12 +262,10 @@ namespace BansheeEngine
             break;
             break;
         }
         }
 
 
-        // should never get here
         return 0;
         return 0;
-
 	}
 	}
 
 
-	D3D9Mappings::eD3DTexType D3D9Mappings::get(TextureType texType)
+	D3D9Mappings::D3DTexType D3D9Mappings::get(TextureType texType)
 	{
 	{
 		switch( texType )
 		switch( texType )
 		{
 		{
@@ -400,7 +402,6 @@ namespace BansheeEngine
 	{
 	{
 		// Transpose matrix
 		// Transpose matrix
 		// D3D9 uses row vectors i.e. V*M
 		// D3D9 uses row vectors i.e. V*M
-		// Ogre, OpenGL and everything else uses column vectors i.e. M*V
 		return D3DXMATRIX(
 		return D3DXMATRIX(
             mat[0][0], mat[1][0], mat[2][0], mat[3][0],
             mat[0][0], mat[1][0], mat[2][0], mat[3][0],
             mat[0][1], mat[1][1], mat[2][1], mat[3][1],
             mat[0][1], mat[1][1], mat[2][1], mat[3][1],
@@ -511,9 +512,7 @@ namespace BansheeEngine
 	PixelFormat D3D9Mappings::_getClosestSupportedPF(PixelFormat enginePF)
 	PixelFormat D3D9Mappings::_getClosestSupportedPF(PixelFormat enginePF)
 	{
 	{
 		if (_getPF(enginePF) != D3DFMT_UNKNOWN)
 		if (_getPF(enginePF) != D3DFMT_UNKNOWN)
-		{
 			return enginePF;
 			return enginePF;
-		}
 
 
 		switch(enginePF)
 		switch(enginePF)
 		{
 		{

+ 1 - 1
BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp

@@ -1028,7 +1028,7 @@ namespace BansheeEngine
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 
 		HRESULT hr;
 		HRESULT hr;
-		D3D9Mappings::eD3DTexType texType = mTexStageDesc[unit].texType;
+		D3D9Mappings::D3DTexType texType = mTexStageDesc[unit].texType;
 		hr = __SetSamplerState( static_cast<DWORD>(unit), D3D9Mappings::get(ftype), 
 		hr = __SetSamplerState( static_cast<DWORD>(unit), D3D9Mappings::get(ftype), 
 			D3D9Mappings::get(ftype, filter, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps(), texType));
 			D3D9Mappings::get(ftype, filter, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps(), texType));