Jelajahi Sumber

More work on improving documentation for doxygen generation

BearishSun 9 tahun lalu
induk
melakukan
f5a83f2a98
74 mengubah file dengan 4886 tambahan dan 5596 penghapusan
  1. 1 1
      README.md
  2. 1 1
      Source/BansheeD3D11RenderAPI/Include/BsD3D11Prerequisites.h
  3. 190 263
      Source/BansheeD3D9RenderAPI/Include/BsD3D9Device.h
  4. 65 82
      Source/BansheeD3D9RenderAPI/Include/BsD3D9DeviceManager.h
  5. 46 53
      Source/BansheeD3D9RenderAPI/Include/BsD3D9Driver.h
  6. 38 42
      Source/BansheeD3D9RenderAPI/Include/BsD3D9DriverList.h
  7. 38 36
      Source/BansheeD3D9RenderAPI/Include/BsD3D9EmulatedParamBlocks.h
  8. 53 65
      Source/BansheeD3D9RenderAPI/Include/BsD3D9EventQuery.h
  9. 56 67
      Source/BansheeD3D9RenderAPI/Include/BsD3D9GpuBuffer.h
  10. 113 137
      Source/BansheeD3D9RenderAPI/Include/BsD3D9GpuProgram.h
  11. 372 371
      Source/BansheeD3D9RenderAPI/Include/BsD3D9HLSLParamParser.h
  12. 38 38
      Source/BansheeD3D9RenderAPI/Include/BsD3D9HLSLProgramFactory.h
  13. 35 41
      Source/BansheeD3D9RenderAPI/Include/BsD3D9HardwareBufferManager.h
  14. 77 98
      Source/BansheeD3D9RenderAPI/Include/BsD3D9IndexBuffer.h
  15. 102 147
      Source/BansheeD3D9RenderAPI/Include/BsD3D9Mappings.h
  16. 66 68
      Source/BansheeD3D9RenderAPI/Include/BsD3D9MultiRenderTexture.h
  17. 66 84
      Source/BansheeD3D9RenderAPI/Include/BsD3D9OcclusionQuery.h
  18. 118 144
      Source/BansheeD3D9RenderAPI/Include/BsD3D9PixelBuffer.h
  19. 85 73
      Source/BansheeD3D9RenderAPI/Include/BsD3D9Prerequisites.h
  20. 28 30
      Source/BansheeD3D9RenderAPI/Include/BsD3D9QueryManager.h
  21. 137 272
      Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderAPI.h
  22. 47 50
      Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderAPIFactory.h
  23. 86 80
      Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderTexture.h
  24. 180 174
      Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderWindow.h
  25. 42 44
      Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderWindowManager.h
  26. 48 53
      Source/BansheeD3D9RenderAPI/Include/BsD3D9Resource.h
  27. 74 93
      Source/BansheeD3D9RenderAPI/Include/BsD3D9ResourceManager.h
  28. 171 165
      Source/BansheeD3D9RenderAPI/Include/BsD3D9Texture.h
  29. 49 59
      Source/BansheeD3D9RenderAPI/Include/BsD3D9TextureManager.h
  30. 71 91
      Source/BansheeD3D9RenderAPI/Include/BsD3D9TimerQuery.h
  31. 77 98
      Source/BansheeD3D9RenderAPI/Include/BsD3D9VertexBuffer.h
  32. 42 46
      Source/BansheeD3D9RenderAPI/Include/BsD3D9VertexDeclaration.h
  33. 46 46
      Source/BansheeD3D9RenderAPI/Include/BsD3D9VideoModeInfo.h
  34. 1 1
      Source/BansheeFBXImporter/Include/BsFBXPrerequisites.h
  35. 1 1
      Source/BansheeFontImporter/Include/BsFontPrerequisites.h
  36. 1 1
      Source/BansheeFreeImgImporter/Include/BsFreeImgPrerequisites.h
  37. 33 34
      Source/BansheeGLRenderAPI/Include/BsGLContext.h
  38. 31 31
      Source/BansheeGLRenderAPI/Include/BsGLEventQuery.h
  39. 90 95
      Source/BansheeGLRenderAPI/Include/BsGLFrameBufferObject.h
  40. 54 66
      Source/BansheeGLRenderAPI/Include/BsGLGpuBuffer.h
  41. 37 41
      Source/BansheeGLRenderAPI/Include/BsGLGpuParamBlockBuffer.h
  42. 40 46
      Source/BansheeGLRenderAPI/Include/BsGLHardwareBufferManager.h
  43. 46 54
      Source/BansheeGLRenderAPI/Include/BsGLIndexBuffer.h
  44. 66 68
      Source/BansheeGLRenderAPI/Include/BsGLMultiRenderTexture.h
  45. 47 54
      Source/BansheeGLRenderAPI/Include/BsGLOcclusionQuery.h
  46. 158 179
      Source/BansheeGLRenderAPI/Include/BsGLPixelBuffer.h
  47. 49 61
      Source/BansheeGLRenderAPI/Include/BsGLPixelFormat.h
  48. 105 93
      Source/BansheeGLRenderAPI/Include/BsGLPrerequisites.h
  49. 28 30
      Source/BansheeGLRenderAPI/Include/BsGLQueryManager.h
  50. 129 258
      Source/BansheeGLRenderAPI/Include/BsGLRenderAPI.h
  51. 47 49
      Source/BansheeGLRenderAPI/Include/BsGLRenderAPIFactory.h
  52. 127 121
      Source/BansheeGLRenderAPI/Include/BsGLRenderTexture.h
  53. 42 44
      Source/BansheeGLRenderAPI/Include/BsGLRenderWindowManager.h
  54. 84 97
      Source/BansheeGLRenderAPI/Include/BsGLSupport.h
  55. 77 71
      Source/BansheeGLRenderAPI/Include/BsGLTexture.h
  56. 62 69
      Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h
  57. 48 55
      Source/BansheeGLRenderAPI/Include/BsGLTimerQuery.h
  58. 24 20
      Source/BansheeGLRenderAPI/Include/BsGLUtil.h
  59. 77 82
      Source/BansheeGLRenderAPI/Include/BsGLVertexArrayObjectManager.h
  60. 55 66
      Source/BansheeGLRenderAPI/Include/BsGLVertexBuffer.h
  61. 41 43
      Source/BansheeGLRenderAPI/Include/Win32/BsWin32Context.h
  62. 80 97
      Source/BansheeGLRenderAPI/Include/Win32/BsWin32GLSupport.h
  63. 22 18
      Source/BansheeGLRenderAPI/Include/Win32/BsWin32Prerequisites.h
  64. 160 154
      Source/BansheeGLRenderAPI/Include/Win32/BsWin32RenderWindow.h
  65. 44 46
      Source/BansheeGLRenderAPI/Include/Win32/BsWin32VideoModeInfo.h
  66. 51 56
      Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLGpuProgram.h
  67. 96 106
      Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLParamParser.h
  68. 35 35
      Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLProgramFactory.h
  69. 68 70
      Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLProgramPipelineManager.h
  70. 1 1
      Source/BansheeMono/Include/BsMonoPrerequisites.h
  71. 1 1
      Source/BansheeOISInput/Include/BsOISPrerequisites.h
  72. 1 1
      Source/BansheePhysX/Include/BsPhysXPrerequisites.h
  73. 33 33
      Source/BansheeSL/Include/BsSLPrerequisites.h
  74. 36 36
      Source/RenderBeast/Include/BsRenderBeastPrerequisites.h

+ 1 - 1
README.md

@@ -5,7 +5,7 @@ On top of the engine Banshee also provides a highly intuitive and customizable *
 
 The scripting system supports C# and comes with an extensive API ensuring you can complete your game without ever touching the C++ engine core. **C# scripting** makes your development easier by giving you access to the entire .NET library and a wide variety of pre-existing managed libraries. Integration of the scripting system with the editor and external tools like Visual Studio, as well as fast compilation times ensures that iteration times between coding and testing are minimized.
 
-Aside from being a fully featured game engine and toolkit, Banshee also aims to provide a **high quality codebase foundation for future technologies**, so others may build and improve upon it. This is reflected in Banshee's architecture which is split into multiple layers allowing developers to use only the functionality they needed, as well as its plugin oriented approach which allows developers to fully remove or replace major engine systems with minimal hassle. You will find that Banshee's code is modern, with clean interfaces that make it easy to learn and maintain. Platform specific functionality is kept at a minimum making porting as easy as possible. Additionally an extensive API reference, for both internals and user-facing code is provided with a full documentation of every non-trivial class and method, as well as a set of manuals introducing you to most major systems.
+Aside from being a fully featured game engine and toolkit, Banshee also aims to provide a **high quality codebase foundation for future technologies**, so others may build and improve upon it. This is reflected in Banshee's architecture which is split into multiple layers allowing developers to use only the functionality they needed, as well as its plugin oriented nature which allows developers to fully remove or replace major engine systems. You will find that Banshee's code is modern, with clean interfaces that make it easy to learn and maintain. Platform specific functionality is kept at a minimum making porting as easy as possible. Additionally, an extensive API reference, for both internals and user-facing code is provided with a full documentation of every non-trivial class and method, as well as a set of manuals introducing you to most major systems.
 
 # Learn more
 * [Features](Documentation/GitHub/features.md)

+ 1 - 1
Source/BansheeD3D11RenderAPI/Include/BsD3D11Prerequisites.h

@@ -19,7 +19,7 @@
 #include <d3d11shader.h>
 #include <D3Dcompiler.h>
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup D3D11 BansheeD3D11RenderAPI
  *	Wrapper around the DirectX 11 render API.

+ 190 - 263
Source/BansheeD3D9RenderAPI/Include/BsD3D9Device.h

@@ -1,264 +1,191 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsRenderTarget.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	High level interface for a DX9 device. Each device represents
-	 *			a hardware adapter or a software emulation device.
-	 */
-	class BS_D3D9_EXPORT D3D9Device
-	{
-	protected:
-		/**
-		 * @brief	Holds device specific render window resources.
-		 */
-		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. */	
-		};
-
-	public:
-		D3D9Device(D3D9DeviceManager* deviceManager, UINT adapterNumber, HMONITOR hMonitor,
-			D3DDEVTYPE devType, DWORD behaviorFlags);
-		~D3D9Device();
-
-		/**
-		 * @brief	Attaches a new render window to this device. Caller must ensure
-		 *			the window is not attached to multiple devices.
-		 */
-		void attachRenderWindow(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Detaches the render window from this device.
-		 */
-		void detachRenderWindow(const D3D9RenderWindowCore* renderWindow);
-	
-		/**
-		 * @brief	Acquires the device. This will cause a device reset in case present parameters changed.
-		 */
-		bool acquire();
-		
-		/**
-		 * @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();		
-		
-		/**
-		 * @brief	Checks is the device lost. If lost you will need to "acquire" the device.
-		 */
-		bool isDeviceLost();				
-		
-		/**
-		 * @brief	Return internal DX9 device object.
-		 */
-		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;
-
-		/**
-		 * @brief	Returns type of the device.
-		 */
-		D3DDEVTYPE getDeviceType() const;
-
-		/**
-		 * @brief	Checks is the device multihead (manages multiple full-screen outputs).
-		 */
-		bool isMultihead() const;					
-
-		/**
-		 * @brief	Returns true if depth/stencil format can be automatically determined.
-		 */
-		bool isAutoDepthStencil() const;
-		
-		/**
-		 * @brief	Returns DX9 device capabilities.
-		 */
-		const D3DCAPS9& getD3D9DeviceCaps() const;
-
-		/**
-		 * @brief	Returns DX9 format of the back buffer used by the primary window for this device.
-		 */
-		D3DFORMAT getBackBufferFormat() const;
-
-		/**
-		 * @brief	Returns DX9 format of the depth stencil buffer used by the primary window for this device.
-		 */
-		D3DFORMAT getDepthStencilFormat() const;
-
-		/**
-		 * @brief	Validates that the window is valid for this device. Will reset device if needed.
-		 */
-		bool validate(D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Invalidates the window so on the next call to validate, the device will be re-acquired.
-		 */
-		void invalidate(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Swap back and front buffers for the specified window.
-		 */
-		void present(const D3D9RenderWindowCore* renderWindow);
-		
-		/**
-		 * @brief	Returns internal DX9 represention of the depth/stencil buffer.
-		 */
-		IDirect3DSurface9* getDepthBuffer(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Returns internal DX9 represention of the backbuffer.
-		 */
-		IDirect3DSurface9* getBackBuffer(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Sets adapter index for the specified window.
-		 */
-		void setAdapterOrdinalIndex(const D3D9RenderWindowCore* renderWindow, UINT32 adapterOrdinalInGroupIndex);
-
-		/**
-		 * @brief	Copies contents of the back or depth/stencil buffer in to the provided object.
-		 */
-		void copyContentsToMemory(const D3D9RenderWindowCore* window, PixelData &dst, RenderTargetCore::FrameBuffer buffer);
-
-		/**
-		 * @brief	Resets bound pipeline states/streams to null.
-		 */
-		void clearDeviceStreams();
-	
-	protected:
-		friend class D3D9DeviceManager;
-		friend class D3D9RenderAPI;
-
-		typedef Map<const D3D9RenderWindowCore*, RenderWindowResources*> RenderWindowToResorucesMap;
-		typedef RenderWindowToResorucesMap::iterator RenderWindowToResorucesIterator;
-
-		/**
-		 * @brief	Find iterator for the specified window in the render window resource list.
-		 */
-		RenderWindowToResorucesIterator getRenderWindowIterator(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Acquires the device for the provided render window.
-		 */
-		bool acquire(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Forcibly reset the device.
-		 */
-		bool reset();
-
-		/**
-		 * @brief	Update presentation parameters from the active render window.
-		 */
-		void updatePresentationParameters();
-
-		/**
-		 * @brief	Updates presentation parameter indices for all windows attached to this device.
-		 */
-		void updateRenderWindowsIndices();
-
-		/**
-		 * @brief	Creates a new DX9 device object.
-		 */
-		void createD3D9Device();
-
-		/**
-		 * @brief	Releases the DX9 device object.
-		 */
-		void releaseD3D9Device();
-
-		/**
-		 * @brief	Releases all render window resources in the provided object.
-		 */
-		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);
-
-		/**
-		 * @brief	Called when it has been detected that device has been lost.
-		 */
-		void notifyDeviceLost();
-
-		/**
-		 * @brief	Checks if focus window changed and should device be reacquired.
-		 */
-		void validateFocusWindow();
-
-		/**
-		 * @brief	Checks if back buffer size has changed and invalidates the window if it has.
-		 */
-		void validateBackBufferSize(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Checks if window monitor changed and re-links the window if needed.
-		 */
-		bool validateDisplayMonitor(D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Checks if device has been lost or active window invalidated and acquires the device if needed.
-		 */
-		bool validateDeviceState(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Checks if the render window contains a custom swap chain.
-		 */
-		bool isSwapChainWindow(const D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Returns primary window for this device.
-		 */
-		const D3D9RenderWindowCore*	getPrimaryWindow();
-
-		/**
-		 * @brief	Sets the shared window handle.
-		 */
-		void setSharedWindowHandle(HWND hSharedHWND);
-
-	protected:			
-		D3D9DeviceManager* mpDeviceManager;	/**< The manager of this device instance. */
-		IDirect3DDevice9* mpDevice;	/**< Will hold the device interface. */
-		UINT mAdapterNumber; /**< The adapter that this device belongs to. */
-		HMONITOR mMonitor; /**< The monitor that this device belongs to. */
-		D3DDEVTYPE mDeviceType; /**< Device type. */
-		static HWND	msSharedFocusWindow; /**< The shared focus window in case of multiple full screen render windows. */
-		HWND mFocusWindow; /**< The focus window this device attached to. */	
-		DWORD mBehaviorFlags; /**< The behavior of this device.	*/
-		
-		/** Presentation parameters which the device was created with. May be
-		 *  an array of presentation parameters in case of multi-head device.
-		 */
-		D3DPRESENT_PARAMETERS* mPresentationParams;
-		UINT mPresentationParamsCount; /**< Number of presentation parameters elements.	 */
-		D3DCAPS9 mD3D9DeviceCaps; /**< Device caps. */
-		bool mD3D9DeviceCapsValid; /**< True if device caps initialized. */
-		D3DDEVICE_CREATION_PARAMETERS mCreationParams; /**< Creation parameters. */
-		bool mDeviceLost; /**< True if device entered lost state. */
-	
-		RenderWindowToResorucesMap mMapRenderWindowToResoruces;	/**< Map between render window to resources. */
-	
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsRenderTarget.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** High level interface for a DX9 device. Each device represents a hardware adapter or a software emulation device. */
+	class BS_D3D9_EXPORT D3D9Device
+	{
+	protected:
+		/**	Holds device specific render window resources. */
+		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. */	
+		};
+
+	public:
+		D3D9Device(D3D9DeviceManager* deviceManager, UINT adapterNumber, HMONITOR hMonitor,
+			D3DDEVTYPE devType, DWORD behaviorFlags);
+		~D3D9Device();
+
+		/**
+		 * Attaches a new render window to this device. Caller must ensure the window is not attached to multiple devices.
+		 */
+		void attachRenderWindow(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Detaches the render window from this device. */
+		void detachRenderWindow(const D3D9RenderWindowCore* renderWindow);
+	
+		/**	Acquires the device. This will cause a device reset in case present parameters changed. */
+		bool acquire();
+		
+		/**	Release the device and all resources directly managed by it. */
+		void release();
+
+		/**	Destroys the device and all resources directly managed by it. */
+		void destroy();		
+		
+		/**	Checks is the device lost. If lost you will need to "acquire" the device. */
+		bool isDeviceLost();				
+		
+		/**	Return internal DX9 device object. */
+		IDirect3DDevice9* getD3D9Device() const;
+
+		/**
+		 * Returns adapter number this device is tied to. This number corresponds to the adapter index returned by DX9 API.
+		 */
+		UINT getAdapterNumber() const;
+
+		/**	Returns type of the device. */
+		D3DDEVTYPE getDeviceType() const;
+
+		/**	Checks is the device multihead (manages multiple full-screen outputs). */
+		bool isMultihead() const;					
+
+		/**	Returns true if depth/stencil format can be automatically determined. */
+		bool isAutoDepthStencil() const;
+		
+		/**	Returns DX9 device capabilities. */
+		const D3DCAPS9& getD3D9DeviceCaps() const;
+
+		/**	Returns DX9 format of the back buffer used by the primary window for this device. */
+		D3DFORMAT getBackBufferFormat() const;
+
+		/**	Returns DX9 format of the depth stencil buffer used by the primary window for this device. */
+		D3DFORMAT getDepthStencilFormat() const;
+
+		/**	Validates that the window is valid for this device. Will reset device if needed. */
+		bool validate(D3D9RenderWindowCore* renderWindow);
+
+		/**	Invalidates the window so on the next call to validate, the device will be re-acquired. */
+		void invalidate(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Swap back and front buffers for the specified window. */
+		void present(const D3D9RenderWindowCore* renderWindow);
+		
+		/**	Returns internal DX9 represention of the depth/stencil buffer. */
+		IDirect3DSurface9* getDepthBuffer(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Returns internal DX9 represention of the backbuffer. */
+		IDirect3DSurface9* getBackBuffer(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Sets adapter index for the specified window. */
+		void setAdapterOrdinalIndex(const D3D9RenderWindowCore* renderWindow, UINT32 adapterOrdinalInGroupIndex);
+
+		/**	Copies contents of the back or depth/stencil buffer in to the provided object. */
+		void copyContentsToMemory(const D3D9RenderWindowCore* window, PixelData &dst, RenderTargetCore::FrameBuffer buffer);
+
+		/**	Resets bound pipeline states/streams to null. */
+		void clearDeviceStreams();
+	
+	protected:
+		friend class D3D9DeviceManager;
+		friend class D3D9RenderAPI;
+
+		typedef Map<const D3D9RenderWindowCore*, RenderWindowResources*> RenderWindowToResorucesMap;
+		typedef RenderWindowToResorucesMap::iterator RenderWindowToResorucesIterator;
+
+		/**	Find iterator for the specified window in the render window resource list. */
+		RenderWindowToResorucesIterator getRenderWindowIterator(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Acquires the device for the provided render window. */
+		bool acquire(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Forcibly reset the device. */
+		bool reset();
+
+		/**	Update presentation parameters from the active render window. */
+		void updatePresentationParameters();
+
+		/**	Updates presentation parameter indices for all windows attached to this device. */
+		void updateRenderWindowsIndices();
+
+		/**	Creates a new DX9 device object. */
+		void createD3D9Device();
+
+		/**	Releases the DX9 device object. */
+		void releaseD3D9Device();
+
+		/**	Releases all render window resources in the provided object. */
+		void releaseRenderWindowResources(RenderWindowResources* renderWindowResources);
+
+		/**
+		 * Acquires all render window resources from the provided render window, and stores them in the provided render
+		 * window resources object.
+		 */
+		void acquireRenderWindowResources(RenderWindowToResorucesIterator it);
+
+		/**	Called when it has been detected that device has been lost. */
+		void notifyDeviceLost();
+
+		/**	Checks if focus window changed and should device be reacquired. */
+		void validateFocusWindow();
+
+		/**	Checks if back buffer size has changed and invalidates the window if it has. */
+		void validateBackBufferSize(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Checks if window monitor changed and re-links the window if needed. */
+		bool validateDisplayMonitor(D3D9RenderWindowCore* renderWindow);
+
+		/**	Checks if device has been lost or active window invalidated and acquires the device if needed. */
+		bool validateDeviceState(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Checks if the render window contains a custom swap chain. */
+		bool isSwapChainWindow(const D3D9RenderWindowCore* renderWindow);
+
+		/**	Returns primary window for this device. */
+		const D3D9RenderWindowCore*	getPrimaryWindow();
+
+		/**	Sets the shared window handle. */
+		void setSharedWindowHandle(HWND hSharedHWND);
+
+	protected:			
+		D3D9DeviceManager* mpDeviceManager;	/**< The manager of this device instance. */
+		IDirect3DDevice9* mpDevice;	/**< Will hold the device interface. */
+		UINT mAdapterNumber; /**< The adapter that this device belongs to. */
+		HMONITOR mMonitor; /**< The monitor that this device belongs to. */
+		D3DDEVTYPE mDeviceType; /**< Device type. */
+		static HWND	msSharedFocusWindow; /**< The shared focus window in case of multiple full screen render windows. */
+		HWND mFocusWindow; /**< The focus window this device attached to. */	
+		DWORD mBehaviorFlags; /**< The behavior of this device.	*/
+		
+		/** 
+		 * Presentation parameters which the device was created with. May be an array of presentation parameters in case of
+		 * multi-head device.
+		 */
+		D3DPRESENT_PARAMETERS* mPresentationParams;
+		UINT mPresentationParamsCount; /**< Number of presentation parameters elements.	 */
+		D3DCAPS9 mD3D9DeviceCaps; /**< Device caps. */
+		bool mD3D9DeviceCapsValid; /**< True if device caps initialized. */
+		D3DDEVICE_CREATION_PARAMETERS mCreationParams; /**< Creation parameters. */
+		bool mDeviceLost; /**< True if device entered lost state. */
+	
+		RenderWindowToResorucesMap mMapRenderWindowToResoruces;	/**< Map between render window to resources. */
+	};
+
+	/** @} */
 }

+ 65 - 82
Source/BansheeD3D9RenderAPI/Include/BsD3D9DeviceManager.h

@@ -1,83 +1,66 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles creation of DirectX 9 devices. Also links the devices
-	 *			with created render targets.
-	 */
-	class BS_D3D9_EXPORT D3D9DeviceManager
-	{	
-	public:
-		D3D9DeviceManager();
-		~D3D9DeviceManager();
-
-		/**
-		 * @brief	Changes the active device to the provided device. Must be not null.
-		 */
-		void setActiveDevice(D3D9Device* device);
-
-		/**
-		 * @brief	Retrieves the currently active device.
-		 */
-		D3D9Device*	getActiveDevice();
-
-		/**
-		 * @brief	Sets the device used by the currently active render target.
-		 */
-		void setActiveRenderTargetDevice(D3D9Device* device);
-
-		/**
-		 * @brief	Retrieves the device used by the currently active render target.
-		 */
-		D3D9Device*	getActiveRenderTargetDevice();		
-
-		/**
-		 * @brief	Returns the total number of devices available.
-		 */
-		UINT getDeviceCount();
-
-		/**
-		 * @brief	Returns the device under the specified index.
-		 */
-		D3D9Device*	getDevice(UINT index);
-
-		/**
-		 * @brief	Links the provided render window with a device. The window will be 
-		 *			assigned an existing device if a match one can be found, otherwise
-		 *			a new device will be created.
-		 */
-		void linkRenderWindow(D3D9RenderWindowCore* renderWindow);
-
-		/**
-		 * @brief	Called by the devices when they're are being destroyed.
-		 */
-		void notifyOnDeviceDestroy(D3D9Device* device);
-
-		/**
-		 * @brief	Retrieves engine device from DX9 device.
-		 */
-		D3D9Device*	getDeviceFromD3D9Device(IDirect3DDevice9* d3d9Device);
-
-	protected:
-		/**
-		 * @brief	Attempts to find a matching device for the provided render window. If one cannot be found a
-		 *			new device is created. Found/created device is returned, as well as a list of all render windows
-		 *			using that device.
-		 */
-		D3D9Device*	selectDevice(D3D9RenderWindowCore* renderWindow, Vector<D3D9RenderWindowCore*>& renderWindowsGroup);
-
-		/**
-		 * @brief	Finds the driver the render window belongs to.
-		 */
-		D3D9Driver*	findDriver(D3D9RenderWindowCore* renderWindow);
-
-		Vector<D3D9Device*> mRenderDevices;
-		D3D9Device*	mActiveDevice;
-		D3D9Device*	mActiveRenderWindowDevice;		
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** Handles creation of DirectX 9 devices. Also links the devices with created render targets. */
+	class BS_D3D9_EXPORT D3D9DeviceManager
+	{	
+	public:
+		D3D9DeviceManager();
+		~D3D9DeviceManager();
+
+		/**	Changes the active device to the provided device. Must be not null. */
+		void setActiveDevice(D3D9Device* device);
+
+		/**	Retrieves the currently active device. */
+		D3D9Device*	getActiveDevice();
+
+		/**	Sets the device used by the currently active render target. */
+		void setActiveRenderTargetDevice(D3D9Device* device);
+
+		/**	Retrieves the device used by the currently active render target. */
+		D3D9Device*	getActiveRenderTargetDevice();		
+
+		/**	Returns the total number of devices available. */
+		UINT getDeviceCount();
+
+		/**	Returns the device under the specified index. */
+		D3D9Device*	getDevice(UINT index);
+
+		/**
+		 * Links the provided render window with a device. The window will be assigned an existing device if a match one
+		 * can be found, otherwise a new device will be created.
+		 */
+		void linkRenderWindow(D3D9RenderWindowCore* renderWindow);
+
+		/**	Called by the devices when they're are being destroyed. */
+		void notifyOnDeviceDestroy(D3D9Device* device);
+
+		/**	Retrieves engine device from DX9 device. */
+		D3D9Device*	getDeviceFromD3D9Device(IDirect3DDevice9* d3d9Device);
+
+	protected:
+		/**
+		 * Attempts to find a matching device for the provided render window. If one cannot be found a new device is
+		 * created. Found/created device is returned, as well as a list of all render windows using that device.
+		 */
+		D3D9Device*	selectDevice(D3D9RenderWindowCore* renderWindow, Vector<D3D9RenderWindowCore*>& renderWindowsGroup);
+
+		/**	Finds the driver the render window belongs to. */
+		D3D9Driver*	findDriver(D3D9RenderWindowCore* renderWindow);
+
+		Vector<D3D9Device*> mRenderDevices;
+		D3D9Device*	mActiveDevice;
+		D3D9Device*	mActiveRenderWindowDevice;		
+	};
+
+	/** @} */
 }

+ 46 - 53
Source/BansheeD3D9RenderAPI/Include/BsD3D9Driver.h

@@ -1,54 +1,47 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-
-namespace BansheeEngine
-{
-	class D3D9VideoModeList;
-	class D3D9VideoMode;
-
-	/**
-	 * @brief	Holds data about a DX9 driver (adapter).
-	 */
-	class BS_D3D9_EXPORT D3D9Driver
-	{
-	public:
-		D3D9Driver();
-		D3D9Driver(const D3D9Driver &ob);
-		D3D9Driver(UINT32 adapterNumber, const D3DCAPS9& deviceCaps, const D3DADAPTER_IDENTIFIER9& adapterIdentifer);
-		~D3D9Driver();
-
-		/**
-		 * @brief	Returns hardware capabilities for this driver.
-		 */
-		const D3DCAPS9&	getD3D9DeviceCaps() const { return mD3D9DeviceCaps; }
-
-		/**
-		 * @brief	Returns name of the driver.
-		 */
-		String getDriverName() const;
-
-		/**
-		 * @brief	Returns description of the driver.
-		 */
-		String getDriverDescription() const;
-
-		/**
-		 * @brief	Returns adapter number which corresponds to adapter number returned by
-		 *			DX9 API.
-		 */
-		UINT32 getAdapterNumber() const { return mAdapterNumber; }
-
-		/**
-		 * @brief	Returns DX9 adapter identifier.
-		 */
-		const D3DADAPTER_IDENTIFIER9& getAdapterIdentifier() const { return mAdapterIdentifier; }
-
-	private:				
-		UINT32 mAdapterNumber;
-		D3DCAPS9 mD3D9DeviceCaps;		
-		D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	class D3D9VideoModeList;
+	class D3D9VideoMode;
+
+	/**	Holds data about a DX9 driver (adapter). */
+	class BS_D3D9_EXPORT D3D9Driver
+	{
+	public:
+		D3D9Driver();
+		D3D9Driver(const D3D9Driver &ob);
+		D3D9Driver(UINT32 adapterNumber, const D3DCAPS9& deviceCaps, const D3DADAPTER_IDENTIFIER9& adapterIdentifer);
+		~D3D9Driver();
+
+		/**	Returns hardware capabilities for this driver. */
+		const D3DCAPS9&	getD3D9DeviceCaps() const { return mD3D9DeviceCaps; }
+
+		/**	Returns name of the driver. */
+		String getDriverName() const;
+
+		/**	Returns description of the driver. */
+		String getDriverDescription() const;
+
+		/** Returns adapter number which corresponds to adapter number returned by DX9 API. */
+		UINT32 getAdapterNumber() const { return mAdapterNumber; }
+
+		/**	Returns DX9 adapter identifier. */
+		const D3DADAPTER_IDENTIFIER9& getAdapterIdentifier() const { return mAdapterIdentifier; }
+
+	private:				
+		UINT32 mAdapterNumber;
+		D3DCAPS9 mD3D9DeviceCaps;		
+		D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
+	};
+
+	/** @} */
 }

+ 38 - 42
Source/BansheeD3D9RenderAPI/Include/BsD3D9DriverList.h

@@ -1,43 +1,39 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9Driver.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Holds a list of all drivers (adapters) and video modes.
-	 */
-	class BS_D3D9_EXPORT D3D9DriverList
-	{
-	public:
-		D3D9DriverList();
-		~D3D9DriverList();
-
-		/**
-		 * @brief	Returns the number of drivers (adapters) available.
-		 */
-		UINT32 count() const;
-
-		/**
-		 * @brief	Returns driver with the specified index.
-		 */
-		D3D9Driver* item(UINT32 index);
-
-		/**
-		 * @brief	Returns drivers with the specified name or null if it cannot be found.
-		 */
-		D3D9Driver* item(const String &name);
-
-		/**
-		 * @brief	Returns available video modes for all drivers and output devices.
-		 */
-		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
-
-	private:
-		Vector<D3D9Driver> mDriverList;
-		VideoModeInfoPtr mVideoModeInfo;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9Driver.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Holds a list of all drivers (adapters) and video modes. */
+	class BS_D3D9_EXPORT D3D9DriverList
+	{
+	public:
+		D3D9DriverList();
+		~D3D9DriverList();
+
+		/**	Returns the number of drivers (adapters) available. */
+		UINT32 count() const;
+
+		/**	Returns driver with the specified index. */
+		D3D9Driver* item(UINT32 index);
+
+		/**	Returns drivers with the specified name or null if it cannot be found. */
+		D3D9Driver* item(const String &name);
+
+		/**	Returns available video modes for all drivers and output devices. */
+		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
+
+	private:
+		Vector<D3D9Driver> mDriverList;
+		VideoModeInfoPtr mVideoModeInfo;
+	};
+
+	/** @} */
 }

+ 38 - 36
Source/BansheeD3D9RenderAPI/Include/BsD3D9EmulatedParamBlocks.h

@@ -1,37 +1,39 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Represents a parameter block that can be used with GPU programs
-	 *			that do not support them natively. Each block is defined with a unique
-	 *			name (user defined) and a set of parameter names belonging to that block
-	 *			(names must reference actual GPU variables).
-	 */
-	struct D3D9EmulatedParamBlock
-	{
-		String blockName;
-		Vector<String> paramNames;
-	};
-
-	/**
-	 * @brief	Parses GPU program source and retrieves 
-	 *			parameter blocks from it.
-	 */
-	class D3D9EmulatedParamBlockParser
-	{
-	public:
-		/**
-		 * Parses GPU program source and retrieves parameter blocks from it. Returns
-		 * source without parameter block code.
-		 *
-		 * Parameter blocks can be anywhere in the source file and they must follow this exact structure:
-		 *  BS_PARAM_BLOCK blockName { param1, param2, etc }
-		 */
-		static String parse(const String& gpuProgSource, Vector<D3D9EmulatedParamBlock>& paramBlocks);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**
+	 * Represents a parameter block that can be used with GPU programs that do not support them natively. Each block is
+	 * defined with a unique name (user defined) and a set of parameter names belonging to that block (names must reference
+	 * actual GPU variables).
+	 */
+	struct D3D9EmulatedParamBlock
+	{
+		String blockName;
+		Vector<String> paramNames;
+	};
+
+	/**	Parses GPU program source and retrieves parameter blocks from it. */
+	class D3D9EmulatedParamBlockParser
+	{
+	public:
+		/**
+		 * Parses GPU program source and retrieves parameter blocks from it. Returns
+		 * source without parameter block code.
+		 *
+		 * Parameter blocks can be anywhere in the source file and they must follow this exact structure:
+		 *  BS_PARAM_BLOCK blockName { param1, param2, etc }
+		 */
+		static String parse(const String& gpuProgSource, Vector<D3D9EmulatedParamBlock>& paramBlocks);
+	};
+
+	/** @} */
 }

+ 53 - 65
Source/BansheeD3D9RenderAPI/Include/BsD3D9EventQuery.h

@@ -1,66 +1,54 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9Resource.h"
-#include "BsEventQuery.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @copydoc EventQuery
-	 */
-	class BS_D3D9_EXPORT D3D9EventQuery : public EventQuery, public D3D9Resource
-	{
-	public:
-		D3D9EventQuery();
-		~D3D9EventQuery();
-
-		/**
-		 * @copydoc EventQuery::begin
-		 */
-		virtual void begin();
-
-		/**
-		 * @copydoc EventQuery::isReady
-		 */
-		virtual bool isReady() const;
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceLost
-		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceReset
-		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
-
-	private:
-		/**
-		 * @brief	Creates the internal DX9 query.
-		 */
-		void createQuery();
-
-		/**
-		 * @brief	Releases the internal DX9 query.
-		 */
-		void releaseQuery();
-
-	private:
-		bool mQueryIssued;
-		IDirect3DQuery9* mQuery;
-		IDirect3DDevice9* mDevice;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9Resource.h"
+#include "BsEventQuery.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** @copydoc EventQuery */
+	class BS_D3D9_EXPORT D3D9EventQuery : public EventQuery, public D3D9Resource
+	{
+	public:
+		D3D9EventQuery();
+		~D3D9EventQuery();
+
+		/** @copydoc EventQuery::begin */
+		void begin() override;
+
+		/** @copydoc EventQuery::isReady */
+		bool isReady() const override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+	private:
+		/**	Creates the internal DX9 query. */
+		void createQuery();
+
+		/**	Releases the internal DX9 query. */
+		void releaseQuery();
+
+	private:
+		bool mQueryIssued;
+		IDirect3DQuery9* mQuery;
+		IDirect3DDevice9* mDevice;
+	};
+
+	/** @} */
 }

+ 56 - 67
Source/BansheeD3D9RenderAPI/Include/BsD3D9GpuBuffer.h

@@ -1,68 +1,57 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsGpuBuffer.h"
-
-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 D3D9GpuBufferCore : public GpuBufferCore
-	{
-	public:
-		~D3D9GpuBufferCore();
-
-		/**
-		 * @copydoc GpuBufferCore::lock
-		 */
-		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-		/**
-		 * @copydoc GpuBufferCore::unlock
-		 */
-		virtual void unlock();
-
-		/**
-		 * @copydoc GpuBufferCore::readData
-		 */
-        virtual void readData(UINT32 offset, UINT32 length, void* pDest);
-
-		/**
-		 * @copydoc GpuBufferCore::writeData
-		 */
-        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**
-		 * @copydoc GpuBufferCore::copyData
-		 */
-		void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
-
-	protected:
-		friend class D3D9HardwareBufferCoreManager;
-
-		D3D9GpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage,
-			bool randomGpuWrite = false, bool useCounter = false);
-
-		/**
-		 * @copydoc	GpuBufferCore::createView
-		 */
-		virtual GpuBufferView* createView();
-
-		/**
-		 * @copydoc	GpuBufferCore::destroyView
-		 */
-		virtual void destroyView(GpuBufferView* view);
-
-		/**
-		 * @copydoc GpuBufferCore::initialize
-		 */
-		void initialize();	
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsGpuBuffer.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**
+	 * 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 D3D9GpuBufferCore : public GpuBufferCore
+	{
+	public:
+		~D3D9GpuBufferCore();
+
+		/** @copydoc GpuBufferCore::lock */
+		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+
+		/** @copydoc GpuBufferCore::unlock */
+		void unlock() override;
+
+		/** @copydoc GpuBufferCore::readData */
+        void readData(UINT32 offset, UINT32 length, void* pDest) override;
+
+		/** @copydoc GpuBufferCore::writeData */
+        void writeData(UINT32 offset, UINT32 length, const void* pSource,
+				BufferWriteType writeFlags = BufferWriteType::Normal) override;
+
+		/** @copydoc GpuBufferCore::copyData */
+		void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) override;
+
+	protected:
+		friend class D3D9HardwareBufferCoreManager;
+
+		D3D9GpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage,
+			bool randomGpuWrite = false, bool useCounter = false);
+
+		/** @copydoc GpuBufferCore::createView */
+		GpuBufferView* createView() override;
+
+		/** @copydoc GpuBufferCore::destroyView */
+		void destroyView(GpuBufferView* view) override;
+
+		/** @copydoc GpuBufferCore::initialize */
+		void initialize() override;	
+	};
+
+	/** @} */
 }

+ 113 - 137
Source/BansheeD3D9RenderAPI/Include/BsD3D9GpuProgram.h

@@ -1,138 +1,114 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsGpuProgram.h"
-#include "BsD3D9Resource.h"
-#include "BsD3D9EmulatedParamBlocks.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Available optimization levels when compiling a GPU program.
-	 */
-	enum OptimizationLevel
-	{
-		OPT_DEFAULT,
-		OPT_NONE,
-		OPT_0,
-		OPT_1,
-		OPT_2,
-		OPT_3
-	};
-
-	/**
-	 * @brief	DirectX 9 implementation of a GPU program.
-	 */
-    class BS_D3D9_EXPORT D3D9GpuProgramCore : public GpuProgramCore, public D3D9Resource
-    {   
-    public:
-		virtual ~D3D9GpuProgramCore();
-
-		/**
-		 * @brief	Sets the preprocessor defines use to compile the program.
-		 */
-		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
-
-		/**
-		 * @brief	Sets optimization level to use when compiling the shader.
-		 */
-		void setOptimizationLevel(OptimizationLevel opt) { mOptimisationLevel = opt; }
-
-    protected:
-		friend class D3D9HLSLProgramFactory;
-
-		D3D9GpuProgramCore(const String& source, const String& entryPoint,
-			GpuProgramType gptype, GpuProgramProfile profile);
-
-		/**
-		 * @copydoc GpuProgramCore::initialize
-		 */
-		void initialize() override;
-      
-		/**
-		 * @brief	Loads the GPU program from compiled microcode.
-		 */
-        virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
-
-	protected:    
-		OptimizationLevel mOptimisationLevel;
-		String mPreprocessorDefines;
-		Vector<D3D9EmulatedParamBlock> mBlocks;
-		bool mColumnMajorMatrices;
-		ID3DXBuffer* mMicrocode;
-    };
-
-	/**
-	 * @brief	DirectX 9 implementation of a vertex GPU program.
-	 */
-    class BS_D3D9_EXPORT D3D9GpuVertexProgramCore : public D3D9GpuProgramCore
-    {  
-    public:
-		~D3D9GpuVertexProgramCore();
-        
-		/**
-		 * @brief	Returns internal DX9 vertex shader object.
-		 */
-        IDirect3DVertexShader9* getVertexShader();
-
-		/**
-		 * @copydoc D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
-
-		/**
-		 * @copydoc D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
-
-    protected:
-		friend class D3D9HLSLProgramFactory;
-
-		D3D9GpuVertexProgramCore(const String& source, const String& entryPoint, GpuProgramProfile profile);
-
-		/**
-		 * @copydoc	D3D9GpuProgramCore::loadFromMicrocode
-		 */
-		void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) override;
-
-	protected:
-		Map<IDirect3DDevice9*, IDirect3DVertexShader9*>	mMapDeviceToVertexShader;
-    };
-
-    /** Direct3D implementation of low-level fragment programs. */
-    class BS_D3D9_EXPORT D3D9GpuFragmentProgramCore : public D3D9GpuProgramCore
-    {  
-    public:
-		~D3D9GpuFragmentProgramCore();
-
-		/**
-		 * @brief	Returns internal DX9 pixel shader object.
-		 */
-        IDirect3DPixelShader9* getPixelShader();
-
-		/**
-		 * @copydoc D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
-
-		/**
-		 * @copydoc D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
-
-    protected:
-		friend class D3D9HLSLProgramFactory;
-
-		D3D9GpuFragmentProgramCore(const String& source, const String& entryPoint, GpuProgramProfile profile);
-
-		/**
-		 * @copydoc	D3D9GpuProgramCore::loadFromMicrocode
-		 */
-		void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) override;
-
-	protected:
-		Map<IDirect3DDevice9*, IDirect3DPixelShader9*> mMapDeviceToPixelShader;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsGpuProgram.h"
+#include "BsD3D9Resource.h"
+#include "BsD3D9EmulatedParamBlocks.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Available optimization levels when compiling a GPU program. */
+	enum OptimizationLevel
+	{
+		OPT_DEFAULT,
+		OPT_NONE,
+		OPT_0,
+		OPT_1,
+		OPT_2,
+		OPT_3
+	};
+
+	/**	DirectX 9 implementation of a GPU program. */
+    class BS_D3D9_EXPORT D3D9GpuProgramCore : public GpuProgramCore, public D3D9Resource
+    {   
+    public:
+		virtual ~D3D9GpuProgramCore();
+
+		/**	Sets the preprocessor defines use to compile the program. */
+		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
+
+		/**	Sets optimization level to use when compiling the shader. */
+		void setOptimizationLevel(OptimizationLevel opt) { mOptimisationLevel = opt; }
+
+    protected:
+		friend class D3D9HLSLProgramFactory;
+
+		D3D9GpuProgramCore(const String& source, const String& entryPoint,
+			GpuProgramType gptype, GpuProgramProfile profile);
+
+		/** @copydoc GpuProgramCore::initialize */
+		void initialize() override;
+      
+		/**	Loads the GPU program from compiled microcode. */
+        virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
+
+	protected:    
+		OptimizationLevel mOptimisationLevel;
+		String mPreprocessorDefines;
+		Vector<D3D9EmulatedParamBlock> mBlocks;
+		bool mColumnMajorMatrices;
+		ID3DXBuffer* mMicrocode;
+    };
+
+	/**	DirectX 9 implementation of a vertex GPU program. */
+    class BS_D3D9_EXPORT D3D9GpuVertexProgramCore : public D3D9GpuProgramCore
+    {  
+    public:
+		~D3D9GpuVertexProgramCore();
+        
+		/**	Returns internal DX9 vertex shader object. */
+        IDirect3DVertexShader9* getVertexShader();
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+    protected:
+		friend class D3D9HLSLProgramFactory;
+
+		D3D9GpuVertexProgramCore(const String& source, const String& entryPoint, GpuProgramProfile profile);
+
+		/** @copydoc D3D9GpuProgramCore::loadFromMicrocode */
+		void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) override;
+
+	protected:
+		Map<IDirect3DDevice9*, IDirect3DVertexShader9*>	mMapDeviceToVertexShader;
+    };
+
+    /** Direct3D implementation of low-level fragment programs. */
+    class BS_D3D9_EXPORT D3D9GpuFragmentProgramCore : public D3D9GpuProgramCore
+    {  
+    public:
+		~D3D9GpuFragmentProgramCore();
+
+		/**	Returns internal DX9 pixel shader object. */
+        IDirect3DPixelShader9* getPixelShader();
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+    protected:
+		friend class D3D9HLSLProgramFactory;
+
+		D3D9GpuFragmentProgramCore(const String& source, const String& entryPoint, GpuProgramProfile profile);
+
+		/** @copydoc D3D9GpuProgramCore::loadFromMicrocode */
+		void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) override;
+
+	protected:
+		Map<IDirect3DDevice9*, IDirect3DPixelShader9*> mMapDeviceToPixelShader;
+    };
+
+	/** @} */
 }

+ 372 - 371
Source/BansheeD3D9RenderAPI/Include/BsD3D9HLSLParamParser.h

@@ -1,372 +1,373 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9GpuProgram.h"
-#include "BsGpuParamDesc.h"
-
-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
-	{
-	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)
-			:mpConstTable(constTable), mBlocks(blocks)
-		{ }
-
-		/**
-		 * @brief	Builds parameter descriptions and returns an object containing all relevant information.
-		 */
-		GpuParamDescPtr buildParameterDescriptions();
-
-	private:
-		/**
-		 * @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);
-
-		/**
-		 * @brief	Returns the name of the parameter with the specified constant table handle.
-		 */
-		String getParamName(D3DXHANDLE constant);
-
-	private:
-		LPD3DXCONSTANTTABLE mpConstTable;
-		Vector<D3D9EmulatedParamBlock> mBlocks;
-		GpuParamDescPtr mParamDesc;
-	};
-
-	String D3D9HLSLParamParser::getParamName(D3DXHANDLE constant)
-	{
-		D3DXCONSTANT_DESC desc;
-		UINT32 numParams = 1;
-		HRESULT hr = mpConstTable->GetConstantDesc(constant, &desc, &numParams);
-		if (FAILED(hr))
-		{
-			BS_EXCEPT(InternalErrorException, "Cannot retrieve constant description from HLSL program.");
-		}
-
-		String paramName = desc.Name;
-		// trim the odd '$' which appears at the start of the names in HLSL
-		if (paramName.at(0) == '$')
-			paramName.erase(paramName.begin());
-
-		// Also trim the '[0]' suffix if it exists, we will add our own indexing later
-		if (StringUtil::endsWith(paramName, "[0]", false))
-			paramName.erase(paramName.size() - 3);
-
-		return paramName;
-	}
-
-	GpuParamDescPtr D3D9HLSLParamParser::buildParameterDescriptions()
-	{
-		// Derive parameter names from const table
-		assert(mpConstTable && "Program not loaded!");
-
-		mParamDesc = bs_shared_ptr_new<GpuParamDesc>();
-
-		// Get contents of the constant table
-		D3DXCONSTANTTABLE_DESC desc;
-		HRESULT hr = mpConstTable->GetDesc(&desc);
-
-		if (FAILED(hr))
-			BS_EXCEPT(InternalErrorException, "Cannot retrieve constant descriptions from HLSL program.");
-
-		// DX9 has no concept of parameter blocks so we emulate them if needed
-		String name = "BS_INTERNAL_Globals";
-		mParamDesc->paramBlocks.insert(std::make_pair(name, GpuParamBlockDesc()));
-		GpuParamBlockDesc& globalBlockDesc = mParamDesc->paramBlocks[name];
-		globalBlockDesc.name = name;
-		globalBlockDesc.slot = 0;
-		globalBlockDesc.blockSize = 0;
-		globalBlockDesc.isShareable = false;
-
-		UnorderedMap<String, String> nonGlobalBlocks;
-		UINT32 curSlot = 1;
-		for (auto& block : mBlocks)
-		{
-			mParamDesc->paramBlocks.insert(std::make_pair(block.blockName, GpuParamBlockDesc()));
-			GpuParamBlockDesc& blockDesc = mParamDesc->paramBlocks[block.blockName];
-			blockDesc.name = block.blockName;
-			blockDesc.slot = curSlot++;
-			blockDesc.blockSize = 0;
-			blockDesc.isShareable = true;
-
-			for (auto& fieldName : block.paramNames)
-			{
-				nonGlobalBlocks.insert(std::make_pair(fieldName, block.blockName));
-			}
-		}
-
-		// Iterate over the constants
-		for (UINT32 i = 0; i < desc.Constants; ++i)
-		{
-			D3DXHANDLE constantHandle = mpConstTable->GetConstant(NULL, i);
-			String paramName = getParamName(constantHandle);
-
-			// Recursively descend through the structure levels
-			auto findIter = nonGlobalBlocks.find(paramName);
-			if (findIter == nonGlobalBlocks.end())
-				processParameter(globalBlockDesc, paramName, constantHandle, "");
-			else
-				processParameter(mParamDesc->paramBlocks[findIter->second], paramName, constantHandle, "");
-		}
-
-		return mParamDesc;
-	}
-
-	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
-		// automatically, we have to do it by hand
-
-		D3DXCONSTANT_DESC desc;
-		UINT32 numParams = 1;
-		HRESULT hr = mpConstTable->GetConstantDesc(constant, &desc, &numParams);
-		if (FAILED(hr))
-		{
-			BS_EXCEPT(InternalErrorException, "Cannot retrieve constant description from HLSL program.");
-		}
-
-		if (desc.Class == D3DXPC_STRUCT)
-		{
-			// work out a new prefix for nested members, if it's an array, we need an index
-			prefix = prefix + paramName + ".";
-			// Cascade into struct
-			for (UINT32 i = 0; i < desc.StructMembers; ++i)
-			{
-				D3DXHANDLE childHandle = mpConstTable->GetConstant(constant, i);
-				String childParamName = getParamName(childHandle);
-
-				processParameter(blockDesc, childParamName, childHandle, prefix);
-			}
-		}
-		else
-		{
-			// Process params
-			if (desc.Type == D3DXPT_FLOAT || desc.Type == D3DXPT_INT || desc.Type == D3DXPT_BOOL)
-			{
-				GpuParamDataDesc memberDesc;
-				memberDesc.gpuMemOffset = desc.RegisterIndex;
-				memberDesc.cpuMemOffset = blockDesc.blockSize;
-				memberDesc.paramBlockSlot = blockDesc.slot;
-				memberDesc.arraySize = 1;
-
-				String name = prefix + paramName;
-				memberDesc.name = name;
-
-				populateParamMemberDesc(memberDesc, desc);
-				mParamDesc->params.insert(std::make_pair(name, memberDesc));
-
-				blockDesc.blockSize += memberDesc.arrayElementStride * memberDesc.arraySize;
-			}
-			else if(desc.Type == D3DXPT_SAMPLER1D || desc.Type == D3DXPT_SAMPLER2D || desc.Type == D3DXPT_SAMPLER3D || desc.Type == D3DXPT_SAMPLERCUBE)
-			{
-				GpuParamObjectDesc samplerDesc;
-				samplerDesc.name = paramName;
-				samplerDesc.slot = desc.RegisterIndex;
-
-				GpuParamObjectDesc textureDesc;
-				textureDesc.name = paramName;
-				textureDesc.slot = desc.RegisterIndex;
-
-				switch(desc.Type)
-				{
-				case D3DXPT_SAMPLER1D:
-					samplerDesc.type = GPOT_SAMPLER1D;
-					textureDesc.type = GPOT_TEXTURE1D;
-					break;
-				case D3DXPT_SAMPLER2D:
-					samplerDesc.type = GPOT_SAMPLER2D;
-					textureDesc.type = GPOT_TEXTURE2D;
-					break;
-				case D3DXPT_SAMPLER3D:
-					samplerDesc.type = GPOT_SAMPLER3D;
-					textureDesc.type = GPOT_TEXTURE3D;
-					break;
-				case D3DXPT_SAMPLERCUBE:
-					samplerDesc.type = GPOT_SAMPLERCUBE;
-					textureDesc.type = GPOT_TEXTURECUBE;
-					break;
-				default:
-					BS_EXCEPT(InternalErrorException, "Invalid sampler type: " + toString(desc.Type) + " for parameter " + paramName);
-				}
-
-				mParamDesc->samplers.insert(std::make_pair(paramName, samplerDesc));
-				mParamDesc->textures.insert(std::make_pair(paramName, textureDesc));
-			}
-			else
-			{
-				BS_EXCEPT(InternalErrorException, "Invalid shader parameter type: " + toString(desc.Type) + " for parameter " + paramName);
-			}
-		}
-	}
-
-	void D3D9HLSLParamParser::populateParamMemberDesc(GpuParamDataDesc& memberDesc, D3DXCONSTANT_DESC& d3dDesc)
-	{
-		memberDesc.arraySize = d3dDesc.Elements;
-		switch(d3dDesc.Type)
-		{
-		case D3DXPT_INT:
-			switch(d3dDesc.Columns)
-			{
-			case 1:
-				memberDesc.type = GPDT_INT1;
-				break;
-			case 2:
-				memberDesc.type = GPDT_INT2;
-				break;
-			case 3:
-				memberDesc.type = GPDT_INT3;
-				break;
-			case 4:
-				memberDesc.type = GPDT_INT4;
-				break;
-			} 
-
-			memberDesc.elementSize = 4;
-			memberDesc.arrayElementStride = 4;
-
-			break;
-		case D3DXPT_FLOAT:
-			switch(d3dDesc.Class)
-			{
-			case D3DXPC_MATRIX_COLUMNS:
-			case D3DXPC_MATRIX_ROWS:
-				{
-					int firstDim, secondDim;
-					int firstActualDim; // Actual size might be less than requested because of optimization, we need to know both
-					firstActualDim = d3dDesc.RegisterCount / d3dDesc.Elements;
-
-					if (d3dDesc.Class == D3DXPC_MATRIX_ROWS)
-					{
-						firstDim = d3dDesc.Rows;
-						secondDim = d3dDesc.Columns;
-					}
-					else
-					{
-						firstDim = d3dDesc.Columns;
-						secondDim = d3dDesc.Rows;
-					}
-
-					switch (firstActualDim)
-					{
-					case 2:
-						memberDesc.elementSize = 8; // HLSL always padds regardless of row size
-						memberDesc.arrayElementStride = 8;
-						break;
-					case 3:
-						memberDesc.elementSize = 12; // HLSL always padds regardless of row size
-						memberDesc.arrayElementStride = 12;
-						break;
-					case 4:
-						memberDesc.elementSize = 16; // HLSL always padds regardless of row size
-						memberDesc.arrayElementStride = 16;
-						break;
-
-					}
-
-					switch (firstDim)
-					{
-					case 2:
-						switch (secondDim)
-						{
-						case 2:
-							memberDesc.type = GPDT_MATRIX_2X2;
-							break;
-						case 3:
-							memberDesc.type = GPDT_MATRIX_2X3;
-							break;
-						case 4:
-							memberDesc.type = GPDT_MATRIX_2X4;
-							break;
-						} 
-						break;
-					case 3:
-						switch (secondDim)
-						{
-						case 2:
-							memberDesc.type = GPDT_MATRIX_3X2;
-							break;
-						case 3:
-							memberDesc.type = GPDT_MATRIX_3X3;
-							break;
-						case 4:
-							memberDesc.type = GPDT_MATRIX_3X4;
-							break;
-						} 
-						break;
-					case 4:
-						switch (secondDim)
-						{
-						case 2:
-							memberDesc.type = GPDT_MATRIX_4X2;
-							break;
-						case 3:
-							memberDesc.type = GPDT_MATRIX_4X3;
-							break;
-						case 4:
-							memberDesc.type = GPDT_MATRIX_4X4;
-							break;
-						}
-						break;
-					}
-				}
-				break;
-			case D3DXPC_SCALAR:
-			case D3DXPC_VECTOR:
-				switch(d3dDesc.Columns)
-				{
-				case 1:
-					memberDesc.type = GPDT_FLOAT1;
-					break;
-				case 2:
-					memberDesc.type = GPDT_FLOAT2;
-					break;
-				case 3:
-					memberDesc.type = GPDT_FLOAT3;
-					break;
-				case 4:
-					memberDesc.type = GPDT_FLOAT4;
-					break;
-				}
-
-				memberDesc.elementSize = 4;
-				memberDesc.arrayElementStride = 4;
-
-				break;
-			}
-			break;
-		case D3DXPT_BOOL:
-			memberDesc.type = GPDT_BOOL;
-			memberDesc.elementSize = 4;
-			memberDesc.arrayElementStride = 4;
-			break;
-		default:
-			break;
-		};
-	}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9GpuProgram.h"
+#include "BsGpuParamDesc.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**
+	 * 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
+	{
+	public:
+		/**
+		 * 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)
+			:mpConstTable(constTable), mBlocks(blocks)
+		{ }
+
+		/**	Builds parameter descriptions and returns an object containing all relevant information. */
+		GpuParamDescPtr buildParameterDescriptions();
+
+	private:
+		/**
+		 * Determines information about the specified parameter and places it in the provided parameter block, as well as
+		 * any children of the parameter.
+		 *
+		 * @param[in]	blockDesc	Parent block into which to add the new parameter.
+		 * @param[in]	paramName	Name of the parameter.
+		 * @param[in]	constant	Parameter handle in the constant table.
+		 * @param[in]	prefix		Prefix to append to the parameter and any child parameters.	
+		 */
+		void processParameter(GpuParamBlockDesc& blockDesc, const String& paramName, D3DXHANDLE constant, String prefix);
+
+		/**
+		 * Populates information about the parameter in @p memberDesc from the data in d3dDesc. Esentially converts DX9
+		 * parameter data to engine data.
+		 */
+		void populateParamMemberDesc(GpuParamDataDesc& memberDesc, D3DXCONSTANT_DESC& d3dDesc);
+
+		/**	Returns the name of the parameter with the specified constant table handle. */
+		String getParamName(D3DXHANDLE constant);
+
+	private:
+		LPD3DXCONSTANTTABLE mpConstTable;
+		Vector<D3D9EmulatedParamBlock> mBlocks;
+		GpuParamDescPtr mParamDesc;
+	};
+
+	String D3D9HLSLParamParser::getParamName(D3DXHANDLE constant)
+	{
+		D3DXCONSTANT_DESC desc;
+		UINT32 numParams = 1;
+		HRESULT hr = mpConstTable->GetConstantDesc(constant, &desc, &numParams);
+		if (FAILED(hr))
+		{
+			BS_EXCEPT(InternalErrorException, "Cannot retrieve constant description from HLSL program.");
+		}
+
+		String paramName = desc.Name;
+		// trim the odd '$' which appears at the start of the names in HLSL
+		if (paramName.at(0) == '$')
+			paramName.erase(paramName.begin());
+
+		// Also trim the '[0]' suffix if it exists, we will add our own indexing later
+		if (StringUtil::endsWith(paramName, "[0]", false))
+			paramName.erase(paramName.size() - 3);
+
+		return paramName;
+	}
+
+	GpuParamDescPtr D3D9HLSLParamParser::buildParameterDescriptions()
+	{
+		// Derive parameter names from const table
+		assert(mpConstTable && "Program not loaded!");
+
+		mParamDesc = bs_shared_ptr_new<GpuParamDesc>();
+
+		// Get contents of the constant table
+		D3DXCONSTANTTABLE_DESC desc;
+		HRESULT hr = mpConstTable->GetDesc(&desc);
+
+		if (FAILED(hr))
+			BS_EXCEPT(InternalErrorException, "Cannot retrieve constant descriptions from HLSL program.");
+
+		// DX9 has no concept of parameter blocks so we emulate them if needed
+		String name = "BS_INTERNAL_Globals";
+		mParamDesc->paramBlocks.insert(std::make_pair(name, GpuParamBlockDesc()));
+		GpuParamBlockDesc& globalBlockDesc = mParamDesc->paramBlocks[name];
+		globalBlockDesc.name = name;
+		globalBlockDesc.slot = 0;
+		globalBlockDesc.blockSize = 0;
+		globalBlockDesc.isShareable = false;
+
+		UnorderedMap<String, String> nonGlobalBlocks;
+		UINT32 curSlot = 1;
+		for (auto& block : mBlocks)
+		{
+			mParamDesc->paramBlocks.insert(std::make_pair(block.blockName, GpuParamBlockDesc()));
+			GpuParamBlockDesc& blockDesc = mParamDesc->paramBlocks[block.blockName];
+			blockDesc.name = block.blockName;
+			blockDesc.slot = curSlot++;
+			blockDesc.blockSize = 0;
+			blockDesc.isShareable = true;
+
+			for (auto& fieldName : block.paramNames)
+			{
+				nonGlobalBlocks.insert(std::make_pair(fieldName, block.blockName));
+			}
+		}
+
+		// Iterate over the constants
+		for (UINT32 i = 0; i < desc.Constants; ++i)
+		{
+			D3DXHANDLE constantHandle = mpConstTable->GetConstant(NULL, i);
+			String paramName = getParamName(constantHandle);
+
+			// Recursively descend through the structure levels
+			auto findIter = nonGlobalBlocks.find(paramName);
+			if (findIter == nonGlobalBlocks.end())
+				processParameter(globalBlockDesc, paramName, constantHandle, "");
+			else
+				processParameter(mParamDesc->paramBlocks[findIter->second], paramName, constantHandle, "");
+		}
+
+		return mParamDesc;
+	}
+
+	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
+		// automatically, we have to do it by hand
+
+		D3DXCONSTANT_DESC desc;
+		UINT32 numParams = 1;
+		HRESULT hr = mpConstTable->GetConstantDesc(constant, &desc, &numParams);
+		if (FAILED(hr))
+		{
+			BS_EXCEPT(InternalErrorException, "Cannot retrieve constant description from HLSL program.");
+		}
+
+		if (desc.Class == D3DXPC_STRUCT)
+		{
+			// work out a new prefix for nested members, if it's an array, we need an index
+			prefix = prefix + paramName + ".";
+			// Cascade into struct
+			for (UINT32 i = 0; i < desc.StructMembers; ++i)
+			{
+				D3DXHANDLE childHandle = mpConstTable->GetConstant(constant, i);
+				String childParamName = getParamName(childHandle);
+
+				processParameter(blockDesc, childParamName, childHandle, prefix);
+			}
+		}
+		else
+		{
+			// Process params
+			if (desc.Type == D3DXPT_FLOAT || desc.Type == D3DXPT_INT || desc.Type == D3DXPT_BOOL)
+			{
+				GpuParamDataDesc memberDesc;
+				memberDesc.gpuMemOffset = desc.RegisterIndex;
+				memberDesc.cpuMemOffset = blockDesc.blockSize;
+				memberDesc.paramBlockSlot = blockDesc.slot;
+				memberDesc.arraySize = 1;
+
+				String name = prefix + paramName;
+				memberDesc.name = name;
+
+				populateParamMemberDesc(memberDesc, desc);
+				mParamDesc->params.insert(std::make_pair(name, memberDesc));
+
+				blockDesc.blockSize += memberDesc.arrayElementStride * memberDesc.arraySize;
+			}
+			else if(desc.Type == D3DXPT_SAMPLER1D || desc.Type == D3DXPT_SAMPLER2D || desc.Type == D3DXPT_SAMPLER3D || desc.Type == D3DXPT_SAMPLERCUBE)
+			{
+				GpuParamObjectDesc samplerDesc;
+				samplerDesc.name = paramName;
+				samplerDesc.slot = desc.RegisterIndex;
+
+				GpuParamObjectDesc textureDesc;
+				textureDesc.name = paramName;
+				textureDesc.slot = desc.RegisterIndex;
+
+				switch(desc.Type)
+				{
+				case D3DXPT_SAMPLER1D:
+					samplerDesc.type = GPOT_SAMPLER1D;
+					textureDesc.type = GPOT_TEXTURE1D;
+					break;
+				case D3DXPT_SAMPLER2D:
+					samplerDesc.type = GPOT_SAMPLER2D;
+					textureDesc.type = GPOT_TEXTURE2D;
+					break;
+				case D3DXPT_SAMPLER3D:
+					samplerDesc.type = GPOT_SAMPLER3D;
+					textureDesc.type = GPOT_TEXTURE3D;
+					break;
+				case D3DXPT_SAMPLERCUBE:
+					samplerDesc.type = GPOT_SAMPLERCUBE;
+					textureDesc.type = GPOT_TEXTURECUBE;
+					break;
+				default:
+					BS_EXCEPT(InternalErrorException, "Invalid sampler type: " + toString(desc.Type) + " for parameter " + paramName);
+				}
+
+				mParamDesc->samplers.insert(std::make_pair(paramName, samplerDesc));
+				mParamDesc->textures.insert(std::make_pair(paramName, textureDesc));
+			}
+			else
+			{
+				BS_EXCEPT(InternalErrorException, "Invalid shader parameter type: " + toString(desc.Type) + " for parameter " + paramName);
+			}
+		}
+	}
+
+	void D3D9HLSLParamParser::populateParamMemberDesc(GpuParamDataDesc& memberDesc, D3DXCONSTANT_DESC& d3dDesc)
+	{
+		memberDesc.arraySize = d3dDesc.Elements;
+		switch(d3dDesc.Type)
+		{
+		case D3DXPT_INT:
+			switch(d3dDesc.Columns)
+			{
+			case 1:
+				memberDesc.type = GPDT_INT1;
+				break;
+			case 2:
+				memberDesc.type = GPDT_INT2;
+				break;
+			case 3:
+				memberDesc.type = GPDT_INT3;
+				break;
+			case 4:
+				memberDesc.type = GPDT_INT4;
+				break;
+			} 
+
+			memberDesc.elementSize = 4;
+			memberDesc.arrayElementStride = 4;
+
+			break;
+		case D3DXPT_FLOAT:
+			switch(d3dDesc.Class)
+			{
+			case D3DXPC_MATRIX_COLUMNS:
+			case D3DXPC_MATRIX_ROWS:
+				{
+					int firstDim, secondDim;
+					int firstActualDim; // Actual size might be less than requested because of optimization, we need to know both
+					firstActualDim = d3dDesc.RegisterCount / d3dDesc.Elements;
+
+					if (d3dDesc.Class == D3DXPC_MATRIX_ROWS)
+					{
+						firstDim = d3dDesc.Rows;
+						secondDim = d3dDesc.Columns;
+					}
+					else
+					{
+						firstDim = d3dDesc.Columns;
+						secondDim = d3dDesc.Rows;
+					}
+
+					switch (firstActualDim)
+					{
+					case 2:
+						memberDesc.elementSize = 8; // HLSL always padds regardless of row size
+						memberDesc.arrayElementStride = 8;
+						break;
+					case 3:
+						memberDesc.elementSize = 12; // HLSL always padds regardless of row size
+						memberDesc.arrayElementStride = 12;
+						break;
+					case 4:
+						memberDesc.elementSize = 16; // HLSL always padds regardless of row size
+						memberDesc.arrayElementStride = 16;
+						break;
+
+					}
+
+					switch (firstDim)
+					{
+					case 2:
+						switch (secondDim)
+						{
+						case 2:
+							memberDesc.type = GPDT_MATRIX_2X2;
+							break;
+						case 3:
+							memberDesc.type = GPDT_MATRIX_2X3;
+							break;
+						case 4:
+							memberDesc.type = GPDT_MATRIX_2X4;
+							break;
+						} 
+						break;
+					case 3:
+						switch (secondDim)
+						{
+						case 2:
+							memberDesc.type = GPDT_MATRIX_3X2;
+							break;
+						case 3:
+							memberDesc.type = GPDT_MATRIX_3X3;
+							break;
+						case 4:
+							memberDesc.type = GPDT_MATRIX_3X4;
+							break;
+						} 
+						break;
+					case 4:
+						switch (secondDim)
+						{
+						case 2:
+							memberDesc.type = GPDT_MATRIX_4X2;
+							break;
+						case 3:
+							memberDesc.type = GPDT_MATRIX_4X3;
+							break;
+						case 4:
+							memberDesc.type = GPDT_MATRIX_4X4;
+							break;
+						}
+						break;
+					}
+				}
+				break;
+			case D3DXPC_SCALAR:
+			case D3DXPC_VECTOR:
+				switch(d3dDesc.Columns)
+				{
+				case 1:
+					memberDesc.type = GPDT_FLOAT1;
+					break;
+				case 2:
+					memberDesc.type = GPDT_FLOAT2;
+					break;
+				case 3:
+					memberDesc.type = GPDT_FLOAT3;
+					break;
+				case 4:
+					memberDesc.type = GPDT_FLOAT4;
+					break;
+				}
+
+				memberDesc.elementSize = 4;
+				memberDesc.arrayElementStride = 4;
+
+				break;
+			}
+			break;
+		case D3DXPT_BOOL:
+			memberDesc.type = GPDT_BOOL;
+			memberDesc.elementSize = 4;
+			memberDesc.arrayElementStride = 4;
+			break;
+		default:
+			break;
+		};
+	}
+
+	/** @} */
 }

+ 38 - 38
Source/BansheeD3D9RenderAPI/Include/BsD3D9HLSLProgramFactory.h

@@ -1,39 +1,39 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsGpuProgramManager.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation of HLSL GPU programs.
-	 */
-    class BS_D3D9_EXPORT D3D9HLSLProgramFactory : public GpuProgramFactory
-    {
-    public:
-        D3D9HLSLProgramFactory();
-        ~D3D9HLSLProgramFactory();
-
-		/**
-		 * @copydoc	GpuProgramFactory::getLanguage
-		 */
-		const String& getLanguage() const override;
-
-		/**
-		 * @copydoc	GpuProgramFactory::getLanguage(const String&, const String&, GpuProgramType,
-		 *			GpuProgramProfile, bool)
-		 */
-        SPtr<GpuProgramCore> create(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, bool requiresAdjacency) override;
-
-		/**
-		 * @copydoc	GpuProgramFactory::create(GpuProgramType)
-		 */
-		SPtr<GpuProgramCore> create(GpuProgramType type) override;
-
-	protected:
-		static String LANGUAGE_NAME;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsGpuProgramManager.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Handles creation of HLSL GPU programs. */
+    class BS_D3D9_EXPORT D3D9HLSLProgramFactory : public GpuProgramFactory
+    {
+    public:
+        D3D9HLSLProgramFactory();
+        ~D3D9HLSLProgramFactory();
+
+		/** @copydoc GpuProgramFactory::getLanguage */
+		const String& getLanguage() const override;
+
+		/**
+		 * @copydoc	GpuProgramFactory::getLanguage(const String&, const String&, GpuProgramType,
+		 *			GpuProgramProfile, bool)
+		 */
+        SPtr<GpuProgramCore> create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, bool requiresAdjacency) override;
+
+		/** @copydoc	GpuProgramFactory::create(GpuProgramType) */
+		SPtr<GpuProgramCore> create(GpuProgramType type) override;
+
+	protected:
+		static String LANGUAGE_NAME;
+    };
+
+	/** @} */
 }

+ 35 - 41
Source/BansheeD3D9RenderAPI/Include/BsD3D9HardwareBufferManager.h

@@ -1,42 +1,36 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsHardwareBufferManager.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Manages creation of DX9 hardware buffers.
-	 */
-    class BS_D3D9_EXPORT D3D9HardwareBufferCoreManager : public HardwareBufferCoreManager
-    {
-	protected:     
-		/**
-		 * @copydoc HardwareBufferCoreManager::createVertexBufferInternal
-		 */
-		SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) override;
-
-		/**
-		 * @copydoc HardwareBufferCoreManager::createIndexBufferInternal
-		 */
-		SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) override;
-
-		/**
-		 * @copydoc	HardwareBufferCoreManager::createVertexDeclarationInternal
-		 */
-		SPtr<VertexDeclarationCore> createVertexDeclarationInternal(const List<VertexElement>& elements) override;
-
-		/** 
-		 * @copydoc HardwareBufferCoreManager::createGpuParamBlockBufferInternal 
-		 */
-		SPtr<GpuParamBlockBufferCore> createGpuParamBlockBufferInternal(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC) override;
-
-		/**
-		 * @copydoc HardwareBufferCoreManager::createGenericBufferInternal
-		 */
-		SPtr<GpuBufferCore> createGpuBufferInternal(UINT32 elementCount, UINT32 elementSize, 
-			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false) override;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsHardwareBufferManager.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Manages creation of DX9 hardware buffers. */
+    class BS_D3D9_EXPORT D3D9HardwareBufferCoreManager : public HardwareBufferCoreManager
+    {
+	protected:     
+		/** @copydoc HardwareBufferCoreManager::createVertexBufferInternal */
+		SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) override;
+
+		/** @copydoc HardwareBufferCoreManager::createIndexBufferInternal */
+		SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) override;
+
+		/** @copydoc	HardwareBufferCoreManager::createVertexDeclarationInternal */
+		SPtr<VertexDeclarationCore> createVertexDeclarationInternal(const List<VertexElement>& elements) override;
+
+		/** @copydoc HardwareBufferCoreManager::createGpuParamBlockBufferInternal */
+		SPtr<GpuParamBlockBufferCore> createGpuParamBlockBufferInternal(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC) override;
+
+		/** @copydoc HardwareBufferCoreManager::createGenericBufferInternal */
+		SPtr<GpuBufferCore> createGpuBufferInternal(UINT32 elementCount, UINT32 elementSize, 
+			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false) override;
+    };
+
+	/** @} */
 }

+ 77 - 98
Source/BansheeD3D9RenderAPI/Include/BsD3D9IndexBuffer.h

@@ -1,99 +1,78 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsIndexBuffer.h"
-#include "BsD3D9Resource.h"
-
-namespace BansheeEngine 
-{ 
-	/**
-	 * @brief	DirectX 9 implementation of an index buffer.
-	 */
-    class BS_D3D9_EXPORT D3D9IndexBufferCore : public IndexBufferCore, public D3D9Resource
-    {
-	protected:
-		/**
-		 * @brief	Container for internal buffer resources.
-		 */
-		struct BufferResources
-		{
-			IDirect3DIndexBuffer9* mBuffer;
-			bool mOutOfDate;
-			UINT32 mLockOffset;
-			UINT32 mLockLength;
-			GpuLockOptions mLockOptions;
-		};
-
-    public:
-		D3D9IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-		~D3D9IndexBufferCore();
-
-		/**
-		 * @copydoc	IndexBufferCore::readData
-		 */
-        void readData(UINT32 offset, UINT32 length, void* dest);
-
-		/**
-		 * @copydoc	IndexBufferCore::writeData
-		 */
-		void writeData(UINT32 offset, UINT32 length, const void* source, BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceLost
-		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceReset
-		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Creates a DX9 index buffer object in the provided memory pool.
-		 */
-		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
-	
-		/**
-		 * @brief	Returns the DX9 index buffer object.
-		 */
-        IDirect3DIndexBuffer9* getD3DIndexBuffer();		
-
-	protected:
-		/**
-		 * @copydoc	IndexBufferCore::lockImpl
-		 */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-		/**
-		 * @copydoc	IndexBufferCore::unlockImpl
-		 */
-		void unlockImpl();
-
-		/**
-		 * @brief	Updates buffer resources from cached system memory buffer.
-		 */
-		bool updateBufferResources(const UINT8* systemMemoryBuffer, BufferResources* bufferResources);
-
-		/**
-		 * @copydoc IndexBufferCore::initialize
-		 */
-		void initialize();	
-		
-	protected:		
-		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
-		D3DINDEXBUFFER_DESC	mBufferDesc;	
-		UINT8* mSystemMemoryBuffer;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsIndexBuffer.h"
+#include "BsD3D9Resource.h"
+
+namespace BansheeEngine 
+{ 
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	DirectX 9 implementation of an index buffer. */
+    class BS_D3D9_EXPORT D3D9IndexBufferCore : public IndexBufferCore, public D3D9Resource
+    {
+	protected:
+		/**	Container for internal buffer resources. */
+		struct BufferResources
+		{
+			IDirect3DIndexBuffer9* mBuffer;
+			bool mOutOfDate;
+			UINT32 mLockOffset;
+			UINT32 mLockLength;
+			GpuLockOptions mLockOptions;
+		};
+
+    public:
+		D3D9IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
+		~D3D9IndexBufferCore();
+
+		/** @copydoc IndexBufferCore::readData */
+        void readData(UINT32 offset, UINT32 length, void* dest) override;
+
+		/** @copydoc IndexBufferCore::writeData */
+		void writeData(UINT32 offset, UINT32 length, const void* source, 
+			BufferWriteType writeFlags = BufferWriteType::Normal) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+		/**	Creates a DX9 index buffer object in the provided memory pool. */
+		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
+	
+		/**	Returns the DX9 index buffer object. */
+        IDirect3DIndexBuffer9* getD3DIndexBuffer();		
+
+	protected:
+		/** @copydoc IndexBufferCore::lockImpl */
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+
+		/** @copydoc IndexBufferCore::unlockImpl */
+		void unlockImpl() override;
+
+		/**	Updates buffer resources from cached system memory buffer. */
+		bool updateBufferResources(const UINT8* systemMemoryBuffer, BufferResources* bufferResources);
+
+		/** @copydoc IndexBufferCore::initialize */
+		void initialize() override;
+		
+	protected:		
+		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
+		D3DINDEXBUFFER_DESC	mBufferDesc;	
+		UINT8* mSystemMemoryBuffer;
+    };
+
+	/** @} */
 }

+ 102 - 147
Source/BansheeD3D9RenderAPI/Include/BsD3D9Mappings.h

@@ -1,148 +1,103 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsRenderAPI.h"
-#include "BsHardwareBuffer.h"
-#include "BsIndexBuffer.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Provides helper methods for mapping between engine and DirectX 9 types.
-	 */
-	class BS_D3D9_EXPORT D3D9Mappings
-	{
-	public:
-		/**
-		 * @brief	DirectX 9 texture types.
-		 */
-		enum D3DTexType
-		{
-			D3D_TEX_TYPE_NORMAL,
-			D3D_TEX_TYPE_CUBE,
-			D3D_TEX_TYPE_VOLUME,
-			D3D_TEX_TYPE_NONE
-		};
-
-		/**
-		 * @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);
-
-		/**
-		 * @brief	Returns DirectX 9 blend factor.
-		 */
-		static D3DBLEND get(BlendFactor sbf);
-
-		/**
-		 * @brief	Returns DirectX 9 blend operation
-		 */
-		static D3DBLENDOP get(BlendOperation sbo);
-
-		/**
-		 * @brief	Return DirectX 9 compare function.
-		 */
-		static DWORD get(CompareFunction cf);
-
-		/**
-		 * @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);
-
-		/**
-		 * @brief	Return DirectX 9 fill mode depending on provided polygon mode.
-		 */
-		static D3DFILLMODE get(PolygonMode level);
-
-		/**
-		 * @brief	Return DirectX 9 stencil operation and optionally 
-		 *			invert it (greater than becomes less than, etc.)
-		 */
-		static DWORD get(StencilOperation op, bool invert = false);
-
-		/**
-		 * @brief	Returns DirectX 9 sampler state based on provided filter type.
-		 */
-		static D3DSAMPLERSTATETYPE get(FilterType ft);
-
-		/**
-		 * @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);
-        
-		/**
-		 * @brief	Returns DirectX 9 lock options, constrained by the provided usage.
-		 */
-        static DWORD get(GpuLockOptions options, GpuBufferUsage usage);
-        
-		/**
-		 * @brief	Returns DirectX 9 index buffer type.
-		 */
-        static D3DFORMAT get(IndexType itype);
-		
-		/**
-		 * @brief	Returns DirectX 9 vertex element type.
-		 */
-		static D3DDECLTYPE get(VertexElementType vType);
-
-		/**
-		 * @brief	Returns DirectX9 vertex element semantic.
-		 */
-		static D3DDECLUSAGE get(VertexElementSemantic sem);
-        
-		/**
-		 * @brief	Converts DirectX9 vertex element semantic to engine vertex element semantic.
-		 */
-		static VertexElementSemantic get(D3DDECLUSAGE sem);
-
-		/**
-		 * @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);
-
-		/**
-		 * @brief	Converts DirectX 9 pixel format to engine pixel format.
-		 */
-		static PixelFormat _getPF(D3DFORMAT d3dPF);
-		
-		/**
-		 * @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);
-
-		/**
-		 * @brief	Returns closest depth/stencil format supported by DirectX 9.
-		 */
-		static PixelFormat _getClosestSupportedDepthStencilPF(PixelFormat pf);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsRenderAPI.h"
+#include "BsHardwareBuffer.h"
+#include "BsIndexBuffer.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Provides helper methods for mapping between engine and DirectX 9 types. */
+	class BS_D3D9_EXPORT D3D9Mappings
+	{
+	public:
+		/**	DirectX 9 texture types. */
+		enum D3DTexType
+		{
+			D3D_TEX_TYPE_NORMAL,
+			D3D_TEX_TYPE_CUBE,
+			D3D_TEX_TYPE_VOLUME,
+			D3D_TEX_TYPE_NONE
+		};
+
+		/** Returns DirectX 9 texture addressing mode. Returns exact mode if supported, or nearest available if not. */
+		static D3DTEXTUREADDRESS get(TextureAddressingMode tam, const D3DCAPS9& devCaps);
+
+		/**	Returns DirectX 9 blend factor. */
+		static D3DBLEND get(BlendFactor sbf);
+
+		/**	Returns DirectX 9 blend operation. */
+		static D3DBLENDOP get(BlendOperation sbo);
+
+		/**	Return DirectX 9 compare function. */
+		static DWORD get(CompareFunction cf);
+
+		/** 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);
+
+		/**	Return DirectX 9 fill mode depending on provided polygon mode. */
+		static D3DFILLMODE get(PolygonMode level);
+
+		/** Return DirectX 9 stencil operation and optionally invert it (greater than becomes less than, etc.). */
+		static DWORD get(StencilOperation op, bool invert = false);
+
+		/**	Returns DirectX 9 sampler state based on provided filter type. */
+		static D3DSAMPLERSTATETYPE get(FilterType ft);
+
+		/**
+		 * 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);
+		
+		/**	Returns DirectX 9 texture type. */
+		static D3DTexType get(TextureType textype);
+        
+		/**	Return DirectX 9 buffer usage. */
+        static DWORD get(GpuBufferUsage usage);
+        
+		/**	Returns DirectX 9 lock options, constrained by the provided usage. */
+        static DWORD get(GpuLockOptions options, GpuBufferUsage usage);
+        
+		/**	Returns DirectX 9 index buffer type. */
+        static D3DFORMAT get(IndexType itype);
+		
+		/**	Returns DirectX 9 vertex element type. */
+		static D3DDECLTYPE get(VertexElementType vType);
+
+		/**	Returns DirectX9 vertex element semantic. */
+		static D3DDECLUSAGE get(VertexElementSemantic sem);
+        
+		/**	Converts DirectX9 vertex element semantic to engine vertex element semantic. */
+		static VertexElementSemantic get(D3DDECLUSAGE sem);
+
+		/**	Converts a matrix to one usable by DirectX 9 API. */
+        static 	D3DXMATRIX makeD3DXMatrix(const Matrix4& mat);
+        
+		/**	Converts matrix returned by DirectX 9 API to engine matrix. */
+        static Matrix4 convertD3DXMatrix(const D3DXMATRIX& mat);
+
+		/**	Converts DirectX 9 pixel format to engine pixel format. */
+		static PixelFormat _getPF(D3DFORMAT d3dPF);
+		
+		/**	Converts engine pixel format to DirectX 9 pixel format. */
+		static D3DFORMAT _getPF(PixelFormat pf);
+
+		/**	Returns closest pixel format supported by DirectX 9. */
+		static PixelFormat _getClosestSupportedPF(PixelFormat pf);
+
+		/**	Returns closest color render target pixel format supported by DirectX 9. */
+		static PixelFormat _getClosestSupportedRenderTargetPF(PixelFormat pf);
+
+		/**	Returns closest depth/stencil format supported by DirectX 9. */
+		static PixelFormat _getClosestSupportedDepthStencilPF(PixelFormat pf);
+	};
+
+	/** @} */
 }

+ 66 - 68
Source/BansheeD3D9RenderAPI/Include/BsD3D9MultiRenderTexture.h

@@ -1,69 +1,67 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsMultiRenderTexture.h"
-
-namespace BansheeEngine
-{
-	class D3D9MultiRenderTexture;
-
-	/**
-	 * @brief	DirectX 9 implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_D3D9_EXPORT D3D9MultiRenderTextureCore : public MultiRenderTextureCore
-	{
-	public:
-		D3D9MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~D3D9MultiRenderTextureCore();
-		
-		/**
-		 * @copydoc	MultiRenderTextureCore::getCustomAttribute
-		 */
-		void getCustomAttribute(const String& name, void* pData) const;
-
-	protected:
-		friend class D3D9MultiRenderTexture;
-
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
-		virtual void initialize();
-
-		/**
-		 * @copydoc	MultiRenderTextureCore::getProperties
-		 */
-		const RenderTargetProperties& getPropertiesInternal() const { return mProperties; }
-
-		Vector<IDirect3DSurface9*> mDX9ColorSurfaces;
-		IDirect3DSurface9* mDX9DepthStencilSurface;
-
-		MultiRenderTextureProperties mProperties;
-	};
-
-	/**
-	 * @brief	DirectX 9 implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_D3D9_EXPORT D3D9MultiRenderTexture : public MultiRenderTexture
-	{
-	public:
-		virtual ~D3D9MultiRenderTexture() { }
-
-	protected:
-		friend class D3D9TextureManager;
-
-		D3D9MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/**
-		 * @copydoc	MultiRenderTexture::getProperties
-		 */
-		const RenderTargetProperties& getPropertiesInternal() const { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsMultiRenderTexture.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	class D3D9MultiRenderTexture;
+
+	/**
+	 * DirectX 9 implementation of a render texture with multiple color surfaces.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_D3D9_EXPORT D3D9MultiRenderTextureCore : public MultiRenderTextureCore
+	{
+	public:
+		D3D9MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
+		virtual ~D3D9MultiRenderTextureCore();
+		
+		/** @copydoc MultiRenderTextureCore::getCustomAttribute */
+		void getCustomAttribute(const String& name, void* pData) const override;
+
+	protected:
+		friend class D3D9MultiRenderTexture;
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/** @copydoc MultiRenderTextureCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		Vector<IDirect3DSurface9*> mDX9ColorSurfaces;
+		IDirect3DSurface9* mDX9DepthStencilSurface;
+
+		MultiRenderTextureProperties mProperties;
+	};
+
+	/**
+	 * DirectX 9 implementation of a render texture with multiple color surfaces.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_D3D9_EXPORT D3D9MultiRenderTexture : public MultiRenderTexture
+	{
+	public:
+		virtual ~D3D9MultiRenderTexture() { }
+
+	protected:
+		friend class D3D9TextureManager;
+
+		D3D9MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
+
+		/** @copydoc MultiRenderTexture::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		MultiRenderTextureProperties mProperties;
+	};
+
+	/** @} */
 }

+ 66 - 84
Source/BansheeD3D9RenderAPI/Include/BsD3D9OcclusionQuery.h

@@ -1,85 +1,67 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9Resource.h"
-#include "BsOcclusionQuery.h"
-
-namespace BansheeEngine
-{
-	/**
-	* @copydoc OcclusionQuery
-	*/
-	class BS_D3D9_EXPORT D3D9OcclusionQuery : public OcclusionQuery, public D3D9Resource
-	{
-	public:
-		D3D9OcclusionQuery(bool binary);
-		~D3D9OcclusionQuery();
-
-		/**
-		* @copydoc OcclusionQuery::begin
-		*/
-		virtual void begin();
-
-		/**
-		* @copydoc OcclusionQuery::end
-		*/
-		virtual void end();
-
-		/**
-		* @copydoc OcclusionQuery::isReady
-		*/
-		virtual bool isReady() const;
-
-		/**
-		* @copydoc OcclusionQuery::getNumFragments
-		*/
-		virtual UINT32 getNumSamples();
-
-		/**
-		* @copydoc	D3D9Resource::notifyOnDeviceCreate
-		*/
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceLost
-		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceReset
-		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
-
-	private:
-		friend class QueryManager;
-
-		/**
-		 * @brief	Creates the internal DX9 query.
-		 */
-		void createQuery();
-
-		/**
-		 * @brief	Releases the internal DX9 query.
-		 */
-		void releaseQuery();
-
-		/**
-		 * @brief	Resolves query results after it is ready.
-		 */
-		void finalize();
-	private:
-		IDirect3DDevice9* mDevice;
-		IDirect3DQuery9* mQuery;
-		bool mQueryIssued;
-		bool mFinalized;
-
-		UINT32 mNumSamples;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9Resource.h"
+#include "BsOcclusionQuery.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** @copydoc OcclusionQuery */
+	class BS_D3D9_EXPORT D3D9OcclusionQuery : public OcclusionQuery, public D3D9Resource
+	{
+	public:
+		D3D9OcclusionQuery(bool binary);
+		~D3D9OcclusionQuery();
+
+		/** @copydoc OcclusionQuery::begin */
+		void begin() override;
+
+		/** @copydoc OcclusionQuery::end */
+		void end() override;
+
+		/** @copydoc OcclusionQuery::isReady */
+		bool isReady() const override;
+
+		/** @copydoc OcclusionQuery::getNumFragments */
+		UINT32 getNumSamples() override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+	private:
+		friend class QueryManager;
+
+		/**	Creates the internal DX9 query. */
+		void createQuery();
+
+		/**	Releases the internal DX9 query. */
+		void releaseQuery();
+
+		/**	Resolves query results after it is ready. */
+		void finalize();
+	private:
+		IDirect3DDevice9* mDevice;
+		IDirect3DQuery9* mQuery;
+		bool mQueryIssued;
+		bool mFinalized;
+
+		UINT32 mNumSamples;
+	};
+
+	/** @} */
 }

+ 118 - 144
Source/BansheeD3D9RenderAPI/Include/BsD3D9PixelBuffer.h

@@ -1,145 +1,119 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsPixelBuffer.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	DirectX9 implementation of a pixel buffer. Represents a hardware buffer
-	 *			containing a surface of pixels.
-	 */
-	class BS_D3D9_EXPORT D3D9PixelBuffer : public PixelBuffer
-	{
-	protected:
-		/**
-		 * @brief	Internal DX9 buffer resources container.
-		 */
-		struct BufferResources
-		{
-			IDirect3DSurface9* surface;
-			IDirect3DVolume9* volume;
-			IDirect3DSurface9* tempSurface;
-			IDirect3DVolume9* tempVolume;
-			IDirect3DBaseTexture9* mipTex;
-		};
-
-	public:
-		D3D9PixelBuffer(GpuBufferUsage usage, D3D9TextureCore* ownerTexture);
-		~D3D9PixelBuffer();
-
-		/**
-		 * @brief	Binds the specified surface object to this buffer. This needs to be called in order
-		 *			to initialize the pixel buffer.
-		 *
-		 * @param	dev			Device the surface was created on.
-		 * @param	surface		DirectX 9 object representing the surface.
-		 * @param	mipTex		Base texture that will be used for generating mipmaps. Usually
-		 *						the parent texture of the surface.
-		 */
-		void bind(IDirect3DDevice9* dev, IDirect3DSurface9* surface, IDirect3DBaseTexture9* mipTex);
-
-		/**
-		 * @brief	Binds the specified volume object to this buffer. This needs to be called in order
-		 *			to initialize the pixel buffer.
-		 *
-		 * @param	dev			Device the volume was created on.
-		 * @param	surface		DirectX 9 object representing the volume.
-		 * @param	mipTex		Base texture that will be used for generating mipmaps. Usually
-		 *						the parent texture of the volume.
-		 */
-		void bind(IDirect3DDevice9* dev, IDirect3DVolume9* volume, IDirect3DBaseTexture9* mipTex);
-
-		/**
-		 * @brief	Enables/disabled automatic mipmap generation on updates.
-		 *
-		 * @param	doMipmapGen	If true, mipmaps will be regenerated whenever data is written to the buffer.
-		 * @param	HWMipmaps	If true the mipmaps will be generated by the hardware, otherwise software (slower).
-		 */
-		void setMipmapping(bool doMipmapGen, bool HWMipmaps);
-
-		/**
-		 * @brief	Returns internal DirectX 9 surface object for this buffer.
-		 */
-		IDirect3DSurface9* getSurface(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Release all surface objects held by this buffer for the specified device.
-		 */
-		void releaseSurfaces(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Destroy all resources associated with the specified device.
-		 */
-		void destroyBufferResources(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Called when device state is changing. Access to any device should be locked.
-		 */
-		static void lockDeviceAccess();
-
-		/**
-		 * @brief	Called when device state change completed. Access to any device is allowed.
-		 */
-		static void unlockDeviceAccess();
-
-		/**
-		 * @brief	Initializes the provided pixel data buffer with information provided in the D3D9 locked rectangle.
-		 */
-		static void initPixelDataFromD3DLock(PixelData& pixelData, const D3DLOCKED_RECT& lrect);
-
-		/**
-		 * @brief	Initializes the provided pixel data buffer with information provided in the D3D9 locked box.
-		 */
-		static void initPixelDataFromD3DLock(PixelData& pixelData, const D3DLOCKED_BOX& lrect);
-
-	protected:
-		/**
-		 * @copydoc	PixelBuffer::lockImpl
-		 */
-		PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options);
-
-		/**
-		 * @copydoc	PixelBuffer::unlockImpl
-		 */
-		void unlockImpl();
-
-		/**
-		 * @brief	Locks the specified volume of the provided buffer objects and 
-		 *			returns a data buffer that you may use to access it.
-		 */
-		PixelData lockBuffer(BufferResources* bufferResources, const PixelVolume& lockBox, DWORD flags);
-
-		/**
-		 * @brief	Unlocks the specified buffer objects.
-		 */
-		void unlockBuffer(BufferResources* bufferResources);
-
-		/**
-		 * @brief	Generates mip-map chain for the specified texture.
-		 */
-		void genMipmaps(IDirect3DBaseTexture9* mipTex);
-
-		/**
-		 * @brief	Retrieves buffer resources for the specified device, or null if they
-		 *			do not exist.
-		 */
-		BufferResources* getBufferResources(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Creates a new empty set of buffer resources.
-		 */
-		BufferResources* createBufferResources();
-
-	protected:
-		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
-
-		bool mDoMipmapGen;
-		bool mHWMipmaps;
-
-		D3D9TextureCore* mOwnerTexture;
-		DWORD mLockFlags;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsPixelBuffer.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** DirectX9 implementation of a pixel buffer. Represents a hardware buffer containing a surface of pixels. */
+	class BS_D3D9_EXPORT D3D9PixelBuffer : public PixelBuffer
+	{
+	protected:
+		/**	Internal DX9 buffer resources container. */
+		struct BufferResources
+		{
+			IDirect3DSurface9* surface;
+			IDirect3DVolume9* volume;
+			IDirect3DSurface9* tempSurface;
+			IDirect3DVolume9* tempVolume;
+			IDirect3DBaseTexture9* mipTex;
+		};
+
+	public:
+		D3D9PixelBuffer(GpuBufferUsage usage, D3D9TextureCore* ownerTexture);
+		~D3D9PixelBuffer();
+
+		/**
+		 * Binds the specified surface object to this buffer. This needs to be called in order to initialize the pixel
+		 * buffer.
+		 *
+		 * @param[in]	dev			Device the surface was created on.
+		 * @param[in]	surface		DirectX 9 object representing the surface.
+		 * @param[in]	mipTex		Base texture that will be used for generating mipmaps. Usually the parent texture of
+		 *							the surface.
+		 */
+		void bind(IDirect3DDevice9* dev, IDirect3DSurface9* surface, IDirect3DBaseTexture9* mipTex);
+
+		/**
+		 * Binds the specified volume object to this buffer. This needs to be called in order to initialize the pixel
+		 * buffer.
+		 *
+		 * @param[in]	dev			Device the volume was created on.
+		 * @param[in]	surface		DirectX 9 object representing the volume.
+		 * @param[in]	mipTex		Base texture that will be used for generating mipmaps. Usually the parent texture of
+		 *							the volume.
+		 */
+		void bind(IDirect3DDevice9* dev, IDirect3DVolume9* volume, IDirect3DBaseTexture9* mipTex);
+
+		/**
+		 * Enables/disabled automatic mipmap generation on updates.
+		 *
+		 * @param[in]	doMipmapGen	If true, mipmaps will be regenerated whenever data is written to the buffer.
+		 * @param[in]	HWMipmaps	If true the mipmaps will be generated by the hardware, otherwise software (slower).
+		 */
+		void setMipmapping(bool doMipmapGen, bool HWMipmaps);
+
+		/**	Returns internal DirectX 9 surface object for this buffer. */
+		IDirect3DSurface9* getSurface(IDirect3DDevice9* d3d9Device);
+
+		/**	Release all surface objects held by this buffer for the specified device. */
+		void releaseSurfaces(IDirect3DDevice9* d3d9Device);
+
+		/**	Destroy all resources associated with the specified device. */
+		void destroyBufferResources(IDirect3DDevice9* d3d9Device);
+
+		/**	Called when device state is changing. Access to any device should be locked. */
+		static void lockDeviceAccess();
+
+		/**	Called when device state change completed. Access to any device is allowed. */
+		static void unlockDeviceAccess();
+
+		/**	Initializes the provided pixel data buffer with information provided in the D3D9 locked rectangle. */
+		static void initPixelDataFromD3DLock(PixelData& pixelData, const D3DLOCKED_RECT& lrect);
+
+		/**	Initializes the provided pixel data buffer with information provided in the D3D9 locked box. */
+		static void initPixelDataFromD3DLock(PixelData& pixelData, const D3DLOCKED_BOX& lrect);
+
+	protected:
+		/** @copydoc PixelBuffer::lockImpl */
+		PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) override;
+
+		/** @copydoc PixelBuffer::unlockImpl */
+		void unlockImpl() override;
+
+		/**
+		 * Locks the specified volume of the provided buffer objects and returns a data buffer that you may use to access
+		 * it.
+		 */
+		PixelData lockBuffer(BufferResources* bufferResources, const PixelVolume& lockBox, DWORD flags);
+
+		/**	Unlocks the specified buffer objects. */
+		void unlockBuffer(BufferResources* bufferResources);
+
+		/**	Generates mip-map chain for the specified texture. */
+		void genMipmaps(IDirect3DBaseTexture9* mipTex);
+
+		/** Retrieves buffer resources for the specified device, or null if they do not exist. */
+		BufferResources* getBufferResources(IDirect3DDevice9* d3d9Device);
+
+		/**	Creates a new empty set of buffer resources. */
+		BufferResources* createBufferResources();
+
+	protected:
+		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
+
+		bool mDoMipmapGen;
+		bool mHWMipmaps;
+
+		D3D9TextureCore* mOwnerTexture;
+		DWORD mLockFlags;
+	};
+
+	/** @} */
 };

+ 85 - 73
Source/BansheeD3D9RenderAPI/Include/BsD3D9Prerequisites.h

@@ -1,74 +1,86 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-#define D3D9_DEVICE_ACCESS_LOCK	
-#define D3D9_DEVICE_ACCESS_UNLOCK
-#define D3D9_DEVICE_ACCESS_CRITICAL_SECTION
-
-#define DIRECT3D_VERSION 0x0900
-
-#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
-
-#if BS_DEBUG_MODE
-#	define D3D_DEBUG_INFO
-#endif
-
-#define WIN32_LEAN_AND_MEAN
-#if !defined(NOMINMAX) && defined(_MSC_VER)
-#	define NOMINMAX // required to stop windows.h messing up std::min
-#endif
-
-#include <d3d9.h>
-#include <d3dx9.h>
-#include <DxErr.h>
-
-namespace BansheeEngine
-{
-	// Predefine classes
-	class D3D9RenderAPI;
-	class D3D9RenderWindow;
-	class D3D9RenderWindowCore;
-	class D3D9TextureCore;
-	class D3D9TextureManager;
-	class D3D9Driver;
-	class D3D9DriverList;
-	class D3D9VideoMode;
-	class D3D9VideoModeList;
-	class D3D9Device;
-	class D3D9DeviceManager;
-	class D3D9ResourceManager;
-	class D3D9GpuProgram;
-	class D3D9GpuProgramManager;
-    class D3D9IndexBuffer;
-    class D3D9HLSLProgramFactory;
-    class D3D9HLSLProgramCore;
-    class D3D9VertexDeclarationCore;
-	class D3D9Resource;
-
-	typedef std::shared_ptr<D3D9RenderWindow> D3D9RenderWindowPtr;
-
-	/**
-	 * @brief	DirectX 9 specific types to track resource statistics for.
-	 */
-	enum D3D9RenderStatResourceType
-	{
-		RenderStatObject_VertexDeclaration = 100
-	};
-
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(BS_STATIC_LIB)
-#	ifdef BS_RSD3D9_EXPORTS
-#		define BS_D3D9_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_D3D9_EXPORT
-#       else
-#    		define BS_D3D9_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#else
-#	define BS_D3D9_EXPORT
-#endif
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+#define D3D9_DEVICE_ACCESS_LOCK	
+#define D3D9_DEVICE_ACCESS_UNLOCK
+#define D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+
+#define DIRECT3D_VERSION 0x0900
+
+#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
+
+#if BS_DEBUG_MODE
+#	define D3D_DEBUG_INFO
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#if !defined(NOMINMAX) && defined(_MSC_VER)
+#	define NOMINMAX // required to stop windows.h messing up std::min
+#endif
+
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <DxErr.h>
+
+/** @addtogroup Plugins
+
+/** @defgroup D3D9 BansheeD3D9RenderAPI
+ *	Wrapper around the DirectX 9 render API.
+ */
+
+/** @} */
+
+namespace BansheeEngine
+{
+	// Predefine classes
+	class D3D9RenderAPI;
+	class D3D9RenderWindow;
+	class D3D9RenderWindowCore;
+	class D3D9TextureCore;
+	class D3D9TextureManager;
+	class D3D9Driver;
+	class D3D9DriverList;
+	class D3D9VideoMode;
+	class D3D9VideoModeList;
+	class D3D9Device;
+	class D3D9DeviceManager;
+	class D3D9ResourceManager;
+	class D3D9GpuProgram;
+	class D3D9GpuProgramManager;
+    class D3D9IndexBuffer;
+    class D3D9HLSLProgramFactory;
+    class D3D9HLSLProgramCore;
+    class D3D9VertexDeclarationCore;
+	class D3D9Resource;
+
+	typedef std::shared_ptr<D3D9RenderWindow> D3D9RenderWindowPtr;
+
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	DirectX 9 specific types to track resource statistics for. */
+	enum D3D9RenderStatResourceType
+	{
+		RenderStatObject_VertexDeclaration = 100
+	};
+
+	/** @} */
+
+#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(BS_STATIC_LIB)
+#	ifdef BS_RSD3D9_EXPORTS
+#		define BS_D3D9_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define BS_D3D9_EXPORT
+#       else
+#    		define BS_D3D9_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#else
+#	define BS_D3D9_EXPORT
+#endif
 }

+ 28 - 30
Source/BansheeD3D9RenderAPI/Include/BsD3D9QueryManager.h

@@ -1,31 +1,29 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsQueryManager.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation of DirectX 9 queries.
-	 */
-	class BS_D3D9_EXPORT D3D9QueryManager : public QueryManager
-	{
-	public:
-		/**
-		 * @copydoc		QueryManager::createEventQuery
-		 */
-		EventQueryPtr createEventQuery() const;
-
-		/**
-		 * @copydoc		QueryManager::createTimerQuery
-		 */
-		TimerQueryPtr createTimerQuery() const;
-
-		/**
-		 * @copydoc		QueryManager::createOcclusionQuery
-		 */
-		OcclusionQueryPtr createOcclusionQuery(bool binary) const;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsQueryManager.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Handles creation of DirectX 9 queries. */
+	class BS_D3D9_EXPORT D3D9QueryManager : public QueryManager
+	{
+	public:
+		/** @copydoc QueryManager::createEventQuery */
+		EventQueryPtr createEventQuery() const override;
+
+		/** @copydoc QueryManager::createTimerQuery */
+		TimerQueryPtr createTimerQuery() const override;
+
+		/** @copydoc QueryManager::createOcclusionQuery */
+		OcclusionQueryPtr createOcclusionQuery(bool binary) const override;
+	};
+
+	/** @} */
 }

+ 137 - 272
Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderAPI.h

@@ -9,212 +9,142 @@
 
 namespace BansheeEngine 
 {
-	/**
-	 * @brief	Implementation of a render system using DirectX 9. Provides abstracted
-	 *			access to various low level DX9 methods.
+	/** @addtogroup D3D9
+	 *  @{
 	 */
+
+	/** Implementation of a render system using DirectX 9. Provides abstracted access to various low level DX9 methods. */
 	class BS_D3D9_EXPORT D3D9RenderAPI : public RenderAPICore
 	{
 	public:
-		/**
-		 * @brief	Constructs a new instance of the render system using the provided module instance.
-		 */
+		/**	Constructs a new instance of the render system using the provided module instance. */
 		D3D9RenderAPI(HINSTANCE hInstance);
 		~D3D9RenderAPI();
 
-		/**
-		 * @copydoc RenderAPICore::getName()
-		 */
+		/** @copydoc RenderAPICore::getName() */
 		const StringID& getName() const override;
 
-		/**
-		 * @copydoc RenderAPICore::getShadingLanguageName()
-		 */
+		/** @copydoc RenderAPICore::getShadingLanguageName() */
 		const String& getShadingLanguageName() const override;
 
-		/**
-		 * @copydoc RenderAPICore::setRenderTarget()
-		 */
+		/** @copydoc RenderAPICore::setRenderTarget() */
 		void setRenderTarget(const SPtr<RenderTargetCore>& target, bool readOnlyDepthStencil = false) override;
 
-		/**
-		 * @copydoc RenderAPICore::bindGpuProgram()
-		 */
+		/** @copydoc RenderAPICore::bindGpuProgram() */
 		void bindGpuProgram(const SPtr<GpuProgramCore>& prg) override;
 
-		/**
-		 * @copydoc RenderAPICore::unbindGpuProgram()
-		 */
+		/** @copydoc RenderAPICore::unbindGpuProgram() */
 		void unbindGpuProgram(GpuProgramType gptype) override;
 
-		/**
-		 * @copydoc RenderAPICore::setConstantBuffers()
-		 */
+		/** @copydoc RenderAPICore::setConstantBuffers() */
 		void setConstantBuffers(GpuProgramType gptype, const SPtr<GpuParamsCore>& params) override;
 
-		/**
-		 * @copydoc RenderAPICore::setVertexBuffers()
-		 */
+		/** @copydoc RenderAPICore::setVertexBuffers() */
 		void setVertexBuffers(UINT32 index, SPtr<VertexBufferCore>* buffers, UINT32 numBuffers) override;
 
-		/**
-		 * @copydoc RenderAPICore::setIndexBuffer()
-		 */
+		/** @copydoc RenderAPICore::setIndexBuffer() */
 		void setIndexBuffer(const SPtr<IndexBufferCore>& buffer) override;
 
-		/**
-		 * @copydoc RenderAPICore::setVertexDeclaration()
-		 */
+		/** @copydoc RenderAPICore::setVertexDeclaration() */
 		void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration) override;
 
-		/**
-		 * @copydoc RenderAPICore::setDrawOperation()
-		 */
+		/** @copydoc RenderAPICore::setDrawOperation() */
 		void setDrawOperation(DrawOperationType op) override;
 
-		/**
-		 * @copydoc RenderAPICore::setTexture()
-		 */
+		/** @copydoc RenderAPICore::setTexture() */
 		void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr) override;
 
-		/**
-		 * @copydoc RenderAPICore::setLoadStoreTexture()
-		 */
+		/** @copydoc RenderAPICore::setLoadStoreTexture() */
 		void setLoadStoreTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr,
 			const TextureSurface& surface) override;
 
-		/**
-		 * @copydoc RenderAPICore::setSamplerState()
-		 */
+		/** @copydoc RenderAPICore::setSamplerState() */
 		void setSamplerState(GpuProgramType gptype, UINT16 unit, const SPtr<SamplerStateCore>& state) override;
 
-		/**
-		 * @copydoc RenderAPICore::setBlendState()
-		 */
+		/** @copydoc RenderAPICore::setBlendState() */
 		void setBlendState(const SPtr<BlendStateCore>& blendState) override;
 
-		/**
-		 * @copydoc RenderAPICore::setRasterizerState()
-		 */
+		/** @copydoc RenderAPICore::setRasterizerState() */
 		void setRasterizerState(const SPtr<RasterizerStateCore>& rasterizerState) override;
 
-		/**
-		 * @copydoc RenderAPICore::setDepthStencilState()
-		 */
+		/** @copydoc RenderAPICore::setDepthStencilState() */
 		void setDepthStencilState(const SPtr<DepthStencilStateCore>& depthStencilState, UINT32 stencilRefValue) override;
 
-		/**
-		 * @copydoc RenderAPICore::setViewport()
-		 */
+		/** @copydoc RenderAPICore::setViewport() */
 		void setViewport(const Rect2& vp) override;
 
-		/**
-		 * @copydoc RenderAPICore::beginFrame()
-		 */
+		/** @copydoc RenderAPICore::beginFrame() */
 		void beginFrame() override;
 
-		/**
-		 * @copydoc RenderAPICore::endFrame()
-		 */
+		/** @copydoc RenderAPICore::endFrame() */
 		void endFrame() override;
 
-		/**
-		 * @copydoc RenderAPICore::draw()
-		 */
+		/** @copydoc RenderAPICore::draw() */
 		void draw(UINT32 vertexOffset, UINT32 vertexCount) override;
 
-		/**
-		 * @copydoc RenderAPICore::drawIndexed()
-		 */
+		/** @copydoc RenderAPICore::drawIndexed() */
 		void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount) override;
 
-		/**
-		 * @copydoc RenderAPICore::dispatchCompute()
-		 */
+		/** @copydoc RenderAPICore::dispatchCompute() */
 		void dispatchCompute(UINT32 numGroupsX, UINT32 numGroupsY = 1, UINT32 numGroupsZ = 1) override;
 
-		/**
-		 * @copydoc RenderAPICore::setScissorRect()
-		 */
+		/** @copydoc RenderAPICore::setScissorRect() */
 		void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) override;
 
-		/**
-		 * @copydoc RenderAPICore::clearRenderTarget()
-		 */
+		/** @copydoc RenderAPICore::clearRenderTarget() */
 		void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, 
 			UINT8 targetMask = 0xFF) override;
 
-		/**
-		 * @copydoc RenderAPICore::clearViewport()
-		 */
+		/** @copydoc RenderAPICore::clearViewport() */
 		void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, 
 			UINT8 targetMask = 0xFF) override;
 
-		/**
-		 * @copydoc RenderAPICore::convertProjectionMatrix()
-		 */
+		/** @copydoc RenderAPICore::convertProjectionMatrix() */
 		void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest) override;
 
 		/** @copydoc RenderAPICore::getAPIInfo */
 		const RenderAPIInfo& getAPIInfo() const override;
 
-		/**
-		 * @copydoc RenderAPICore::generateParamBlockDesc()
-		 */
+		/** @copydoc RenderAPICore::generateParamBlockDesc() */
 		GpuParamBlockDesc generateParamBlockDesc(const String& name, Vector<GpuParamDataDesc>& params) override;
 
 		/************************************************************************/
 		/* 				Internal use by DX9 RenderAPI only                   */
 		/************************************************************************/
 
-		/**
-		 * @brief	Returns the resource manager instance.
-		 */
+		/**	Returns the resource manager instance. */
 		static D3D9ResourceManager* getResourceManager();
 
-		/**
-		 * @brief	Returns the device manager instance.
-		 */
+		/**	Returns the device manager instance. */
 		static D3D9DeviceManager* getDeviceManager();
 
-		/**
-		 * @brief	Returns the internal DirectX 9 device object.
-		 */
+		/**	Returns the internal DirectX 9 device object. */
 		static IDirect3D9* getDirect3D9();
 
-		/**
-		 * @brief	Returns the number of devices that resources should be created on.
-		 */
+		/**	Returns the number of devices that resources should be created on. */
 		static UINT	getResourceCreationDeviceCount();
 
-		/**
-		 * @brief	Returns DirectX 9 device used for resource creation at the specified index.
-		 */
+		/**	Returns DirectX 9 device used for resource creation at the specified index. */
 		static IDirect3DDevice9* getResourceCreationDevice(UINT index);
 
-		/**
-		 * @brief	Returns the currently active DirectX 9 device.
-		 */
+		/**	Returns the currently active DirectX 9 device. */
 		static IDirect3DDevice9* getActiveD3D9Device();
 
 		/**
-		 * @brief	Converts engine multisample options into DirectX 9 specific ones.
-		 *			Also test for multi-sample support on the device and returns nearest
-		 *			supported type if requested type is not available.
+		 * Converts engine multisample options into DirectX 9 specific ones. Also test for multi-sample support on the
+		 * device and returns nearest supported type if requested type is not available.
 		 *
-		 * @param	d3d9Device				Device to check for multisampling.
-		 * @param	multisampleCount		Number of requested samples.
-		 * @param	d3dPixelFormat			Pixel format used by the render target.
-		 * @param	fullscreen				Are we testing multisampling for a full-screen render target.
-		 * @param	outMultisampleType		Output parameter containing DirectX type representing valid multisample type.
-		 * @param	outMultisampleQuality	Output parameter containing multisample quality.
+		 * @param[in]	d3d9Device				Device to check for multisampling.
+		 * @param[in]	multisampleCount		Number of requested samples.
+		 * @param[in]	d3dPixelFormat			Pixel format used by the render target.
+		 * @param[in]	fullscreen				Are we testing multisampling for a full-screen render target.
+		 * @param[in]	outMultisampleType		Output parameter containing DirectX type representing valid multisample type.
+		 * @param[in]	outMultisampleQuality	Output parameter containing multisample quality.
 		 */
 		void determineMultisampleSettings(IDirect3DDevice9* d3d9Device, UINT32 multisampleCount, D3DFORMAT d3dPixelFormat,
 			bool fullScreen, D3DMULTISAMPLE_TYPE* outMultisampleType, DWORD* outMultisampleQuality) const;
 
-		/**
-		 * @brief	Register a newly open window with the render system.
-		 */
+		/**	Register a newly open window with the render system. */
 		void registerWindow(RenderWindowCore& renderWindow);
 
 	private:
@@ -227,101 +157,65 @@ namespace BansheeEngine
 		friend class D3D9RenderWindowManager;
 		friend class D3D9RenderWindowCoreManager;
 
-		/**
-		 * @copydoc	RenderAPICore::initializePrepare
-		 */
+		/** @copydoc RenderAPICore::initializePrepare */
 		void initializePrepare() override;
 
-		/**
-		 * @copydoc	RenderAPICore::initializeFinalize
-		 */
+		/** @copydoc RenderAPICore::initializeFinalize */
 		void initializeFinalize(const SPtr<RenderWindowCore>& primaryWindow) override;
 
-		/**
-		 * @copydoc	RenderAPICore::destroy_internal
-		 */
+		/** @copydoc RenderAPICore::destroy_internal */
 		void destroyCore() override;
 
-		/**
-		 * @brief	Returns a list of available drivers and their properties.
-		 */
+		/**	Returns a list of available drivers and their properties. */
 		D3D9DriverList* getDirect3DDrivers() const;
 				
-		/**
-		 * @brief	Sets DirectX 9 render state option.
-		 */
+		/**	Sets DirectX 9 render state option. */
 		HRESULT setRenderState(D3DRENDERSTATETYPE state, DWORD value);
 
-		/**
-		 * @brief	Sets DirectX 9 sampler state option for a sampler at the specified index.
-		 */
+		/**	Sets DirectX 9 sampler state option for a sampler at the specified index. */
 		HRESULT setSamplerState(DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value);
 
-		/**
-		 * @brief	Sets DirectX 9 texture state option for a texture unit at the specified index.
-		 */
+		/**	Sets DirectX 9 texture state option for a texture unit at the specified index. */
 		HRESULT setTextureStageState(DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD value);
 
-		/**
-		 * @brief	Set a floating point render state option.
-		 */
+		/**	Set a floating point render state option. */
 		HRESULT setFloatRenderState(D3DRENDERSTATETYPE state, float value)
 		{
 			return setRenderState(state, *((LPDWORD)(&value)));
 		}
 
-		/**
-		 * @brief	Returns currently active anisotropy level for the provided texture unit.
-		 */
+		/**	Returns currently active anisotropy level for the provided texture unit. */
 		DWORD getCurrentAnisotropy(UINT32 unit);
 
 		/**
-		 * @brief	Updates active render system capabilities. Requires active render window to check
-		 *			certain capabilities.
+		 * Updates active render system capabilities. Requires active render window to check certain capabilities.
 		 *
 		 * @note	Also performs an initialization step when called the first time.
 		 */
 		RenderAPICapabilities* updateRenderSystemCapabilities(D3D9RenderWindowCore* renderWindow);
 
-		/**
-		 * @brief	Updates render system capabilities with vertex shader related data.
-		 */
+		/**	Updates render system capabilities with vertex shader related data. */
         void updateVertexShaderCaps(RenderAPICapabilities* rsc) const;
 
-		/**
-		 * @brief	Updates render system capabilities with pixel shader related data.
-		 */
+		/**	Updates render system capabilities with pixel shader related data. */
         void updatePixelShaderCaps(RenderAPICapabilities* rsc) const;
 
-		/**
-		 * @copydoc	RenderAPICore::setClipPlanesImpl
-		 */
+		/** @copydoc RenderAPICore::setClipPlanesImpl */
 		void setClipPlanesImpl(const PlaneList& clipPlanes) override;
 
-		/**
-		 * @brief	Converts a HRESULT error number into an error description.
-		 */
+		/**	Converts a HRESULT error number into an error description. */
 		String getErrorDescription(long errorNumber) const;
 
-		/**
-		 * @brief	Sets a clip plane with the specified index.
-		 */
+		/**	Sets a clip plane with the specified index. */
 		void setClipPlane(UINT16 index, float A, float B, float C, float D);
 
-		/**
-		 * @brief	Enables or disables a clip plane at the specified index.
-		 */
+		/**	Enables or disables a clip plane at the specified index. */
 		void enableClipPlane(UINT16 index, bool enable);
 
-		/**
-		 * @brief	Returns current module instance.
-		 */
+		/**	Returns current module instance. */
 		HINSTANCE getInstanceHandle() const { return mhInstance; }
 
-		/**
-		 * @brief	Returns the D3D9 specific mode used for drawing, depending on the
-		 * 			currently set draw operation.
-		 */
+		/** Returns the D3D9 specific mode used for drawing, depending on the currently set draw operation. */
 		D3DPRIMITIVETYPE getD3D9PrimitiveType() const;
 
 		/************************************************************************/
@@ -329,35 +223,30 @@ namespace BansheeEngine
 		/************************************************************************/
 
 		/**
-		 * @brief	Sets the texture addressing mode for a texture unit. This determines
-		 *			how are UV address values outside of [0, 1] range handled when sampling
-		 *			from texture.
+		 * Sets the texture addressing mode for a texture unit. This determines how are UV address values outside of [0, 1]
+		 * range handled when sampling from texture.
 		 */
 		void setTextureAddressingMode(UINT16 stage, const UVWAddressingMode& uvw);
 
 		/**
-		 * @brief	Allows you to specify how is the texture bound to the specified texture unit filtered.
-		 *			Different filter types are used for different situations like magnifying or minifying a texture.
+		 * Allows you to specify how is the texture bound to the specified texture unit filtered. Different filter types are
+		 * used for different situations like magnifying or minifying a texture.
 		 */
 		void setTextureFiltering(UINT16 unit, FilterType ftype, FilterOptions filter);
 
-		/**
-		 * @brief	Sets anisotropy value for the specified texture unit.
-		 */
+		/**	Sets anisotropy value for the specified texture unit. */
 		void setTextureAnisotropy(UINT16 unit, unsigned int maxAnisotropy);
 
 		/**
-		 * @brief	Sets the texture border color for a texture unit. Border color
-		 *			determines color returned by the texture sampler when border addressing mode
-		 *			is used and texture address is outside of [0, 1] range.
+		 * Sets the texture border color for a texture unit. Border color determines color returned by the texture sampler
+		 * when border addressing mode is used and texture address is outside of [0, 1] range.
 		 */
 		void setTextureBorderColor(UINT16 stage, const Color& color);
 
 		/**
-		 * @brief	Sets the mipmap bias value for a given texture unit. Bias allows
-		 *			you to adjust the mipmap selection calculation. Negative values force a
-		 *			larger mipmap to be used, and positive values smaller. Units are in values
-		 *			of mip levels, so -1 means use a mipmap one level higher than default.
+		 * Sets the mipmap bias value for a given texture unit. Bias allows you to adjust the mipmap selection calculation.
+		 * Negative values force a larger mipmap to be used, and positive values smaller. Units are in values of mip levels,
+		 * so -1 means use a mipmap one level higher than default.
 		 */
 		void setTextureMipmapBias(UINT16 unit, float bias);
 
@@ -366,79 +255,71 @@ namespace BansheeEngine
 		/************************************************************************/
 
 		/**
-		 * @brief	Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
-		 *			Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor).
+		 * Sets up blending mode that allows you to combine new pixels with pixels already in the render target. Final pixel
+		 * value = (renderTargetPixel * sourceFactor) op (pixel * destFactor).
 		 */
 		void setSceneBlending(BlendFactor sourceFactor, BlendFactor destFactor, BlendOperation op);
 
 		/**
-		* @brief	Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
-		*			Allows you to set up separate blend operations for alpha values.
-		*	
-		*			Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor). (And the same for alpha)
-		*/
+		 * Sets up blending mode that allows you to combine new pixels with pixels already in the render target. Allows you
+		 * to set up separate blend operations for alpha values.
+		 *	
+		 *	Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor). (And the same for alpha)
+		 */
 		void setSceneBlending(BlendFactor sourceFactor, BlendFactor destFactor, BlendFactor sourceFactorAlpha, 
 			BlendFactor destFactorAlpha, BlendOperation op, BlendOperation alphaOp);
 
 		/**
-		 * @brief	Sets alpha test that allows you to reject pixels that fail the comparison function
-		 *			versus the provided reference value.
+		 * Sets alpha test that allows you to reject pixels that fail the comparison function versus the provided reference
+		 * value.
 		 */
 		void setAlphaTest(CompareFunction func, unsigned char value);
 
 		/**
-		 * @brief	Enable alpha to coverage. Alpha to coverage allows you to perform blending without needing 
-		 *			to worry about order of rendering like regular blending does. It requires multi-sampling to 
-		 *			be active in order to work, and you need to supply an alpha texture that determines object transparency.
+		 * Enable alpha to coverage. Alpha to coverage allows you to perform blending without needing to worry about order
+		 * of rendering like regular blending does. It requires multi-sampling to be active in order to work, and you need
+		 * to supply an alpha texture that determines object transparency.
 		 */
 		void setAlphaToCoverage(bool enabled);
 
-		/**
-		 * @brief	Enables or disables writing to certain color channels of the render target.
-		 */
+		/**	Enables or disables writing to certain color channels of the render target. */
 		void setColorBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
 
 		/************************************************************************/
 		/* 								Rasterizer states                  		*/
 		/************************************************************************/
 
-		/**
-		 * @brief	Sets vertex winding order. Normally you would use this to cull back facing
-		 *			polygons.
-		 */
+		/** Sets vertex winding order. Normally you would use this to cull back facing polygons. */
 		void setCullingMode(CullingMode mode);
 
-		/**
-		 * @brief	Sets the polygon rasterization mode. Determines how are polygons interpreted.
-		 */
+		/**	Sets the polygon rasterization mode. Determines how are polygons interpreted. */
 		void setPolygonMode(PolygonMode level);
 
 		/**
-		 * @brief	Sets a depth bias that will offset the depth values of new pixels by the specified amount.
-		 *			Final depth bias value is a combination of the constant depth bias and slope depth bias.
-		 *			Slope depth bias has more effect the higher the slope of the rendered polygon.
+		 * Sets a depth bias that will offset the depth values of new pixels by the specified amount. Final depth bias value
+		 * is a combination of the constant depth bias and slope depth bias. Slope depth bias has more effect the higher the
+		 * slope of the rendered polygon.
 		 *
 		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
 		 */
 		void setDepthBias(float constantBias, float slopeScaleBias);
 
 		/**
-		 * @brief	Scissor test allows you to mask off rendering in all but a given rectangular area
-		 * 			identified by the rectangle set by setScissorRect().
+		 * Scissor test allows you to mask off rendering in all but a given rectangular area identified by the rectangle
+		 * set by setScissorRect().
 		 */
 		void setScissorTestEnable(bool enable);
 
 		/**
-		 * @brief	Only applies when rendering to a multisample render target.
-		 * 			If disabled all of the samples will be taken from the center of the pixel,
-		 * 			effectively making the image aliased. Default value is true where samples are
-		 * 			picked randomly within the pixel.
+		 * Only applies when rendering to a multisample render target. If disabled all of the samples will be taken from the
+		 * center of the pixel, effectively making the image aliased. Default value is true where samples are picked
+		 * randomly within the pixel.
 		 */
 		void setMultisampleAntialiasEnable(bool enable);
 
-		/**
-		 * @brief	Only applies when rendering to a non-multisample render target.
-		 * 			If enabled, lines will be antialiased. Default state is disabled.
+		/**	
+		 * Only applies when rendering to a non-multisample render target. If enabled, lines will be antialiased. Default
+		 * state is disabled.
 		 */
 		void setAntialiasedLineEnable(bool enable);
 
@@ -446,104 +327,86 @@ namespace BansheeEngine
 		/* 						Depth stencil state                      		*/
 		/************************************************************************/
 		
-		/**
-		 * @brief	Should new pixels perform depth testing using the set depth comparison function before
-		 *			being written.
-		 */
+		/** Should new pixels perform depth testing using the set depth comparison function before being written. */
 		void setDepthBufferCheckEnabled(bool enabled = true);
 
-		/**
-		 * @brief	Should new pixels write to the depth buffer.
-		 */
+		/**	Should new pixels write to the depth buffer. */
 		void setDepthBufferWriteEnabled(bool enabled = true);
 
 		/**
-		 * @brief	Sets comparison function used for depth testing. Determines how are new and existing
-		 *			pixel values compared - if comparison function returns true the new pixel is written.
+		 * Sets comparison function used for depth testing. Determines how are new and existing pixel values compared - if
+		 * comparison function returns true the new pixel is written.
 		 */
 		void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
 
 		/**
-		 * @brief	Turns stencil tests on or off. By default this is disabled.
-		 *			Stencil testing allow you to mask out a part of the rendered image by using
-		 *			various stencil operations provided.
+		 * Turns stencil tests on or off. By default this is disabled. Stencil testing allow you to mask out a part of the
+		 * rendered image by using various stencil operations provided.
 		 */
 		void setStencilCheckEnabled(bool enabled);
 
 		/**
-		 * @brief	Allows you to set stencil operations that are performed when stencil test passes or fails.
+		 * Allows you to set stencil operations that are performed when stencil test passes or fails.
 		 *
-		 * @param	stencilFailOp	Operation executed when stencil test fails.
-		 * @param	depthFailOp		Operation executed when stencil test succeeds but depth test fails.
-		 * @param	passOp			Operation executed when stencil test succeeds and depth test succeeds.
-		 * @param	front			Should the stencil operations be applied to front or back facing polygons.
+		 * @param[in]	stencilFailOp	Operation executed when stencil test fails.
+		 * @param[in]	depthFailOp		Operation executed when stencil test succeeds but depth test fails.
+		 * @param[in]	passOp			Operation executed when stencil test succeeds and depth test succeeds.
+		 * @param[in]	front			Should the stencil operations be applied to front or back facing polygons.
 		 */
 		void setStencilBufferOperations(StencilOperation stencilFailOp = SOP_KEEP,
 			StencilOperation depthFailOp = SOP_KEEP, StencilOperation passOp = SOP_KEEP,
 			bool ccw = true);
 
 		/**
-		 * @brief	Sets a stencil buffer comparison function. The result of this will cause one of 3 actions 
-		 *			depending on whether the test fails, succeeds but with the depth buffer check still failing, 
-		 *			or succeeds with the depth buffer check passing too.
+		 * Sets a stencil buffer comparison function. The result of this will cause one of 3 actions depending on whether
+		 * the test fails, succeeds but with the depth buffer check still failing, or succeeds with the depth buffer check
+		 * passing too.
 		 *
-		 * @param func	Comparison function that determines whether a stencil test fails or passes. Reference value
-		 *				gets compared to the value already in the buffer using this function.
-		 * @param ccw	If set to true, the stencil operations will be applied to counterclockwise
-		 *				faces. Otherwise they will be applied to clockwise faces.
+		 * @param[in] func	Comparison function that determines whether a stencil test fails or passes. Reference value
+		 *					gets compared to the value already in the buffer using this function.
+		 * @param[in] ccw	If set to true, the stencil operations will be applied to counterclockwise
+		 *					faces. Otherwise they will be applied to clockwise faces.
 		 */
 		void setStencilBufferFunc(CompareFunction func = CMPF_ALWAYS_PASS, bool ccw = true);
 
-		/**
-		 * @brief	The bitmask applied to both the stencil value and the reference value
-		 *			before comparison.
-		 */
+		/** The bitmask applied to both the stencil value and the reference value before comparison. */
 		void setStencilBufferReadMask(UINT32 mask = 0xFFFFFFFF);
 
-		/**
-		 * @brief	The bitmask applied to the stencil value before writing it to the stencil buffer.
-		 */
+		/**	The bitmask applied to the stencil value before writing it to the stencil buffer. */
 		void setStencilBufferWriteMask(UINT32 mask = 0xFFFFFFFF);
 
 		/**
-		 * @brief	Sets a reference values used for stencil buffer comparisons. 
-		 * 			Actual comparison function and stencil operations are set by setting the DepthStencilState.
+		 * Sets a reference values used for stencil buffer comparisons. Actual comparison function and stencil operations
+		 * are set by setting the DepthStencilState.
 		 */
 		void setStencilRefValue(UINT32 refValue);
 
 		/**
-		 * @brief	Clears an area of the currently active render target.
+		 * Clears an area of the currently active render target.
 		 *
-		 * @param	buffers			Combination of one or more elements of FrameBufferType
-		 *							denoting which buffers are to be cleared.
-		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
-		 * @param	depth			(optional) The value to initialize the depth buffer with, if enabled.
-		 * @param	stencil			(optional) The value to initialize the stencil buffer with, if enabled.
-		 * @param	clearArea		(optional) Area in pixels to clear.
+		 * @param[in]	buffers			Combination of one or more elements of FrameBufferType denoting which buffers are
+		 *								to be cleared.
+		 * @param[in]	color			(optional) The color to clear the color buffer with, if enabled.
+		 * @param[in]	depth			(optional) The value to initialize the depth buffer with, if enabled.
+		 * @param[in]	stencil			(optional) The value to initialize the stencil buffer with, if enabled.
+		 * @param[in]	clearArea		(optional) Area in pixels to clear.
 		 */
 		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const Rect2I& clearArea = Rect2I::EMPTY);
 
 		/**
-		 * @brief	Recalculates actual viewport dimensions based on currently 
-		 *			set viewport normalized dimensions and render target and applies
-		 *			them for further rendering.
+		 * Recalculates actual viewport dimensions based on currently set viewport normalized dimensions and render target
+		 * and applies them for further rendering.
 		 */
 		void applyViewport();
 
-		/**
-		 * @brief	Triggered when device has been lost.
-		 */
+		/**	Triggered when device has been lost. */
 		void notifyOnDeviceLost(D3D9Device* device);
 
-		/**
-		 * @brief	Triggered when device is being reset.
-		 */
+		/**	Triggered when device is being reset. */
 		void notifyOnDeviceReset(D3D9Device* device);
 
 	private:
-		/**
-		 * @brief	Holds texture unit settings.
-		 */
+		/**	Holds texture unit settings. */
 		struct sD3DTextureStageDesc
 		{
 			D3D9Mappings::D3DTexType texType;
@@ -576,4 +439,6 @@ namespace BansheeEngine
 
 		DrawOperationType mCurrentDrawOperation;
 	};
+
+	/** @} */
 }

+ 47 - 50
Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderAPIFactory.h

@@ -1,51 +1,48 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include <string>
-#include "BsRenderAPIFactory.h"
-#include "BsRenderAPIManager.h"
-#include "BsD3D9RenderAPI.h"
-
-namespace BansheeEngine
-{
-	const String SystemName = "BansheeD3D9RenderSystem";
-
-	/**
-	 * @brief	Handles creation of the DX9 render system.
-	 */
-	class D3D9RenderAPIFactory : public RenderAPIFactory
-	{
-	public:
-		/**
-		 * @copydoc	RenderSystemFactory::create
-		 */
-		virtual void create();
-
-		/**
-		 * @copydoc	RenderSystemFactory::name
-		 */
-		virtual const String& name() const { return SystemName; }
-
-	private:
-
-		/**
-		 * @brief	Registers the factory with the render system manager when constructed.
-		 */
-		class InitOnStart
-		{
-			public:
-				InitOnStart() 
-				{ 
-					static RenderAPIFactoryPtr newFactory;
-					if(newFactory == nullptr)
-					{
-						newFactory = bs_shared_ptr_new<D3D9RenderAPIFactory>();
-						RenderAPIManager::instance().registerFactory(newFactory);
-					}
-				}
-		};
-
-		static InitOnStart initOnStart; // Makes sure factory is registered on program start
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include <string>
+#include "BsRenderAPIFactory.h"
+#include "BsRenderAPIManager.h"
+#include "BsD3D9RenderAPI.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	const String SystemName = "BansheeD3D9RenderSystem";
+
+	/**	Handles creation of the DX9 render system. */
+	class D3D9RenderAPIFactory : public RenderAPIFactory
+	{
+	public:
+		/** @copydoc RenderSystemFactory::create */
+		void create() override;
+
+		/** @copydoc RenderSystemFactory::name */
+		const String& name() const override { return SystemName; }
+
+	private:
+		/**	Registers the factory with the render system manager when constructed. */
+		class InitOnStart
+		{
+			public:
+				InitOnStart() 
+				{ 
+					static RenderAPIFactoryPtr newFactory;
+					if(newFactory == nullptr)
+					{
+						newFactory = bs_shared_ptr_new<D3D9RenderAPIFactory>();
+						RenderAPIManager::instance().registerFactory(newFactory);
+					}
+				}
+		};
+
+		static InitOnStart initOnStart; // Makes sure factory is registered on program start
+	};
+
+	/** @} */
 }

+ 86 - 80
Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderTexture.h

@@ -1,81 +1,87 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9Resource.h"
-#include "BsRenderTexture.h"
-
-namespace BansheeEngine
-{
-	class D3D9RenderTexture;
-
-	/**
-	 * DirectX 9 implementation of a render texture.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_D3D9_EXPORT D3D9RenderTextureCore : public RenderTextureCore, public D3D9Resource
-	{
-	public:
-		D3D9RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
-
-		virtual ~D3D9RenderTextureCore();
-
-		/** @copydoc RenderTextureCore::getCustomAttribute */
-		void getCustomAttribute(const String& name, void* pData) const override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
-		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
-		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceLost */
-		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceReset */
-		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
-
-	protected:
-		friend class D3D9RenderTexture;
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/**	Initializes the internal color and depth surfaces. */
-		void initializeSurfaces();
-
-		/**	Releases the internal color and depth surfaces. */
-		void releaseSurfaces();
-
-		/** @copydoc RenderTextureCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		IDirect3DSurface9* mDX9ColorSurface;
-		IDirect3DSurface9* mDX9DepthStencilSurface;
-		bool mIsBindableToShader;
-		RenderTextureProperties mProperties;
-	};
-
-	/**
-	 * DirectX 9 implementation of a render texture.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class D3D9RenderTexture : public RenderTexture
-	{
-	public:
-		virtual ~D3D9RenderTexture() { }
-
-	protected:
-		friend class D3D9TextureManager;
-
-		D3D9RenderTexture(const RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc RenderTexture::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		RenderTextureProperties mProperties;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9Resource.h"
+#include "BsRenderTexture.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	class D3D9RenderTexture;
+
+	/**
+	 * DirectX 9 implementation of a render texture.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_D3D9_EXPORT D3D9RenderTextureCore : public RenderTextureCore, public D3D9Resource
+	{
+	public:
+		D3D9RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
+
+		virtual ~D3D9RenderTextureCore();
+
+		/** @copydoc RenderTextureCore::getCustomAttribute */
+		void getCustomAttribute(const String& name, void* pData) const override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+	protected:
+		friend class D3D9RenderTexture;
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/**	Initializes the internal color and depth surfaces. */
+		void initializeSurfaces();
+
+		/**	Releases the internal color and depth surfaces. */
+		void releaseSurfaces();
+
+		/** @copydoc RenderTextureCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		IDirect3DSurface9* mDX9ColorSurface;
+		IDirect3DSurface9* mDX9DepthStencilSurface;
+		bool mIsBindableToShader;
+		RenderTextureProperties mProperties;
+	};
+
+	/**
+	 * DirectX 9 implementation of a render texture.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class D3D9RenderTexture : public RenderTexture
+	{
+	public:
+		virtual ~D3D9RenderTexture() { }
+
+	protected:
+		friend class D3D9TextureManager;
+
+		D3D9RenderTexture(const RENDER_TEXTURE_DESC& desc);
+
+		/** @copydoc RenderTexture::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		RenderTextureProperties mProperties;
+	};
+
+	/** @} */
 }

+ 180 - 174
Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderWindow.h

@@ -1,175 +1,181 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsRenderWindow.h"
-#include "BsD3D9Device.h"
-
-namespace BansheeEngine 
-{
-	class D3D9RenderWindow;
-
-	/**	Contains various properties that describe a render window. */
-	class BS_D3D9_EXPORT D3D9RenderWindowProperties : public RenderWindowProperties
-	{
-	public:
-		D3D9RenderWindowProperties(const RENDER_WINDOW_DESC& desc);
-		virtual ~D3D9RenderWindowProperties() { }
-
-	private:
-		friend class D3D9RenderWindowCore;
-		friend class D3D9RenderWindow;
-	};
-
-	/**
-	 * Render window implementation for Windows.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_D3D9_EXPORT D3D9RenderWindowCore : public RenderWindowCore
-	{
-	public:
-		D3D9RenderWindowCore(const RENDER_WINDOW_DESC& desc, UINT32 windowId, HINSTANCE instance);
-		~D3D9RenderWindowCore();
-		
-		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
-		void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0) override;
-
-		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
-		void setFullscreen(const VideoMode& mode) override;
-
-		/** @copydoc RenderWindowCore::setWindowed */
-		void setWindowed(UINT32 width, UINT32 height) override;
-
-		/** @copydoc RenderWindowCore::setActive */
-		virtual void setActive(bool state) override;
-
-		/** @copydoc RenderWindowCore::setHidden */
-		void setHidden(bool hidden) override;
-
-		/** @copydoc RenderWindowCore::minimize */
-		void minimize() override;
-
-		/** @copydoc RenderWindowCore::maximize */
-		void maximize() override;
-
-		/** @copydoc RenderWindowCore::restore */
-		void restore() override;
-
-		/** @copydoc RenderWindowCore::move */
-		void move(INT32 left, INT32 top) override;
-
-		/** @copydoc RenderWindowCore::resize */
-		void resize(UINT32 width, UINT32 height) override;
-
-		/** @copydoc RenderWindowCore::getCustomAttribute */
-		void getCustomAttribute(const String& name, void* pData) const override;
-
-		/** @copydoc RenderWindowCore::copyContentsToMemory */
-		void copyToMemory(PixelData &dst, FrameBuffer buffer);
-
-		/** @copydoc RenderWindowCore::swapBuffers */
-		void swapBuffers() override;
-
-		/** @copydoc RenderWindowCore::_windowMovedOrResized */
-		void _windowMovedOrResized() override;
-
-		/**	Gets internal Win32 window handle. */
-		HWND _getWindowHandle() const;
-
-		/**	Gets the DirectX 9 device object that manages this window. */
-		IDirect3DDevice9* _getD3D9Device() const;
-
-		/**	Gets the device that manages this window. */
-		D3D9Device* _getDevice() const;
-
-		/**	Sets the device that manages this window. */
-		void _setDevice(D3D9Device* device);
-
-		/**	Build the presentation parameters used with this window. */
-		void _buildPresentParameters(D3DPRESENT_PARAMETERS* presentParams) const;
-
-		/**	Accessor for render surface. */
-		IDirect3DSurface9* _getRenderSurface() const;
-	
-		/**	Returns true if this window use depth buffer. */
-		bool _isDepthBuffered() const;
-
-		/**	Validate the device for this window. */
-		bool _validateDevice();
-		
-	protected:
-		friend class D3D9RenderWindow;
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
-
-		/** @copydoc RenderWindowCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		/** @copydoc RenderWindowCore::getSyncedProperties */
-		RenderWindowProperties& getSyncedProperties() override { return mSyncedProperties; }
-
-		/** @copydoc RenderWindowCore::syncProperties */
-		void syncProperties() override;
-
-	protected:
-		Win32Window* mWindow;
-		HINSTANCE mInstance;
-		D3D9Device* mDevice;
-		bool mDeviceValid;
-		D3DMULTISAMPLE_TYPE	mMultisampleType;
-		DWORD mMultisampleQuality;
-		UINT mDisplayFrequency;
-		unsigned int mVSyncInterval;
-		bool mIsDepthBuffered;
-		bool mIsChild;
-		bool mShowOnSwap;
-		
-		D3D9RenderWindowProperties mProperties;
-		D3D9RenderWindowProperties mSyncedProperties;
-	};
-
-	/**
-	 * Render window implementation for Windows.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_D3D9_EXPORT D3D9RenderWindow : public RenderWindow
-	{
-	public:
-		~D3D9RenderWindow() { }
-
-		/** @copydoc RenderWindow::screenToWindowPos */
-		void getCustomAttribute(const String& name, void* pData) const override;
-
-		/** @copydoc RenderWindow::screenToWindowPos */
-		Vector2I screenToWindowPos(const Vector2I& screenPos) const override;
-
-		/** @copydoc RenderWindow::windowToScreenPos */
-		Vector2I windowToScreenPos(const Vector2I& windowPos) const override;
-
-		/** @copydoc RenderWindow::getCore */
-		SPtr<D3D9RenderWindowCore> getCore() const;
-
-	protected:
-		friend class D3D9RenderWindowManager;
-		friend class D3D9RenderWindowCore;
-
-		D3D9RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId, HINSTANCE instance);
-
-		/** @copydoc RenderWindowCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		/** @copydoc RenderWindow::syncProperties */
-		void syncProperties() override;
-
-		/**	Retrieves internal window handle. */
-		HWND getHWnd() const;
-
-	private:
-		HINSTANCE mInstance;
-		D3D9RenderWindowProperties mProperties;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsRenderWindow.h"
+#include "BsD3D9Device.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	class D3D9RenderWindow;
+
+	/**	Contains various properties that describe a render window. */
+	class BS_D3D9_EXPORT D3D9RenderWindowProperties : public RenderWindowProperties
+	{
+	public:
+		D3D9RenderWindowProperties(const RENDER_WINDOW_DESC& desc);
+		virtual ~D3D9RenderWindowProperties() { }
+
+	private:
+		friend class D3D9RenderWindowCore;
+		friend class D3D9RenderWindow;
+	};
+
+	/**
+	 * Render window implementation for Windows.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_D3D9_EXPORT D3D9RenderWindowCore : public RenderWindowCore
+	{
+	public:
+		D3D9RenderWindowCore(const RENDER_WINDOW_DESC& desc, UINT32 windowId, HINSTANCE instance);
+		~D3D9RenderWindowCore();
+		
+		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
+		void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0) override;
+
+		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
+		void setFullscreen(const VideoMode& mode) override;
+
+		/** @copydoc RenderWindowCore::setWindowed */
+		void setWindowed(UINT32 width, UINT32 height) override;
+
+		/** @copydoc RenderWindowCore::setActive */
+		virtual void setActive(bool state) override;
+
+		/** @copydoc RenderWindowCore::setHidden */
+		void setHidden(bool hidden) override;
+
+		/** @copydoc RenderWindowCore::minimize */
+		void minimize() override;
+
+		/** @copydoc RenderWindowCore::maximize */
+		void maximize() override;
+
+		/** @copydoc RenderWindowCore::restore */
+		void restore() override;
+
+		/** @copydoc RenderWindowCore::move */
+		void move(INT32 left, INT32 top) override;
+
+		/** @copydoc RenderWindowCore::resize */
+		void resize(UINT32 width, UINT32 height) override;
+
+		/** @copydoc RenderWindowCore::getCustomAttribute */
+		void getCustomAttribute(const String& name, void* pData) const override;
+
+		/** @copydoc RenderWindowCore::copyContentsToMemory */
+		void copyToMemory(PixelData &dst, FrameBuffer buffer);
+
+		/** @copydoc RenderWindowCore::swapBuffers */
+		void swapBuffers() override;
+
+		/** @copydoc RenderWindowCore::_windowMovedOrResized */
+		void _windowMovedOrResized() override;
+
+		/**	Gets internal Win32 window handle. */
+		HWND _getWindowHandle() const;
+
+		/**	Gets the DirectX 9 device object that manages this window. */
+		IDirect3DDevice9* _getD3D9Device() const;
+
+		/**	Gets the device that manages this window. */
+		D3D9Device* _getDevice() const;
+
+		/**	Sets the device that manages this window. */
+		void _setDevice(D3D9Device* device);
+
+		/**	Build the presentation parameters used with this window. */
+		void _buildPresentParameters(D3DPRESENT_PARAMETERS* presentParams) const;
+
+		/**	Accessor for render surface. */
+		IDirect3DSurface9* _getRenderSurface() const;
+	
+		/**	Returns true if this window use depth buffer. */
+		bool _isDepthBuffered() const;
+
+		/**	Validate the device for this window. */
+		bool _validateDevice();
+		
+	protected:
+		friend class D3D9RenderWindow;
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize() override;
+
+		/** @copydoc RenderWindowCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		/** @copydoc RenderWindowCore::getSyncedProperties */
+		RenderWindowProperties& getSyncedProperties() override { return mSyncedProperties; }
+
+		/** @copydoc RenderWindowCore::syncProperties */
+		void syncProperties() override;
+
+	protected:
+		Win32Window* mWindow;
+		HINSTANCE mInstance;
+		D3D9Device* mDevice;
+		bool mDeviceValid;
+		D3DMULTISAMPLE_TYPE	mMultisampleType;
+		DWORD mMultisampleQuality;
+		UINT mDisplayFrequency;
+		unsigned int mVSyncInterval;
+		bool mIsDepthBuffered;
+		bool mIsChild;
+		bool mShowOnSwap;
+		
+		D3D9RenderWindowProperties mProperties;
+		D3D9RenderWindowProperties mSyncedProperties;
+	};
+
+	/**
+	 * Render window implementation for Windows.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_D3D9_EXPORT D3D9RenderWindow : public RenderWindow
+	{
+	public:
+		~D3D9RenderWindow() { }
+
+		/** @copydoc RenderWindow::screenToWindowPos */
+		void getCustomAttribute(const String& name, void* pData) const override;
+
+		/** @copydoc RenderWindow::screenToWindowPos */
+		Vector2I screenToWindowPos(const Vector2I& screenPos) const override;
+
+		/** @copydoc RenderWindow::windowToScreenPos */
+		Vector2I windowToScreenPos(const Vector2I& windowPos) const override;
+
+		/** @copydoc RenderWindow::getCore */
+		SPtr<D3D9RenderWindowCore> getCore() const;
+
+	protected:
+		friend class D3D9RenderWindowManager;
+		friend class D3D9RenderWindowCore;
+
+		D3D9RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId, HINSTANCE instance);
+
+		/** @copydoc RenderWindowCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		/** @copydoc RenderWindow::syncProperties */
+		void syncProperties() override;
+
+		/**	Retrieves internal window handle. */
+		HWND getHWnd() const;
+
+	private:
+		HINSTANCE mInstance;
+		D3D9RenderWindowProperties mProperties;
+	};
+
+	/** @} */
 }

+ 42 - 44
Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderWindowManager.h

@@ -1,45 +1,43 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsRenderWindowManager.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation of windows for DirectX 9.
-	 */
-	class BS_D3D9_EXPORT D3D9RenderWindowManager : public RenderWindowManager
-	{
-	public:
-		D3D9RenderWindowManager(D3D9RenderAPI* renderSystem);
-
-	protected:
-		/**
-		 * @copydoc RenderWindowManager::createImpl()
-		 */
-		RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const RenderWindowPtr& parentWindow) override;
-
-	private:
-		D3D9RenderAPI* mRenderSystem;
-	};
-
-	/**
-	 * @brief	Handles creation of windows for DirectX 9.
-	 */
-	class BS_D3D9_EXPORT D3D9RenderWindowCoreManager : public RenderWindowCoreManager
-	{
-	public:
-		D3D9RenderWindowCoreManager(D3D9RenderAPI* renderSystem);
-
-	protected:
-		/**
-		 * @copydoc RenderWindowCoreManager::createInternal
-		 */
-		SPtr<RenderWindowCore> createInternal(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
-
-	private:
-		D3D9RenderAPI* mRenderSystem;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsRenderWindowManager.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Handles creation of windows for DirectX 9. */
+	class BS_D3D9_EXPORT D3D9RenderWindowManager : public RenderWindowManager
+	{
+	public:
+		D3D9RenderWindowManager(D3D9RenderAPI* renderSystem);
+
+	protected:
+		/** @copydoc RenderWindowManager::createImpl() */
+		RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const RenderWindowPtr& parentWindow) override;
+
+	private:
+		D3D9RenderAPI* mRenderSystem;
+	};
+
+	/**	Handles creation of windows for DirectX 9. */
+	class BS_D3D9_EXPORT D3D9RenderWindowCoreManager : public RenderWindowCoreManager
+	{
+	public:
+		D3D9RenderWindowCoreManager(D3D9RenderAPI* renderSystem);
+
+	protected:
+		/** @copydoc RenderWindowCoreManager::createInternal */
+		SPtr<RenderWindowCore> createInternal(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
+
+	private:
+		D3D9RenderAPI* mRenderSystem;
+	};
+
+	/** @} */
 }

+ 48 - 53
Source/BansheeD3D9RenderAPI/Include/BsD3D9Resource.h

@@ -1,54 +1,49 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Provides an interface for dealing with DX9 resources. Primarily
-	 *			notifying the resources of any changed states.
-	 */
-	class BS_D3D9_EXPORT D3D9Resource
-	{
-	public:
-		D3D9Resource();
-		virtual ~D3D9Resource();
-
-		/**
-		 * @brief	Called immediately after the Direct3D device has been created.
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) {}
-
-		/**
-		 * @brief	Called before the Direct3D device is going to be destroyed.
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) {}
-
-		/**
-		 * @brief	Called immediately after the Direct3D device has entered a lost state.
-		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) {}
-
-		/**
-		 * @brief	Called immediately after the Direct3D device has been reset.
-		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) {}
-
-		/**
-		 * @brief	Called when device state is changing. Access to any device should be locked.
-		 *			Relevant for multi thread application.
-		 */
-		static void lockDeviceAccess();
-
-		/**
-		 * @brief	Called when device state change completed. Access to any device is allowed.
-		 *			Relevant for multi thread application.
-		 */
-		static void unlockDeviceAccess();
-
-	protected:
-		BS_STATIC_MUTEX(msDeviceAccessMutex)		
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** Provides an interface for dealing with DX9 resources. Primarily notifying the resources of any changed states. */
+	class BS_D3D9_EXPORT D3D9Resource
+	{
+	public:
+		D3D9Resource();
+		virtual ~D3D9Resource();
+
+		/**	Called immediately after the Direct3D device has been created. */
+		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) {}
+
+		/**	Called before the Direct3D device is going to be destroyed. */
+		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) {}
+
+		/**	Called immediately after the Direct3D device has entered a lost state. */
+		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) {}
+
+		/**	Called immediately after the Direct3D device has been reset. */
+		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) {}
+
+		/**
+		 * Called when device state is changing. Access to any device should be locked. Relevant for multi thread
+		 * application.
+		 */
+		static void lockDeviceAccess();
+
+		/**
+		 * Called when device state change completed. Access to any device is allowed. Relevant for multi thread
+		 * application.
+		 */
+		static void unlockDeviceAccess();
+
+	protected:
+		BS_STATIC_MUTEX(msDeviceAccessMutex)		
+	};
+
+	/** @} */
 }

+ 74 - 93
Source/BansheeD3D9RenderAPI/Include/BsD3D9ResourceManager.h

@@ -1,94 +1,75 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Types of resource creation policies.
-	 */
-	enum D3D9ResourceCreationPolicy
-	{
-		/**
-		 *	Creates resources only on active device. Meaning those resources will be unavailable
-		 *	for other devices.
-		 */
-		RCP_CREATE_ON_ACTIVE_DEVICE,
-
-		/**
-		 *	Creates resources on all devices making them available to all of them.
-		 */
-		RCP_CREATE_ON_ALL_DEVICES
-	};
-	
-	/**
-	 * @brief	Handles DirectX 9 resource life, notifying them
-	 *			about relevant device changes.
-	 */
-	class BS_D3D9_EXPORT D3D9ResourceManager
-	{
-	public:
-		D3D9ResourceManager();
-		~D3D9ResourceManager();
-
-		/**
-		 * @brief	Called after the device has been created.
-		 */
-		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Called before the device is destroyed.
-		 */
-		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Called after the device has entered the lost state.
-		 */
-		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Called after the device has been reset.
-		 */
-		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Called when device state is changing. Access to any device should be locked.
-		 */
-		void lockDeviceAccess();
-
-		/**
-		 * @brief	Called when device state change completed. Access to any device is allowed.
-		 */
-		void unlockDeviceAccess();
-		
-		/**
-		 * @brief	Called when new resource is created.
-		 */
-		void _notifyResourceCreated(D3D9Resource* pResource);
-
-		/**
-		 * @brief	Called before resource is destroyed.
-		 */
-		void _notifyResourceDestroyed(D3D9Resource* pResource);
-
-		/**
-		 * @brief	Sets creation policy that specifies on what devices will resources be created on.
-		 */
-		void setCreationPolicy(D3D9ResourceCreationPolicy creationPolicy);
-
-		/**
-		 * @brief	Returns creation policy that specifies on what devices will resources be created on.
-		 */
-		D3D9ResourceCreationPolicy getCreationPolicy() const;
-		
-	protected:
-		friend class D3D9Resource;
-		
-		BS_MUTEX(mResourcesMutex)
-		Vector<D3D9Resource*> mResources;
-		D3D9ResourceCreationPolicy mResourceCreationPolicy;
-		long mDeviceAccessLockCount;		
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Types of resource creation policies. */
+	enum D3D9ResourceCreationPolicy
+	{
+		/**
+		 *	Creates resources only on active device. Meaning those resources will be unavailable
+		 *	for other devices.
+		 */
+		RCP_CREATE_ON_ACTIVE_DEVICE,
+
+		/**
+		 *	Creates resources on all devices making them available to all of them.
+		 */
+		RCP_CREATE_ON_ALL_DEVICES
+	};
+	
+	/** Handles DirectX 9 resource life, notifying them about relevant device changes. */
+	class BS_D3D9_EXPORT D3D9ResourceManager
+	{
+	public:
+		D3D9ResourceManager();
+		~D3D9ResourceManager();
+
+		/**	Called after the device has been created. */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
+
+		/**	Called before the device is destroyed. */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
+
+		/**	Called after the device has entered the lost state. */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
+
+		/**	Called after the device has been reset. */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
+
+		/**	Called when device state is changing. Access to any device should be locked. */
+		void lockDeviceAccess();
+
+		/**	Called when device state change completed. Access to any device is allowed. */
+		void unlockDeviceAccess();
+		
+		/**	Called when new resource is created. */
+		void _notifyResourceCreated(D3D9Resource* pResource);
+
+		/**	Called before resource is destroyed. */
+		void _notifyResourceDestroyed(D3D9Resource* pResource);
+
+		/**	Sets creation policy that specifies on what devices will resources be created on. */
+		void setCreationPolicy(D3D9ResourceCreationPolicy creationPolicy);
+
+		/**	Returns creation policy that specifies on what devices will resources be created on. */
+		D3D9ResourceCreationPolicy getCreationPolicy() const;
+		
+	protected:
+		friend class D3D9Resource;
+		
+		BS_MUTEX(mResourcesMutex)
+		Vector<D3D9Resource*> mResources;
+		D3D9ResourceCreationPolicy mResourceCreationPolicy;
+		long mDeviceAccessLockCount;		
+	};
+
+	/** @} */
 }

+ 171 - 165
Source/BansheeD3D9RenderAPI/Include/BsD3D9Texture.h

@@ -1,166 +1,172 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsTexture.h"
-#include "BsD3D9PixelBuffer.h"
-#include "BsD3D9Resource.h"
-
-namespace BansheeEngine 
-{
-	/**	DirectX 9 implementation of a texture. */
-	class BS_D3D9_EXPORT D3D9TextureCore : public TextureCore, public D3D9Resource
-	{
-	protected:
-		/**	Container for internal resources. */
-		struct TextureResources
-		{
-			IDirect3DTexture9* pNormTex;
-			IDirect3DCubeTexture9* pCubeTex;
-			IDirect3DVolumeTexture9* pVolumeTex;
-			IDirect3DBaseTexture9* pBaseTex;
-			IDirect3DSurface9* pMultisampleSurface;
-			IDirect3DSurface9* pDepthStencilSurface;
-		};
-
-	public:
-		~D3D9TextureCore();
-
-		/** @copydoc Texture::isBindableAsShaderResource */
-		bool isBindableAsShaderResource() const override { return mIsBindableAsShaderResource; }
-
-		/**	Returns internal DirectX 9 texture object. */
-		IDirect3DBaseTexture9* getTexture_internal();	
-
-		/**	Returns internal DirectX 9 texture object pointing to a 1D or 2D texture. */
-		IDirect3DTexture9* getNormTexture_internal();
-
-		/**	Returns internal DirectX 9 texture object pointing to a cube texture. */
-		IDirect3DCubeTexture9* getCubeTexture_internal();
-
-		/**	Indicates whether the hardware gamma is enabled and supported. */
-		bool isHardwareGammaReadToBeUsed() const { return mProperties.isHardwareGammaEnabled() && mHwGammaReadSupported; }
-					
-		/**
-		 * Returns a hardware pixel buffer for a certain face and level of the texture.
-		 * 
-		 * @param[in]	face	Index of the texture face, if texture has more than one. Array index for texture arrays and
-		 *						a cube face for cube textures.
-		 * @param[in]	mipmap	Index of the mip level. 0 being the largest mip level.
-		 *
-		 * @note	Cube face indices: +X (0), -X (1), +Y (2), -Y (3), +Z (4), -Z (5)
-		 */
-		PixelBufferPtr getBuffer(UINT32 face, UINT32 mipmap);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceLost */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
-
-		/** @copydoc D3D9Resource::notifyOnDeviceReset */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
-
-	protected:	
-		friend class D3D9TextureCoreManager;
-		friend class D3D9PixelBuffer;
-
-		D3D9TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
-
-		/** @copydoc TextureCore::initialize */
-		void initialize() override;
-		
-		/** @copydoc TextureCore::lock */
-		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) override;
-
-		/** @copydoc TextureCore::unlock */
-		void unlockImpl() override;
-
-		/** @copydoc TextureCore::copy */
-		void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target) override;
-
-		/** @copydoc TextureCore::readData */
-		void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) override;
-
-		/** @copydoc TextureCore::writeData */
-		void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) override;
-
-		/**	Returns true if the texture should be allocated in the default pool. */
-		bool useDefaultPool();
-
-		/**	Creates a DirectX object for blank normal 1D/2D texture. */
-		void createNormTex(IDirect3DDevice9* d3d9Device);
-
-		/**	Creates a DirectX object for blank cube texture. */
-		void createCubeTex(IDirect3DDevice9* d3d9Device);
-
-		/**	Creates a DirectX object for blank volume (3D) texture. */	
-		void createVolumeTex(IDirect3DDevice9* d3d9Device);
-
-		/**	Selects a DirectX 9 pixel format depending on requested format and device capabilities. */
-		D3DFORMAT chooseD3DFormat(IDirect3DDevice9* d3d9Device);
-
-		/** @copydoc Texture::calculateSize */
-		UINT32 calculateSize() const;
-
-		/**	Creates internal resources for the texture for the specified device. */
-		void createInternalResources(IDirect3DDevice9* d3d9Device);
-
-		/** Updates texture attributes with final attributes provided by the API after the texture has been created. */
-		void setFinalAttributes(IDirect3DDevice9* d3d9Device, TextureResources* textureResources, 
-			UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
-
-		/**	Returns best texture filtering method. */
-		D3DTEXTUREFILTERTYPE getBestFilterMethod(IDirect3DDevice9* d3d9Device);
-
-		/**	Returns if the specified combination of texture type, format and usage supports dynamic texture usage. */
-		bool canUseDynamicTextures(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat);
-
-		/**	Returns if the specified combination of texture type, format and usage supports automatic mipmap generation. */
-		bool canAutoGenMipmaps(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat);
-
-		/**	Returns if the specified combination of texture type, format and usage supports hardware gamma. */
-		bool canUseHardwareGammaCorrection(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat, bool forwriting);
-
-		/**
-		 * Creates a list of pixel buffers for all surfaces in the texture. This must be called after the texture has been
-		 * created.
-		 */
-		void createSurfaceList(IDirect3DDevice9* d3d9Device, TextureResources* textureResources);
-	 
-		/**	Retrieves texture resources for the device, or null if they don't exist. */
-		TextureResources* getTextureResources(IDirect3DDevice9* d3d9Device);
-
-		/**	Allocates a new set of texture resources for the device. */
-		TextureResources* allocateTextureResources(IDirect3DDevice9* d3d9Device);
-
-		/**	Frees all the given texture resources. */
-		void freeTextureResources(IDirect3DDevice9* d3d9Device, TextureResources* textureResources);
-
-		/**	Determines the pool in which to create the texture in. */
-		void determinePool();
-
-	protected:
-		Map<IDirect3DDevice9*, TextureResources*> mMapDeviceToTextureResources;
-
-		Vector<PixelBufferPtr> mSurfaceList;
-
-		D3DPOOL	mD3DPool;
-		bool mDynamicTextures;
-		bool mIsBindableAsShaderResource;
-
-		PixelBufferPtr mLockedBuffer;
-
-		bool mHwGammaReadSupported;
-		bool mHwGammaWriteSupported;
-		D3DMULTISAMPLE_TYPE mMultisampleType;
-		DWORD mMultisampleQuality;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsTexture.h"
+#include "BsD3D9PixelBuffer.h"
+#include "BsD3D9Resource.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	DirectX 9 implementation of a texture. */
+	class BS_D3D9_EXPORT D3D9TextureCore : public TextureCore, public D3D9Resource
+	{
+	protected:
+		/**	Container for internal resources. */
+		struct TextureResources
+		{
+			IDirect3DTexture9* pNormTex;
+			IDirect3DCubeTexture9* pCubeTex;
+			IDirect3DVolumeTexture9* pVolumeTex;
+			IDirect3DBaseTexture9* pBaseTex;
+			IDirect3DSurface9* pMultisampleSurface;
+			IDirect3DSurface9* pDepthStencilSurface;
+		};
+
+	public:
+		~D3D9TextureCore();
+
+		/** @copydoc Texture::isBindableAsShaderResource */
+		bool isBindableAsShaderResource() const override { return mIsBindableAsShaderResource; }
+
+		/**	Returns internal DirectX 9 texture object. */
+		IDirect3DBaseTexture9* getTexture_internal();	
+
+		/**	Returns internal DirectX 9 texture object pointing to a 1D or 2D texture. */
+		IDirect3DTexture9* getNormTexture_internal();
+
+		/**	Returns internal DirectX 9 texture object pointing to a cube texture. */
+		IDirect3DCubeTexture9* getCubeTexture_internal();
+
+		/**	Indicates whether the hardware gamma is enabled and supported. */
+		bool isHardwareGammaReadToBeUsed() const { return mProperties.isHardwareGammaEnabled() && mHwGammaReadSupported; }
+					
+		/**
+		 * Returns a hardware pixel buffer for a certain face and level of the texture.
+		 * 
+		 * @param[in]	face	Index of the texture face, if texture has more than one. Array index for texture arrays and
+		 *						a cube face for cube textures.
+		 * @param[in]	mipmap	Index of the mip level. 0 being the largest mip level.
+		 *
+		 * @note	Cube face indices: +X (0), -X (1), +Y (2), -Y (3), +Z (4), -Z (5)
+		 */
+		PixelBufferPtr getBuffer(UINT32 face, UINT32 mipmap);
+
+		/**
+		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
+		 */
+		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+	protected:	
+		friend class D3D9TextureCoreManager;
+		friend class D3D9PixelBuffer;
+
+		D3D9TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
+
+		/** @copydoc TextureCore::initialize */
+		void initialize() override;
+		
+		/** @copydoc TextureCore::lock */
+		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) override;
+
+		/** @copydoc TextureCore::unlock */
+		void unlockImpl() override;
+
+		/** @copydoc TextureCore::copy */
+		void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target) override;
+
+		/** @copydoc TextureCore::readData */
+		void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) override;
+
+		/** @copydoc TextureCore::writeData */
+		void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) override;
+
+		/**	Returns true if the texture should be allocated in the default pool. */
+		bool useDefaultPool();
+
+		/**	Creates a DirectX object for blank normal 1D/2D texture. */
+		void createNormTex(IDirect3DDevice9* d3d9Device);
+
+		/**	Creates a DirectX object for blank cube texture. */
+		void createCubeTex(IDirect3DDevice9* d3d9Device);
+
+		/**	Creates a DirectX object for blank volume (3D) texture. */	
+		void createVolumeTex(IDirect3DDevice9* d3d9Device);
+
+		/**	Selects a DirectX 9 pixel format depending on requested format and device capabilities. */
+		D3DFORMAT chooseD3DFormat(IDirect3DDevice9* d3d9Device);
+
+		/** @copydoc Texture::calculateSize */
+		UINT32 calculateSize() const;
+
+		/**	Creates internal resources for the texture for the specified device. */
+		void createInternalResources(IDirect3DDevice9* d3d9Device);
+
+		/** Updates texture attributes with final attributes provided by the API after the texture has been created. */
+		void setFinalAttributes(IDirect3DDevice9* d3d9Device, TextureResources* textureResources, 
+			UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
+
+		/**	Returns best texture filtering method. */
+		D3DTEXTUREFILTERTYPE getBestFilterMethod(IDirect3DDevice9* d3d9Device);
+
+		/**	Returns if the specified combination of texture type, format and usage supports dynamic texture usage. */
+		bool canUseDynamicTextures(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat);
+
+		/**	Returns if the specified combination of texture type, format and usage supports automatic mipmap generation. */
+		bool canAutoGenMipmaps(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat);
+
+		/**	Returns if the specified combination of texture type, format and usage supports hardware gamma. */
+		bool canUseHardwareGammaCorrection(IDirect3DDevice9* d3d9Device, DWORD srcUsage, D3DRESOURCETYPE srcType, D3DFORMAT srcFormat, bool forwriting);
+
+		/**
+		 * Creates a list of pixel buffers for all surfaces in the texture. This must be called after the texture has been
+		 * created.
+		 */
+		void createSurfaceList(IDirect3DDevice9* d3d9Device, TextureResources* textureResources);
+	 
+		/**	Retrieves texture resources for the device, or null if they don't exist. */
+		TextureResources* getTextureResources(IDirect3DDevice9* d3d9Device);
+
+		/**	Allocates a new set of texture resources for the device. */
+		TextureResources* allocateTextureResources(IDirect3DDevice9* d3d9Device);
+
+		/**	Frees all the given texture resources. */
+		void freeTextureResources(IDirect3DDevice9* d3d9Device, TextureResources* textureResources);
+
+		/**	Determines the pool in which to create the texture in. */
+		void determinePool();
+
+	protected:
+		Map<IDirect3DDevice9*, TextureResources*> mMapDeviceToTextureResources;
+
+		Vector<PixelBufferPtr> mSurfaceList;
+
+		D3DPOOL	mD3DPool;
+		bool mDynamicTextures;
+		bool mIsBindableAsShaderResource;
+
+		PixelBufferPtr mLockedBuffer;
+
+		bool mHwGammaReadSupported;
+		bool mHwGammaWriteSupported;
+		D3DMULTISAMPLE_TYPE mMultisampleType;
+		DWORD mMultisampleQuality;
+    };
+
+	/** @} */
 }

+ 49 - 59
Source/BansheeD3D9RenderAPI/Include/BsD3D9TextureManager.h

@@ -1,60 +1,50 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9Texture.h"
-#include "BsTextureManager.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles creation of DirectX 9 textures.
-	 */
-	class BS_D3D9_EXPORT D3D9TextureManager : public TextureManager
-	{
-	public:
-		D3D9TextureManager();
-		~D3D9TextureManager();
-
-		/**
-		 * @copydoc TextureManager::getNativeFormat
-		 */
-		PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma) override;
-
-	protected:	
-		/**
-		 * @copydoc TextureManager::createRenderTextureImpl
-		 */
-		RenderTexturePtr createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
-
-		/**
-		 * @copydoc TextureManager::createMultiRenderTextureImpl
-		 */
-		MultiRenderTexturePtr createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) override;
-	};
-
-	/**
-	 * @brief	Handles creation of DirectX 9 textures.
-	 */
-	class BS_D3D9_EXPORT D3D9TextureCoreManager : public TextureCoreManager
-	{
-	protected:		
-		/**
-		 * @copydoc	TextureCoreManager::createTextureInternal
-		 */
-		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
-
-		/**
-		 * @copydoc	TextureCoreManager::createRenderTextureInternal
-		 */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) override;
-
-		/**
-		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
-		 */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) override;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9Texture.h"
+#include "BsTextureManager.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	Handles creation of DirectX 9 textures. */
+	class BS_D3D9_EXPORT D3D9TextureManager : public TextureManager
+	{
+	public:
+		D3D9TextureManager();
+		~D3D9TextureManager();
+
+		/** @copydoc TextureManager::getNativeFormat */
+		PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma) override;
+
+	protected:	
+		/** @copydoc TextureManager::createRenderTextureImpl */
+		RenderTexturePtr createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
+
+		/** @copydoc TextureManager::createMultiRenderTextureImpl */
+		MultiRenderTexturePtr createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) override;
+	};
+
+	/**	Handles creation of DirectX 9 textures. */
+	class BS_D3D9_EXPORT D3D9TextureCoreManager : public TextureCoreManager
+	{
+	protected:		
+		/** @copydoc TextureCoreManager::createTextureInternal */
+		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
+			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
+
+		/** @copydoc TextureCoreManager::createRenderTextureInternal */
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) override;
+
+		/** @copydoc TextureCoreManager::createMultiRenderTextureInternal */
+		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) override;
+	};
+
+	/** @} */
 }

+ 71 - 91
Source/BansheeD3D9RenderAPI/Include/BsD3D9TimerQuery.h

@@ -1,92 +1,72 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsD3D9Resource.h"
-#include "BsTimerQuery.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @copydoc TimerQuery
-	 */
-	class BS_D3D9_EXPORT D3D9TimerQuery : public TimerQuery, public D3D9Resource
-	{
-	public:
-		D3D9TimerQuery();
-		~D3D9TimerQuery();
-
-		/**
-		 * @copydoc TimerQuery::begin
-		 */
-		virtual void begin();
-
-		/**
-		 * @copydoc TimerQuery::end
-		 */
-		virtual void end();
-
-		/**
-		 * @copydoc TimerQuery::isReady
-		 */
-		virtual bool isReady() const;
-
-		/**
-		 * @copydoc TimerQuery::getTimeMs
-		 */
-		virtual float getTimeMs();
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceLost
-		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceReset
-		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
-
-	private:
-		/**
-		 * @brief	Resolve timing information after the query has finished.
-		 */
-		void finalize();
-
-		/**
-		 * @brief	Creates the internal DX9 query.
-		 */
-		void createQuery();
-
-		/**
-		 * @brief	Releases the internal DX9 query.
-		 */
-		void releaseQuery();
-
-		/**
-		 * @brief	Checks if the internal query object is valid.
-		 */
-		bool isQueryValid() const;
-
-	private:
-		bool mFinalized;
-		bool mQueryIssued;
-		float mTimeDelta;
-
-		IDirect3DDevice9* mDevice;
-		IDirect3DQuery9* mBeginQuery;
-		IDirect3DQuery9* mEndQuery;
-		IDirect3DQuery9* mDisjointQuery;
-		IDirect3DQuery9* mFreqQuery;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsD3D9Resource.h"
+#include "BsTimerQuery.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** @copydoc TimerQuery */
+	class BS_D3D9_EXPORT D3D9TimerQuery : public TimerQuery, public D3D9Resource
+	{
+	public:
+		D3D9TimerQuery();
+		~D3D9TimerQuery();
+
+		/** @copydoc TimerQuery::begin */
+		void begin() override;
+
+		/** @copydoc TimerQuery::end */
+		void end() override;
+
+		/** @copydoc TimerQuery::isReady */
+		bool isReady() const override;
+
+		/** @copydoc TimerQuery::getTimeMs */
+		float getTimeMs() override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+	private:
+		/**	Resolve timing information after the query has finished. */
+		void finalize();
+
+		/**	Creates the internal DX9 query. */
+		void createQuery();
+
+		/**	Releases the internal DX9 query. */
+		void releaseQuery();
+
+		/**	Checks if the internal query object is valid. */
+		bool isQueryValid() const;
+
+	private:
+		bool mFinalized;
+		bool mQueryIssued;
+		float mTimeDelta;
+
+		IDirect3DDevice9* mDevice;
+		IDirect3DQuery9* mBeginQuery;
+		IDirect3DQuery9* mEndQuery;
+		IDirect3DQuery9* mDisjointQuery;
+		IDirect3DQuery9* mFreqQuery;
+	};
+
+	/** @} */
 }

+ 77 - 98
Source/BansheeD3D9RenderAPI/Include/BsD3D9VertexBuffer.h

@@ -1,99 +1,78 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsVertexBuffer.h"
-#include "BsD3D9Resource.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	DirectX 9 implementation of a vertex buffer.
-	 */
-    class BS_D3D9_EXPORT D3D9VertexBufferCore : public VertexBufferCore, public D3D9Resource
-    {   
-	protected:
-		/**
-		 * @brief	Container for internal buffer resources.
-		 */
-		struct BufferResources
-		{
-			IDirect3DVertexBuffer9*	mBuffer;
-			bool mOutOfDate;
-			UINT32 mLockOffset;
-			UINT32 mLockLength;
-			GpuLockOptions mLockOptions;
-		};
-
-    public:
-		D3D9VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
-		~D3D9VertexBufferCore();
-
-		/**
-		 * @copydoc	VertexBufferCore::readData
-		 */
-        void readData(UINT32 offset, UINT32 length, void* dest);
-
-		/**
-		 * @copydoc	VertexBufferCore::writeData
-		 */
-        void writeData(UINT32 offset, UINT32 length, const void* source, BufferWriteType writeFlags = BufferWriteType::Normal);
-	
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceLost
-		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceReset
-		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
-
-		/**
-		 * @brief	Creates a DX9 vertex buffer object in the provided memory pool.
-		 */
-		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL pool);
-		
-		/**
-		 * @brief	Returns the DX9 vertex buffer object.
-		 */
-        IDirect3DVertexBuffer9* getD3D9VertexBuffer();
-
-	protected:	
-		/**
-		 * @copydoc VertexBufferCore::initialize
-		 */
-		void initialize();	
-		
-		/**
-		 * @copydoc	VertexBufferCore::lockImpl
-		 */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-		/**
-		 * @copydoc	VertexBufferCore::unlockImpl
-		 */
-		void unlockImpl();
-
-		/**
-		 * @brief	Updates buffer resources from cached system memory buffer.
-		 */
-		bool updateBufferResources(const UINT8* systemMemoryBuffer, BufferResources* bufferResources);		
-
-	protected:
-		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
-		D3DVERTEXBUFFER_DESC mBufferDesc;	
-		UINT8* mSystemMemoryBuffer;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsVertexBuffer.h"
+#include "BsD3D9Resource.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	DirectX 9 implementation of a vertex buffer. */
+    class BS_D3D9_EXPORT D3D9VertexBufferCore : public VertexBufferCore, public D3D9Resource
+    {   
+	protected:
+		/**	Container for internal buffer resources. */
+		struct BufferResources
+		{
+			IDirect3DVertexBuffer9*	mBuffer;
+			bool mOutOfDate;
+			UINT32 mLockOffset;
+			UINT32 mLockLength;
+			GpuLockOptions mLockOptions;
+		};
+
+    public:
+		D3D9VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
+		~D3D9VertexBufferCore();
+
+		/** @copydoc VertexBufferCore::readData */
+        void readData(UINT32 offset, UINT32 length, void* dest) override;
+
+		/** @copydoc VertexBufferCore::writeData */
+        void writeData(UINT32 offset, UINT32 length, const void* source, 
+			BufferWriteType writeFlags = BufferWriteType::Normal) override;
+	
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceLost */
+		void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceReset */
+		void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
+
+		/**	Creates a DX9 vertex buffer object in the provided memory pool. */
+		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL pool);
+		
+		/**	Returns the DX9 vertex buffer object. */
+        IDirect3DVertexBuffer9* getD3D9VertexBuffer();
+
+	protected:	
+		/** @copydoc VertexBufferCore::initialize */
+		void initialize() override;
+		
+		/** @copydoc VertexBufferCore::lockImpl */
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+
+		/** @copydoc VertexBufferCore::unlockImpl */
+		void unlockImpl() override;
+
+		/**	Updates buffer resources from cached system memory buffer. */
+		bool updateBufferResources(const UINT8* systemMemoryBuffer, BufferResources* bufferResources);		
+
+	protected:
+		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
+		D3DVERTEXBUFFER_DESC mBufferDesc;	
+		UINT8* mSystemMemoryBuffer;
+    };
+
+	/** @} */
 }

+ 42 - 46
Source/BansheeD3D9RenderAPI/Include/BsD3D9VertexDeclaration.h

@@ -1,47 +1,43 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsVertexDeclaration.h"
-#include "BsD3D9Resource.h"
-
-namespace BansheeEngine 
-{ 
-	/**
-	 * @brief	DirectX 9 implementation of a vertex declaration.
-	 */
-    class BS_D3D9_EXPORT D3D9VertexDeclarationCore : public VertexDeclarationCore, public D3D9Resource
-    {
-    public:
-		~D3D9VertexDeclarationCore();
-        
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
-		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
-
-		/**
-		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
-		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
-
-		/**
-		 * @brief	Creates a DirectX 9 vertex declaration object.
-		 */
-        IDirect3DVertexDeclaration9* getD3DVertexDeclaration();
-
-	protected:
-		friend class D3D9HardwareBufferCoreManager;
-
-		D3D9VertexDeclarationCore(const List<VertexElement>& elements);
-
-		/**
-		 * @brief	Releases the internal DirectX 9 vertex declaration object.
-		 */
-		void releaseDeclaration();
-
-	protected:        
-		Map<IDirect3DDevice9*, IDirect3DVertexDeclaration9*> mMapDeviceToDeclaration;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsVertexDeclaration.h"
+#include "BsD3D9Resource.h"
+
+namespace BansheeEngine 
+{ 
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/**	DirectX 9 implementation of a vertex declaration. */
+    class BS_D3D9_EXPORT D3D9VertexDeclarationCore : public VertexDeclarationCore, public D3D9Resource
+    {
+    public:
+		~D3D9VertexDeclarationCore();
+        
+		/** @copydoc D3D9Resource::notifyOnDeviceCreate */
+		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
+
+		/** @copydoc D3D9Resource::notifyOnDeviceDestroy */
+		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
+
+		/**	Creates a DirectX 9 vertex declaration object. */
+        IDirect3DVertexDeclaration9* getD3DVertexDeclaration();
+
+	protected:
+		friend class D3D9HardwareBufferCoreManager;
+
+		D3D9VertexDeclarationCore(const List<VertexElement>& elements);
+
+		/**	Releases the internal DirectX 9 vertex declaration object. */
+		void releaseDeclaration();
+
+	protected:        
+		Map<IDirect3DDevice9*, IDirect3DVertexDeclaration9*> mMapDeviceToDeclaration;
+    };
+
+	/** @} */
 }

+ 46 - 46
Source/BansheeD3D9RenderAPI/Include/BsD3D9VideoModeInfo.h

@@ -1,47 +1,47 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D9Prerequisites.h"
-#include "BsVideoModeInfo.h"
-
-namespace BansheeEngine
-{
-	/**
-	* @copydoc	VideoMode
-	*/
-	class BS_D3D9_EXPORT D3D9VideoMode : public VideoMode
-	{
-	public:
-		D3D9VideoMode(UINT32 width, UINT32 height, float refreshRate, UINT32 outputIdx);
-
-	private:
-		friend class D3D9VideoOutputInfo;
-	};
-
-	/**
-	* @copydoc	VideoOutputInfo
-	*/
-	class BS_D3D9_EXPORT D3D9VideoOutputInfo : public VideoOutputInfo
-	{
-	public:
-		D3D9VideoOutputInfo(IDirect3D9* d3d9device, UINT32 adapterIdx);
-
-		/**
-		 * @brief	Gets a Win32 handle to the monitor referenced by this object.
-		 */
-		HMONITOR getMonitorHandle() const { return mMonitorHandle; }
-
-	private:
-		HMONITOR mMonitorHandle;
-	};
-
-	/**
-	* @copydoc	VideoModeInfo
-	*/
-	class BS_D3D9_EXPORT D3D9VideoModeInfo : public VideoModeInfo
-	{
-	public:
-		D3D9VideoModeInfo(IDirect3D9* d3d9device);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsD3D9Prerequisites.h"
+#include "BsVideoModeInfo.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup D3D9
+	 *  @{
+	 */
+
+	/** @copydoc VideoMode */
+	class BS_D3D9_EXPORT D3D9VideoMode : public VideoMode
+	{
+	public:
+		D3D9VideoMode(UINT32 width, UINT32 height, float refreshRate, UINT32 outputIdx);
+
+	private:
+		friend class D3D9VideoOutputInfo;
+	};
+
+	/** @copydoc VideoOutputInfo	*/
+	class BS_D3D9_EXPORT D3D9VideoOutputInfo : public VideoOutputInfo
+	{
+	public:
+		D3D9VideoOutputInfo(IDirect3D9* d3d9device, UINT32 adapterIdx);
+
+		/**
+		 * @brief	Gets a Win32 handle to the monitor referenced by this object.
+		 */
+		HMONITOR getMonitorHandle() const { return mMonitorHandle; }
+
+	private:
+		HMONITOR mMonitorHandle;
+	};
+
+	/** @copydoc VideoModeInfo */
+	class BS_D3D9_EXPORT D3D9VideoModeInfo : public VideoModeInfo
+	{
+	public:
+		D3D9VideoModeInfo(IDirect3D9* d3d9device);
+	};
+
+	/** @} */
 }

+ 1 - 1
Source/BansheeFBXImporter/Include/BsFBXPrerequisites.h

@@ -20,7 +20,7 @@
 #    define BS_FBX_EXPORT
 #endif
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup FBX BansheeFBXImporter
  *	Mesh importer for FBX file format.

+ 1 - 1
Source/BansheeFontImporter/Include/BsFontPrerequisites.h

@@ -20,7 +20,7 @@
 #    define BS_FONT_EXPORT
 #endif
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup Font BansheeFontImporter
  *	FreeType importer for font file formats (TTF, OTF).

+ 1 - 1
Source/BansheeFreeImgImporter/Include/BsFreeImgPrerequisites.h

@@ -20,7 +20,7 @@
 #    define BS_FREEIMG_EXPORT
 #endif
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup FreeImg BansheeFreeImgImporter
  *	FreeImg importer for importing most popular image formats (e.g. PSD, PNG, JPG, etc.).

+ 33 - 34
Source/BansheeGLRenderAPI/Include/BsGLContext.h

@@ -1,34 +1,33 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Abstract class that encapsulated an OpenGL context. Each platform
-	 *			should provide its own GLContext specialization.
-	 */
-    class BS_RSGL_EXPORT GLContext
-    {
-    public:
-        GLContext();
-        virtual ~GLContext();
-
-		/**
-		 * @brief	Activates the rendering context (all subsequent rendering commands will be executed on it).
-		 */
-        virtual void setCurrent() = 0;
-
-		/**
-		 * @brief	Deactivates the rendering context. Normally called just before setCurrent is called on another context.
-		 */
-        virtual void endCurrent() = 0;
-        
-		/**
-		 * @brief	Releases the render context, freeing all of its resources.
-		 */
-		virtual void releaseContext() {}
-    };
-}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**
+	 * Abstract class that encapsulated an OpenGL context. Each platform should provide its own GLContext specialization.
+	 */
+    class BS_RSGL_EXPORT GLContext
+    {
+    public:
+        GLContext();
+        virtual ~GLContext();
+
+		/**	Activates the rendering context (all subsequent rendering commands will be executed on it). */
+        virtual void setCurrent() = 0;
+
+		/**	Deactivates the rendering context. Normally called just before setCurrent is called on another context. */
+        virtual void endCurrent() = 0;
+        
+		/**	Releases the render context, freeing all of its resources. */
+		virtual void releaseContext() {}
+    };
+
+	/** @} */
+}

+ 31 - 31
Source/BansheeGLRenderAPI/Include/BsGLEventQuery.h

@@ -1,32 +1,32 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsEventQuery.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @copydoc EventQuery
-	 */
-	class BS_RSGL_EXPORT GLEventQuery : public EventQuery
-	{
-	public:
-		GLEventQuery();
-		~GLEventQuery();
-
-		/**
-		 * @copydoc EventQuery::begin
-		 */
-		virtual void begin();
-
-		/**
-		 * @copydoc EventQuery::isReady
-		 */
-		virtual bool isReady() const;
-
-	private:
-		GLuint mQueryObj;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsEventQuery.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/** @copydoc EventQuery */
+	class BS_RSGL_EXPORT GLEventQuery : public EventQuery
+	{
+	public:
+		GLEventQuery();
+		~GLEventQuery();
+
+		/** @copydoc EventQuery::begin */
+		void begin() override;
+
+		/** @copydoc EventQuery::isReady */
+		bool isReady() const override;
+
+	private:
+		GLuint mQueryObj;
+	};
+
+	/** @} */
 }

+ 90 - 95
Source/BansheeGLRenderAPI/Include/BsGLFrameBufferObject.h

@@ -1,96 +1,91 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGLContext.h"
-#include "BsGLPixelBuffer.h"
-#include "BsPixelData.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Describes OpenGL frame buffer surface.
-	 */
-    struct BS_RSGL_EXPORT GLSurfaceDesc
-    {
-    public:
-		GLSurfaceDesc() 
-			:zoffset(0), numSamples(0) 
-		{ }
-
-		GLPixelBufferPtr buffer;
-		UINT32 zoffset;
-		UINT32 numSamples;
-    };
-
-	/**
-	 * @brief	Manages an OpenGL frame-buffer object. Frame buffer object
-	 *			is used as a rendering destination in the render system pipeline,
-	 *			and it may consist out of one or multiple color surfaces and an optional
-	 *			depth/stencil surface.
-	 */
-    class BS_RSGL_EXPORT GLFrameBufferObject
-    {
-    public:
-        GLFrameBufferObject();
-        ~GLFrameBufferObject();
-
-		/**
-		 * @brief	Binds a color surface to the specific attachment point.
-		 *
-		 * @param	attachment	Attachment point index in the range [0, BS_MAX_MULTIPLE_RENDER_TARGETS).
-		 * @param	target		Description of the color surface to attach.
-		 *
-		 * @note	Multisample counts of all surfaces must match.
-		 *			0th attachment must be bound in order for the object to be usable, rest are optional.
-		 */
-        void bindSurface(UINT32 attachment, const GLSurfaceDesc& target);
-
-		/**
-		 * @brief	Unbinds the attachment at the specified attachment index.
-		 *
-		 * @param	attachment	Attachment point index in the range [0, BS_MAX_MULTIPLE_RENDER_TARGETS).
-		 */
-        void unbindSurface(UINT32 attachment);
-
-		/**
-		 * @brief	Binds a depth/stencil buffer.
-		 *
-		 * @note	Multisample counts of depth/stencil and color surfaces must match.
-		 *			Binding a depth/stencil buffer is optional.
-		 */
-		void bindDepthStencil(GLPixelBufferPtr depthStencilBuffer);
-
-		/**
-		 * @brief	Unbinds a depth stencil buffer.
-		 */
-		void unbindDepthStencil();
-        
-		/**
-		 * @brief	Binds the frame buffer object to the OpenGL pipeline, making it used
-		 *			for any further rendering operations.
-		 */
-        void bind();
-
-		/** Checks is the color buffer at the specified index bound. */
-		bool hasColorBuffer(UINT32 idx) const { return mColor[idx].buffer != nullptr; }
-
-		/**
-		 * @brief	Returns internal OpenGL frame buffer id.
-		 */
-		GLuint getGLFBOID() const { return mFB; }
-
-    private:
-		/**
-		 * @brief	Rebuilds internal frame buffer object. Should be called whenever surfaces change.
-		 */
-        void rebuild();
-
-	private:
-        GLuint mFB;
-
-        GLSurfaceDesc mColor[BS_MAX_MULTIPLE_RENDER_TARGETS];
-		GLPixelBufferPtr mDepthStencilBuffer;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGLContext.h"
+#include "BsGLPixelBuffer.h"
+#include "BsPixelData.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Describes OpenGL frame buffer surface. */
+    struct BS_RSGL_EXPORT GLSurfaceDesc
+    {
+    public:
+		GLSurfaceDesc() 
+			:zoffset(0), numSamples(0) 
+		{ }
+
+		GLPixelBufferPtr buffer;
+		UINT32 zoffset;
+		UINT32 numSamples;
+    };
+
+	/**
+	 * Manages an OpenGL frame-buffer object. Frame buffer object is used as a rendering destination in the render system
+	 * pipeline, and it may consist out of one or multiple color surfaces and an optional depth/stencil surface.
+	 */
+    class BS_RSGL_EXPORT GLFrameBufferObject
+    {
+    public:
+        GLFrameBufferObject();
+        ~GLFrameBufferObject();
+
+		/**
+		 * Binds a color surface to the specific attachment point.
+		 *
+		 * @param[in]	attachment	Attachment point index in the range [0, BS_MAX_MULTIPLE_RENDER_TARGETS).
+		 * @param[in]	target		Description of the color surface to attach.
+		 *
+		 * @note	
+		 * Multisample counts of all surfaces must match.
+		 * 0th attachment must be bound in order for the object to be usable, rest are optional.
+		 */
+        void bindSurface(UINT32 attachment, const GLSurfaceDesc& target);
+
+		/**
+		 * Unbinds the attachment at the specified attachment index.
+		 *
+		 * @param[in]	attachment	Attachment point index in the range [0, BS_MAX_MULTIPLE_RENDER_TARGETS).
+		 */
+        void unbindSurface(UINT32 attachment);
+
+		/**
+		 * Binds a depth/stencil buffer.
+		 *
+		 * @note	
+		 * Multisample counts of depth/stencil and color surfaces must match.
+		 * Binding a depth/stencil buffer is optional.
+		 */
+		void bindDepthStencil(GLPixelBufferPtr depthStencilBuffer);
+
+		/**	Unbinds a depth stencil buffer. */
+		void unbindDepthStencil();
+        
+		/** Binds the frame buffer object to the OpenGL pipeline, making it used for any further rendering operations. */
+        void bind();
+
+		/** Checks is the color buffer at the specified index bound. */
+		bool hasColorBuffer(UINT32 idx) const { return mColor[idx].buffer != nullptr; }
+
+		/**	Returns internal OpenGL frame buffer id. */
+		GLuint getGLFBOID() const { return mFB; }
+
+    private:
+		/**	Rebuilds internal frame buffer object. Should be called whenever surfaces change. */
+        void rebuild();
+
+	private:
+        GLuint mFB;
+
+        GLSurfaceDesc mColor[BS_MAX_MULTIPLE_RENDER_TARGETS];
+		GLPixelBufferPtr mDepthStencilBuffer;
+    };
+
+	/** @} */
 }

+ 54 - 66
Source/BansheeGLRenderAPI/Include/BsGLGpuBuffer.h

@@ -1,67 +1,55 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGpuBuffer.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	OpenGL implementation of a generic GPU buffer.
-	 */
-	// TODO - Not implemented, just a dummy class for now
-	class BS_RSGL_EXPORT GLGpuBufferCore : public GpuBufferCore
-	{
-	public:
-		~GLGpuBufferCore();
-
-		/**
-		 * @copydoc GpuBufferCore::lock
-		 */
-		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-		/**
-		 * @copydoc GpuBufferCore::unlock
-		 */
-		virtual void unlock();
-
-		/**
-		 * @copydoc GpuBufferCore::readData
-		 */
-        virtual void readData(UINT32 offset, UINT32 length, void* pDest);
-
-		/**
-		 * @copydoc GpuBufferCore::writeData
-		 */
-        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**
-		 * @copydoc GpuBufferCore::copyData
-		 */
-		void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
-
-	protected:
-		friend class GLHardwareBufferCoreManager;
-
-		GLGpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, 
-			GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
-
-		/**
-		 * @copydoc GpuBufferCore::initialize
-		 */
-		void initialize();	
-
-		/**
-		 * @copydoc GpuBufferCore::createView
-		 */
-		virtual GpuBufferView* createView();
-
-		/**
-		 * @copydoc GpuBufferCore::destroyView
-		 */
-		virtual void destroyView(GpuBufferView* view);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGpuBuffer.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of a generic GPU buffer. */
+	// TODO - Not implemented, just a dummy class for now
+	class BS_RSGL_EXPORT GLGpuBufferCore : public GpuBufferCore
+	{
+	public:
+		~GLGpuBufferCore();
+
+		/** @copydoc GpuBufferCore::lock */
+		void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+
+		/** @copydoc GpuBufferCore::unlock */
+		void unlock() override;
+
+		/** @copydoc GpuBufferCore::readData */
+        void readData(UINT32 offset, UINT32 length, void* pDest) override;
+
+		/** @copydoc GpuBufferCore::writeData */
+        void writeData(UINT32 offset, UINT32 length, const void* pSource,
+				BufferWriteType writeFlags = BufferWriteType::Normal) override;
+
+		/** @copydoc GpuBufferCore::copyData */
+		void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) override;
+
+	protected:
+		friend class GLHardwareBufferCoreManager;
+
+		GLGpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, 
+			GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+		/** @copydoc GpuBufferCore::initialize */
+		void initialize() override;
+
+		/** @copydoc GpuBufferCore::createView */
+		virtual GpuBufferView* createView() override;
+
+		/** @copydoc GpuBufferCore::destroyView */
+		virtual void destroyView(GpuBufferView* view) override;
+	};
+
+	/** @} */
 }

+ 37 - 41
Source/BansheeGLRenderAPI/Include/BsGLGpuParamBlockBuffer.h

@@ -1,42 +1,38 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGpuParamBlockBuffer.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	OpenGL implementation of a GPU parameter buffer (Uniform buffer).
-	 */
-	class BS_RSGL_EXPORT GLGpuParamBlockBufferCore : public GpuParamBlockBufferCore
-	{
-	public:
-		GLGpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage);
-		~GLGpuParamBlockBufferCore();
-
-		/**
-		 * @copydoc GpuParamBlockBufferCore::writeData
-		 */
-		void writeToGPU(const UINT8* data);
-
-		/**
-		 * @copydoc GpuParamBlockBufferCore::readData
-		 */
-		void readFromGPU(UINT8* data) const;
-
-		/**
-		 * @brief	Returns internal OpenGL uniform buffer handle.
-		 */
-		GLuint getGLHandle() const { return mGLHandle; }
-	protected:
-		/**
-		 * @copydoc GpuParamBlockBufferCore::initialize
-		 */
-		virtual void initialize();
-
-	private:
-		GLuint mGLHandle;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGpuParamBlockBuffer.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of a GPU parameter buffer (Uniform buffer). */
+	class BS_RSGL_EXPORT GLGpuParamBlockBufferCore : public GpuParamBlockBufferCore
+	{
+	public:
+		GLGpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage);
+		~GLGpuParamBlockBufferCore();
+
+		/** @copydoc GpuParamBlockBufferCore::writeData */
+		void writeToGPU(const UINT8* data) override;
+
+		/** @copydoc GpuParamBlockBufferCore::readData */
+		void readFromGPU(UINT8* data) const override;
+
+		/**	Returns internal OpenGL uniform buffer handle. */
+		GLuint getGLHandle() const { return mGLHandle; }
+	protected:
+		/** @copydoc GpuParamBlockBufferCore::initialize */
+		virtual void initialize()override ;
+
+	private:
+		GLuint mGLHandle;
+	};
+
+	/** @} */
 }

+ 40 - 46
Source/BansheeGLRenderAPI/Include/BsGLHardwareBufferManager.h

@@ -1,47 +1,41 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsHardwareBufferManager.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles creation of OpenGL specific hardware buffers.
-	 */
-    class BS_RSGL_EXPORT GLHardwareBufferCoreManager : public HardwareBufferCoreManager
-    {
-    public:
-		/**
-		 * @brief	Converts engine buffer usage flags into OpenGL specific flags.
-		 */
-		static GLenum getGLUsage(GpuBufferUsage usage);
-
-		/**
-		 * @brief	Converts vertex element type into OpenGL specific type.
-		 */
-        static GLenum getGLType(VertexElementType type);
-
-	protected:
-		/**
-		 * @copydoc HardwareBufferCoreManager::createVertexBufferImpl
-		 */
-        SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, 
-			UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) override;
-
-		/**
-		 * @copydoc HardwareBufferCoreManager::createIndexBufferImpl
-		 */
-		SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) override;
-
-		/** @copydoc HardwareBufferCoreManager::createGpuParamBlockBufferInternal */
-		SPtr<GpuParamBlockBufferCore> createGpuParamBlockBufferInternal(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC) override;
-
-		/**
-		 * @copydoc HardwareBufferCoreManager::createGenericBufferInternal
-		 */
-		SPtr<GpuBufferCore> createGpuBufferInternal(UINT32 elementCount, UINT32 elementSize, 
-			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false) override;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsHardwareBufferManager.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Handles creation of OpenGL specific hardware buffers. */
+    class BS_RSGL_EXPORT GLHardwareBufferCoreManager : public HardwareBufferCoreManager
+    {
+    public:
+		/**	Converts engine buffer usage flags into OpenGL specific flags. */
+		static GLenum getGLUsage(GpuBufferUsage usage);
+
+		/**	Converts vertex element type into OpenGL specific type. */
+        static GLenum getGLType(VertexElementType type);
+
+	protected:
+		/** @copydoc HardwareBufferCoreManager::createVertexBufferImpl */
+        SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, 
+			UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) override;
+
+		/** @copydoc HardwareBufferCoreManager::createIndexBufferImpl */
+		SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) override;
+
+		/** @copydoc HardwareBufferCoreManager::createGpuParamBlockBufferInternal */
+		SPtr<GpuParamBlockBufferCore> createGpuParamBlockBufferInternal(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC) override;
+
+		/** @copydoc HardwareBufferCoreManager::createGenericBufferInternal */
+		SPtr<GpuBufferCore> createGpuBufferInternal(UINT32 elementCount, UINT32 elementSize, 
+			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false) override;
+    };
+
+	/** @} */
 }

+ 46 - 54
Source/BansheeGLRenderAPI/Include/BsGLIndexBuffer.h

@@ -1,55 +1,47 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsIndexBuffer.h"
-
-namespace BansheeEngine 
-{ 
-	/**
-	 * @brief	OpenGL implementation of an index buffer.
-	 */
-    class BS_RSGL_EXPORT GLIndexBufferCore : public IndexBufferCore
-    {
-    public:
-		GLIndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-		~GLIndexBufferCore();
-
-		/**
-		 * @copydoc IndexBufferCore::readData
-		 */
-        void readData(UINT32 offset, UINT32 length, void* pDest);
-
-		/**
-		 * @copydoc IndexBufferCore::writeData
-		 */
-        void writeData(UINT32 offset, UINT32 length, const void* pSource, 
-			BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**
-		 * @brief	Returns internal OpenGL index buffer handle.
-		 */
-        GLuint getGLBufferId() const { return mBufferId; }
-
-	protected:
-		/**
-		 * @copydoc IndexBufferCore::initialize
-		 */
-		void initialize();	
-
-		/**
-		 * @copydoc IndexBufferCore::lockImpl
-		 */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-		/**
-		 * @copydoc IndexBufferCore::unlockImpl
-		 */
-		void unlockImpl();
-
-	private:
-		GLuint mBufferId;
-		bool mZeroLocked;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsIndexBuffer.h"
+
+namespace BansheeEngine 
+{ 
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of an index buffer. */
+    class BS_RSGL_EXPORT GLIndexBufferCore : public IndexBufferCore
+    {
+    public:
+		GLIndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
+		~GLIndexBufferCore();
+
+		/** @copydoc IndexBufferCore::readData */
+        void readData(UINT32 offset, UINT32 length, void* pDest) override;
+
+		/** @copydoc IndexBufferCore::writeData */
+        void writeData(UINT32 offset, UINT32 length, const void* pSource, 
+			BufferWriteType writeFlags = BufferWriteType::Normal) override;
+
+		/**	Returns internal OpenGL index buffer handle. */
+        GLuint getGLBufferId() const { return mBufferId; }
+
+	protected:
+		/** @copydoc IndexBufferCore::initialize */
+		void initialize() override;	
+
+		/** @copydoc IndexBufferCore::lockImpl */
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+
+		/** @copydoc IndexBufferCore::unlockImpl */
+		void unlockImpl() override;
+
+	private:
+		GLuint mBufferId;
+		bool mZeroLocked;
+    };
+
+	/** @} */
 }

+ 66 - 68
Source/BansheeGLRenderAPI/Include/BsGLMultiRenderTexture.h

@@ -1,69 +1,67 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsMultiRenderTexture.h"
-#include "BsGLFrameBufferObject.h"
-
-namespace BansheeEngine
-{
-	class GLMultiRenderTexture;
-
-	/**
-	 * @brief	OpenGL implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_RSGL_EXPORT GLMultiRenderTextureCore : public MultiRenderTextureCore
-	{
-	public:
-		GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~GLMultiRenderTextureCore();
-
-		/**
-		 * @copydoc MultiRenderTextureCore::getCustomAttribute
-		 */
-		void getCustomAttribute(const String& name, void* pData) const override;
-	protected:
-		friend class GLTextureManager;
-
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
-		virtual void initialize() override;
-
-	private:
-		GLFrameBufferObject* mFB;
-
-		/**
-		 * @copydoc	MultiRenderTextureCore::getProperties
-		 */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
-
-	/**
-	* @brief	OpenGL implementation of a render texture with multiple color surfaces.
-	*
-	* @note	Sim thread only.
-	*/
-	class BS_RSGL_EXPORT GLMultiRenderTexture : public MultiRenderTexture
-	{
-	public:
-		virtual ~GLMultiRenderTexture() { }
-
-	protected:
-		friend class GLTextureManager;
-
-		GLMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/**
-		 * @copydoc	MultiRenderTexture::getProperties
-		 */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsMultiRenderTexture.h"
+#include "BsGLFrameBufferObject.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	class GLMultiRenderTexture;
+
+	/**
+	 * OpenGL implementation of a render texture with multiple color surfaces.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_RSGL_EXPORT GLMultiRenderTextureCore : public MultiRenderTextureCore
+	{
+	public:
+		GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
+		virtual ~GLMultiRenderTextureCore();
+
+		/** @copydoc MultiRenderTextureCore::getCustomAttribute */
+		void getCustomAttribute(const String& name, void* pData) const override;
+	protected:
+		friend class GLTextureManager;
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize() override;
+
+	private:
+		GLFrameBufferObject* mFB;
+
+		/** @copydoc MultiRenderTextureCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		MultiRenderTextureProperties mProperties;
+	};
+
+	/**
+	 * OpenGL implementation of a render texture with multiple color surfaces.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_RSGL_EXPORT GLMultiRenderTexture : public MultiRenderTexture
+	{
+	public:
+		virtual ~GLMultiRenderTexture() { }
+
+	protected:
+		friend class GLTextureManager;
+
+		GLMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
+
+		/** @copydoc MultiRenderTexture::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		MultiRenderTextureProperties mProperties;
+	};
+
+	/** @} */
 }

+ 47 - 54
Source/BansheeGLRenderAPI/Include/BsGLOcclusionQuery.h

@@ -1,55 +1,48 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsOcclusionQuery.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	OpenGL implementation of an occlusion query.
-	 */
-	class BS_RSGL_EXPORT GLOcclusionQuery : public OcclusionQuery
-	{
-	public:
-		GLOcclusionQuery(bool binary);
-		~GLOcclusionQuery();
-
-		/**
-		 * @copydoc OcclusionQuery::begin
-		 */
-		virtual void begin();
-
-		/**
-		 * @copydoc OcclusionQuery::end
-		 */
-		virtual void end();
-
-		/**
-		 * @copydoc OcclusionQuery::isReady
-		 */
-		virtual bool isReady() const;
-
-		/**
-		 * @copydoc OcclusionQuery::getNumFragments
-		 */
-		virtual UINT32 getNumSamples();
-
-	private:
-		friend class QueryManager;
-
-		/**
-		 * @brief	Processes query results and saves them for later use. To be called
-		 *			when query has completed.
-		 */
-		void finalize();
-
-	private:
-		GLuint mQueryObj;
-		bool mFinalized;
-		bool mEndIssued;
-
-		UINT32 mNumSamples;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsOcclusionQuery.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of an occlusion query. */
+	class BS_RSGL_EXPORT GLOcclusionQuery : public OcclusionQuery
+	{
+	public:
+		GLOcclusionQuery(bool binary);
+		~GLOcclusionQuery();
+
+		/** @copydoc OcclusionQuery::begin */
+		void begin() override;
+
+		/** @copydoc OcclusionQuery::end */
+		void end() override;
+
+		/** @copydoc OcclusionQuery::isReady */
+		bool isReady() const override;
+
+		/** @copydoc OcclusionQuery::getNumFragments */
+		UINT32 getNumSamples() override;
+
+	private:
+		friend class QueryManager;
+
+		/** Processes query results and saves them for later use. To be called when query has completed. */
+		void finalize();
+
+	private:
+		GLuint mQueryObj;
+		bool mFinalized;
+		bool mEndIssued;
+
+		UINT32 mNumSamples;
+	};
+
+	/** @} */
 }

+ 158 - 179
Source/BansheeGLRenderAPI/Include/BsGLPixelBuffer.h

@@ -1,180 +1,159 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsPixelBuffer.h"
-
-namespace BansheeEngine 
-{
-	class GLTextureBuffer;
-
-	/**
-	 * @brief	OpenGL implementation of a pixel buffer. Represents a hardware buffer
-	 *			containing a surface of pixels.
-	 */
-	class BS_RSGL_EXPORT GLPixelBuffer : public PixelBuffer
-	{
-	public:
-		/**
-		 * @brief	Constructs a new pixel buffer with the provided settings.
-		 *
-		 * @param	width			Width of the pixel buffer in pixels.
-		 * @param	height			Height of the pixel buffer in pixels.
-		 * @param	depth			Depth of the pixel buffer in pixels (number of 2D slices).
-		 * @param	format			Format of each pixel in the buffer.
-		 * @param	usage			Usage signaling the render system how we plan on using the buffer.
-		 */
-		GLPixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth,
-			PixelFormat mFormat, GpuBufferUsage usage);
-
-		~GLPixelBuffer();
-
-		/**
-		 * @brief	Upload some pixel data to the buffer.
-		 *
-		 * @param	data	Data to upload.
-		 * @param	dest	Coordinates to which to upload the data.
-		 */
-		virtual void upload(const PixelData& data, const PixelVolume& dest);
-
-		/**
-		 * @brief	Reads data from the pixel buffer into the provided object.
-		 *			Caller must ensure the data object is of adequate size.
-		 */
-		virtual void download(const PixelData& data);
-
-		/**
-		 * @brief	Binds the buffers to a frame buffer object at the specified attachment point.
-		 *
-		 * @param	attachment	Attachment point index in the range [0, BS_MAX_MULTIPLE_RENDER_TARGETS).
-		 * @param	zoffset		Depth slice to bind, in the case of a 3D texture.
-		 */
-		virtual void bindToFramebuffer(GLenum attachment, UINT32 zoffset);
-
-		/**
-		 * @brief	Returns internal OpenGL pixel format used by the buffer.
-		 */
-		GLenum getGLFormat() { return mGLInternalFormat; }
-
-		/**
-		 * @brief	Blits the contents of the provided buffer into this pixel buffer.
-		 *			Data is bilinearily interpolated in case buffer sizes don't match.
-		 */
-		virtual void blitFromTexture(GLTextureBuffer* src);
-
-		/**
-		 * @brief	Blits contents of a sub-region of the provided buffer into a sub-region of this pixel buffer.
-		 *			Data is bilinearily interpolated in case source and destination sizes don't match.
-		 */
-		virtual void blitFromTexture(GLTextureBuffer* src, const PixelVolume& srcBox, const PixelVolume& dstBox);
-
-	protected:  
-		/**
-		 * @copydoc	PixelBuffer::lockImpl
-		 */
-		PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options);
-
-		/**
-		 * @copydoc	PixelBuffer::unlockImpl
-		 */
-		void unlockImpl();
-
-		/**
-		 * @brief	Allocates an internal buffer on the CPU, the size of the hardware buffer.
-		 */
-		void allocateBuffer();
-
-		/**
-		 * @brief	Deallocates the internal CPU buffer.
-		 */
-		void freeBuffer();
-
-	protected:
-		PixelData mBuffer;
-		GLenum mGLInternalFormat;
-		GpuLockOptions mCurrentLockOptions;
-	};
-
-	/**
-	 * @brief	Pixel buffer specialization that represents a single surface in a texture.
-	 */
-    class BS_RSGL_EXPORT GLTextureBuffer : public GLPixelBuffer
-	{
-    public:
-		/**
-		 * @brief	Constructs a new texture buffer from a specific surface in the provided texture.
-		 *
-		 * @param	target				OpenGL type of the texture to retrieve the surface from.
-		 * @param	id					OpenGL handle to the texture to retrieve the surface from.
-		 * @param	face				Face index of the texture in the case of cube textures or texture arrays.
-		 * @param	level				Mip level of the texture.
-		 * @param	usage				Usage signaling the render system how we plan on using the buffer.
-		 * @param	writeGamma			True if the parent texture was created with SRGB support.
-		 * @param	multisampleCount	Number of samples the parent texture was created with.
-		 */
-		GLTextureBuffer(GLenum target, GLuint id, GLint face, 
-			GLint level, GpuBufferUsage usage, bool writeGamma, UINT32 multisampleCount);
-        ~GLTextureBuffer();
-        
-		/**
-		 * @copydoc	GLPixelBuffer::bindToFramebuffer
-		 */
-        virtual void bindToFramebuffer(GLenum attachment, UINT32 zoffset);
-
-		/**
-		 * @copydoc	GLPixelBuffer::upload
-		 */
-		virtual void upload(const PixelData &data, const PixelVolume &dest);
-
-		/**
-		 * @copydoc	GLPixelBuffer::download
-		 */
-		virtual void download(const PixelData &data);
-  
-		/**
-		 * @copydoc	GLPixelBuffer::blitFromTexture
-		 */
-		void blitFromTexture(GLTextureBuffer *src, const PixelVolume &srcBox, const PixelVolume &dstBox);
-
-        /**
-         * @brief	Populate texture buffer with the data in the currently attached frame buffer.
-		 *
-		 * @param	zoffset		3D slice of the texture to copy to. 0 if texture is not 3D.
-         */
-        void copyFromFramebuffer(UINT32 zoffset);
-
-    protected:
-		GLenum mTarget;
-		GLenum mFaceTarget;
-		GLuint mTextureID;
-		GLint mFace;
-		GLint mLevel;
-		UINT32 mMultisampleCount;
-    };
-
-	/**
-	 * @brief	Pixel buffer specialization that represents a render buffer.
-	 */
-    class BS_RSGL_EXPORT GLRenderBuffer : public GLPixelBuffer
-	{
-    public:
-		/**
-		 * @brief	Initializes a new render buffer.
-		 *
-		 * @param	format		OpenGL pixel format.
-		 * @param	width		Width of the render buffer in pixels.
-		 * @param	height		Height of the render buffer in pixels.
-		 * @param	numSamples	Number of samples to support.
-		 */
-        GLRenderBuffer(GLenum format, UINT32 width, UINT32 height, GLsizei numSamples);
-        ~GLRenderBuffer();
-        
-		/**
-		 * @copydoc	GLPixelBuffer::bindToFramebuffer
-		 */
-        virtual void bindToFramebuffer(GLenum attachment, UINT32 zoffset);
-    protected:
-        GLuint mRenderbufferID;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsPixelBuffer.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	class GLTextureBuffer;
+
+	/** OpenGL implementation of a pixel buffer. Represents a hardware buffer containing a surface of pixels. */
+	class BS_RSGL_EXPORT GLPixelBuffer : public PixelBuffer
+	{
+	public:
+		/**
+		 * Constructs a new pixel buffer with the provided settings.
+		 *
+		 * @param[in]	width			Width of the pixel buffer in pixels.
+		 * @param[in]	height			Height of the pixel buffer in pixels.
+		 * @param[in]	depth			Depth of the pixel buffer in pixels (number of 2D slices).
+		 * @param[in]	format			Format of each pixel in the buffer.
+		 * @param[in]	usage			Usage signaling the render system how we plan on using the buffer.
+		 */
+		GLPixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth,
+			PixelFormat mFormat, GpuBufferUsage usage);
+
+		~GLPixelBuffer();
+
+		/**
+		 * Upload some pixel data to the buffer.
+		 *
+		 * @param[in]	data	Data to upload.
+		 * @param[in]	dest	Coordinates to which to upload the data.
+		 */
+		virtual void upload(const PixelData& data, const PixelVolume& dest);
+
+		/**
+		 * Reads data from the pixel buffer into the provided object. Caller must ensure the data object is of adequate
+		 * size.
+		 */
+		virtual void download(const PixelData& data);
+
+		/**
+		 * Binds the buffers to a frame buffer object at the specified attachment point.
+		 *
+		 * @param[in]	attachment	Attachment point index in the range [0, BS_MAX_MULTIPLE_RENDER_TARGETS).
+		 * @param[in]	zoffset		Depth slice to bind, in the case of a 3D texture.
+		 */
+		virtual void bindToFramebuffer(GLenum attachment, UINT32 zoffset);
+
+		/**	Returns internal OpenGL pixel format used by the buffer. */
+		GLenum getGLFormat() const { return mGLInternalFormat; }
+
+		/**
+		 * Blits the contents of the provided buffer into this pixel buffer. Data is bilinearily interpolated in case buffer
+		 * sizes don't match.
+		 */
+		virtual void blitFromTexture(GLTextureBuffer* src);
+
+		/**
+		 * Blits contents of a sub-region of the provided buffer into a sub-region of this pixel buffer. Data is bilinearily
+		 * interpolated in case source and destination sizes don't match.
+		 */
+		virtual void blitFromTexture(GLTextureBuffer* src, const PixelVolume& srcBox, const PixelVolume& dstBox);
+
+	protected:  
+		/** @copydoc PixelBuffer::lockImpl */
+		PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) override;
+
+		/** @copydoc PixelBuffer::unlockImpl */
+		void unlockImpl() override;
+
+		/**	Allocates an internal buffer on the CPU, the size of the hardware buffer. */
+		void allocateBuffer();
+
+		/**	Deallocates the internal CPU buffer. */
+		void freeBuffer();
+
+	protected:
+		PixelData mBuffer;
+		GLenum mGLInternalFormat;
+		GpuLockOptions mCurrentLockOptions;
+	};
+
+	/**	Pixel buffer specialization that represents a single surface in a texture. */
+    class BS_RSGL_EXPORT GLTextureBuffer : public GLPixelBuffer
+	{
+    public:
+		/**
+		 * Constructs a new texture buffer from a specific surface in the provided texture.
+		 *
+		 * @param[in]	target				OpenGL type of the texture to retrieve the surface from.
+		 * @param[in]	id					OpenGL handle to the texture to retrieve the surface from.
+		 * @param[in]	face				Face index of the texture in the case of cube textures or texture arrays.
+		 * @param[in]	level				Mip level of the texture.
+		 * @param[in]	usage				Usage signaling the render system how we plan on using the buffer.
+		 * @param[in]	writeGamma			True if the parent texture was created with SRGB support.
+		 * @param[in]	multisampleCount	Number of samples the parent texture was created with.
+		 */
+		GLTextureBuffer(GLenum target, GLuint id, GLint face, 
+			GLint level, GpuBufferUsage usage, bool writeGamma, UINT32 multisampleCount);
+        ~GLTextureBuffer();
+        
+		/** @copydoc GLPixelBuffer::bindToFramebuffer */
+        void bindToFramebuffer(GLenum attachment, UINT32 zoffset) override;
+
+		/** @copydoc GLPixelBuffer::upload */
+		void upload(const PixelData &data, const PixelVolume &dest) override;
+
+		/** @copydoc GLPixelBuffer::download */
+		void download(const PixelData &data) override;
+  
+		/** @copydoc GLPixelBuffer::blitFromTexture */
+		void blitFromTexture(GLTextureBuffer *src, const PixelVolume &srcBox, const PixelVolume &dstBox) override;
+
+        /**
+         * Populate texture buffer with the data in the currently attached frame buffer.
+		 *
+		 * @param[in]	zoffset		3D slice of the texture to copy to. 0 if texture is not 3D.
+         */
+        void copyFromFramebuffer(UINT32 zoffset);
+
+    protected:
+		GLenum mTarget;
+		GLenum mFaceTarget;
+		GLuint mTextureID;
+		GLint mFace;
+		GLint mLevel;
+		UINT32 mMultisampleCount;
+    };
+
+	/**	Pixel buffer specialization that represents a render buffer. */
+    class BS_RSGL_EXPORT GLRenderBuffer : public GLPixelBuffer
+	{
+    public:
+		/**
+		 * Initializes a new render buffer.
+		 *
+		 * @param[in]	format		OpenGL pixel format.
+		 * @param[in]	width		Width of the render buffer in pixels.
+		 * @param[in]	height		Height of the render buffer in pixels.
+		 * @param[in]	numSamples	Number of samples to support.
+		 */
+        GLRenderBuffer(GLenum format, UINT32 width, UINT32 height, GLsizei numSamples);
+        ~GLRenderBuffer();
+        
+		/** @copydoc	GLPixelBuffer::bindToFramebuffer */
+        void bindToFramebuffer(GLenum attachment, UINT32 zoffset) override;
+    protected:
+        GLuint mRenderbufferID;
+    };
+
+	/** @} */
 };

+ 49 - 61
Source/BansheeGLRenderAPI/Include/BsGLPixelFormat.h

@@ -1,62 +1,50 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsPixelUtil.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Converts pixel formats to OpenGL formats
-	 */
-	class BS_RSGL_EXPORT GLPixelUtil
-	{
-	public:
-		/**
-		 * @brief	Returns matching OpenGL base pixel format type if one is found,
-		 *			zero otherwise.
-		 */
-		static GLenum getGLOriginFormat(PixelFormat mFormat);
-	
-		/**
-		 * @brief	Returns OpenGL data type used in the provided format.
-		 */
-		static GLenum getGLOriginDataType(PixelFormat mFormat);
-        
-		/**
-		 * @brief	Returns matching OpenGL internal pixel format type if one is found,
-		 *			zero otherwise. Optionally returns an SRGB format if "hwGamma" is specified
-		 *			and such format exists.
-		 */
-		static GLenum getGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
-	
-		/**
-		 * @brief	Returns matching OpenGL internal pixel format type if one is found,
-		 *			otherwise it returns the closest matching format. Optionally returns an 
-		 *			SRGB format if "hwGamma" is specified and such format exists.
-		 */
-		static GLenum getClosestGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
-		
-		/**
-		 * @brief	Returns an OpenGL type that should be used for creating a buffer for the specified
-		 * 			depth/stencil format.
-		 */
-		static GLenum getDepthStencilTypeFromFormat(PixelFormat mFormat);
-
-		/**
-		 * @brief	Returns pixel format closest to the provided internal OpenGL format.
-		 */
-		static PixelFormat getClosestEngineFormat(GLenum fmt);
-
-		/**
-		 * @brief	Returns closest supported format to the provided format.
-		 */
-		static PixelFormat getClosestValidFormat(PixelFormat fmt);
-
-		/**
-		 * @brief	Converts an OpenGL internal format into base format.
-		 */
-		static GLenum getBaseFormatFromCompressedInternalFormat(GLenum internalFormat);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsPixelUtil.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Converts pixel formats to OpenGL formats */
+	class BS_RSGL_EXPORT GLPixelUtil
+	{
+	public:
+		/**	Returns matching OpenGL base pixel format type if one is found, zero otherwise. */
+		static GLenum getGLOriginFormat(PixelFormat mFormat);
+	
+		/**	Returns OpenGL data type used in the provided format. */
+		static GLenum getGLOriginDataType(PixelFormat mFormat);
+        
+		/**
+		 * Returns matching OpenGL internal pixel format type if one is found, zero otherwise. Optionally returns an SRGB
+		 * format if @p hwGamma is specified and such format exists.
+		 */
+		static GLenum getGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
+	
+		/**
+		 * Returns matching OpenGL internal pixel format type if one is found, otherwise it returns the closest matching
+		 * format. Optionally returns an SRGB format if @p hwGamma is specified and such format exists.
+		 */
+		static GLenum getClosestGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
+		
+		/** Returns an OpenGL type that should be used for creating a buffer for the specified depth/stencil format. */
+		static GLenum getDepthStencilTypeFromFormat(PixelFormat mFormat);
+
+		/**	Returns pixel format closest to the provided internal OpenGL format. */
+		static PixelFormat getClosestEngineFormat(GLenum fmt);
+
+		/**	Returns closest supported format to the provided format. */
+		static PixelFormat getClosestValidFormat(PixelFormat fmt);
+
+		/**	Converts an OpenGL internal format into base format. */
+		static GLenum getBaseFormatFromCompressedInternalFormat(GLenum internalFormat);
+	};
+
+	/** @} */
 };

+ 105 - 93
Source/BansheeGLRenderAPI/Include/BsGLPrerequisites.h

@@ -1,93 +1,105 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine 
-{
-	extern const char* MODULE_NAME;
-
-    class GLSupport;
-    class GLRenderAPI;
-    class GLTextureCore;
-	class GLVertexBuffer;
-	class GLVertexBufferCore;
-    class GLTextureManager;
-    class GLContext;
-    class GLRTTManager;
-    class GLPixelBuffer;
-	class GLGpuParamBlock;
-	class GLSLGpuProgramCore;
-	class GLVertexArrayObject;
-	struct GLSLProgramPipeline;
-	class GLSLProgramPipelineManager;
-
-	typedef std::shared_ptr<GLPixelBuffer> GLPixelBufferPtr;
-	typedef std::shared_ptr<GLGpuParamBlock> GLGpuParamBlockPtr;
-
-	/**
-	 * @brief	OpenGL specific types to track resource statistics for.
-	 */
-	enum GLRenderStatResourceType
-	{
-		RenderStatObject_PipelineObject = 100,
-		RenderStatObject_FrameBufferObject,
-		RenderStatObject_VertexArrayObject
-	};
-}
-
-#if BS_THREAD_SUPPORT == 1
-#	define GLEW_MX
-#endif
-
-#if BS_PLATFORM == BS_PLATFORM_WIN32
-#if !defined( __MINGW32__ )
-#   define WIN32_LEAN_AND_MEAN
-#  ifndef NOMINMAX
-#	define NOMINMAX // required to stop windows.h messing up std::min
-#  endif
-#endif
-#   include <windows.h>
-#   include <wingdi.h>
-#   include <GL/glew.h>
-#   include <GL/wglew.h>
-#   include <GL/glu.h>
-#elif BS_PLATFORM == BS_PLATFORM_LINUX
-#   include <GL/glew.h>
-#   include <GL/glu.h>
-#   define GL_GLEXT_PROTOTYPES
-#elif BS_PLATFORM == BS_PLATFORM_APPLE
-#   include <GL/glew.h>
-#   include <OpenGL/glu.h>
-#endif
-
-#if BS_THREAD_SUPPORT == 1
-	GLEWContext * glewGetContext();
-
-#	if BS_PLATFORM == BS_PLATFORM_WIN32
-	WGLEWContext * wglewGetContext();
-#	endif
-
-#endif
-
-// Lots of generated code in here which triggers the new VC CRT security warnings
-#if !defined( _CRT_SECURE_NO_DEPRECATE )
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(BS_STATIC_LIB)
-#	ifdef BS_RSGL_EXPORTS
-#		define BS_RSGL_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_RSGL_EXPORT
-#       else
-#    		define BS_RSGL_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_RSGL_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_RSGL_EXPORT
-#endif
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+#if BS_THREAD_SUPPORT == 1
+#	define GLEW_MX
+#endif
+
+#if BS_PLATFORM == BS_PLATFORM_WIN32
+#if !defined( __MINGW32__ )
+#   define WIN32_LEAN_AND_MEAN
+#  ifndef NOMINMAX
+#	define NOMINMAX // required to stop windows.h messing up std::min
+#  endif
+#endif
+#   include <windows.h>
+#   include <wingdi.h>
+#   include <GL/glew.h>
+#   include <GL/wglew.h>
+#   include <GL/glu.h>
+#elif BS_PLATFORM == BS_PLATFORM_LINUX
+#   include <GL/glew.h>
+#   include <GL/glu.h>
+#   define GL_GLEXT_PROTOTYPES
+#elif BS_PLATFORM == BS_PLATFORM_APPLE
+#   include <GL/glew.h>
+#   include <OpenGL/glu.h>
+#endif
+
+#if BS_THREAD_SUPPORT == 1
+	GLEWContext * glewGetContext();
+
+#	if BS_PLATFORM == BS_PLATFORM_WIN32
+	WGLEWContext * wglewGetContext();
+#	endif
+
+#endif
+
+// Lots of generated code in here which triggers the new VC CRT security warnings
+#if !defined( _CRT_SECURE_NO_DEPRECATE )
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(BS_STATIC_LIB)
+#	ifdef BS_RSGL_EXPORTS
+#		define BS_RSGL_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define BS_RSGL_EXPORT
+#       else
+#    		define BS_RSGL_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#elif defined ( BS_GCC_VISIBILITY )
+#    define BS_RSGL_EXPORT  __attribute__ ((visibility("default")))
+#else
+#    define BS_RSGL_EXPORT
+#endif
+
+/** @addtogroup Plugins
+
+/** @defgroup GL BansheeGLRenderAPI
+ *	Wrapper around the OpenGL render API.
+ */
+
+/** @} */
+
+namespace BansheeEngine 
+{
+	extern const char* MODULE_NAME;
+
+    class GLSupport;
+    class GLRenderAPI;
+    class GLTextureCore;
+	class GLVertexBuffer;
+	class GLVertexBufferCore;
+    class GLTextureManager;
+    class GLContext;
+    class GLRTTManager;
+    class GLPixelBuffer;
+	class GLGpuParamBlock;
+	class GLSLGpuProgramCore;
+	class GLVertexArrayObject;
+	struct GLSLProgramPipeline;
+	class GLSLProgramPipelineManager;
+
+	typedef std::shared_ptr<GLPixelBuffer> GLPixelBufferPtr;
+	typedef std::shared_ptr<GLGpuParamBlock> GLGpuParamBlockPtr;
+
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL specific types to track resource statistics for. */
+	enum GLRenderStatResourceType
+	{
+		RenderStatObject_PipelineObject = 100,
+		RenderStatObject_FrameBufferObject,
+		RenderStatObject_VertexArrayObject
+	};
+
+	/** @} */
+}

+ 28 - 30
Source/BansheeGLRenderAPI/Include/BsGLQueryManager.h

@@ -1,31 +1,29 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsQueryManager.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation and life of OpenGL queries.
-	 */
-	class BS_RSGL_EXPORT GLQueryManager : public QueryManager
-	{
-	public:
-		/**
-		 * @copydoc	QueryManager::createEventQuery
-		 */
-		EventQueryPtr createEventQuery() const;
-
-		/**
-		 * @copydoc	QueryManager::createTimerQuery
-		 */
-		TimerQueryPtr createTimerQuery() const;
-
-		/**
-		 * @copydoc	QueryManager::createOcclusionQuery
-		 */
-		OcclusionQueryPtr createOcclusionQuery(bool binary) const;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsQueryManager.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Handles creation and life of OpenGL queries. */
+	class BS_RSGL_EXPORT GLQueryManager : public QueryManager
+	{
+	public:
+		/** @copydoc QueryManager::createEventQuery */
+		EventQueryPtr createEventQuery() const override;
+
+		/** @copydoc QueryManager::createTimerQuery */
+		TimerQueryPtr createTimerQuery() const override;
+
+		/** @copydoc QueryManager::createOcclusionQuery */
+		OcclusionQueryPtr createOcclusionQuery(bool binary) const override;
+	};
+
+	/** @} */
 }

+ 129 - 258
Source/BansheeGLRenderAPI/Include/BsGLRenderAPI.h

@@ -10,295 +10,199 @@
 
 namespace BansheeEngine 
 {
-	/**
-	 * @brief	Implementation of a render system using OpenGL. Provides abstracted
-	 *			access to various low level OpenGL methods.
+	/** @addtogroup GL
+	 *  @{
 	 */
+
+	/** Implementation of a render system using OpenGL. Provides abstracted access to various low level OpenGL methods. */
     class BS_RSGL_EXPORT GLRenderAPI : public RenderAPICore
     {
     public:
         GLRenderAPI();
         ~GLRenderAPI();
 
-		/**
-		 * @copydoc RenderAPICore::getName()
-		 */
+		/** @copydoc RenderAPICore::getName() */
 		const StringID& getName() const override;
 
-		/**
-		 * @copydoc RenderAPICore::getShadingLanguageName()
-		 */
+		/** @copydoc RenderAPICore::getShadingLanguageName() */
 		const String& getShadingLanguageName() const override;
 
-		/**
-		 * @copydoc RenderAPICore::setRenderTarget()
-		 */
+		/** @copydoc RenderAPICore::setRenderTarget() */
 		void setRenderTarget(const SPtr<RenderTargetCore>& target, bool readOnlyDepthStencil = false) override;
 
-        /**
-		 * @copydoc RenderAPICore::setVertexBuffers()
-		 */
+        /** @copydoc RenderAPICore::setVertexBuffers() */
 		void setVertexBuffers(UINT32 index, SPtr<VertexBufferCore>* buffers, UINT32 numBuffers) override;
 
-		/**
-		 * @copydoc RenderAPICore::setIndexBuffer()
-		 */
+		/** @copydoc RenderAPICore::setIndexBuffer() */
 		void setIndexBuffer(const SPtr<IndexBufferCore>& buffer) override;
 
-		/**
-		 * @copydoc RenderAPICore::setVertexDeclaration()
-		 */
+		/** @copydoc RenderAPICore::setVertexDeclaration() */
 		void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration) override;
 
-		/**
-		 * @copydoc RenderAPICore::setDrawOperation()
-		 */
+		/** @copydoc RenderAPICore::setDrawOperation() */
 		void setDrawOperation(DrawOperationType op) override;
 
-        /**
-		 * @copydoc RenderAPICore::setScissorRect()
-		 */
+        /** @copydoc RenderAPICore::setScissorRect() */
 		void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) override;
 
-		/**
-		 * @copydoc RenderAPICore::setTexture()
-		 */
+		/** @copydoc RenderAPICore::setTexture() */
 		void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& tex) override;
 
-		/**
-		 * @copydoc	RenderAPICore::setLoadStoreTexture
-		 */
+		/** @copydoc RenderAPICore::setLoadStoreTexture */
 		void setLoadStoreTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr,
 			const TextureSurface& surface) override;
         
-		/**
-		 * @copydoc RenderAPICore::setSamplerState()
-		 */
+		/** @copydoc RenderAPICore::setSamplerState() */
 		void setSamplerState(GpuProgramType gptype, UINT16 unit, const SPtr<SamplerStateCore>& state) override;
 
-		/**
-		 * @copydoc RenderAPICore::setBlendState()
-		 */
+		/** @copydoc RenderAPICore::setBlendState() */
 		void setBlendState(const SPtr<BlendStateCore>& blendState) override;
 
-		/**
-		 * @copydoc RenderAPICore::setRasterizerState()
-		 */
+		/** @copydoc RenderAPICore::setRasterizerState() */
 		void setRasterizerState(const SPtr<RasterizerStateCore>& rasterizerState) override;
 
-		/**
-		 * @copydoc RenderAPICore::setDepthStencilState()
-		 */
+		/** @copydoc RenderAPICore::setDepthStencilState() */
 		void setDepthStencilState(const SPtr<DepthStencilStateCore>& depthStencilState, UINT32 stencilRefValue) override;
 
-		/**
-		 * @copydoc RenderAPICore::setViewport()
-		 */
+		/** @copydoc RenderAPICore::setViewport() */
 		void setViewport(const Rect2& area) override;
 
-		/**
-		 * @copydoc RenderAPICore::bindGpuProgram()
-		 */
+		/** @copydoc RenderAPICore::bindGpuProgram() */
 		void bindGpuProgram(const SPtr<GpuProgramCore>& prg) override;
 
-		/**
-		 * @copydoc RenderAPICore::unbindGpuProgram()
-		 */
+		/** @copydoc RenderAPICore::unbindGpuProgram() */
 		void unbindGpuProgram(GpuProgramType gptype) override;
 
-		/**
-		 * @copydoc RenderAPICore::setConstantBuffers()
-		 */
+		/** @copydoc RenderAPICore::setConstantBuffers() */
 		void setConstantBuffers(GpuProgramType gptype, const SPtr<GpuParamsCore>& params) override;
 
-		/**
-		 * @copydoc RenderAPICore::beginFrame()
-		 */
+		/** @copydoc RenderAPICore::beginFrame() */
 		void beginFrame() override;
 
-		/**
-		 * @copydoc RenderAPICore::endFrame()
-		 */
+		/** @copydoc RenderAPICore::endFrame() */
 		void endFrame() override;
 
-		/**
-		 * @copydoc RenderAPICore::draw()
-		 */
+		/** @copydoc RenderAPICore::draw() */
 		void draw(UINT32 vertexOffset, UINT32 vertexCount) override;
 
-		/**
-		 * @copydoc RenderAPICore::drawIndexed()
-		 */
+		/** @copydoc RenderAPICore::drawIndexed() */
 		void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount) override;
 
-		/**
-		 * @copydoc RenderAPICore::dispatchCompute()
-		 */
+		/** @copydoc RenderAPICore::dispatchCompute() */
 		void dispatchCompute(UINT32 numGroupsX, UINT32 numGroupsY = 1, UINT32 numGroupsZ = 1) override;
 
-		/**
-		 * @copydoc RenderAPICore::clearRenderTarget()
-		 */
+		/** @copydoc RenderAPICore::clearRenderTarget() */
 		void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, 
 			UINT8 targetMask = 0xFF) override;
 
-		/**
-		 * @copydoc RenderAPICore::clearViewport()
-		 */
+		/** @copydoc RenderAPICore::clearViewport() */
 		void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, 
 			UINT8 targetMask = 0xFF) override;
 
-		/**
-		 * @copydoc RenderAPICore::convertProjectionMatrix()
-		 */
+		/** @copydoc RenderAPICore::convertProjectionMatrix() */
 		void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest) override;
 
 		/** @copydoc RenderAPICore::getAPIInfo */
 		const RenderAPIInfo& getAPIInfo() const override;
 
-		/**
-		 * @copydoc RenderAPICore::generateParamBlockDesc()
-		 */
+		/** @copydoc RenderAPICore::generateParamBlockDesc() */
 		GpuParamBlockDesc generateParamBlockDesc(const String& name, Vector<GpuParamDataDesc>& params) override;
 
 		/************************************************************************/
 		/* 				Internal use by OpenGL RenderSystem only                */
 		/************************************************************************/
 
-		/**
-		 * @brief	Query has the main context been initialized.
-		 */
+		/**	Query has the main context been initialized. */
 		bool _isContextInitialized() const { return mGLInitialised; }
 
-		/**
-		 * @brief	Returns main context. Caller must ensure the context has been initialized.
-		 */
+		/**	Returns main context. Caller must ensure the context has been initialized. */
 		SPtr<GLContext> getMainContext() const { return mMainContext; } 
 
-		/**
-		 * @brief	Returns a support object you may use for creating
-		 */
+		/**	Returns a support object you may use for creating */
 		GLSupport* getGLSupport() const { return mGLSupport; }
 
 	protected:
-		/**
-		 * @copydoc	RenderAPICore::initializePrepare
-		 */
+		/** @copydoc RenderAPICore::initializePrepare */
 		void initializePrepare() override;
 
-		/**
-		 * @copydoc	RenderAPICore::initializeFinalize
-		 */
+		/** @copydoc RenderAPICore::initializeFinalize */
 		void initializeFinalize(const SPtr<RenderWindowCore>& primaryWindow) override;
 
-		/**
-		 * @copydoc	RenderAPICore::destroy_internal().
-		 */
+		/** @copydoc RenderAPICore::destroyCore. */
 		void destroyCore() override;
 
-		/**
-		* @brief	Call before doing a draw operation, this method sets everything up.
-		*/
+		/**	Call before doing a draw operation, this method sets everything up. */
 		void beginDraw();
 
-		/**
-		* @brief	Needs to accompany every beginDraw after you are done with a single draw operation.
-		*/
+		/**	Needs to accompany every beginDraw after you are done with a single draw operation. */
 		void endDraw();
 
-		/**
-		 * @brief	Clear a part of a render target.
-		 */
+		/**	Clear a part of a render target. */
 		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, 
 			const Rect2I& clearArea = Rect2I::EMPTY, UINT8 targetMask = 0xFF);
 
-		/**
-		 * @brief	Set up clip planes against which all geometry will get clipped.
-		 */
+		/**	Set up clip planes against which all geometry will get clipped. */
 		void setClipPlanesImpl(const PlaneList& clipPlanes) override;
 
 		/**
-		 * @brief	Set up a clip plane at a specific clip plane index. If enabled,
-		 *			geometry will be clipped against the positive side of the plane.
+		 * Set up a clip plane at a specific clip plane index. If enabled, geometry will be clipped against the positive
+		 * side of the plane.
 		 *
 		 * @note	Valid index range is [0, 5].
 		 */
         void setClipPlane(UINT16 index, float A, float B, float C, float D);
 
 		/**
-		 * @brief	Enable or disable clipping against a clip plane at the specified index.
+		 * Enable or disable clipping against a clip plane at the specified index.
 		 *
 		 * @note	Valid index range is [0, 5].
 		 */
         void enableClipPlane (UINT16 index, bool enable);
 
-		/**
-		* @brief	Changes the currently active texture unit. Any texture related operations
-		*			will then be performed on this unit.
-		*/
+		/** 
+		 * Changes the currently active texture unit. Any texture related operations will then be performed on this unit. 
+		 */
 		bool activateGLTextureUnit(UINT16 unit);
 
-		/**
-		 * @brief	Changes the active GPU program.
-		 */
+		/**	Changes the active GPU program. */
 		void setActiveProgram(GpuProgramType gptype, const SPtr<GLSLGpuProgramCore>& program);
 
-		/**
-		 * @brief	Retrieves the active GPU program of the specified type.
-		 */
+		/**	Retrieves the active GPU program of the specified type. */
 		SPtr<GLSLGpuProgramCore> getActiveProgram(GpuProgramType gptype) const;
 
-		/**
-		 * @brief	Converts Banshee blend mode to OpenGL blend mode.
-		 */
+		/**	Converts Banshee blend mode to OpenGL blend mode. */
 		GLint getBlendMode(BlendFactor blendMode) const;
 
-		/**
-		* @brief	Converts Banshee texture addressing mode to OpenGL texture addressing mode.
-		*/
+		/**	Converts Banshee texture addressing mode to OpenGL texture addressing mode. */
 		GLint getTextureAddressingMode(TextureAddressingMode tam) const;
 
-		/**
-		 * @brief	Gets a combined min/mip filter value usable by OpenGL from the currently
-		 *			set min and mip filters.
-		 */
+		/** Gets a combined min/mip filter value usable by OpenGL from the currently set min and mip filters. */
 		GLuint getCombinedMinMipFilter() const;
 
 		/**
-		* @brief	OpenGL shares all texture slots, but the engine prefers to keep textures
-		* 			separate per-stage. This will convert texture unit that is set per stage
-		* 			into a global texture unit usable by OpenGL.
-		*/
+		 * OpenGL shares all texture slots, but the engine prefers to keep textures separate per-stage. This will convert
+		 * texture unit that is set per stage into a global texture unit usable by OpenGL.
+		 */
 		UINT32 getGLTextureUnit(GpuProgramType gptype, UINT32 unit);
 
 		/**
-		* @brief	OpenGL shares all buffer bindings, but the engine prefers to keep buffers
-		* 			separate per-stage. This will convert block buffer binding that is set per stage
-		* 			into a global block buffer binding usable by OpenGL.
-		*/
+		 * OpenGL shares all buffer bindings, but the engine prefers to keep buffers separate per-stage. This will convert
+		 * block buffer binding that is set per stage into a global block buffer binding usable by OpenGL.
+		 */
 		UINT32 getGLUniformBlockBinding(GpuProgramType gptype, UINT32 binding);
 
-		/**
-		* @brief	Returns the OpenGL specific mode used for drawing, depending on the
-		* 			currently set draw operation;
-		*/
+		/** Returns the OpenGL specific mode used for drawing, depending on the currently set draw operation. */
 		GLint getGLDrawMode() const;
 
-		/**
-		 * @brief	Creates render system capabilities that specify which features are
-		 *			or aren't supported.
-		 */
+		/**	Creates render system capabilities that specify which features are or aren't supported. */
 		RenderAPICapabilities* createRenderSystemCapabilities() const;
 
-		/**
-		 * @brief	Finish initialization by setting up any systems dependant on render system
-		 *			capabilities.
-		 */
+		/**	Finish initialization by setting up any systems dependant on render systemcapabilities. */
 		void initFromCaps(RenderAPICapabilities* caps);
 
 		/**
-		 * @brief	Switch the currently used OpenGL context. You will need to re-bind
-		 *			any previously bound values manually. (e.g. textures, gpu programs and such)
+		 * Switch the currently used OpenGL context. You will need to re-bind any previously bound values manually. (e.g.
+		 * textures, gpu programs and such)
 		 */
 		void switchContext(const SPtr<GLContext>& context);
 
@@ -307,41 +211,34 @@ namespace BansheeEngine
 		/************************************************************************/
 
 		/**
-		 * @brief	Sets the texture addressing mode for a texture unit. This determines
-		 *			how are UV address values outside of [0, 1] range handled when sampling
-		 *			from texture.
+		 * Sets the texture addressing mode for a texture unit. This determines how are UV address values outside of [0, 1]
+		 * range handled when sampling from texture.
 		 */
         void setTextureAddressingMode(UINT16 stage, const UVWAddressingMode& uvw);
 
 		/**
-		 * @brief	Sets the texture border color for a texture unit. Border color
-		 *			determines color returned by the texture sampler when border addressing mode
-		 *			is used and texture address is outside of [0, 1] range.
+		 * Sets the texture border color for a texture unit. Border color determines color returned by the texture sampler
+		 * when border addressing mode is used and texture address is outside of [0, 1] range.
 		 */
         void setTextureBorderColor(UINT16 stage, const Color& color);
 
 		/**
-		 * @brief	Sets the mipmap bias value for a given texture unit. Bias allows
-		 *			you to adjust the mipmap selection calculation. Negative values force a
-		 *			larger mipmap to be used, and positive values smaller. Units are in values
-		 *			of mip levels, so -1 means use a mipmap one level higher than default.
+		 * Sets the mipmap bias value for a given texture unit. Bias allows	you to adjust the mipmap selection calculation.
+		 * Negative values force a larger mipmap to be used, and positive values smaller. Units are in values of mip levels,
+		 * so -1 means use a mipmap one level higher than default.
 		 */
 		void setTextureMipmapBias(UINT16 unit, float bias);
 
 		/**
-		 * @brief	Allows you to specify how is the texture bound to the specified texture unit filtered.
-		 *			Different filter types are used for different situations like magnifying or minifying a texture.
+		 * Allows you to specify how is the texture bound to the specified texture unit filtered. Different filter types are
+		 * used for different situations like magnifying or minifying a texture.
 		 */
         void setTextureFiltering(UINT16 unit, FilterType ftype, FilterOptions filter);
 
-		/**
-		 * @brief	Sets anisotropy value for the specified texture unit.
-		 */
+		/**	Sets anisotropy value for the specified texture unit. */
 		void setTextureAnisotropy(UINT16 unit, UINT32 maxAnisotropy);
 
-		/**
-		 * @brief	Gets anisotropy value for the specified texture unit.
-		 */
+		/**	Gets anisotropy value for the specified texture unit. */
 		GLfloat getCurrentAnisotropy(UINT16 unit);
 
 		/************************************************************************/
@@ -349,145 +246,124 @@ namespace BansheeEngine
 		/************************************************************************/
 
 		/**
-		 * @brief	Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
-		 *			Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor).
+		 * Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
+		 * Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor).
 		 */
 		void setSceneBlending(BlendFactor sourceFactor, BlendFactor destFactor, BlendOperation op);
 
 		/**
-		* @brief	Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
-		*			Allows you to set up separate blend operations for alpha values.
-		*	
-		*			Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor). (And the same for alpha)
-		*/
+		 * Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
+		 * Allows you to set up separate blend operations for alpha values.
+		 *	
+		 * Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor). (And the same for alpha)
+		 */
 		void setSceneBlending(BlendFactor sourceFactor, BlendFactor destFactor, BlendFactor sourceFactorAlpha, 
 			BlendFactor destFactorAlpha, BlendOperation op, BlendOperation alphaOp);
 
 		/**
-		 * @brief	Sets alpha test that allows you to reject pixels that fail the comparison function
-		 *			versus the provided reference value.
+		 * Sets alpha test that allows you to reject pixels that fail the comparison function versus the provided reference
+		 * value.
 		 */
 		void setAlphaTest(CompareFunction func, unsigned char value);
 
 		/**
-		 * @brief	Enable alpha to coverage. Alpha to coverage allows you to perform blending without needing 
-		 *			to worry about order of rendering like regular blending does. It requires multi-sampling to 
-		 *			be active in order to work, and you need to supply an alpha texture that determines object transparency.
+		 * Enable alpha to coverage. Alpha to coverage allows you to perform blending without needing to worry about order
+		 * of rendering like regular blending does. It requires multi-sampling to be active in order to work, and you need
+		 * to supply an alpha texture that determines object transparency.
 		 */
 		void setAlphaToCoverage(bool enabled);
 
-		/**
-		 * @brief	Enables or disables writing to certain color channels of the render target.
-		 */
+		/**	Enables or disables writing to certain color channels of the render target. */
 		void setColorBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
 
 		/************************************************************************/
 		/* 								Rasterizer states                  		*/
 		/************************************************************************/
 
-		/**
-		 * @brief	Sets vertex winding order. Normally you would use this to cull back facing
-		 *			polygons.
-		 */
+		/**	Sets vertex winding order. Normally you would use this to cull back facing polygons. */
 		void setCullingMode(CullingMode mode);
 
-		/**
-		 * @brief	Sets the polygon rasterization mode. Determines how are polygons interpreted.
-		 */
+		/**	Sets the polygon rasterization mode. Determines how are polygons interpreted. */
 		void setPolygonMode(PolygonMode level);
 
 		/**
-		 * @brief	Sets a depth bias that will offset the depth values of new pixels by the specified amount.
-		 *			Final depth bias value is a combination of the constant depth bias and slope depth bias.
-		 *			Slope depth bias has more effect the higher the slope of the rendered polygon.
+		 * Sets a depth bias that will offset the depth values of new pixels by the specified amount. Final depth bias value
+		 * is a combination of the constant depth bias and slope depth bias. Slope depth bias has more effect the higher
+		 * the slope of the rendered polygon.
 		 *
 		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
 		 */
 		void setDepthBias(float constantBias, float slopeScaleBias);
 
 		/**
-		 * @brief	Scissor test allows you to mask off rendering in all but a given rectangular area
-		 * 			identified by the rectangle set by setScissorRect().
+		 * Scissor test allows you to mask off rendering in all but a given rectangular area identified by the rectangle
+		 * set by setScissorRect().
 		 */
 		void setScissorTestEnable(bool enable);
 
-		/**
-		 * @brief	Enables or disables multisample antialiasing.
-		 */
+		/**	Enables or disables multisample antialiasing. */
 		void setMultisamplingEnable(bool enable);
 
-		/**
-		 * @brief	Enables or disables depth clipping (i.e. near/fear plane clipping).
-		 */
+		/**	Enables or disables depth clipping (i.e. near/fear plane clipping). */
 		void setDepthClipEnable(bool enable);
 
-		/**
-		 * @brief	Enables or disables antialiased line rendering.
-		 */
+		/**	Enables or disables antialiased line rendering. */
 		void setAntialiasedLineEnable(bool enable);
 
 		/************************************************************************/
 		/* 						Depth stencil state                      		*/
 		/************************************************************************/
 		
-		/**
-		 * @brief	Should new pixels perform depth testing using the set depth comparison function before
-		 *			being written.
-		 */
+		/**	Should new pixels perform depth testing using the set depth comparison function before being written. */
 		void setDepthBufferCheckEnabled(bool enabled = true);
 
-		/**
-		 * @brief	Should new pixels write to the depth buffer.
-		 */
+		/**	Should new pixels write to the depth buffer. */
 		void setDepthBufferWriteEnabled(bool enabled = true);
 
 		/**
-		 * @brief	Sets comparison function used for depth testing. Determines how are new and existing
-		 *			pixel values compared - if comparison function returns true the new pixel is written.
+		 * Sets comparison function used for depth testing. Determines how are new and existing pixel values compared - if
+		 * comparison function returns true the new pixel is written.
 		 */
 		void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
 
 		/**
-		 * @brief	Turns stencil tests on or off. By default this is disabled.
-		 *			Stencil testing allow you to mask out a part of the rendered image by using
-		 *			various stencil operations provided.
+		 * Turns stencil tests on or off. By default this is disabled. Stencil testing allow you to mask out a part of the
+		 * rendered image by using various stencil operations provided.
 		 */
 		void setStencilCheckEnabled(bool enabled);
 
 		/**
-		 * @brief	Allows you to set stencil operations that are performed when stencil test passes or fails.
+		 * Allows you to set stencil operations that are performed when stencil test passes or fails.
 		 *
-		 * @param	stencilFailOp	Operation executed when stencil test fails.
-		 * @param	depthFailOp		Operation executed when stencil test succeeds but depth test fails.
-		 * @param	passOp			Operation executed when stencil test succeeds and depth test succeeds.
-		 * @param	front			Should the stencil operations be applied to front or back facing polygons.
+		 * @param[in]	stencilFailOp	Operation executed when stencil test fails.
+		 * @param[in]	depthFailOp		Operation executed when stencil test succeeds but depth test fails.
+		 * @param[in]	passOp			Operation executed when stencil test succeeds and depth test succeeds.
+		 * @param[in]	front			Should the stencil operations be applied to front or back facing polygons.
 		 */
 		void setStencilBufferOperations(StencilOperation stencilFailOp = SOP_KEEP,
 			StencilOperation depthFailOp = SOP_KEEP, StencilOperation passOp = SOP_KEEP,
 			bool front = true);
 
 		/**
-		 * @brief	Sets a stencil buffer comparison function. The result of this will cause one of 3 actions 
-		 *			depending on whether the test fails, succeeds but with the depth buffer check still failing, 
-		 *			or succeeds with the depth buffer check passing too.
+		 * Sets a stencil buffer comparison function. The result of this will cause one of 3 actions depending on whether
+		 * the test fails, succeeds but with the depth buffer check still failing, or succeeds with the depth buffer check
+		 * passing too.
 		 *
-		 * @param func	Comparison function that determines whether a stencil test fails or passes. Reference value
-		 *				gets compared to the value already in the buffer using this function.
-		 * @param mask	The bitmask applied to both the stencil value and the reference value
-		 *				before comparison
-		 * @param ccw	If set to true, the stencil operations will be applied to counterclockwise
-		 *				faces. Otherwise they will be applied to clockwise faces.
+		 * @param[in] func	Comparison function that determines whether a stencil test fails or passes. Reference value
+		 *					gets compared to the value already in the buffer using this function.
+		 * @param[in] mask	The bitmask applied to both the stencil value and the reference value
+		 *					before comparison
+		 * @param[in] ccw	If set to true, the stencil operations will be applied to counterclockwise
+		 *					faces. Otherwise they will be applied to clockwise faces.
 		 */
 		void setStencilBufferFunc(CompareFunction func = CMPF_ALWAYS_PASS, UINT32 mask = 0xFFFFFFFF, bool front = true);
 
-		/**
-		 * @brief	The bitmask applied to the stencil value before writing it to the stencil buffer.
-		 */
+		/**	The bitmask applied to the stencil value before writing it to the stencil buffer. */
 		void setStencilBufferWriteMask(UINT32 mask = 0xFFFFFFFF);
 
 		/**
-		 * @brief	Sets a reference values used for stencil buffer comparisons. 
-		 * 			Actual comparison function and stencil operations are set by setting the DepthStencilState.
+		 * Sets a reference values used for stencil buffer comparisons. Actual comparison function and stencil operations
+		 * are set by setting the DepthStencilState.
 		 */
 		void setStencilRefValue(UINT32 refValue);
 
@@ -496,31 +372,24 @@ namespace BansheeEngine
 		/************************************************************************/
 
 		/**
-		 * @brief	Recalculates actual viewport dimensions based on currently 
-		 *			set viewport normalized dimensions and render target and applies
-		 *			them for further rendering.
+		 * Recalculates actual viewport dimensions based on currently set viewport normalized dimensions and render target
+		 * and applies them for further rendering.
 		 */
 		void applyViewport();
 
-		/**
-		 * @brief	Converts the provided matrix m into a representation usable by OpenGL.
-		 */
+		/**	Converts the provided matrix m into a representation usable by OpenGL. */
 		void makeGLMatrix(GLfloat gl_matrix[16], const Matrix4& m);
 
-		/**
-		 * @brief	Converts the engine depth/stencil compare function into OpenGL representation.
-		 */
+		/**	Converts the engine depth/stencil compare function into OpenGL representation. */
 		GLint convertCompareFunction(CompareFunction func) const;
 
 		/**
-		 * @brief	Convers the engine stencil operation in OpenGL representation. Optionally inverts
-		 *			the operation (increment becomes decrement, etc.).
+		 * Convers the engine stencil operation in OpenGL representation. Optionally inverts the operation (increment
+		 * becomes decrement, etc.).
 		 */
 		GLint convertStencilOp(StencilOperation op, bool invert = false) const;
 
-		/**
-		 * @brief	Checks if there are any OpenGL errors and prints them to the log.
-		 */
+		/**	Checks if there are any OpenGL errors and prints them to the log. */
 		bool checkForErrors() const;
 
 	private:
@@ -586,4 +455,6 @@ namespace BansheeEngine
 
 		UINT16 mActiveTextureUnit;
     };
+
+	/** @} */
 }

+ 47 - 49
Source/BansheeGLRenderAPI/Include/BsGLRenderAPIFactory.h

@@ -1,50 +1,48 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include <string>
-#include "BsRenderAPIFactory.h"
-#include "BsRenderAPIManager.h"
-#include "BsGLRenderAPI.h"
-
-namespace BansheeEngine
-{
-	const String SystemName = "BansheeGLRenderSystem";
-
-	/**
-	 * @brief Handles creation of the OpenGL render system.
-	 */
-	class GLRenderAPIFactory : public RenderAPIFactory
-	{
-	public:
-		/**
-		 * @copydoc	RenderSystemFactory::create
-		 */
-		virtual void create();
-
-		/**
-		 * @copydoc	RenderSystemFactory::name
-		 */
-		virtual const String& name() const { return SystemName; }
-
-	private:
-		/**
-		 * @brief	Registers the factory with the render system manager when constructed.
-		 */
-		class InitOnStart
-		{
-		public:
-			InitOnStart() 
-			{ 
-				static RenderAPIFactoryPtr newFactory;
-				if(newFactory == nullptr)
-				{
-					newFactory = bs_shared_ptr_new<GLRenderAPIFactory>();
-					RenderAPIManager::instance().registerFactory(newFactory);
-				}
-			}
-		};
-
-		static InitOnStart initOnStart; // Makes sure factory is registered on library load
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include <string>
+#include "BsRenderAPIFactory.h"
+#include "BsRenderAPIManager.h"
+#include "BsGLRenderAPI.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	const String SystemName = "BansheeGLRenderSystem";
+
+	/** Handles creation of the OpenGL render system. */
+	class GLRenderAPIFactory : public RenderAPIFactory
+	{
+	public:
+		/** @copydoc RenderSystemFactory::create */
+		void create() override;
+
+		/** @copydoc RenderSystemFactory::name */
+		const String& name() const override { return SystemName; }
+
+	private:
+		/**	Registers the factory with the render system manager when constructed. */
+		class InitOnStart
+		{
+		public:
+			InitOnStart() 
+			{ 
+				static RenderAPIFactoryPtr newFactory;
+				if(newFactory == nullptr)
+				{
+					newFactory = bs_shared_ptr_new<GLRenderAPIFactory>();
+					RenderAPIManager::instance().registerFactory(newFactory);
+				}
+			}
+		};
+
+		static InitOnStart initOnStart; // Makes sure factory is registered on library load
+	};
+
+	/** @} */
 }

+ 127 - 121
Source/BansheeGLRenderAPI/Include/BsGLRenderTexture.h

@@ -1,122 +1,128 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGLTexture.h"
-#include "BsGLFrameBufferObject.h"
-#include "BsModule.h"
-
-#define GL_DEPTH24_STENCIL8_EXT 0x88F0
-
-namespace BansheeEngine 
-{  
-	class GLRenderTexture;
-
-	/**
-	 * OpenGL implementation of a render texture.
-	 *
-	 * @note	Core thread only.
-	 */
-    class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
-    {
-	public:
-		GLRenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~GLRenderTextureCore();
-
-		/** @copydoc RenderTextureCore::getCustomAttribute */
-		virtual void getCustomAttribute(const String& name, void* pData) const override;
-
-	protected:
-		friend class GLRenderTexture;
-
-		/** @copydoc RenderTextureCore::initialize */
-		virtual void initialize() override;
-
-		/** @copydoc RenderTextureCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		RenderTextureProperties mProperties;
-		GLFrameBufferObject* mFB;
-    };
-
-    /**
-     * Manager that handles valid render texture formats.
-     * 			
-	 * @note	Must be initialized when RenderSystem is first started.
-     */
-    class BS_RSGL_EXPORT GLRTTManager : public Module<GLRTTManager>
-    {
-    public:
-        GLRTTManager();
-		~GLRTTManager();
-        
-        /**
-         * Check if a certain format is usable as a render target format.
-         *
-         * @note	Thread safe.
-         */
-        bool checkFormat(PixelFormat format) const { return mProps[format].valid; }
-        
-        /**
-         * Get the closest supported alternative format. If format is supported, returns format.
-         *
-         * @note	Thread safe.
-         */
-        virtual PixelFormat getSupportedAlternative(PixelFormat format);
-
-		/** Returns a persistent FBO that is used as a source buffer for blit operations. */
-		GLuint getBlitReadFBO() const { return mBlitReadFBO; }
-
-		/** Returns a persistent FBO that is used as a destination buffer for blit operations. */
-		GLuint getBlitDrawFBO() const { return mBlitWriteFBO; }
-    private:
-        /** Frame buffer object properties for a certain texture format. */
-        struct FormatProperties
-        {
-            /** Allowed modes/properties for this pixel format. */
-            struct Mode
-            {
-                UINT32 depth;     /**< Depth format (0 = no depth). */
-                UINT32 stencil;   /**< Stencil format (0 = no stencil). */
-            };
-            
-            Vector<Mode> modes;
-			bool valid;
-        };
-
-		/** Detect which internal formats are allowed to be used on render target color or depth/stencil surfaces. */
-        void detectFBOFormats();
-
-		/**	Checks are the specified depth & stencil formats compatible. */
-		bool _tryFormat(GLenum depthFormat, GLenum stencilFormat);
-
-		/**	Checks is the specified packed format valid for using in the render target. */
-        bool _tryPackedFormat(GLenum packedFormat);
-
-		FormatProperties mProps[PF_COUNT];
-		GLuint mBlitReadFBO;
-		GLuint mBlitWriteFBO;
-    };
-
-	/**
-	 * OpenGL implementation of a render texture.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class GLRenderTexture : public RenderTexture
-	{
-	public:
-		virtual ~GLRenderTexture() { }
-
-	protected:
-		friend class GLTextureManager;
-
-		GLRenderTexture(const RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc RenderTexture::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		RenderTextureProperties mProperties;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGLTexture.h"
+#include "BsGLFrameBufferObject.h"
+#include "BsModule.h"
+
+#define GL_DEPTH24_STENCIL8_EXT 0x88F0
+
+namespace BansheeEngine 
+{  
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	class GLRenderTexture;
+
+	/**
+	 * OpenGL implementation of a render texture.
+	 *
+	 * @note	Core thread only.
+	 */
+    class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
+    {
+	public:
+		GLRenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
+		virtual ~GLRenderTextureCore();
+
+		/** @copydoc RenderTextureCore::getCustomAttribute */
+		virtual void getCustomAttribute(const String& name, void* pData) const override;
+
+	protected:
+		friend class GLRenderTexture;
+
+		/** @copydoc RenderTextureCore::initialize */
+		virtual void initialize() override;
+
+		/** @copydoc RenderTextureCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		RenderTextureProperties mProperties;
+		GLFrameBufferObject* mFB;
+    };
+
+    /**
+     * Manager that handles valid render texture formats.
+     * 			
+	 * @note	Must be initialized when RenderSystem is first started.
+     */
+    class BS_RSGL_EXPORT GLRTTManager : public Module<GLRTTManager>
+    {
+    public:
+        GLRTTManager();
+		~GLRTTManager();
+        
+        /**
+         * Check if a certain format is usable as a render target format.
+         *
+         * @note	Thread safe.
+         */
+        bool checkFormat(PixelFormat format) const { return mProps[format].valid; }
+        
+        /**
+         * Get the closest supported alternative format. If format is supported, returns format.
+         *
+         * @note	Thread safe.
+         */
+        virtual PixelFormat getSupportedAlternative(PixelFormat format);
+
+		/** Returns a persistent FBO that is used as a source buffer for blit operations. */
+		GLuint getBlitReadFBO() const { return mBlitReadFBO; }
+
+		/** Returns a persistent FBO that is used as a destination buffer for blit operations. */
+		GLuint getBlitDrawFBO() const { return mBlitWriteFBO; }
+    private:
+        /** Frame buffer object properties for a certain texture format. */
+        struct FormatProperties
+        {
+            /** Allowed modes/properties for this pixel format. */
+            struct Mode
+            {
+                UINT32 depth;     /**< Depth format (0 = no depth). */
+                UINT32 stencil;   /**< Stencil format (0 = no stencil). */
+            };
+            
+            Vector<Mode> modes;
+			bool valid;
+        };
+
+		/** Detect which internal formats are allowed to be used on render target color or depth/stencil surfaces. */
+        void detectFBOFormats();
+
+		/**	Checks are the specified depth & stencil formats compatible. */
+		bool _tryFormat(GLenum depthFormat, GLenum stencilFormat);
+
+		/**	Checks is the specified packed format valid for using in the render target. */
+        bool _tryPackedFormat(GLenum packedFormat);
+
+		FormatProperties mProps[PF_COUNT];
+		GLuint mBlitReadFBO;
+		GLuint mBlitWriteFBO;
+    };
+
+	/**
+	 * OpenGL implementation of a render texture.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class GLRenderTexture : public RenderTexture
+	{
+	public:
+		virtual ~GLRenderTexture() { }
+
+	protected:
+		friend class GLTextureManager;
+
+		GLRenderTexture(const RENDER_TEXTURE_DESC& desc);
+
+		/** @copydoc RenderTexture::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		RenderTextureProperties mProperties;
+	};
+
+	/** @} */
 }

+ 42 - 44
Source/BansheeGLRenderAPI/Include/BsGLRenderWindowManager.h

@@ -1,45 +1,43 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsRenderWindowManager.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Manager that handles window creation for OpenGL.
-	 */
-	class BS_RSGL_EXPORT GLRenderWindowManager : public RenderWindowManager
-	{
-	public:
-		GLRenderWindowManager(GLRenderAPI* renderSystem);
-
-	protected:
-		/**
-		 * @copydoc RenderWindowManager::createImpl()
-		 */
-		RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const RenderWindowPtr& parentWindow);
-
-	private:
-		GLRenderAPI* mRenderSystem;
-	};
-
-	/**
-	 * @brief	Manager that handles window creation for OpenGL.
-	 */
-	class BS_RSGL_EXPORT GLRenderWindowCoreManager : public RenderWindowCoreManager
-	{
-	public:
-		GLRenderWindowCoreManager(GLRenderAPI* renderSystem);
-
-	protected:
-		/**
-		 * @copydoc RenderWindowCoreManager::createInternal
-		 */
-		SPtr<RenderWindowCore> createInternal(RENDER_WINDOW_DESC& desc, UINT32 windowId);
-
-	private:
-		GLRenderAPI* mRenderSystem;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsRenderWindowManager.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Manager that handles window creation for OpenGL. */
+	class BS_RSGL_EXPORT GLRenderWindowManager : public RenderWindowManager
+	{
+	public:
+		GLRenderWindowManager(GLRenderAPI* renderSystem);
+
+	protected:
+		/** @copydoc RenderWindowManager::createImpl() */
+		RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const RenderWindowPtr& parentWindow) override;
+
+	private:
+		GLRenderAPI* mRenderSystem;
+	};
+
+	/**	Manager that handles window creation for OpenGL. */
+	class BS_RSGL_EXPORT GLRenderWindowCoreManager : public RenderWindowCoreManager
+	{
+	public:
+		GLRenderWindowCoreManager(GLRenderAPI* renderSystem);
+
+	protected:
+		/** @copydoc RenderWindowCoreManager::createInternal */
+		SPtr<RenderWindowCore> createInternal(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
+
+	private:
+		GLRenderAPI* mRenderSystem;
+	};
+
+	/** @} */
 }

+ 84 - 97
Source/BansheeGLRenderAPI/Include/BsGLSupport.h

@@ -1,98 +1,85 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGLRenderAPI.h"
-#include "BsRenderWindow.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Helper class dealing mostly with platform specific OpenGL functionality,
-	 *			initialization, extensions and window creation.
-	 */
-	class BS_RSGL_EXPORT GLSupport
-	{
-	public:
-		GLSupport() { }
-		virtual ~GLSupport() { }
-
-		/**
-		 * @brief	Creates a new render window using the specified descriptor.
-		 *
-		 * @param	desc			Description of a render window to create.
-		 * @param	windowId		Window ID provided by the render window manager.
-		 * @param	parentWindow	Optional parent window if the window shouldn't be a main window. First
-		 *							created window cannot have a parent.
-		 *
-		 * @param	Returns newly created window.
-		 */
-		virtual RenderWindowPtr newWindow(RENDER_WINDOW_DESC& desc, UINT32 windowId, RenderWindowPtr parentWindow) = 0;
-
-		/**
-		 * @brief	Creates a new render window using the specified descriptor.
-		 *
-		 * @param	desc			Description of a render window to create.
-		 * @param	windowId		Window ID provided by the render window manager.
-		 * @param	parentWindow	Optional parent window if the window shouldn't be a main window. First
-		 *							created window cannot have a parent.
-		 *
-		 * @param	Returns newly created window.
-		 */
-		virtual SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId) = 0;
-
-		/**
-		 * @brief	Called when OpenGL is being initialized.
-		 */
-		virtual void start() = 0;
-
-		/**
-		 * @brief	Called when OpenGL is being shut down.
-		 */
-		virtual void stop() = 0;
-
-		/**
-		 * @brief	Gets OpenGL vendor name.
-		 */
-		const String& getGLVendor() const
-		{
-			return mVendor;
-		}
-
-		/**
-		 * @brief	Gets OpenGL version string.
-		 */
-		const String& getGLVersion() const
-		{
-			return mVersion;
-		}
-
-		/**
-		 * @brief	Checks is the specified extension available.
-		 */
-		virtual bool checkExtension(const String& ext) const;
-
-		/**
-		 * @brief	Gets an address of an OpenGL procedure with the specified name.
-		 */
-		virtual void* getProcAddress(const String& procname) = 0;
-
-		/**
-		 * @brief	Initializes OpenGL extensions. Must be called after we have a valid and active
-		 *			OpenGL context.
-		 */
-		virtual void initializeExtensions();
-
-		/**
-		 * @brief	Gets a structure describing all available video modes.
-		 */
-		virtual VideoModeInfoPtr getVideoModeInfo() const = 0;
-
-	protected:
-		Set<String> extensionList;
-
-		String mVersion;
-		String mVendor;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGLRenderAPI.h"
+#include "BsRenderWindow.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**
+	 * Helper class dealing mostly with platform specific OpenGL functionality, initialization, extensions and window
+	 * creation.
+	 */
+	class BS_RSGL_EXPORT GLSupport
+	{
+	public:
+		GLSupport() { }
+		virtual ~GLSupport() { }
+
+		/**
+		 * Creates a new render window using the specified descriptor.
+		 *
+		 * @param[in]	desc			Description of a render window to create.
+		 * @param[in]	windowId		Window ID provided by the render window manager.
+		 * @param[in]	parentWindow	Optional parent window if the window shouldn't be a main window. First created
+		 *								window cannot have a parent.
+		 * @return						Returns newly created window.
+		 */
+		virtual RenderWindowPtr newWindow(RENDER_WINDOW_DESC& desc, UINT32 windowId, RenderWindowPtr parentWindow) = 0;
+
+		/**
+		 * Creates a new render window using the specified descriptor.
+		 *
+		 * @param[in]	desc			Description of a render window to create.
+		 * @param[in]	windowId		Window ID provided by the render window manager.
+		 * @param[in]	parentWindow	Optional parent window if the window shouldn't be a main window. First created
+		 *								window cannot have a parent.
+		 * @return						Returns newly created window.
+		 */
+		virtual SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId) = 0;
+
+		/**	Called when OpenGL is being initialized. */
+		virtual void start() = 0;
+
+		/**	Called when OpenGL is being shut down. */
+		virtual void stop() = 0;
+
+		/**	Gets OpenGL vendor name. */
+		const String& getGLVendor() const
+		{
+			return mVendor;
+		}
+
+		/**	Gets OpenGL version string. */
+		const String& getGLVersion() const
+		{
+			return mVersion;
+		}
+
+		/**	Checks is the specified extension available. */
+		virtual bool checkExtension(const String& ext) const;
+
+		/**	Gets an address of an OpenGL procedure with the specified name. */
+		virtual void* getProcAddress(const String& procname) = 0;
+
+		/** Initializes OpenGL extensions. Must be called after we have a valid and active OpenGL context. */
+		virtual void initializeExtensions();
+
+		/**	Gets a structure describing all available video modes. */
+		virtual VideoModeInfoPtr getVideoModeInfo() const = 0;
+
+	protected:
+		Set<String> extensionList;
+
+		String mVersion;
+		String mVendor;
+	};
+
+	/** @} */
 };

+ 77 - 71
Source/BansheeGLRenderAPI/Include/BsGLTexture.h

@@ -1,72 +1,78 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsTexture.h"
-#include "BsGLSupport.h"
-
-namespace BansheeEngine 
-{
-	/**	OpenGL implementation of a texture. */
-    class BS_RSGL_EXPORT GLTextureCore : public TextureCore
-    {
-    public:
-		virtual ~GLTextureCore();
-
-		/**	Returns OpenGL texture target type. */
-        GLenum getGLTextureTarget() const;
-
-		/**	Returns internal OpenGL texture handle. */
-        GLuint getGLID() const;
-
-		/**	Returns the internal OpenGL format used by the texture. */
-		GLenum getGLFormat() const { return mGLFormat; }
-		
-		/**
-		 * Returns a hardware pixel buffer for a certain face and level of the texture.
-		 * 
-		 * @param[in]	face	Index of the texture face, if texture has more than one. Array index for texture arrays and
-		 *						a cube face for cube textures.
-		 * @param[in]	mipmap	Index of the mip level. 0 being the largest mip level.
-		 *
-		 * @note	Cube face indices: +X (0), -X (1), +Y (2), -Y (3), +Z (4), -Z (5)
-		 */
-		std::shared_ptr<GLPixelBuffer> getBuffer(UINT32 face, UINT32 mipmap);
-
-    protected:
-		friend class GLTextureCoreManager;
-
-		GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
-
-		/** @copydoc TextureCore::initialize */
-		void initialize() override;
-
-		/** @copydoc TextureCore::lock */
-		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) override;
-
-		/** @copydoc TextureCore::unlock */
-		void unlockImpl() override;
-
-		/** @copydoc TextureCore::copy */
-		void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target) override;
-
-		/** @copydoc TextureCore::readData */
-		void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) override;
-
-		/** @copydoc TextureCore::writeData */
-		void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) override;
-
-		/** Creates pixel buffers for each face and mip level. Texture must have been created previously. */
-		void createSurfaceList();
-
-    private:
-        GLuint mTextureID;
-		GLenum mGLFormat;
-        GLSupport& mGLSupport;
-		std::shared_ptr<GLPixelBuffer> mLockedBuffer;
-		
-		Vector<std::shared_ptr<GLPixelBuffer>>mSurfaceList;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsTexture.h"
+#include "BsGLSupport.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of a texture. */
+    class BS_RSGL_EXPORT GLTextureCore : public TextureCore
+    {
+    public:
+		virtual ~GLTextureCore();
+
+		/**	Returns OpenGL texture target type. */
+        GLenum getGLTextureTarget() const;
+
+		/**	Returns internal OpenGL texture handle. */
+        GLuint getGLID() const;
+
+		/**	Returns the internal OpenGL format used by the texture. */
+		GLenum getGLFormat() const { return mGLFormat; }
+		
+		/**
+		 * Returns a hardware pixel buffer for a certain face and level of the texture.
+		 * 
+		 * @param[in]	face	Index of the texture face, if texture has more than one. Array index for texture arrays and
+		 *						a cube face for cube textures.
+		 * @param[in]	mipmap	Index of the mip level. 0 being the largest mip level.
+		 *
+		 * @note	Cube face indices: +X (0), -X (1), +Y (2), -Y (3), +Z (4), -Z (5)
+		 */
+		std::shared_ptr<GLPixelBuffer> getBuffer(UINT32 face, UINT32 mipmap);
+
+    protected:
+		friend class GLTextureCoreManager;
+
+		GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
+
+		/** @copydoc TextureCore::initialize */
+		void initialize() override;
+
+		/** @copydoc TextureCore::lock */
+		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) override;
+
+		/** @copydoc TextureCore::unlock */
+		void unlockImpl() override;
+
+		/** @copydoc TextureCore::copy */
+		void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target) override;
+
+		/** @copydoc TextureCore::readData */
+		void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) override;
+
+		/** @copydoc TextureCore::writeData */
+		void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) override;
+
+		/** Creates pixel buffers for each face and mip level. Texture must have been created previously. */
+		void createSurfaceList();
+
+    private:
+        GLuint mTextureID;
+		GLenum mGLFormat;
+        GLSupport& mGLSupport;
+		std::shared_ptr<GLPixelBuffer> mLockedBuffer;
+		
+		Vector<std::shared_ptr<GLPixelBuffer>>mSurfaceList;
+    };
+
+	/** @} */
 }

+ 62 - 69
Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h

@@ -1,69 +1,62 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGLTexture.h"
-#include "BsGLSupport.h"
-#include "BsTextureManager.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles creation of OpenGL textures.
-	 */
-    class BS_RSGL_EXPORT GLTextureManager : public TextureManager
-    {
-    public:
-        GLTextureManager(GLSupport& support);
-        virtual ~GLTextureManager();
-
-		/**
-		 * @brief	Converts the provided format for the specified texture type and usage
-		 *			into a format that is supported by OpenGL.
-		 */
-		PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma) override;
-
-	protected:
-		/**
-		 * @copydoc	TextureManager::createRenderTextureImpl
-		 */
-		RenderTexturePtr createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
-
-		/**
-		 * @copydoc	TextureManager::createMultiRenderTextureImpl
-		 */
-		MultiRenderTexturePtr createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) override;
-
-        GLSupport& mGLSupport;
-    };
-
-	/**
-	 * @brief	Handles creation of OpenGL textures.
-	 */
-	class BS_RSGL_EXPORT GLTextureCoreManager : public TextureCoreManager
-	{
-	public:
-		GLTextureCoreManager(GLSupport& support);
-
-	protected:		
-		/**
-		 * @copydoc	TextureCoreManager::createTextureInternal
-		 */
-		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
-
-		/**
-		 * @copydoc	TextureCoreManager::createRenderTextureInternal
-		 */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) override;
-
-		/**
-		 * @copydoc	TextureCoreManager::createMultiRenderTextureInternal
-		 */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) override;
-
-		GLSupport& mGLSupport;
-	};
-}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGLTexture.h"
+#include "BsGLSupport.h"
+#include "BsTextureManager.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Handles creation of OpenGL textures. */
+    class BS_RSGL_EXPORT GLTextureManager : public TextureManager
+    {
+    public:
+        GLTextureManager(GLSupport& support);
+        virtual ~GLTextureManager();
+
+		/**
+		 * Converts the provided format for the specified texture type and usage into a format that is supported by OpenGL.
+		 */
+		PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma) override;
+
+	protected:
+		/** @copydoc TextureManager::createRenderTextureImpl */
+		RenderTexturePtr createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
+
+		/** @copydoc TextureManager::createMultiRenderTextureImpl */
+		MultiRenderTexturePtr createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) override;
+
+        GLSupport& mGLSupport;
+    };
+
+	/**
+	 * @brief	Handles creation of OpenGL textures.
+	 */
+	class BS_RSGL_EXPORT GLTextureCoreManager : public TextureCoreManager
+	{
+	public:
+		GLTextureCoreManager(GLSupport& support);
+
+	protected:		
+		/** @copydoc TextureCoreManager::createTextureInternal */
+		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
+			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
+
+		/** @copydoc TextureCoreManager::createRenderTextureInternal */
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) override;
+
+		/** @copydoc TextureCoreManager::createMultiRenderTextureInternal */
+		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) override;
+
+		GLSupport& mGLSupport;
+	};
+
+	/** @} */
+}

+ 48 - 55
Source/BansheeGLRenderAPI/Include/BsGLTimerQuery.h

@@ -1,56 +1,49 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsTimerQuery.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	OpenGL implementation of a timer query.
-	 */
-	class BS_RSGL_EXPORT GLTimerQuery : public TimerQuery
-	{
-	public:
-		GLTimerQuery();
-		~GLTimerQuery();
-
-		/**
-		 * @copydoc TimerQuery::begin
-		 */
-		virtual void begin();
-
-		/**
-		 * @copydoc TimerQuery::end
-		 */
-		virtual void end();
-
-		/**
-		 * @copydoc TimerQuery::isReady
-		 */
-		virtual bool isReady() const;
-
-		/**
-		 * @copydoc TimerQuery::getTimeMs
-		 */
-		virtual float getTimeMs();
-
-	private:
-		friend class QueryManager;
-
-		/**
-		 * @brief	Processes query results and saves them for later use. To be called
-		 *			when query has completed.
-		 */
-		void finalize();
-
-	private:
-		GLuint mQueryStartObj;
-		GLuint mQueryEndObj;
-		bool mFinalized;
-		bool mEndIssued;
-
-		float mTimeDelta;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsTimerQuery.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of a timer query. */
+	class BS_RSGL_EXPORT GLTimerQuery : public TimerQuery
+	{
+	public:
+		GLTimerQuery();
+		~GLTimerQuery();
+
+		/** @copydoc TimerQuery::begin */
+		void begin() override;
+
+		/** @copydoc TimerQuery::end */
+		void end() override;
+
+		/** @copydoc TimerQuery::isReady */
+		bool isReady() const override;
+
+		/** @copydoc TimerQuery::getTimeMs */
+		float getTimeMs() override;
+
+	private:
+		friend class QueryManager;
+
+		/** Processes query results and saves them for later use. To be called when query has completed. */
+		void finalize();
+
+	private:
+		GLuint mQueryStartObj;
+		GLuint mQueryEndObj;
+		bool mFinalized;
+		bool mEndIssued;
+
+		float mTimeDelta;
+	};
+
+	/** @} */
 }

+ 24 - 20
Source/BansheeGLRenderAPI/Include/BsGLUtil.h

@@ -1,21 +1,25 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#if BS_PLATFORM == BS_PLATFORM_WIN32
-
-#include "Win32/BsWin32GLSupport.h"
-#include "Win32/BsWin32VideoModeInfo.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Helper method that returns a platform specific GL support object.
-	 */
-	GLSupport* getGLSupport()
-	{
-		return bs_new<Win32GLSupport>();
-	}
-};
-
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#if BS_PLATFORM == BS_PLATFORM_WIN32
+
+#include "Win32/BsWin32GLSupport.h"
+#include "Win32/BsWin32VideoModeInfo.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Helper method that returns a platform specific GL support object. */
+	GLSupport* getGLSupport()
+	{
+		return bs_new<Win32GLSupport>();
+	}
+
+	/** @} */
+};
+
 #endif

+ 77 - 82
Source/BansheeGLRenderAPI/Include/BsGLVertexArrayObjectManager.h

@@ -1,83 +1,78 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Vertex array object that contains vertex buffer object bindings and vertex
-	 *			attribute pointers for a specific set of vertex buffers and a vertex declaration.
-	 */
-	class BS_RSGL_EXPORT GLVertexArrayObject
-	{
-	private:
-		/**
-		 * @brief	Generates hash value for the VAO object.
-		 */
-		class Hash
-		{
-		public:
-			::std::size_t operator()(const GLVertexArrayObject& vao) const;
-		};
-
-		/**
-		 * @brief	Checks if two VAO objects are equal.
-		 */
-		class Equal
-		{
-		public:
-			bool operator()(const GLVertexArrayObject &a, const GLVertexArrayObject &b) const;
-		};
-
-	public:
-		bool operator== (const GLVertexArrayObject& obj);
-		bool operator!= (const GLVertexArrayObject& obj);
-
-		/**
-		 * @brief	Returns internal OpenGL VBO handle.
-		 */
-		GLuint getGLHandle() const { return mHandle;  }
-
-	private:
-		friend class GLVertexArrayObjectManager;
-
-		GLVertexArrayObject();
-		GLVertexArrayObject(GLuint handle, UINT64 vertexProgramId, GLVertexBufferCore** attachedBuffers, UINT32 numBuffers);
-
-		GLuint mHandle;
-		UINT64 mVertProgId;
-		GLVertexBufferCore** mAttachedBuffers;
-		UINT32 mNumBuffers;
-	};
-
-	/**
-	 * @brief	Manager that handles creation and destruction of vertex array objects.
-	 */
-	class BS_RSGL_EXPORT GLVertexArrayObjectManager : public Module<GLVertexArrayObjectManager>
-	{
-	public:
-		~GLVertexArrayObjectManager();
-
-		/**
-		 * @brief	Attempts to find an existing vertex array object matching the provided set of vertex buffers,
-		 *			vertex declaration, and vertex shader input parameters. If one cannot be found new one is created
-		 *			and returned.
-		 *
-		 *			Lifetime of returned VAO is managed by the vertex buffers that it binds.
-		 */
-		const GLVertexArrayObject& getVAO(const SPtr<GLSLGpuProgramCore>& vertexProgram,
-			const SPtr<VertexDeclarationCore>& vertexDecl, const Vector<SPtr<VertexBufferCore>>& boundBuffers);
-
-		/**
-		 * @brief	Called when a vertex buffer containing the provided VAO is destroyed.
-		 */
-		void notifyBufferDestroyed(GLVertexArrayObject vao);
-	private:
-		typedef UnorderedSet<GLVertexArrayObject, GLVertexArrayObject::Hash, GLVertexArrayObject::Equal> VAOMap;
-
-		VAOMap mVAObjects;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**
+	 * Vertex array object that contains vertex buffer object bindings and vertex attribute pointers for a specific set of
+	 * vertex buffers and a vertex declaration.
+	 */
+	class BS_RSGL_EXPORT GLVertexArrayObject
+	{
+	private:
+		/**	Generates hash value for the VAO object. */
+		class Hash
+		{
+		public:
+			::std::size_t operator()(const GLVertexArrayObject& vao) const;
+		};
+
+		/**	Checks if two VAO objects are equal. */
+		class Equal
+		{
+		public:
+			bool operator()(const GLVertexArrayObject &a, const GLVertexArrayObject &b) const;
+		};
+
+	public:
+		bool operator== (const GLVertexArrayObject& obj);
+		bool operator!= (const GLVertexArrayObject& obj);
+
+		/**	Returns internal OpenGL VBO handle. */
+		GLuint getGLHandle() const { return mHandle;  }
+
+	private:
+		friend class GLVertexArrayObjectManager;
+
+		GLVertexArrayObject();
+		GLVertexArrayObject(GLuint handle, UINT64 vertexProgramId, GLVertexBufferCore** attachedBuffers, UINT32 numBuffers);
+
+		GLuint mHandle;
+		UINT64 mVertProgId;
+		GLVertexBufferCore** mAttachedBuffers;
+		UINT32 mNumBuffers;
+	};
+
+	/**	Manager that handles creation and destruction of vertex array objects. */
+	class BS_RSGL_EXPORT GLVertexArrayObjectManager : public Module<GLVertexArrayObjectManager>
+	{
+	public:
+		~GLVertexArrayObjectManager();
+
+		/**
+		 * Attempts to find an existing vertex array object matching the provided set of vertex buffers, vertex declaration,
+		 * and vertex shader input parameters. If one cannot be found new one is created and returned.
+		 *
+		 * Lifetime of returned VAO is managed by the vertex buffers that it binds.
+		 */
+		const GLVertexArrayObject& getVAO(const SPtr<GLSLGpuProgramCore>& vertexProgram,
+			const SPtr<VertexDeclarationCore>& vertexDecl, const Vector<SPtr<VertexBufferCore>>& boundBuffers);
+
+		/**	Called when a vertex buffer containing the provided VAO is destroyed. */
+		void notifyBufferDestroyed(GLVertexArrayObject vao);
+	private:
+		typedef UnorderedSet<GLVertexArrayObject, GLVertexArrayObject::Hash, GLVertexArrayObject::Equal> VAOMap;
+
+		VAOMap mVAObjects;
+	};
+
+	/** @} */
 }

+ 55 - 66
Source/BansheeGLRenderAPI/Include/BsGLVertexBuffer.h

@@ -1,67 +1,56 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsVertexBuffer.h"
-#include "BsGLVertexArrayObjectManager.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	OpenGL implementation of a vertex buffer.
-	 */
-    class BS_RSGL_EXPORT GLVertexBufferCore : public VertexBufferCore
-    {
-    public:
-		GLVertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
-		~GLVertexBufferCore();
-
-		/**
-		 * @copydoc	VertexBufferCore::readData
-		 */
-        void readData(UINT32 offset, UINT32 length, void* pDest);
-
-		/**
-		* @copydoc	VertexBufferCore::writeData
-		*/
-        void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**
-		 * @brief	Returns internal OpenGL buffer ID.
-		 */
-        GLuint getGLBufferId() const { return mBufferId; }
-
-		/**
-		 * @brief	Registers a new VertexArrayObject that uses this vertex buffer.
-		 */
-		void registerVAO(const GLVertexArrayObject& vao);
-
-		/**
-		 * @brief	Unregisters a VAO from this vertex buffer. Does not destroy it.
-		 */
-		void unregisterVAO(const GLVertexArrayObject& vao);
-
-	protected:
-		/**
-		 * @copydoc VertexBufferCore::initialize
-		 */
-		void initialize();
-
-		/**
-		 * @copydoc	VertexBufferCore::lockImpl
-		 */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-		/**
-		 * @copydoc	VertexBufferCore::unlockImpl
-		 */
-		void unlockImpl();
-
-	private:
-		GLuint mBufferId;
-		bool mZeroLocked;
-
-		Vector<GLVertexArrayObject> mVAObjects;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsVertexBuffer.h"
+#include "BsGLVertexArrayObjectManager.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	OpenGL implementation of a vertex buffer. */
+    class BS_RSGL_EXPORT GLVertexBufferCore : public VertexBufferCore
+    {
+    public:
+		GLVertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
+		~GLVertexBufferCore();
+
+		/** @copydoc VertexBufferCore::readData */
+        void readData(UINT32 offset, UINT32 length, void* pDest) override;
+
+		/** @copydoc VertexBufferCore::writeData */
+        void writeData(UINT32 offset, UINT32 length, const void* pSource, 
+			BufferWriteType writeFlags = BufferWriteType::Normal) override;
+
+		/**	Returns internal OpenGL buffer ID. */
+        GLuint getGLBufferId() const { return mBufferId; }
+
+		/**	Registers a new VertexArrayObject that uses this vertex buffer. */
+		void registerVAO(const GLVertexArrayObject& vao);
+
+		/**	Unregisters a VAO from this vertex buffer. Does not destroy it. */
+		void unregisterVAO(const GLVertexArrayObject& vao);
+
+	protected:
+		/** @copydoc VertexBufferCore::initialize */
+		void initialize() override;
+
+		/** @copydoc VertexBufferCore::lockImpl */
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+
+		/** @copydod VertexBufferCore::unlockImpl */
+		void unlockImpl() override;
+
+	private:
+		GLuint mBufferId;
+		bool mZeroLocked;
+
+		Vector<GLVertexArrayObject> mVAObjects;
+    };
+
+	/** @} */
 }

+ 41 - 43
Source/BansheeGLRenderAPI/Include/Win32/BsWin32Context.h

@@ -1,44 +1,42 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsWin32Prerequisites.h"
-#include "BsGLContext.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Windows specific implementation of an OpenGL context.
-	 */
-    class BS_RSGL_EXPORT Win32Context : public GLContext
-    {
-    public:
-		/**
-		 * @brief	Constructs a new context from a Windows device context and OpenGL rendering context.
-		 *			Optionally you may specify that the context isn't owned by us (might be created by some external
-		 *			library), in which case it will not be automatically released.
-		 */
-        Win32Context(HDC hdc, HGLRC glrc, bool ownsContext);
-        virtual ~Win32Context();
-
-        /**
-         * @copydoc	GLContext::setCurrent
-         */
-        virtual void setCurrent();
-
-        /**
-         * @copydoc	GLContext::endCurrent
-         */
-		virtual void endCurrent();
-
-        /**
-         * @copydoc	GLContext::releaseContext
-         */
-		virtual void releaseContext();
-
-	protected:
-        HDC     mHDC;
-        HGLRC   mGlrc;
-		bool	mOwnsContext;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsWin32Prerequisites.h"
+#include "BsGLContext.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Windows specific implementation of an OpenGL context. */
+    class BS_RSGL_EXPORT Win32Context : public GLContext
+    {
+    public:
+		/**
+		 * Constructs a new context from a Windows device context and OpenGL rendering context. Optionally you may specify
+		 * that the context isn't owned by us (might be created by some external library), in which case it will not be
+		 * automatically released.
+		 */
+        Win32Context(HDC hdc, HGLRC glrc, bool ownsContext);
+        virtual ~Win32Context();
+
+        /** @copydoc GLContext::setCurrent */
+        void setCurrent() override;
+
+        /** @copydoc GLContext::endCurrent */
+		void endCurrent() override;
+
+        /** @copydoc GLContext::releaseContext  */
+		void releaseContext() override;
+
+	protected:
+        HDC     mHDC;
+        HGLRC   mGlrc;
+		bool	mOwnsContext;
+    };
+
+	/** @} */
 }

+ 80 - 97
Source/BansheeGLRenderAPI/Include/Win32/BsWin32GLSupport.h

@@ -1,98 +1,81 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsWin32Prerequisites.h"
-#include "BsGLSupport.h"
-#include "BsGLRenderAPI.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles OpenGL initialization, window creation and extensions
-	 *			on Windows.
-	 */
-	class BS_RSGL_EXPORT Win32GLSupport : public GLSupport
-	{
-	public:
-        Win32GLSupport();
-
-		/**
-		 * @copydoc	GLSupport::newWindow
-		 */
-		virtual RenderWindowPtr newWindow(RENDER_WINDOW_DESC& desc, UINT32 windowId, RenderWindowPtr parentWindow) override;
-
-		/**
-		 * @copydoc	GLSupport::newWindowCore
-		 */
-		virtual SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
-
-		/**
-		 * @copydoc	GLSupport::start
-		 */
-		void start() override;
-
-		/**
-		 * @copydoc	GLSupport::stop
-		 */
-		void stop() override;
-
-		/**
-		 * @copydoc	GLSupport::getProcAddress
-		 */
-		void* getProcAddress(const String& procname) override;
-
-		/**
-		 * @copydoc	GLSupport::initializeExtensions
-		 */
-		virtual void initializeExtensions() override;
-		
-		/**
-		 * @brief	Creates a new OpenGL context.
-		 *
-		 * @param	hdc				Handle to device context to create the context from.
-		 * @param	externalGlrc	(Optional) Handle to external OpenGL context. If not provided
-		 *							new context will be created.
-		 *
-		 * @returns	Newly created GLContext class referencing the created or external context handle.
-		 */
-		SPtr<Win32Context> createContext(HDC hdc, HGLRC externalGlrc = 0);
-
-		/**
-		 * @brief	Selects and sets an appropriate pixel format based on the provided parameters.
-		 *
-		 * @param	hdc			Handle to device context to create the context from.
-		 * @param	colorDepth	Wanted color depth of the pixel format, in bits.
-		 * @param	multisample	Amount of multisampling wanted, if any.
-		 * @param	hwGamma		Should the format support automatic gamma conversion on write/read.
-		 * @param	depth		Should the pixel format contain the depth/stencil buffer.
-		 *
-		 * @returns	True if a pixel format was successfully set.
-		 */
-		bool selectPixelFormat(HDC hdc, int colorDepth, int multisample, bool hwGamma, bool depthStencil);
-
-		/**
-		 * @copydoc	GLSupport::getVideoModeInfo
-		 */
-		VideoModeInfoPtr getVideoModeInfo() const override;
-
-	private:
-		/**
-		 * @brief	Initializes windows specific OpenGL extensions needed for advanced context creation.
-		 */
-		void initialiseWGL();
-
-		/**
-		 * @brief	Dummy window procedure used when creating the initial dummy OpenGL context.
-		 */
-		static LRESULT CALLBACK dummyWndProc(HWND hwnd, UINT umsg, WPARAM wp, LPARAM lp);
-
-		Vector<DEVMODE> mDevModes;
-		Win32RenderWindowCore *mInitialWindow;
-		Vector<int> mMultisampleLevels;
-		bool mHasPixelFormatARB;
-        bool mHasMultisample;
-		bool mHasHardwareGamma;
-		bool mHasAdvancedContext;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsWin32Prerequisites.h"
+#include "BsGLSupport.h"
+#include "BsGLRenderAPI.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Handles OpenGL initialization, window creation and extensions on Windows. */
+	class BS_RSGL_EXPORT Win32GLSupport : public GLSupport
+	{
+	public:
+        Win32GLSupport();
+
+		/** @copydoc GLSupport::newWindow */
+		virtual RenderWindowPtr newWindow(RENDER_WINDOW_DESC& desc, UINT32 windowId, RenderWindowPtr parentWindow) override;
+
+		/** @copydoc GLSupport::newWindowCore */
+		virtual SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
+
+		/** @copydoc GLSupport::start */
+		void start() override;
+
+		/** @copydoc GLSupport::stop */
+		void stop() override;
+
+		/** @copydoc GLSupport::getProcAddress */
+		void* getProcAddress(const String& procname) override;
+
+		/** @copydoc GLSupport::initializeExtensions */
+		void initializeExtensions() override;
+		
+		/**
+		 * Creates a new OpenGL context.
+		 *
+		 * @param[in]	hdc				Handle to device context to create the context from.
+		 * @param[in]	externalGlrc	(Optional) Handle to external OpenGL context. If not provided new context will be
+		 *								created.
+		 * @return						Newly created GLContext class referencing the created or external context handle.
+		 */
+		SPtr<Win32Context> createContext(HDC hdc, HGLRC externalGlrc = 0);
+
+		/**
+		 * Selects and sets an appropriate pixel format based on the provided parameters.
+		 *
+		 * @param[in]	hdc			Handle to device context to create the context from.
+		 * @param[in]	colorDepth	Wanted color depth of the pixel format, in bits.
+		 * @param[in]	multisample	Amount of multisampling wanted, if any.
+		 * @param[in]	hwGamma		Should the format support automatic gamma conversion on write/read.
+		 * @param[in]	depth		Should the pixel format contain the depth/stencil buffer.
+		 * @return					True if a pixel format was successfully set.
+		 */
+		bool selectPixelFormat(HDC hdc, int colorDepth, int multisample, bool hwGamma, bool depthStencil);
+
+		/** @copydoc GLSupport::getVideoModeInfo */
+		VideoModeInfoPtr getVideoModeInfo() const override;
+
+	private:
+		/**	Initializes windows specific OpenGL extensions needed for advanced context creation. */
+		void initialiseWGL();
+
+		/**	Dummy window procedure used when creating the initial dummy OpenGL context. */
+		static LRESULT CALLBACK dummyWndProc(HWND hwnd, UINT umsg, WPARAM wp, LPARAM lp);
+
+		Vector<DEVMODE> mDevModes;
+		Win32RenderWindowCore *mInitialWindow;
+		Vector<int> mMultisampleLevels;
+		bool mHasPixelFormatARB;
+        bool mHasMultisample;
+		bool mHasHardwareGamma;
+		bool mHasAdvancedContext;
+	};
+
+	/** @} */
 }

+ 22 - 18
Source/BansheeGLRenderAPI/Include/Win32/BsWin32Prerequisites.h

@@ -1,19 +1,23 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include <windows.h>
-#include <BsGLPrerequisites.h>
-
-namespace BansheeEngine
-{
-    class Win32GLSupport;
-    class Win32RenderWindow;
-    class Win32Context;
-	class Win32RenderWindowCore;
-
-	/**
-	 * @brief	Retrieves last Windows API error and returns a description of it.
-	 */
-	String translateWGLError();
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include <windows.h>
+#include <BsGLPrerequisites.h>
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+    class Win32GLSupport;
+    class Win32RenderWindow;
+    class Win32Context;
+	class Win32RenderWindowCore;
+
+	/**	Retrieves last Windows API error and returns a description of it. */
+	String translateWGLError();
+
+	/** @} */
 }

+ 160 - 154
Source/BansheeGLRenderAPI/Include/Win32/BsWin32RenderWindow.h

@@ -1,155 +1,161 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsWin32Prerequisites.h"
-#include "BsRenderWindow.h"
-
-namespace BansheeEngine 
-{
-	class Win32RenderWindow;
-
-	/**	Contains various properties that describe a render window. */
-	class BS_RSGL_EXPORT Win32RenderWindowProperties : public RenderWindowProperties
-	{
-	public:
-		Win32RenderWindowProperties(const RENDER_WINDOW_DESC& desc);
-		virtual ~Win32RenderWindowProperties() { }
-
-	private:
-		friend class Win32RenderWindowCore;
-		friend class Win32RenderWindow;
-	};
-
-	/**
-	 * Render window implementation for Windows.
-	 *
-	 * @note	Core thread only.
-	 */
-    class BS_RSGL_EXPORT Win32RenderWindowCore : public RenderWindowCore
-    {
-    public:
-		Win32RenderWindowCore(const RENDER_WINDOW_DESC& desc, UINT32 windowId, Win32GLSupport &glsupport);
-		~Win32RenderWindowCore();
-
-		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
-		void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0) override;
-
-		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
-		void setFullscreen(const VideoMode& mode) override;
-
-		/** @copydoc RenderWindowCore::setWindowed */
-		void setWindowed(UINT32 width, UINT32 height) override;
-
-		/** @copydoc RenderWindowCore::setHidden */
-		void setHidden(bool hidden) override;
-
-		/** @copydoc RenderWindowCore::minimize */
-		void minimize() override;
-
-		/** @copydoc RenderWindowCore::maximize */
-		void maximize() override;
-
-		/** @copydoc RenderWindowCore::restore */
-		void restore() override;
-
-		/** @copydoc RenderWindowCore::move */
-		void move(INT32 left, INT32 top) override;
-
-		/** @copydoc RenderWindowCore::resize */
-		void resize(UINT32 width, UINT32 height) override;
-
-		/** @copydoc RenderWindowCore::copyContentsToMemory */
-		void copyToMemory(PixelData &dst, FrameBuffer buffer);
-
-		/** @copydoc RenderWindowCore::swapBuffers */
-		void swapBuffers() override;
-
-		/** @copydoc RenderWindowCore::getCustomAttribute */
-		void getCustomAttribute(const String& name, void* pData) const override;
-
-		/** @copydoc RenderWindowCore::setActive */
-		virtual void setActive(bool state) override;
-
-		/** @copydoc RenderWindowCore::_windowMovedOrResized */
-		void _windowMovedOrResized() override;
-
-		/**	Returns handle to device context associated with the window. */
-		HDC _getHDC() const { return mHDC; }
-
-		/**	Returns internal window handle. */
-		HWND _getHWnd() const;
-
-	protected:
-		friend class Win32GLSupport;
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
-
-		/** @copydoc RenderWindowCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		/** @copydoc RenderWindowCore::getSyncedProperties */
-		RenderWindowProperties& getSyncedProperties() override { return mSyncedProperties; }
-
-		/** @copydoc RenderWindowCore::syncProperties */
-		void syncProperties() override;
-
-	protected:
-		friend class Win32RenderWindow;
-
-		Win32Window* mWindow;
-		Win32GLSupport& mGLSupport;
-		HDC	mHDC;
-		bool mIsChild;
-		char* mDeviceName;
-		int mDisplayFrequency;
-		bool mShowOnSwap;
-		SPtr<Win32Context> mContext;
-		Win32RenderWindowProperties mProperties;
-		Win32RenderWindowProperties mSyncedProperties;
-    };
-
-	/**
-	 * Render window implementation for Windows.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_RSGL_EXPORT Win32RenderWindow : public RenderWindow
-	{
-	public:
-		~Win32RenderWindow() { }
-
-		/** @copydoc RenderWindow::screenToWindowPos */
-		void getCustomAttribute(const String& name, void* pData) const override;
-
-		/** @copydoc RenderWindow::screenToWindowPos */
-		Vector2I screenToWindowPos(const Vector2I& screenPos) const override;
-
-		/** @copydoc RenderWindow::windowToScreenPos */
-		Vector2I windowToScreenPos(const Vector2I& windowPos) const override;
-
-		/** @copydoc RenderWindow::getCore */
-		SPtr<Win32RenderWindowCore> getCore() const;
-
-	protected:
-		friend class GLRenderWindowManager;
-		friend class Win32GLSupport;
-		friend class Win32RenderWindowCore;
-
-		Win32RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId, Win32GLSupport& glsupport);
-
-		/** @copydoc RenderWindow::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		/** @copydoc RenderWindow::syncProperties */
-		void syncProperties() override;
-
-		/**	Retrieves internal window handle. */
-		HWND getHWnd() const;
-
-	private:
-		Win32GLSupport& mGLSupport;
-		Win32RenderWindowProperties mProperties;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsWin32Prerequisites.h"
+#include "BsRenderWindow.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	class Win32RenderWindow;
+
+	/**	Contains various properties that describe a render window. */
+	class BS_RSGL_EXPORT Win32RenderWindowProperties : public RenderWindowProperties
+	{
+	public:
+		Win32RenderWindowProperties(const RENDER_WINDOW_DESC& desc);
+		virtual ~Win32RenderWindowProperties() { }
+
+	private:
+		friend class Win32RenderWindowCore;
+		friend class Win32RenderWindow;
+	};
+
+	/**
+	 * Render window implementation for Windows.
+	 *
+	 * @note	Core thread only.
+	 */
+    class BS_RSGL_EXPORT Win32RenderWindowCore : public RenderWindowCore
+    {
+    public:
+		Win32RenderWindowCore(const RENDER_WINDOW_DESC& desc, UINT32 windowId, Win32GLSupport &glsupport);
+		~Win32RenderWindowCore();
+
+		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
+		void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0) override;
+
+		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
+		void setFullscreen(const VideoMode& mode) override;
+
+		/** @copydoc RenderWindowCore::setWindowed */
+		void setWindowed(UINT32 width, UINT32 height) override;
+
+		/** @copydoc RenderWindowCore::setHidden */
+		void setHidden(bool hidden) override;
+
+		/** @copydoc RenderWindowCore::minimize */
+		void minimize() override;
+
+		/** @copydoc RenderWindowCore::maximize */
+		void maximize() override;
+
+		/** @copydoc RenderWindowCore::restore */
+		void restore() override;
+
+		/** @copydoc RenderWindowCore::move */
+		void move(INT32 left, INT32 top) override;
+
+		/** @copydoc RenderWindowCore::resize */
+		void resize(UINT32 width, UINT32 height) override;
+
+		/** @copydoc RenderWindowCore::copyContentsToMemory */
+		void copyToMemory(PixelData &dst, FrameBuffer buffer);
+
+		/** @copydoc RenderWindowCore::swapBuffers */
+		void swapBuffers() override;
+
+		/** @copydoc RenderWindowCore::getCustomAttribute */
+		void getCustomAttribute(const String& name, void* pData) const override;
+
+		/** @copydoc RenderWindowCore::setActive */
+		virtual void setActive(bool state) override;
+
+		/** @copydoc RenderWindowCore::_windowMovedOrResized */
+		void _windowMovedOrResized() override;
+
+		/**	Returns handle to device context associated with the window. */
+		HDC _getHDC() const { return mHDC; }
+
+		/**	Returns internal window handle. */
+		HWND _getHWnd() const;
+
+	protected:
+		friend class Win32GLSupport;
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize() override;
+
+		/** @copydoc RenderWindowCore::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		/** @copydoc RenderWindowCore::getSyncedProperties */
+		RenderWindowProperties& getSyncedProperties() override { return mSyncedProperties; }
+
+		/** @copydoc RenderWindowCore::syncProperties */
+		void syncProperties() override;
+
+	protected:
+		friend class Win32RenderWindow;
+
+		Win32Window* mWindow;
+		Win32GLSupport& mGLSupport;
+		HDC	mHDC;
+		bool mIsChild;
+		char* mDeviceName;
+		int mDisplayFrequency;
+		bool mShowOnSwap;
+		SPtr<Win32Context> mContext;
+		Win32RenderWindowProperties mProperties;
+		Win32RenderWindowProperties mSyncedProperties;
+    };
+
+	/**
+	 * Render window implementation for Windows.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_RSGL_EXPORT Win32RenderWindow : public RenderWindow
+	{
+	public:
+		~Win32RenderWindow() { }
+
+		/** @copydoc RenderWindow::screenToWindowPos */
+		void getCustomAttribute(const String& name, void* pData) const override;
+
+		/** @copydoc RenderWindow::screenToWindowPos */
+		Vector2I screenToWindowPos(const Vector2I& screenPos) const override;
+
+		/** @copydoc RenderWindow::windowToScreenPos */
+		Vector2I windowToScreenPos(const Vector2I& windowPos) const override;
+
+		/** @copydoc RenderWindow::getCore */
+		SPtr<Win32RenderWindowCore> getCore() const;
+
+	protected:
+		friend class GLRenderWindowManager;
+		friend class Win32GLSupport;
+		friend class Win32RenderWindowCore;
+
+		Win32RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId, Win32GLSupport& glsupport);
+
+		/** @copydoc RenderWindow::getProperties */
+		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
+
+		/** @copydoc RenderWindow::syncProperties */
+		void syncProperties() override;
+
+		/**	Retrieves internal window handle. */
+		HWND getHWnd() const;
+
+	private:
+		Win32GLSupport& mGLSupport;
+		Win32RenderWindowProperties mProperties;
+	};
+
+	/** @} */
 }

+ 44 - 46
Source/BansheeGLRenderAPI/Include/Win32/BsWin32VideoModeInfo.h

@@ -1,47 +1,45 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsVideoModeInfo.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @copydoc	VideoMode
-	 */
-	class BS_RSGL_EXPORT Win32VideoMode : public VideoMode
-	{
-	public:
-		Win32VideoMode(UINT32 width, UINT32 height, float refreshRate, UINT32 outputIdx);
-
-	private:
-		friend class Win32VideoOutputInfo;
-	};
-
-	/**
-	 * @copydoc	VideoOutputInfo
-	 */
-	class BS_RSGL_EXPORT Win32VideoOutputInfo : public VideoOutputInfo
-	{
-	public:
-		Win32VideoOutputInfo(HMONITOR monitorHandle, UINT32 outputIdx);
-
-		/**
-		 * @brief	Gets a Win32 handle to the monitor referenced by this object.
-		 */
-		HMONITOR getMonitorHandle() const { return mMonitorHandle; }
-
-	private:
-		HMONITOR mMonitorHandle;
-	};
-
-	/**
-	 * @copydoc	VideoModeInfo
-	 */
-	class BS_RSGL_EXPORT Win32VideoModeInfo : public VideoModeInfo
-	{
-	public:
-		Win32VideoModeInfo();
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsVideoModeInfo.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/** @copydoc VideoMode */
+	class BS_RSGL_EXPORT Win32VideoMode : public VideoMode
+	{
+	public:
+		Win32VideoMode(UINT32 width, UINT32 height, float refreshRate, UINT32 outputIdx);
+
+	private:
+		friend class Win32VideoOutputInfo;
+	};
+
+	/** @copydoc VideoOutputInfo */
+	class BS_RSGL_EXPORT Win32VideoOutputInfo : public VideoOutputInfo
+	{
+	public:
+		Win32VideoOutputInfo(HMONITOR monitorHandle, UINT32 outputIdx);
+
+		/**	Gets a Win32 handle to the monitor referenced by this object. */
+		HMONITOR getMonitorHandle() const { return mMonitorHandle; }
+
+	private:
+		HMONITOR mMonitorHandle;
+	};
+
+	/** @copydoc VideoModeInfo */
+	class BS_RSGL_EXPORT Win32VideoModeInfo : public VideoModeInfo
+	{
+	public:
+		Win32VideoModeInfo();
+	};
+
+	/** @} */
 }

+ 51 - 56
Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLGpuProgram.h

@@ -1,56 +1,51 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGpuProgram.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	GPU program compiled from GLSL and usable by OpenGL.
-	 */
-    class BS_RSGL_EXPORT GLSLGpuProgramCore : public GpuProgramCore
-    {
-	public:
-		~GLSLGpuProgramCore();
-
-		/**
-		 * @copydoc	GpuProgramCore::isSupported
-		 */
-		bool isSupported() const override;
-
-		/**
-		 * @brief	Gets internal OpenGL handle to the program.
-		 */
-		GLuint getGLHandle() const { return mGLHandle; }
-
-		/**
-		 * @brief	Gets an unique index for this GPU program. Each created GPU program is
-		 *			assigned a unique index on creation.
-		 */
-		UINT32 getProgramID() const { return mProgramID; }
-
-	private:
-		friend class GLSLProgramFactory;
-
-		GLSLGpuProgramCore(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, bool isAdjacencyInfoRequired);
-
-		/**
-		 * @copydoc GpuProgramCore::initialize
-		 */
-		void initialize() override;
-
-	private:
-		UINT32 mProgramID;
-		GLuint mGLHandle;
-
-		static UINT32 mVertexShaderCount;
-		static UINT32 mFragmentShaderCount;
-		static UINT32 mGeometryShaderCount;
-		static UINT32 mHullShaderCount;
-		static UINT32 mDomainShaderCount;
-		static UINT32 mComputeShaderCount;
-    };
-}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGpuProgram.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	GPU program compiled from GLSL and usable by OpenGL. */
+    class BS_RSGL_EXPORT GLSLGpuProgramCore : public GpuProgramCore
+    {
+	public:
+		~GLSLGpuProgramCore();
+
+		/** @copydoc GpuProgramCore::isSupported */
+		bool isSupported() const override;
+
+		/**	Gets internal OpenGL handle to the program. */
+		GLuint getGLHandle() const { return mGLHandle; }
+
+		/** Gets an unique index for this GPU program. Each created GPU program is assigned a unique index on creation. */
+		UINT32 getProgramID() const { return mProgramID; }
+
+	private:
+		friend class GLSLProgramFactory;
+
+		GLSLGpuProgramCore(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, bool isAdjacencyInfoRequired);
+
+		/** @copydoc GpuProgramCore::initialize */
+		void initialize() override;
+
+	private:
+		UINT32 mProgramID;
+		GLuint mGLHandle;
+
+		static UINT32 mVertexShaderCount;
+		static UINT32 mFragmentShaderCount;
+		static UINT32 mGeometryShaderCount;
+		static UINT32 mHullShaderCount;
+		static UINT32 mDomainShaderCount;
+		static UINT32 mComputeShaderCount;
+    };
+
+	/** @} */
+}

+ 96 - 106
Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLParamParser.h

@@ -1,107 +1,97 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsVertexDeclaration.h"
-#include "BsDebug.h"
-#include "BsException.h"
-#include "BsGpuParamDesc.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Holds a GLSL program input attribute used in vertex programs.
-	 */
-	struct GLSLAttribute
-	{
-		/**
-		 * @brief	Constructs a new attribute from a name and a semantic that represents
-		 *			in which way is the attribute used.
-		 */
-		GLSLAttribute(const String& name, VertexElementSemantic semantic)
-		:mName(name), mSemantic(semantic)
-		{ }
-
-		/**
-		 * @brief	Return true if attribute name matches the specified name
-		 *			and returns optional semantic index if it exists. Start of the
-		 *			two compared strings must match, and the remaining non-matching
-		 *			bit will be assumed to be the semantic index. Returns -1 if no
-		 *			match is made.
-		 */
-		INT32 matchesName(const String& name);
-
-		/**
-		 * @brief	Returns the semantic of this attribute.
-		 */
-		VertexElementSemantic getSemantic() const { return mSemantic; }
-
-	private:
-		String mName;
-		VertexElementSemantic mSemantic;
-	};
-
-	/**
-	 * @brief	Helper class that is able to parse a GLSL GPU program and retrieve
-	 *			used uniforms and input attributes.
-	 */
-	class GLSLParamParser
-	{
-	public:
-		/**
-		 * @brief	Parses a compiled OpenGL program and outputs a parameter description
-		 *			that contains information about used uniforms.
-		 *
-		 * @param	glProgram		OpenGL handle to the GPU program.
-		 * @param	returnParamDesc	Output structure containing the parsed data.
-		 */
-		void buildUniformDescriptions(GLuint glProgram, GpuParamDesc& returnParamDesc);
-
-		/**
-		 * @brief	Parses a compiled OpenGL program and outputs vertex element list that
-		 *			describes input attributes to the program. Only valid for vertex programs.
-		 *
-		 * @param	glProgram	OpenGL handle to the GPU program.
-		 */
-		List<VertexElement> buildVertexDeclaration(GLuint glProgram);
-
-	private:
-		/**
-		 * @brief	Populates information for uniform with the specified index into the
-		 *			provided structure.
-		 *
-		 * @param	desc			Output structure containing the parsed data.
-		 * @param	paramName		Name of the uniform.
-		 * @param	programHandle	Internal OpenGL handle to the GPU program.
-		 * @param	uniformIndex	Unique uniform index to retrieve data from. Obtained from OpenGL parsing methods.
-		 */
-		void determineParamInfo(GpuParamDataDesc& desc, const String& paramName, GLuint programHandle, GLuint uniformIndex);
-
-		/**
-		* Attempts to find out a vertex element semantic based on input parameter name.
-		* GLSL has no concept of semantics, so we require all shaders to use specific names for attributes
-		* so that we know what they are used for.
-		*
-		* Valid names and semantics:
-		*  bs_position - VES_POSITION
-		*  bs_normal - VES_NORMAL
-		*  bs_tangent - VES_TANGENT
-		*  bs_bitangent - VES_BITANGENT
-		*  bs_texcoord - VES_TEXCOORD
-		*  bs_color - VES_COLOR
-		*  bs_blendweights - VES_BLEND_WEIGHTS
-		*  bs_blendindices - VES_BLEND_INDICES
-		*
-		* You may append a number to the end of the name to specify semantic index.
-		*
-		* @return	True if it succeeds, false if it fails.
-		*/
-		bool attribNameToElementSemantic(const String& name, VertexElementSemantic& semantic, UINT16& index);
-
-		/**
-		 * @brief	Converts an OpenGL type to vertex element type.
-		 */
-		VertexElementType glTypeToAttributeType(GLenum glType);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsVertexDeclaration.h"
+#include "BsDebug.h"
+#include "BsException.h"
+#include "BsGpuParamDesc.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Holds a GLSL program input attribute used in vertex programs. */
+	struct GLSLAttribute
+	{
+		/** Constructs a new attribute from a name and a semantic that represents in which way is the attribute used. */
+		GLSLAttribute(const String& name, VertexElementSemantic semantic)
+		:mName(name), mSemantic(semantic)
+		{ }
+
+		/**
+		 * Return true if attribute name matches the specified name and returns optional semantic index if it exists. Start
+		 * of the two compared strings must match, and the remaining non-matching bit will be assumed to be the semantic
+		 * index. Returns -1 if no match is made.
+		 */
+		INT32 matchesName(const String& name);
+
+		/**	Returns the semantic of this attribute. */
+		VertexElementSemantic getSemantic() const { return mSemantic; }
+
+	private:
+		String mName;
+		VertexElementSemantic mSemantic;
+	};
+
+	/** Helper class that is able to parse a GLSL GPU program and retrieve used uniforms and input attributes. */
+	class GLSLParamParser
+	{
+	public:
+		/**
+		 * Parses a compiled OpenGL program and outputs a parameter description that contains information about used
+		 * uniforms.
+		 *
+		 * @param[in]	glProgram		OpenGL handle to the GPU program.
+		 * @param[in]	returnParamDesc	Output structure containing the parsed data.
+		 */
+		void buildUniformDescriptions(GLuint glProgram, GpuParamDesc& returnParamDesc);
+
+		/**
+		 * Parses a compiled OpenGL program and outputs vertex element list that describes input attributes to the program.
+		 * Only valid for vertex programs.
+		 *
+		 * @param[in]	glProgram	OpenGL handle to the GPU program.
+		 */
+		List<VertexElement> buildVertexDeclaration(GLuint glProgram);
+
+	private:
+		/**
+		 * Populates information for uniform with the specified index into the provided structure.
+		 *
+		 * @param[in]	desc			Output structure containing the parsed data.
+		 * @param[in]	paramName		Name of the uniform.
+		 * @param[in]	programHandle	Internal OpenGL handle to the GPU program.
+		 * @param[in]	uniformIndex	Unique uniform index to retrieve data from. Obtained from OpenGL parsing methods.
+		 */
+		void determineParamInfo(GpuParamDataDesc& desc, const String& paramName, GLuint programHandle, GLuint uniformIndex);
+
+		/**
+		 * Attempts to find out a vertex element semantic based on input parameter name. GLSL has no concept of semantics,
+		 * so we require all shaders to use specific names for attributes so that we know what they are used for.
+		 *
+		 * Valid names and semantics:
+		 *  bs_position - VES_POSITION
+		 *  bs_normal - VES_NORMAL
+		 *  bs_tangent - VES_TANGENT
+		 *  bs_bitangent - VES_BITANGENT
+		 *  bs_texcoord - VES_TEXCOORD
+		 *  bs_color - VES_COLOR
+		 *  bs_blendweights - VES_BLEND_WEIGHTS
+		 *  bs_blendindices - VES_BLEND_INDICES
+		 *
+		 * You may append a number to the end of the name to specify semantic index.
+		 *
+		 * @return	True if it succeeds, false if it fails.
+		 */
+		bool attribNameToElementSemantic(const String& name, VertexElementSemantic& semantic, UINT16& index);
+
+		/**	Converts an OpenGL type to vertex element type. */
+		VertexElementType glTypeToAttributeType(GLenum glType);
+	};
+
+	/** @} */
 }

+ 35 - 35
Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLProgramFactory.h

@@ -1,36 +1,36 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsGpuProgramManager.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Factory class that deals with creating GLSL GPU programs.
-	 */
-    class BS_RSGL_EXPORT GLSLProgramFactory : public GpuProgramFactory
-    {
-    public:
-		/**
-		 * @copydoc	GpuProgramFactory::getLanguage
-		 */
-		const String& getLanguage() const override;
-
-		/**
-		 * @copydoc	GpuProgramFactory::getLanguage(const String&, const String&, GpuProgramType,
-		 *			GpuProgramProfile, bool)
-		 */
-        SPtr<GpuProgramCore> create(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, bool requireAdjacency) override;
-
-		/**
-		 * @copydoc	GpuProgramFactory::create(GpuProgramType)
-		 */
-		SPtr<GpuProgramCore> create(GpuProgramType type) override;
-
-	protected:
-		static const String LANGUAGE_NAME;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+#include "BsGpuProgramManager.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Factory class that deals with creating GLSL GPU programs. */
+    class BS_RSGL_EXPORT GLSLProgramFactory : public GpuProgramFactory
+    {
+    public:
+		/** @copydoc GpuProgramFactory::getLanguage */
+		const String& getLanguage() const override;
+
+		/**
+		 * @copydoc	GpuProgramFactory::getLanguage(const String&, const String&, GpuProgramType,
+		 *			GpuProgramProfile, bool)
+		 */
+        SPtr<GpuProgramCore> create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, bool requireAdjacency) override;
+
+		/** @copydoc GpuProgramFactory::create(GpuProgramType) */
+		SPtr<GpuProgramCore> create(GpuProgramType type) override;
+
+	protected:
+		static const String LANGUAGE_NAME;
+    };
+
+	/** @} */
 }

+ 68 - 70
Source/BansheeGLRenderAPI/Source/GLSL/include/BsGLSLProgramPipelineManager.h

@@ -1,71 +1,69 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Wrapper around OpenGL pipeline object.
-	 */
-	struct GLSLProgramPipeline
-	{
-		GLuint glHandle;
-	};
-
-	/**
-	 * @brief	Managed OpenGL pipeline objects that are used for binding a certain combination
-	 *			of GPU programs to the render system.
-	 *
-	 * @note	In OpenGL you cannot bind GPU programs to the pipeline manually. Instead as a preprocessing step
-	 *			you create a pipeline object containing the programs you plan on using, and then later you bind the
-	 *			previously created pipeline object. 
-	 */
-	class GLSLProgramPipelineManager
-	{
-	public:
-		~GLSLProgramPipelineManager();
-
-		/**
-		 * @brief	Creates or returns an existing pipeline that uses the provided combination of GPU programs. Provide
-		 *			null for unused programs.
-		 */
-		const GLSLProgramPipeline* getPipeline(GLSLGpuProgramCore* vertexProgram, GLSLGpuProgramCore* fragmentProgram,
-			GLSLGpuProgramCore* geometryProgram, GLSLGpuProgramCore* hullProgram, GLSLGpuProgramCore* domainProgram);
-
-	private:
-		/**
-		 * @brief	Key that uniquely identifies a pipeline object.
-		 */
-		struct ProgramPipelineKey
-		{
-			UINT32 vertexProgKey;
-			UINT32 fragmentProgKey;
-			UINT32 geometryProgKey;
-			UINT32 hullProgKey;
-			UINT32 domainProgKey;
-		};
-
-		/**
-		 * @brief	Used for calculating a hash code from pipeline object key.
-		 */
-		class ProgramPipelineKeyHashFunction 
-		{
-		public:
-			::std::size_t operator()(const ProgramPipelineKey &key) const;
-		};
-
-		/**
-		 * @brief	Used for comparing two pipeline objects for equality.
-		 */
-		class ProgramPipelineKeyEqual 
-		{
-		public:
-			bool operator()(const ProgramPipelineKey &a, const ProgramPipelineKey &b) const;
-		};
-
-		typedef UnorderedMap<ProgramPipelineKey, GLSLProgramPipeline, ProgramPipelineKeyHashFunction, ProgramPipelineKeyEqual> ProgramPipelineMap;
-		ProgramPipelineMap mPipelines;
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsGLPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup GL
+	 *  @{
+	 */
+
+	/**	Wrapper around OpenGL pipeline object. */
+	struct GLSLProgramPipeline
+	{
+		GLuint glHandle;
+	};
+
+	/**
+	 * Managed OpenGL pipeline objects that are used for binding a certain combination of GPU programs to the render system.
+	 *
+	 * @note	
+	 * In OpenGL you cannot bind GPU programs to the pipeline manually. Instead as a preprocessing step you create a
+	 * pipeline object containing the programs you plan on using, and then later you bind the previously created pipeline
+	 * object. 
+	 */
+	class GLSLProgramPipelineManager
+	{
+	public:
+		~GLSLProgramPipelineManager();
+
+		/**
+		 * Creates or returns an existing pipeline that uses the provided combination of GPU programs. Provide null for
+		 * unused programs.
+		 */
+		const GLSLProgramPipeline* getPipeline(GLSLGpuProgramCore* vertexProgram, GLSLGpuProgramCore* fragmentProgram,
+			GLSLGpuProgramCore* geometryProgram, GLSLGpuProgramCore* hullProgram, GLSLGpuProgramCore* domainProgram);
+
+	private:
+		/**	Key that uniquely identifies a pipeline object. */
+		struct ProgramPipelineKey
+		{
+			UINT32 vertexProgKey;
+			UINT32 fragmentProgKey;
+			UINT32 geometryProgKey;
+			UINT32 hullProgKey;
+			UINT32 domainProgKey;
+		};
+
+		/**	Used for calculating a hash code from pipeline object key. */
+		class ProgramPipelineKeyHashFunction 
+		{
+		public:
+			::std::size_t operator()(const ProgramPipelineKey &key) const;
+		};
+
+		/**	Used for comparing two pipeline objects for equality. */
+		class ProgramPipelineKeyEqual 
+		{
+		public:
+			bool operator()(const ProgramPipelineKey &a, const ProgramPipelineKey &b) const;
+		};
+
+		typedef UnorderedMap<ProgramPipelineKey, GLSLProgramPipeline, ProgramPipelineKeyHashFunction, ProgramPipelineKeyEqual> ProgramPipelineMap;
+		ProgramPipelineMap mPipelines;
+	};
+
+	/** @} */
 }

+ 1 - 1
Source/BansheeMono/Include/BsMonoPrerequisites.h

@@ -20,7 +20,7 @@
 #    define BS_MONO_EXPORT
 #endif
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup Mono BansheeMono
  *	Scripting language backend using Mono's CLR.

+ 1 - 1
Source/BansheeOISInput/Include/BsOISPrerequisites.h

@@ -20,7 +20,7 @@
 #    define BS_OIS_EXPORT
 #endif
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup OISInput BansheeOISInput
  *	OIS implementation for raw keyboard/mouse/gamepad input.

+ 1 - 1
Source/BansheePhysX/Include/BsPhysXPrerequisites.h

@@ -24,7 +24,7 @@ namespace BansheeEngine
 #	define BS_PHYSX_EXPORT
 #endif
 
-/** @addtogroup Plugins/
+/** @addtogroup Plugins
 
 /** @defgroup PhysX BansheePhysX
  *	NVIDIA PhysX implementation of Banshee's physics.

+ 33 - 33
Source/BansheeSL/Include/BsSLPrerequisites.h

@@ -1,34 +1,34 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
-#	ifdef BS_SL_EXPORTS
-#		define BS_SL_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_SL_EXPORT
-#       else
-#    		define BS_SL_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_SL_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_SL_EXPORTS
-#endif
-
-/** @addtogroup Plugins/
-
-/** @defgroup BansheeSL BansheeSL
- *	Implementation of the Banshee Shading Language.
- */
-
-/** @} */
-
-namespace BansheeEngine
-{
-	const String SystemName = "BansheeSL";
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPrerequisites.h"
+
+#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
+#	ifdef BS_SL_EXPORTS
+#		define BS_SL_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define BS_SL_EXPORT
+#       else
+#    		define BS_SL_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#elif defined ( BS_GCC_VISIBILITY )
+#    define BS_SL_EXPORT  __attribute__ ((visibility("default")))
+#else
+#    define BS_SL_EXPORTS
+#endif
+
+/** @addtogroup Plugins
+
+/** @defgroup BansheeSL BansheeSL
+ *	Implementation of the Banshee Shading Language.
+ */
+
+/** @} */
+
+namespace BansheeEngine
+{
+	const String SystemName = "BansheeSL";
 }

+ 36 - 36
Source/RenderBeast/Include/BsRenderBeastPrerequisites.h

@@ -1,37 +1,37 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
-#	ifdef BS_BSRND_EXPORTS
-#		define BS_BSRND_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_BSRND_EXPORT
-#       else
-#    		define BS_BSRND_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_BSRND_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_BSRND_EXPORT
-#endif
-
-/** @addtogroup Plugins/
-
-/** @defgroup RenderBeast RenderBeast
- *	Banshee's default renderer implementation.
- */
-
-/** @} */
-
-namespace BansheeEngine
-{
-	class StaticRenderableHandler;
-	struct RenderBeastOptions;
-	struct PooledRenderTexture;
-	class RenderTargets;
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPrerequisites.h"
+
+#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
+#	ifdef BS_BSRND_EXPORTS
+#		define BS_BSRND_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define BS_BSRND_EXPORT
+#       else
+#    		define BS_BSRND_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#elif defined ( BS_GCC_VISIBILITY )
+#    define BS_BSRND_EXPORT  __attribute__ ((visibility("default")))
+#else
+#    define BS_BSRND_EXPORT
+#endif
+
+/** @addtogroup Plugins
+
+/** @defgroup RenderBeast RenderBeast
+ *	Banshee's default renderer implementation.
+ */
+
+/** @} */
+
+namespace BansheeEngine
+{
+	class StaticRenderableHandler;
+	struct RenderBeastOptions;
+	struct PooledRenderTexture;
+	class RenderTargets;
 }