Marko Pintera 11 лет назад
Родитель
Сommit
0d839f9f3d
27 измененных файлов с 702 добавлено и 366 удалено
  1. 3 2
      BansheeCore/Include/BsGpuBufferView.h
  2. 7 0
      BansheeD3D11RenderSystem/Include/BsD3D11BlendState.h
  3. 7 0
      BansheeD3D11RenderSystem/Include/BsD3D11DepthStencilState.h
  4. 42 17
      BansheeD3D11RenderSystem/Include/BsD3D11Device.h
  5. 42 2
      BansheeD3D11RenderSystem/Include/BsD3D11Driver.h
  6. 21 2
      BansheeD3D11RenderSystem/Include/BsD3D11DriverList.h
  7. 26 9
      BansheeD3D11RenderSystem/Include/BsD3D11GpuBuffer.h
  8. 38 3
      BansheeD3D11RenderSystem/Include/BsD3D11GpuBufferView.h
  9. 8 3
      BansheeD3D11RenderSystem/Include/BsD3D11GpuParamBlockBuffer.h
  10. 121 25
      BansheeD3D11RenderSystem/Include/BsD3D11GpuProgram.h
  11. 25 0
      BansheeD3D11RenderSystem/Include/BsD3D11HLSLParamParser.h
  12. 16 1
      BansheeD3D11RenderSystem/Include/BsD3D11HLSLProgramFactory.h
  13. 46 21
      BansheeD3D11RenderSystem/Include/BsD3D11HardwareBuffer.h
  14. 8 5
      BansheeD3D11RenderSystem/Include/BsD3D11HardwareBufferManager.h
  15. 8 2
      BansheeD3D11RenderSystem/Include/BsD3D11IndexBuffer.h
  16. 42 12
      BansheeD3D11RenderSystem/Include/BsD3D11InputLayoutManager.h
  17. 128 49
      BansheeD3D11RenderSystem/Include/BsD3D11Mappings.h
  18. 2 8
      BansheeD3D11RenderSystem/Include/BsD3D11Prerequisites.h
  19. 1 2
      BansheeD3D11RenderSystem/Source/BsD3D11Device.cpp
  20. 3 3
      BansheeD3D11RenderSystem/Source/BsD3D11Driver.cpp
  21. 1 3
      BansheeD3D11RenderSystem/Source/BsD3D11GpuBuffer.cpp
  22. 9 18
      BansheeD3D11RenderSystem/Source/BsD3D11HardwareBuffer.cpp
  23. 64 123
      BansheeD3D11RenderSystem/Source/BsD3D11Mappings.cpp
  24. 16 16
      BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp
  25. 2 2
      BansheeD3D11RenderSystem/Source/BsD3D11TextureManager.cpp
  26. 16 1
      Polish.txt
  27. 0 37
      Renderer.txt

+ 3 - 2
BansheeCore/Include/BsGpuBufferView.h

@@ -47,8 +47,9 @@ namespace BansheeEngine
 		virtual ~GpuBufferView();
 
 		/**
-		 * @brief	Initializes the GPU buffer view. Must be called right after
-		 *			construction.
+		 * @brief	Initializes the view with the specified buffer and 
+		 *			a set of parameters describing the view to create.
+		 *			Must be called right after construction.
 		 */
 		virtual void initialize(GpuBufferPtr buffer, GPU_BUFFER_DESC& desc);
 

+ 7 - 0
BansheeD3D11RenderSystem/Include/BsD3D11BlendState.h

@@ -5,11 +5,18 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	DirectX 11 implementation of a blend state. 
+	 *			Corresponds directly with a DX11 blend state object.
+	 */
 	class BS_D3D11_EXPORT D3D11BlendState : public BlendState
 	{
 	public:
 		~D3D11BlendState();
 
+		/**
+		 * @brief	Returns the internal DX11 blend state object.
+		 */
 		ID3D11BlendState* getInternal() const { return mBlendState; }
 
 	protected:

+ 7 - 0
BansheeD3D11RenderSystem/Include/BsD3D11DepthStencilState.h

@@ -5,11 +5,18 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	DirectX 11 implementation of a depth stencil state. 
+	 *			Corresponds directly with a DX11 depth stencil state object.
+	 */
 	class BS_D3D11_EXPORT D3D11DepthStencilState : public DepthStencilState
 	{
 	public:
 		~D3D11DepthStencilState();
 
+		/**
+		 * @brief	Returns the internal DX11 depth stencil state object.
+		 */
 		ID3D11DepthStencilState* getInternal() const { return mDepthStencilState; }
 
 	protected:

+ 42 - 17
BansheeD3D11RenderSystem/Include/BsD3D11Device.h

@@ -4,16 +4,48 @@
 
 namespace BansheeEngine
 {
+		/**
+		 * @brief	Available DX11 error levels.
+		 */
+		enum BS_D3D11_ERROR_LEVEL
+		{
+			D3D11ERR_NO_EXCEPTION,
+			D3D11ERR_CORRUPTION,
+			D3D11ERR_ERROR,
+			D3D11ERR_WARNING,
+			D3D11ERR_INFO
+		};
+
+	/**
+	 * @brief	Wrapper around DirectX 11 device object.
+	 */
 	class BS_D3D11_EXPORT D3D11Device
 	{
 	public:
+		/**
+		 * @brief	Constructs the object with a previously created DX11 device.
+		 */
 		D3D11Device(ID3D11Device* device);
 		~D3D11Device();
 
+		/**
+		 * @brief	Shuts down the device any releases any internal resources.
+		 */
 		void shutdown();
 
+		/**
+		 * @brief	Returns DX11 immediate context object.
+		 */
 		ID3D11DeviceContext* getImmediateContext() const { return mImmediateContext; }
+
+		/**
+		 * @brief	Returns DX11 class linkage object.
+		 */
 		ID3D11ClassLinkage* getClassLinkage() const { return mClassLinkage; }
+
+		/**
+		 * @brief	Returns internal DX11 device.
+		 */
 		ID3D11Device* getD3D11Device() const { return mD3D11Device; }		
 
 		/**
@@ -22,35 +54,28 @@ namespace BansheeEngine
 		void clearErrors();
 
 		/**
-		 * @brief	Query if error occurred at any point since class "clearError" call.
+		 * @brief	Query if error occurred at any point since last "clearError" call.
 		 * 			Use getErrorDescription to get a string describing the error.
 		 */
 		bool hasError() const;
 
 		/**
-		 * @brief	Returns a string describing an error, if one occurred.
+		 * @brief	Returns a string describing an error if one occurred.
 		 */
 		String getErrorDescription(bool clearErrors = true);
 		
-		enum BS_D3D11_ERROR_LEVEL
-		{
-			D3D11ERR_NO_EXCEPTION,
-			D3D11ERR_CORRUPTION,
-			D3D11ERR_ERROR,
-			D3D11ERR_WARNING,
-			D3D11ERR_INFO
-		};
-
+		/**
+		 * @brief	Sets the level for which we want to receive errors for. Errors will be reported
+		 *			for the provided level and any higher priority level.
+		 */
 		void setExceptionsErrorLevel(const BS_D3D11_ERROR_LEVEL exceptionsErrorLevel);
 
 	private:
-		ID3D11Device*			mD3D11Device;
-		ID3D11DeviceContext*	mImmediateContext;
-		ID3D11InfoQueue*		mInfoQueue; 
+		D3D11Device();
 
-		// Storing class linkage
+		ID3D11Device* mD3D11Device;
+		ID3D11DeviceContext* mImmediateContext;
+		ID3D11InfoQueue* mInfoQueue; 
 		ID3D11ClassLinkage* mClassLinkage;
-
-		D3D11Device();
 	};
 }

+ 42 - 2
BansheeD3D11RenderSystem/Include/BsD3D11Driver.h

@@ -4,27 +4,67 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Provides information about a driver (e.g. hardware GPU driver or software emulated).
+	 */
 	class D3D11Driver
 	{
 	public:
-		D3D11Driver(const D3D11Driver &ob);
+		/**
+		 * @brief	Constructs a new object from the adapter number provided by DX11 runtime, and
+		 *			DXGI adapter object.
+		 */
 		D3D11Driver(UINT32 adapterNumber, IDXGIAdapter* dxgiAdapter);
+		D3D11Driver(const D3D11Driver &ob);
 		~D3D11Driver();
 
 		D3D11Driver& operator=(const D3D11Driver& r);
 
+		/**
+		 * @brief	Returns the name of the driver.
+		 */
 		String getDriverName() const;
+
+		/**
+		 * @brief	Returns the description of the driver.
+		 */
 		String getDriverDescription() const;
+
+		/**
+		 * @brief	Returns adapter index of the adapter the driver is managing.
+		 */
 		UINT32 getAdapterNumber() const { return mAdapterNumber; }
+
+		/**
+		 * @brief	Returns number of outputs connected to the adapter the driver is managing.
+		 */
 		UINT32 getNumAdapterOutputs() const { return mNumOutputs; }
+
+		/**
+		 * @brief	Returns a description of the adapter the driver is managing.
+		 */
 		const DXGI_ADAPTER_DESC& getAdapterIdentifier() const { return mAdapterIdentifier; }
+
+		/**
+		 * @brief	Returns internal DXGI adapter object for the driver.
+		 */
 		IDXGIAdapter* getDeviceAdapter() { return mDXGIAdapter; }
+
+		/**
+		 * @brief	Returns description of an output device at the specified index.
+		 */
 		DXGI_OUTPUT_DESC getOutputDesc(UINT32 adapterOutputIdx) const;
 
+		/**
+		 * @brief	Returns a list of all available video modes for all output devices.
+		 */
 		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
 
 	private:
-		void init();
+		/**
+		 * @brief	Initializes the internal data.
+		 */
+		void construct();
 
 	private:
 		UINT32 mAdapterNumber;

+ 21 - 2
BansheeD3D11RenderSystem/Include/BsD3D11DriverList.h

@@ -4,20 +4,39 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Contains a list of all available drivers.
+	 */
 	class BS_D3D11_EXPORT D3D11DriverList
 	{
 	public:
+		/**
+		 * @brief	Constructs a new driver list from an existing DXGI factory object.
+		 */
 		D3D11DriverList(IDXGIFactory* dxgiFactory);
 		~D3D11DriverList();
 
+		/**
+		 * @brief	Returns the number of available drivers.
+		 */
 		UINT32 count() const;
 
+		/**
+		 * @brief	Returns a driver at the specified index.
+		 */
 		D3D11Driver* item(UINT32 idx) const;
+
+		/**
+		 * @brief	Returns a driver with the specified name, or null if it cannot be found.
+		 */
 		D3D11Driver* item(const String &name) const;
 
 	private:
-		Vector<D3D11Driver*> mDriverList;
-
+		/**
+		 * @brief	Enumerates the DXGI factory object and constructs a list of available drivers.
+		 */
 		void enumerate(IDXGIFactory* dxgiFactory);
+
+		Vector<D3D11Driver*> mDriverList;
 	};
 }

+ 26 - 9
BansheeD3D11RenderSystem/Include/BsD3D11GpuBuffer.h

@@ -5,6 +5,9 @@
 
 namespace BansheeEngine 
 {
+	/**
+	 * @brief	DirectX 11 implementation of a generic GPU buffer.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuBuffer : public GpuBuffer
     {
     public:
@@ -21,39 +24,53 @@ namespace BansheeEngine
 		virtual void unlock();
 
 		/**
-		* @copydoc GenericBuffer::readData
-		*/
+		 * @copydoc GenericBuffer::readData
+		 */
         virtual void readData(UINT32 offset, UINT32 length, void* pDest);
 
 		/**
-		* @copydoc GenericBuffer::writeData
-		*/
+		 * @copydoc GenericBuffer::writeData
+		 */
         virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
 			BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		/**
-		* @copydoc GenericBuffer::copyData
-		*/
+		 * @copydoc GenericBuffer::copyData
+		 */
 		void copyData(GpuBuffer& srcBuffer, UINT32 srcOffset, 
 			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
 
+		/**
+		 * @brief	Returns the internal DX11 GPU buffer object.
+		 */
 		ID3D11Buffer* getDX11Buffer() const;
 
 	protected:
 		friend class D3D11HardwareBufferManager;
 
-		D3D11GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+		/**
+		 * @copydoc	GpuBuffer::GpuBuffer
+		 */
+		D3D11GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
+			bool randomGpuWrite = false, bool useCounter = false);
 
+		/**
+		 * @copydoc GpuBuffer::createView
+		 */
 		virtual GpuBufferView* createView();
+
+		/**
+		 * @copydoc GpuBuffer::destroyView
+		 */
 		virtual void destroyView(GpuBufferView* view);
 
 		/**
-		 * @copydoc GpuBuffer::initialize_internal()
+		 * @copydoc GpuBuffer::initialize_internal
 		 */
 		void initialize_internal();	
 		
 		/**
-		 * @copydoc GpuBuffer::destroy_internal()
+		 * @copydoc GpuBuffer::destroy_internal
 		 */
 		void destroy_internal();
 

+ 38 - 3
BansheeD3D11RenderSystem/Include/BsD3D11GpuBufferView.h

@@ -5,19 +5,54 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Represents a specific view of a GpuBuffer. Different views all of the same buffer be used
+	 *			in different situations (e.g. for reading from a shader, or for a unordered read/write operation).
+	 */
 	class BS_D3D11_EXPORT D3D11GpuBufferView : public GpuBufferView
 	{
 	public:
 		D3D11GpuBufferView();
 		virtual ~D3D11GpuBufferView();
 
+		/**
+		 * @copydoc	GpuBufferView::initialize
+		 */
 		void initialize(GpuBufferPtr buffer, GPU_BUFFER_DESC& desc);
 
 	private:
-		ID3D11ShaderResourceView* mSRV;
-		ID3D11UnorderedAccessView* mUAV;
-
+		/**
+		 * @brief	Creates a DX11 shader resource view that allows a buffer to be bound to a shader for reading (the most
+		 *			common option). 
+		 *
+		 * @param	buffer			Buffer to create the view for.
+		 * @param	firstElement	Index of the first element the view manages. Interpretation of this value depends on
+		 *							exact buffer type. It may be byte offset for raw buffers, or number of elements for
+		 *							structured buffers.
+		 * @param	elementWidth	Width of a single element in the buffer. Size of the structure in structured buffers and
+		 *							ignored for raw buffers as they always operate on single byte basis.
+		 * @param	numElements		Number of elements the view manages, starting after the "firstElement". This means number of
+		 *							bytes for raw buffers or number of structures for structured buffers.
+		 *
+		 * @returns	Constructed DX11 shader resource view object.
+		 */
 		ID3D11ShaderResourceView* createSRV(D3D11GpuBuffer* buffer, UINT32 firstElement, UINT32 elementWidth, UINT32 numElements);
+
+		/**
+		 * @brief	Creates a DX11 unordered access view that allows a buffer to be bound to a shader for random reading or writing.
+		 *
+		 * @param	buffer			Buffer to create the view for.
+		 * @param	firstElement	Index of the first element the view manages. Interpretation of this value depends on
+		 *							exact buffer type. It may be byte offset for raw buffers, or number of elements for
+		 *							structured buffers.
+		 * @param	numElements		Number of elements the view manages, starting after the "firstElement". This means number of
+		 *							bytes for raw buffers or number of structures for structured buffers.
+		 *
+		 * @returns	Constructed DX11 unordered access view object.
+		 */
 		ID3D11UnorderedAccessView* createUAV(D3D11GpuBuffer* buffer, UINT32 firstElement, UINT32 numElements, bool useCounter);
+
+		ID3D11ShaderResourceView* mSRV;
+		ID3D11UnorderedAccessView* mUAV;
 	};
 }

+ 8 - 3
BansheeD3D11RenderSystem/Include/BsD3D11GpuParamBlockBuffer.h

@@ -5,22 +5,27 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	DirectX 11 implementation of a parameter block buffer (constant buffer in DX11 lingo).
+	 */
 	class BS_D3D11_EXPORT D3D11GpuParamBlockBuffer : public GpuParamBlockBuffer
 	{
 	public:
 		D3D11GpuParamBlockBuffer();
 
 		/**
-		 * @brief	Writes all of the data to the buffer.
-		 * 			Data size must be the same size as the buffer;
+		 * @copydoc GpuParamBlockBuffer::writeData.
 		 */
 		void writeData(const UINT8* data);
 
 		/**
-		 * @copydoc GpuParamBlockBuffer::readAll.
+		 * @copydoc GpuParamBlockBuffer::readData.
 		 */
 		void readData(UINT8* data) const;
 
+		/**
+		 * @brief	Returns internal DX11 buffer object.
+		 */
 		ID3D11Buffer* getD3D11Buffer() const;
 	protected:
 		/**

+ 121 - 25
BansheeD3D11RenderSystem/Include/BsD3D11GpuProgram.h

@@ -5,15 +5,22 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Abstraction of a DirectX 11 shader object.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuProgram : public GpuProgram
 	{
-		static UINT32 GlobalProgramId;
-
 	public:
 		virtual ~D3D11GpuProgram();
 
+		/**
+		 * @copydoc	GpuProgram::getLanguage
+		 */
 		const String& getLanguage() const;
 
+		/**
+		 * @copydoc	GpuProgram::createParameters
+		 */
 		GpuParamsPtr createParameters();
 
 		/**
@@ -21,36 +28,40 @@ namespace BansheeEngine
 		 */
 		virtual bool requiresMatrixTranspose() const { return mColumnMajorMatrices; }
 
-		/** Sets whether matrix packing in column-major order. */
-		void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
-		/** Gets whether matrix packed in column-major order. */
-		bool getColumnMajorMatrices() const { return mColumnMajorMatrices; }
-		/** Sets whether backwards compatibility is enabled. */
-		void setEnableBackwardsCompatibility(bool enableBackwardsCompatibility) { mEnableBackwardsCompatibility = enableBackwardsCompatibility; }
-		/** Gets whether backwards compatibility is enabled. */
-		bool getEnableBackwardsCompatibility() const { return mEnableBackwardsCompatibility; }
-
+		/**
+		 * @brief	Returns compiled shader microcode.
+		 */
 		const HLSLMicroCode& getMicroCode() const { return mMicrocode; }
 
+		/**
+		 * @brief	Returns GPU program input declaration. Only relevant for vertex programs.
+		 */
 		VertexDeclarationPtr getInputDeclaration() const { return mInputDeclaration; }
+
+		/**
+		 * @brief	Returns unique GPU program ID.
+		 */
 		UINT32 getProgramId() const { return mProgramId; }
 
 	protected:
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuProgram(const String& source, const String& entryPoint, GpuProgramType gptype, 
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired);
 
 		/**
-		* @copydoc GpuProgram::initialize_internal()
-		*/
+		 * @copydoc GpuProgram::initialize_internal
+		 */
 		void initialize_internal();
 
 		/**
-		* @copydoc GpuProgram::destroy_internal()
-		*/
+		 * @copydoc GpuProgram::destroy_internal
+		 */
 		void destroy_internal();
 
 		/**
-		 * @brief	Loads shader from microcode.
+		 * @brief	Loads the shader from microcode.
 		 */
 		virtual void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode) = 0;
 
@@ -66,6 +77,8 @@ namespace BansheeEngine
 		void populateParametersAndConstants(ID3DBlob* microcode);
 
 	protected:
+		static UINT32 GlobalProgramId;
+
 		bool mColumnMajorMatrices;
 		bool mEnableBackwardsCompatibility;
 		UINT32 mProgramId;
@@ -82,16 +95,25 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 	};
 
+	/**
+	 * @brief	Implementation of a DX11 vertex shader.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuVertexProgram : public D3D11GpuProgram
 	{
 	public:
 		~D3D11GpuVertexProgram();
 
+		/**
+		 * @brief	Returns internal DX11 vertex shader object.
+		 */
 		ID3D11VertexShader* getVertexShader() const;
-		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		friend class D3D11HLSLProgramFactory;
 
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuVertexProgram(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
 
@@ -100,6 +122,11 @@ namespace BansheeEngine
 		 */
 		void destroy_internal();
 
+		/**
+		 * @copydoc	D3D11GpuProgram::loadFromMicrocode
+		 */
+		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		ID3D11VertexShader* mVertexShader;
 
@@ -112,16 +139,25 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 	};
 
+	/**
+	 * @brief	Implementation of a DX11 pixel shader.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuFragmentProgram : public D3D11GpuProgram
 	{
 	public:
 		~D3D11GpuFragmentProgram();
 
+		/**
+		 * @brief	Returns internal DX11 pixel shader object.
+		 */
 		ID3D11PixelShader* getPixelShader() const;
-		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		friend class D3D11HLSLProgramFactory;
 
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuFragmentProgram(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
 
@@ -129,6 +165,12 @@ namespace BansheeEngine
 		 * @copydoc GpuProgram::destroy_internal().
 		 */
 		void destroy_internal();
+
+		/**
+		 * @copydoc	D3D11GpuProgram::loadFromMicrocode
+		 */
+		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		ID3D11PixelShader* mPixelShader;
 
@@ -141,16 +183,25 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 	};
 
+	/**
+	 * @brief	Implementation of a DX11 domain shader.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuDomainProgram : public D3D11GpuProgram
 	{
 	public:
 		~D3D11GpuDomainProgram();
 
+		/**
+		 * @brief	Returns internal DX11 domain shader object.
+		 */
 		ID3D11DomainShader* getDomainShader() const;
-		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		friend class D3D11HLSLProgramFactory;
 
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuDomainProgram(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
 
@@ -159,6 +210,11 @@ namespace BansheeEngine
 		 */
 		void destroy_internal();
 
+		/**
+		 * @copydoc	D3D11GpuProgram::loadFromMicrocode
+		 */
+		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		ID3D11DomainShader* mDomainShader;
 
@@ -171,24 +227,38 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 	};
 
+	/**
+	 * @brief	Implementation of a DX11 hull shader.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuHullProgram : public D3D11GpuProgram
 	{
 	public:
 		~D3D11GpuHullProgram();
 
+		/**
+		 * @brief	Returns internal DX11 hull shader object.
+		 */
 		ID3D11HullShader* getHullShader() const;
-		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		friend class D3D11HLSLProgramFactory;
 
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuHullProgram(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
 
 		/**
-		 * @copydoc GpuProgram::destroy_internal().
+		 * @copydoc GpuProgram::destroy_internal
 		 */
 		void destroy_internal();
 
+		/**
+		 * @copydoc	D3D11GpuProgram::loadFromMicrocode
+		 */
+		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		ID3D11HullShader* mHullShader;
 
@@ -201,26 +271,39 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 	};
 
+	/**
+	 * @brief	Implementation of a DX11 geometry shader.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuGeometryProgram : public D3D11GpuProgram
 	{
 	public:
 		~D3D11GpuGeometryProgram();
 
+		/**
+		 * @brief	Returns internal DX11 geometry shader object.
+		 */
 		ID3D11GeometryShader* getGeometryShader() const;
-		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 
 	protected:
 		friend class D3D11HLSLProgramFactory;
 
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuGeometryProgram(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
 			bool isAdjacencyInfoRequired);
 
 		/**
-		 * @copydoc GpuProgram::destroy_internal().
+		 * @copydoc GpuProgram::destroy_internal
 		 */
 		void destroy_internal();
 
+		/**
+		 * @copydoc	D3D11GpuProgram::loadFromMicrocode
+		 */
+		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		ID3D11GeometryShader* mGeometryShader;
 
@@ -233,25 +316,38 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const;
 	};
 
+	/**
+	 * @brief	Implementation of a DX11 compute shader.
+	 */
 	class BS_D3D11_EXPORT D3D11GpuComputeProgram : public D3D11GpuProgram
 	{
 	public:
 		~D3D11GpuComputeProgram();
 
+		/**
+		 * @brief	Returns internal DX11 compute shader object.
+		 */
 		ID3D11ComputeShader* getComputeShader() const;
-		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 
 	protected:
 		friend class D3D11HLSLProgramFactory;
 
+		/**
+		 * @copydoc	GpuProgram::GpuProgram
+		 */
 		D3D11GpuComputeProgram(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
 
 		/**
-		 * @copydoc GpuProgram::destroy_internal().
+		 * @copydoc GpuProgram::destroy_internal
 		 */
 		void destroy_internal();
 
+		/**
+		 * @copydoc	D3D11GpuProgram::loadFromMicrocode
+		 */
+		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
+
 	protected:
 		ID3D11ComputeShader* mComputeShader;
 

+ 25 - 0
BansheeD3D11RenderSystem/Include/BsD3D11HLSLParamParser.h

@@ -5,14 +5,39 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Handles parsing of GPU program microcode and extracting constant and input parameter data.
+	 */
 	class D3D11HLSLParamParser
 	{
 	public:
+		/**
+		 * @brief	Parses the provided microcode and outputs constant parameter descriptions, and optionally for
+		 *			vertex GPU programs a set of input parameters.
+		 *
+		 * @param	microcode	Compiled GPU program microcode to parse.
+		 * @param	desc		Output object that will contain parameter descriptions.
+		 * @param	inputParams	Output object that will contain a set of program input parameters. Can be null if not required.
+		 *						Only relevant for vertex programs.
+		 */
 		void parse(ID3DBlob* microcode, GpuParamDesc& desc, VertexDeclaration::VertexElementList* inputParams);
 
 	private:
+		/**
+		 * @brief	Parses the provided constant buffer retrieving information about all of its members and storing
+		 *			them in the provided GPU params description object.
+		 */
 		void parseBuffer(ID3D11ShaderReflectionConstantBuffer* bufferReflection, GpuParamDesc& desc);
+
+		/**
+		 * @brief	Parses the resource description structure and stores it in the provided GPU params description object.
+		 */
 		void parseResource(D3D11_SHADER_INPUT_BIND_DESC& resourceDesc, GpuParamDesc& desc);
+
+		/**
+		 * @brief	Parses a variable with the specified type and variable description. Adds the variable in the provided
+		 *			GPU params description object and assigns it to the provided param block.
+		 */
 		void parseVariable(D3D11_SHADER_TYPE_DESC& varTypeDesc, D3D11_SHADER_VARIABLE_DESC& varDesc, GpuParamDesc& desc, GpuParamBlockDesc& paramBlock);
 	};
 }

+ 16 - 1
BansheeD3D11RenderSystem/Include/BsD3D11HLSLProgramFactory.h

@@ -5,15 +5,30 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Handles creation of DirectX 11 HLSL GPU programs.
+	 */
 	class BS_D3D11_EXPORT D3D11HLSLProgramFactory : public GpuProgramFactory
 	{
 	public:
 		D3D11HLSLProgramFactory();
 		~D3D11HLSLProgramFactory();
 
-		const String& getLanguage(void) const;
+		/**
+		 * @copydoc	GpuProgramFactory::getLanguage
+		 */
+		const String& getLanguage() const;
+
+		/**
+		 * @copydoc	GpuProgramFactory::getLanguage(const String&, const String&, GpuProgramType,
+		 *			GpuProgramProfile, const Vector<HGpuProgInclude>*, bool)
+		 */
 		GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
 			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requireAdjacencyInfo);
+
+		/**
+		* @copydoc	GpuProgramFactory::create(GpuProgramType)
+		*/
 		GpuProgramPtr create(GpuProgramType type);
 
 	protected:

+ 46 - 21
BansheeD3D11RenderSystem/Include/BsD3D11HardwareBuffer.h

@@ -5,37 +5,67 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Class containing common functionality for all DirectX 11 hardware buffers.
+	 */
 	class BS_D3D11_EXPORT D3D11HardwareBuffer : public HardwareBuffer
 	{
 	public:
+		/**
+		 * @brief	Available types of DX11 buffers
+		 */
 		enum BufferType
 		{
-			BT_VERTEX = 0x1,
-			BT_INDEX = 0x2,
-			BT_CONSTANT = 0x4,
-			BT_GROUP_GENERIC = 0x8,
-			BT_STRUCTURED = BT_GROUP_GENERIC | 0x10,
-			BT_RAW = BT_GROUP_GENERIC | 0x20,
-			BT_INDIRECTARGUMENT = BT_GROUP_GENERIC | 0x40,
-			BT_APPENDCONSUME = BT_GROUP_GENERIC | 0x80
+			BT_VERTEX = 0x1, /**< Contains geometry vertices and their properties. */
+			BT_INDEX = 0x2, /**< Contains triangle to vertex mapping. */
+			BT_CONSTANT = 0x4, /**< Contains GPU program parameters. */
+			BT_GROUP_GENERIC = 0x8, /**< Special value signifying a buffer is of generic type. Not an actual buffer. */
+			BT_STRUCTURED = BT_GROUP_GENERIC | 0x10, /**< Generic buffer that holds one or more user-defined structures laid out sequentially. */
+			BT_RAW = BT_GROUP_GENERIC | 0x20, /**< Generic buffer that holds raw block of bytes with no defined structure. */
+			BT_INDIRECTARGUMENT = BT_GROUP_GENERIC | 0x40, /**< Generic buffer that is used for holding parameters used for indirect rendering. */
+			BT_APPENDCONSUME = BT_GROUP_GENERIC | 0x80 /**< Generic buffer that allows the GPU program to use append/consume functionality. */
 		};
 
+		/**
+		 * @copydoc	HardwareBuffer::HardwareBuffer
+		 */
 		D3D11HardwareBuffer(BufferType btype, GpuBufferUsage usage, UINT32 elementCount, UINT32 elementSize, 
 			D3D11Device& device, bool useSystemMem = false, bool streamOut = false, bool randomGpuWrite = false, bool useCounter = false);
 		~D3D11HardwareBuffer();
 
-		/** See HardwareBuffer. */
+		/**
+		 * @copydoc	HardwareBuffer::readData
+		 */
 		void readData(UINT32 offset, UINT32 length, void* pDest);
-		/** See HardwareBuffer. */
-		void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
-		/** See HardwareBuffer. We perform a hardware copy here. */
-		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
 
-		/// Get the D3D-specific buffer
-		ID3D11Buffer* getD3DBuffer(void) { return mD3DBuffer; }
+		/**
+		 * @copydoc	HardwareBuffer::writeData
+		 */
+		void writeData(UINT32 offset, UINT32 length, const void* pSource, 
+			BufferWriteType writeFlags = BufferWriteType::Normal);
+
+		/**
+		 * @copydoc	HardwareBuffer::copyData
+		 */
+		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, 
+			UINT32 length, bool discardWholeBuffer = false);
+
+		/**
+		 * @brief	Returns the internal DX11 buffer object.
+		 */
+		ID3D11Buffer* getD3DBuffer() { return mD3DBuffer; }
 
 	protected:
+		/**
+		 * @copydoc	HardwareBuffer::lockImpl
+		 */
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
+
+		/**
+		 * @copydoc	HardwareBuffer::unlockImpl
+		 */
+		void unlockImpl();
+
 		BufferType mBufferType;
 		bool mRandomGpuWrite;
 		bool mUseCounter;
@@ -50,10 +80,5 @@ namespace BansheeEngine
 		
 		D3D11Device& mDevice;
 		D3D11_BUFFER_DESC mDesc;
-
-		/** See HardwareBuffer. */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-		/** See HardwareBuffer. */
-		void unlockImpl(void);
 	};
 }

+ 8 - 5
BansheeD3D11RenderSystem/Include/BsD3D11HardwareBufferManager.h

@@ -5,6 +5,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Handles creation of DirectX 11 hardware buffers.
+	 */
 	class BS_D3D11_EXPORT D3D11HardwareBufferManager : public HardwareBufferManager
 	{
 	public:
@@ -12,8 +15,6 @@ namespace BansheeEngine
 		~D3D11HardwareBufferManager();
 
 	protected:     
-		D3D11Device& mDevice;
-
 		/**
 		 * @copydoc HardwareBufferManager::createVertexBufferImpl
 		 */
@@ -24,15 +25,17 @@ namespace BansheeEngine
 		 */
 		IndexBufferPtr createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
 
-		/** @copydoc HardwareBufferManager::createGpuParamBlockBufferImpl */
+		/** 
+		 * @copydoc HardwareBufferManager::createGpuParamBlockBufferImpl 
+		 */
 		GpuParamBlockBufferPtr createGpuParamBlockBufferImpl();
 
 		/**
 		 * @copydoc HardwareBufferManager::createGenericBufferImpl
-		 *
-		 * DirectX 9 does not support generic buffers so this method will return a dummy instance.
 		 */
 		GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+		D3D11Device& mDevice;
 	};
 }

+ 8 - 2
BansheeD3D11RenderSystem/Include/BsD3D11IndexBuffer.h

@@ -6,6 +6,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	DirectX 11 implementation of an index buffer.
+	 */
 	class BS_D3D11_EXPORT D3D11IndexBuffer : public IndexBuffer
 	{
 	public:
@@ -27,18 +30,21 @@ namespace BansheeEngine
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
 
 		/**
-		 * @brief	Get the D3D-specific index buffer
+		 * @brief	Gets the internal DX11 index buffer object.
 		 */
 		ID3D11Buffer* getD3DIndexBuffer() const { return mBuffer->getD3DBuffer(); }		
 
 	protected:
 		friend class D3D11HardwareBufferManager;
 
+		/**
+		 * @copydoc	IndexBuffer::IndexBuffer.
+		 */
 		D3D11IndexBuffer(D3D11Device& device, IndexType idxType, UINT32 numIndexes, 
 			GpuBufferUsage usage, bool useSystemMem);
 
 		/**
-		* @copydoc HardwareBuffer::lockImpl
+		 * @copydoc HardwareBuffer::lockImpl
 		 */
 		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 

+ 42 - 12
BansheeD3D11RenderSystem/Include/BsD3D11InputLayoutManager.h

@@ -5,27 +5,42 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Handles creation and caching of DirectX 11 input layout objects.
+	 */
 	class D3D11InputLayoutManager
 	{
 	public:
+		/**
+		 * @brief	Key uniquely identifying vertex declaration and vertex shader combination.
+		 */
 		struct VertexDeclarationKey
 		{
 			UINT64 vertxDeclId;
 			UINT32 vertexProgramId;
 		};
 
+		/**
+		 * @brief	Creates a hash from vertex declaration key.
+		 */
 		class HashFunc 
 		{
 		public:
 			::std::size_t operator()(const VertexDeclarationKey &key) const;
 		};
 
+		/**
+		 * @brief	Compares two vertex declaration keys.
+		 */
 		class EqualFunc
 		{
 		public:
 			bool operator()(const VertexDeclarationKey &a, const VertexDeclarationKey &b) const;
 		};
 
+		/**
+		 * @brief	Contains data about a single instance of DX11 input layout object.
+		 */
 		struct InputLayoutEntry
 		{
 			InputLayoutEntry() {}
@@ -39,16 +54,36 @@ namespace BansheeEngine
 		~D3D11InputLayoutManager();
 
 		/**
-		 * @brief	Finds an existing one or creates a new D3D11 input layout.
-		 * 			
-		 *			The created declaration will try to match the input to the provided shader with the
-		 *			data provided in the vertex buffer (described by the vertex buffer declaration).
-		 *			
-		 *			Error may be thrown if the vertex buffer doesn't provide all the necessary data.
-		 *			(TODO: Depends on how the driver handles missing data)
+		 * Finds an existing or creates a new D3D11 input layout. Input layout maps a vertex declaration
+		 * from a vertex buffer to vertex program input declaration
+		 *
+		 * @param	vertexShaderDecl	Vertex declaration describing vertex program input parameters.
+		 * @param	vertexBufferDecl	Vertex declaration describing structure of a vertex buffer to be bound as input
+		 *								to the GPU program.
+		 * @param	vertexProgram		Instance of the vertex program we are creating input layout for.
+		 *
+		 * @note	Error will be thrown if the vertex buffer doesn't provide all the necessary data that the shader expects.
 		 */
 		ID3D11InputLayout* retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram);
 
+	private:
+		/**
+		 * @brief	Creates a new input layout using the specified parameters and stores it in the input layout map.
+		 */
+		void addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram);
+
+		/**
+		 * @brief	Destroys least used input layout.
+		 */
+		void removeLeastUsed();
+
+		/**
+		 * @brief	Checks are the specified vertex shader input and vertex buffer declarations compatible.
+		 *			Vertex buffer must provide all inputs to the shader in order for them to be compatible
+		 *			(extra data is allowed).
+		 */
+		bool areCompatible(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl);
+
 	private:
 		static const int DECLARATION_BUFFER_SIZE = 1024;
 		static const int NUM_ELEMENTS_TO_PRUNE = 64;
@@ -57,10 +92,5 @@ namespace BansheeEngine
 
 		bool mWarningShown;
 		UINT32 mLastUsedCounter;
-
-		void addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram);
-		void removeLeastUsed();
-
-		bool areCompatible(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl);
 	};
 }

+ 128 - 49
BansheeD3D11RenderSystem/Include/BsD3D11Mappings.h

@@ -10,76 +10,155 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Helper class that maps engine types to DirectX 1 types
+	 */
 	class BS_D3D11_EXPORT D3D11Mappings
 	{
 	public:
-
-		/// enum identifying D3D11 filter usage type
-		enum eD3DFilterUsage
-		{
-			/// min filter
-			D3D_FUSAGE_MIN,
-			/// mag filter
-			D3D_FUSAGE_MAG,
-			/// mip filter
-			D3D_FUSAGE_MIP
-		};
-
-		/// return a D3D11 equivalent for an engine TextureAddressingMode value
+		/**
+		 * @brief	Converts engine to DX11 specific texture addressing mode.
+		 */
 		static D3D11_TEXTURE_ADDRESS_MODE get(TextureAddressingMode tam);
-		/// return a D3D11 equivalent for an engine SceneBlendFactor value
-		static D3D11_BLEND get(BlendFactor sbf);
-		/// return a D3D11 equivalent for an engine SceneBlendOperation value
-		static D3D11_BLEND_OP get(BlendOperation sbo);
-		/// return a D3D11 equivalent for an engine CompareFunction value
+
+		/**
+		 * @brief	Converts engine to DX11 specific blend factor.
+		 */
+		static D3D11_BLEND get(BlendFactor bf);
+
+		/**
+		 * @brief	Converts engine to DX11 specific blend operation.
+		 */
+		static D3D11_BLEND_OP get(BlendOperation bo);
+
+		/**
+		 * @brief	Converts engine to DX11 specific comparison function.
+		 */
 		static D3D11_COMPARISON_FUNC get(CompareFunction cf);
-		/// return a D3D11 equivalent for an engine CillingMode value
+
+		/**
+		 * @brief	Converts engine to DX11 specific culling mode.
+		 */
 		static D3D11_CULL_MODE get(CullingMode cm);
-		/// return a D3D11 equivalent for an engine PolygonMode value
-		static D3D11_FILL_MODE get(PolygonMode level);
-		/// return a D3D11 equivalent for an engine StencilOperation value
+
+		/**
+		 * @brief	Converts engine to DX11 specific polygon fill mode.
+		 */
+		static D3D11_FILL_MODE get(PolygonMode mode);
+
+		/**
+		 * @brief	Return DirectX 11 stencil operation and optionally 
+		 *			invert it (greater than becomes less than, etc.)
+		 */
 		static D3D11_STENCIL_OP get(StencilOperation op, bool invert = false);
-		/// return a D3D11 state type for engine FilterType value
+
+		/**
+		 * @brief	Converts engine texture filter type to DirectX 11 filter
+		 *			shift (used for combining to get actual min/mag/mip filter
+		 *			bit location).
+		 */
 		static DWORD get(FilterType ft);
-		static D3D11_FILTER get(const FilterOptions minification, const FilterOptions magnification, const FilterOptions mips, const bool comparison = false);
-		/// return the combination of D3DUSAGE values for engine buffer usage
+
+		/**
+		 * @brief	Returns DirectX 11 texture filter from the provided min, mag
+		 *			and mip filter options, and optionally a filter with comparison support.
+		 */
+		static D3D11_FILTER get(const FilterOptions min, const FilterOptions mag, 
+			const FilterOptions mip, const bool comparison = false);
+
+		/**
+		 * @brief	Converts engine to DX11 buffer usage.
+		 */
 		static DWORD get(GpuBufferUsage usage);
-		/// Get lock options
+
+		/**
+		 * @brief	Converts engine to DX11 lock options, while also constraining
+		 *			the options depending on provided usage type.
+		 */
 		static D3D11_MAP get(GpuLockOptions options, GpuBufferUsage usage);
-		static UINT getByteWidth(IndexBuffer::IndexType itype);
-		/// Get vertex data type
-		static DXGI_FORMAT get(VertexElementType vType);
-		/// Get vertex semantic
+
+		/**
+		 * @brief	Converts engine to DX11 vertex element type.
+		 */
+		static DXGI_FORMAT get(VertexElementType type);
+
+		/**
+		 * @brief	Returns a string describing the provided vertex element semantic.
+		 */
 		static LPCSTR get(VertexElementSemantic sem);
+
+		/**
+		 * @brief	Returns engine semantic from the provided semantic string. Throws an exception
+		 *			for semantics that do not exist.
+		 */
 		static VertexElementSemantic get(LPCSTR sem);
+
+		/**
+		 * @brief	Converts DirectX 11 GPU parameter component type to engine vertex element type.
+		 */
 		static VertexElementType getInputType(D3D_REGISTER_COMPONENT_TYPE type);
+
+		/**
+		 * @brief	Returns DX11 primitive topology based on the provided draw operation type.
+		 */
 		static D3D11_PRIMITIVE_TOPOLOGY getPrimitiveType(DrawOperationType type);
-		/// Get dx11 color
-		static void get(const Color& inColour, float * outColour );
+
+		/**
+		 * @brief	Converts engine color to DX11 color.
+		 */
+		static void get(const Color& inColor, float* outColor);
+
+		/**
+		 * @brief	Checks does the provided map value include writing.
+		 */
 		static bool isMappingWrite(D3D11_MAP map);
+
+		/**
+		 * @brief	Checks does the provided map value include reading.
+		 */
 		static bool isMappingRead(D3D11_MAP map);
-		static D3D11_BOX toDx11Box(const PixelVolume &inBox);
 
-		/// utility method, convert D3D11 pixel format to engine pixel format
-		static PixelFormat _getPF(DXGI_FORMAT d3dPF);
-		/// utility method, convert engine pixel format to D3D11 pixel format
-		static DXGI_FORMAT _getPF(PixelFormat format, bool hwGamma);
-		//
-		static D3D11_USAGE _getUsage(GpuBufferUsage mUsage);
-		static D3D11_USAGE _getUsage(int mUsage);
-		static UINT _getAccessFlags(GpuBufferUsage mUsage);
-		static UINT _getAccessFlags(int mUsage);
-		static bool _isDynamic(GpuBufferUsage mUsage);
+		/**
+		 * @brief	Converts DX11 pixel format to engine pixel format.
+		 */
+		static PixelFormat getPF(DXGI_FORMAT d3dPF);
 
-		static bool _isDynamic(int mUsage);
+		/**
+		 * @brief	Converts engine pixel format to DX11 pixel format. Some formats
+		 *			depend on whether hardware gamma is used or not, in which case
+		 *			set the "hwGamma" parameter as needed.
+		 */
+		static DXGI_FORMAT getPF(PixelFormat format, bool hwGamma);
+		
+		/**
+		 * @brief	Converts engine to DX11 buffer usage.
+		 */
+		static D3D11_USAGE getUsage(GpuBufferUsage mUsage);
 
-		/// utility method, find closest engine pixel format that D3D11 can support
-		static PixelFormat _getClosestSupportedPF(PixelFormat format, bool hwGamma);
+		/**
+		 * @brief	Converts engine to DX11 buffer access flags.
+		 */
+		static UINT getAccessFlags(GpuBufferUsage mUsage);
 
-		static TextureType _getTexType(D3D11_SRV_DIMENSION type);
+		/**
+		 * @brief	Converts engine to DX11 lock options.
+		 */
+		static D3D11_MAP getLockOptions(GpuLockOptions lockOptions);
 
-		static UINT32 _getSizeInBytes(PixelFormat pf, UINT32 xcount = 1, UINT32 ycount = 1);
+		/**
+		 * @brief	Checks is the provided buffer usage dynamic.
+		 */
+		static bool isDynamic(GpuBufferUsage mUsage);
 
-		static D3D11_MAP getLockOptions(GpuLockOptions lockOptions);
+		/**
+		 * @brief	Finds the closest pixel format that DX11 supports.
+		 */
+		static PixelFormat getClosestSupportedPF(PixelFormat format, bool hwGamma);
+
+		/**
+		 * @brief	Returns size in bytes of a pixel surface of the specified size and format, while
+		 *			using DX11 allocation rules for padding.
+		 */
+		static UINT32 getSizeInBytes(PixelFormat pf, UINT32 width = 1, UINT32 height = 1);
 	};
 }

+ 2 - 8
BansheeD3D11RenderSystem/Include/BsD3D11Prerequisites.h

@@ -2,17 +2,15 @@
 
 #include "BsCorePrerequisites.h"
 
-// some D3D commonly used macros
 #define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
 
-// enable extended d3d debug 
 #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
+#	define NOMINMAX // Required to stop windows.h messing up std::min
 #endif
 
 #include <d3d11.h>
@@ -21,7 +19,6 @@
 
 namespace BansheeEngine
 {
-	// Predefine classes
 	class D3D11RenderSystem;
 	class D3D11RenderWindow;
 	class D3D11Texture;
@@ -79,9 +76,6 @@ namespace BansheeEngine
 	typedef std::shared_ptr<D3D11RenderWindow> D3D11RenderWindowPtr;
 	typedef std::shared_ptr<D3D11GpuProgram> D3D11GpuProgramPtr;
 
-    //-------------------------------------------
-	// Windows setttings
-	//-------------------------------------------
 #if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(BS_STATIC_LIB)
 #	ifdef BS_RSD3D11_EXPORTS
 #		define BS_D3D11_EXPORT __declspec(dllexport)
@@ -94,5 +88,5 @@ namespace BansheeEngine
 #	endif
 #else
 #	define BS_D3D11_EXPORT
-#endif	// BS_PLATFORM_WIN32
+#endif
 }

+ 1 - 2
BansheeD3D11RenderSystem/Source/BsD3D11Device.cpp

@@ -49,7 +49,6 @@ namespace BansheeEngine
 
 	void D3D11Device::shutdown()
 	{
-		// Clear state
 		if (mImmediateContext)
 		{
 			mImmediateContext->Flush();
@@ -65,7 +64,7 @@ namespace BansheeEngine
 	String D3D11Device::getErrorDescription(bool doClearErrors)
 	{
 		if (mD3D11Device == nullptr)
-			return "NULL device";
+			return "Null device.";
 
 		String res;
 

+ 3 - 3
BansheeD3D11RenderSystem/Source/BsD3D11Driver.cpp

@@ -13,7 +13,7 @@ namespace BansheeEngine
 		if(mDXGIAdapter)
 			mDXGIAdapter->AddRef();
 
-		init();
+		construct();
 	}
 
 	D3D11Driver::D3D11Driver(UINT32 adapterNumber, IDXGIAdapter* pDXGIAdapter)
@@ -26,7 +26,7 @@ namespace BansheeEngine
 
 		pDXGIAdapter->GetDesc(&mAdapterIdentifier);
 
-		init();
+		construct();
 	}
 
 	D3D11Driver::~D3D11Driver()
@@ -34,7 +34,7 @@ namespace BansheeEngine
 		SAFE_RELEASE(mDXGIAdapter);
 	}
 
-	void D3D11Driver::init()
+	void D3D11Driver::construct()
 	{
 		assert(mDXGIAdapter != nullptr);
 

+ 1 - 3
BansheeD3D11RenderSystem/Source/BsD3D11GpuBuffer.cpp

@@ -9,9 +9,7 @@ namespace BansheeEngine
 {
 	D3D11GpuBuffer::D3D11GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter) 
 		: GpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter), mBuffer(nullptr)
-	{
-
-	}
+	{ }
 
 	D3D11GpuBuffer::~D3D11GpuBuffer()
 	{ }

+ 9 - 18
BansheeD3D11RenderSystem/Source/BsD3D11HardwareBuffer.cpp

@@ -41,8 +41,8 @@ namespace BansheeEngine
 		}
 		else
 		{
-			mDesc.Usage = D3D11Mappings::_getUsage(mUsage);
-			mDesc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage); 
+			mDesc.Usage = D3D11Mappings::getUsage(mUsage);
+			mDesc.CPUAccessFlags = D3D11Mappings::getAccessFlags(mUsage); 
 
 			switch(btype)
 			{
@@ -90,8 +90,7 @@ namespace BansheeEngine
 			bs_delete<PoolAlloc>(mpTempStagingBuffer);
 	}
 
-	void* D3D11HardwareBuffer::lockImpl(UINT32 offset, 
-		UINT32 length, GpuLockOptions options)
+	void* D3D11HardwareBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 		if (length > mSizeInBytes)
 			BS_EXCEPT(RenderingAPIException, "Provided length " + toString(length) + " larger than the buffer " + toString(mSizeInBytes) + ".");		
@@ -180,15 +179,15 @@ namespace BansheeEngine
 			mUseTempStagingBuffer = true;
 			if (!mpTempStagingBuffer)
 			{
-				// create another buffer instance but use system memory
+				// Create another buffer instance but use system memory
 				mpTempStagingBuffer = bs_new<D3D11HardwareBuffer, PoolAlloc>(mBufferType, mUsage, 1, mSizeInBytes, std::ref(mDevice), true);
 			}
 
-			// schedule a copy to the staging
+			// Schedule a copy to the staging
 			if (options == GBL_READ_ONLY || options == GBL_READ_WRITE)
 				mpTempStagingBuffer->copyData(*this, 0, 0, mSizeInBytes, true);
 
-			// register whether we'll need to upload on unlock
+			// Register whether we'll need to upload on unlock
 			mStagingUploadNeeded = (options != GBL_READ_ONLY);
 
 			return mpTempStagingBuffer->lock(offset, length, options);
@@ -201,16 +200,11 @@ namespace BansheeEngine
 		{
 			mUseTempStagingBuffer = false;
 
-			// ok, we locked the staging buffer
 			mpTempStagingBuffer->unlock();
 
-			// copy data if needed
-			// this is async but driver should keep reference
 			if (mStagingUploadNeeded)
 				copyData(*mpTempStagingBuffer, 0, 0, mSizeInBytes, true);
 
-			// delete
-			// not that efficient, but we should not be locking often
 			if(mpTempStagingBuffer != nullptr)
 			{
 				bs_delete<PoolAlloc>(mpTempStagingBuffer);
@@ -219,7 +213,6 @@ namespace BansheeEngine
 		}
 		else
 		{
-			// unmap
 			mDevice.getImmediateContext()->Unmap(mD3DBuffer, 0);
 		}
 	}
@@ -227,11 +220,10 @@ namespace BansheeEngine
 	void D3D11HardwareBuffer::copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
 		UINT32 dstOffset, UINT32 length, bool discardWholeBuffer)
 	{
-		// If we're copying same-size buffers in their entirety...
+		// If we're copying same-size buffers in their entirety
 		if (srcOffset == 0 && dstOffset == 0 &&
 			length == mSizeInBytes && mSizeInBytes == srcBuffer.getSizeInBytes())
 		{
-			// schedule hardware buffer copy
 			mDevice.getImmediateContext()->CopyResource(mD3DBuffer, static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer());
 			if (mDevice.hasError())
 			{
@@ -241,7 +233,7 @@ namespace BansheeEngine
 		}
 		else
 		{
-			// copy subregion
+			// Copy subregion
 			D3D11_BOX srcBox;
 			srcBox.left = (UINT)srcOffset;
 			srcBox.right = (UINT)srcOffset + length;
@@ -262,8 +254,7 @@ namespace BansheeEngine
 
 	void D3D11HardwareBuffer::readData(UINT32 offset, UINT32 length, void* pDest)
 	{
-		// There is no functional interface in D3D, just do via manual 
-		// lock, copy & unlock
+		// There is no functional interface in D3D, just do via manual lock, copy & unlock
 		void* pSrc = this->lock(offset, length, GBL_READ_ONLY);
 		memcpy(pDest, pSrc, length);
 		this->unlock();

+ 64 - 123
BansheeD3D11RenderSystem/Source/BsD3D11Mappings.cpp

@@ -6,7 +6,7 @@ namespace BansheeEngine
 {
 	D3D11_TEXTURE_ADDRESS_MODE D3D11Mappings::get(TextureAddressingMode tam)
 	{
-		switch( tam )
+		switch(tam)
 		{
 		case TAM_WRAP:
 			return D3D11_TEXTURE_ADDRESS_WRAP;
@@ -17,12 +17,13 @@ namespace BansheeEngine
 		case TAM_BORDER:
 			return D3D11_TEXTURE_ADDRESS_BORDER;
 		}
+
 		return D3D11_TEXTURE_ADDRESS_MIRROR_ONCE;
 	}
 
-	D3D11_BLEND D3D11Mappings::get(BlendFactor sbf)
+	D3D11_BLEND D3D11Mappings::get(BlendFactor bf)
 	{
-		switch( sbf )
+		switch(bf)
 		{
 		case BF_ONE:
 			return D3D11_BLEND_ONE;
@@ -45,12 +46,14 @@ namespace BansheeEngine
 		case BF_INV_SOURCE_ALPHA:
 			return D3D11_BLEND_INV_SRC_ALPHA;
 		}
+
+		// Unsupported type
 		return D3D11_BLEND_ZERO;
 	}
 
-	D3D11_BLEND_OP D3D11Mappings::get(BlendOperation sbo)
+	D3D11_BLEND_OP D3D11Mappings::get(BlendOperation bo)
 	{
-		switch( sbo )
+		switch(bo)
 		{
 		case BO_ADD:
 			return D3D11_BLEND_OP_ADD;
@@ -63,12 +66,14 @@ namespace BansheeEngine
 		case BO_MAX:
 			return D3D11_BLEND_OP_MAX;
 		}
+
+		// Unsupported type
 		return D3D11_BLEND_OP_ADD;
 	}
 
 	D3D11_COMPARISON_FUNC D3D11Mappings::get(CompareFunction cf)
 	{
-		switch( cf )
+		switch(cf)
 		{
 		case CMPF_ALWAYS_FAIL:
 			return D3D11_COMPARISON_NEVER;
@@ -87,12 +92,14 @@ namespace BansheeEngine
 		case CMPF_GREATER:
 			return D3D11_COMPARISON_GREATER;
 		};
+
+		// Unsupported type
 		return D3D11_COMPARISON_ALWAYS;
 	}
 
 	D3D11_CULL_MODE D3D11Mappings::get(CullingMode cm)
 	{
-		switch( cm )
+		switch(cm)
 		{
 		case CULL_NONE:
 			return D3D11_CULL_NONE;
@@ -101,18 +108,21 @@ namespace BansheeEngine
 		case CULL_COUNTERCLOCKWISE:
 			return D3D11_CULL_BACK;
 		}
+
+		// Unsupported type
 		return D3D11_CULL_NONE;
 	}
 
-	D3D11_FILL_MODE D3D11Mappings::get(PolygonMode level)
+	D3D11_FILL_MODE D3D11Mappings::get(PolygonMode mode)
 	{
-		switch(level)
+		switch(mode)
 		{
 		case PM_WIREFRAME:
 			return D3D11_FILL_WIREFRAME;
 		case PM_SOLID:
 			return D3D11_FILL_SOLID;
 		}
+
 		return D3D11_FILL_SOLID;
 	}
 
@@ -127,16 +137,18 @@ namespace BansheeEngine
 		case SOP_REPLACE:
 			return D3D11_STENCIL_OP_REPLACE;
 		case SOP_INCREMENT:
-			return invert? D3D11_STENCIL_OP_DECR_SAT : D3D11_STENCIL_OP_INCR_SAT;
+			return invert ? D3D11_STENCIL_OP_DECR_SAT : D3D11_STENCIL_OP_INCR_SAT;
 		case SOP_DECREMENT:
-			return invert? D3D11_STENCIL_OP_INCR_SAT : D3D11_STENCIL_OP_DECR_SAT;
+			return invert ? D3D11_STENCIL_OP_INCR_SAT : D3D11_STENCIL_OP_DECR_SAT;
 		case SOP_INCREMENT_WRAP:
-			return invert? D3D11_STENCIL_OP_DECR : D3D11_STENCIL_OP_INCR;
+			return invert ? D3D11_STENCIL_OP_DECR : D3D11_STENCIL_OP_INCR;
 		case SOP_DECREMENT_WRAP:
-			return invert? D3D11_STENCIL_OP_INCR : D3D11_STENCIL_OP_DECR;
+			return invert ? D3D11_STENCIL_OP_INCR : D3D11_STENCIL_OP_DECR;
 		case SOP_INVERT:
 			return D3D11_STENCIL_OP_INVERT;
 		}
+
+		// Unsupported type
 		return D3D11_STENCIL_OP_KEEP;
 	}
 
@@ -155,13 +167,12 @@ namespace BansheeEngine
 			break;
 		}
 
-		// to keep compiler happy
+		// Unsupported type
 		return D3D11_MIP_FILTER_SHIFT;
 	}
-	//---------------------------------------------------------------------
+
 	D3D11_FILTER D3D11Mappings::get(const FilterOptions min, const FilterOptions mag, const FilterOptions mip, const bool comparison)
 	{
-
 		D3D11_FILTER res;
 #define MERGE_FOR_SWITCH(_comparison_, _min_ , _mag_, _mip_ ) ((_comparison_ << 16) | (_min_ << 8) | (_mag_ << 4) | (_mip_))
 
@@ -194,7 +205,6 @@ namespace BansheeEngine
 		case MERGE_FOR_SWITCH(true, FO_ANISOTROPIC, FO_ANISOTROPIC, FO_ANISOTROPIC):
 			res = D3D11_FILTER_COMPARISON_ANISOTROPIC;
 			break;
-
 		case MERGE_FOR_SWITCH(false, FO_POINT, FO_POINT, FO_POINT):
 			res = D3D11_FILTER_MIN_MAG_MIP_POINT;
 			break;
@@ -226,8 +236,6 @@ namespace BansheeEngine
 			res = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
 		}	
 
-#undef MERGE_FOR_SWITCH
-		
 		return res;
 	}
 
@@ -236,9 +244,7 @@ namespace BansheeEngine
 		DWORD ret = D3D11_USAGE_DEFAULT;
 
 		if (usage & GBU_DYNAMIC)
-		{
 			ret = D3D11_USAGE_DYNAMIC;
-		}
 
 		return ret;
 	}
@@ -266,21 +272,9 @@ namespace BansheeEngine
 		return ret;
 	}
 
-	UINT D3D11Mappings::getByteWidth(IndexBuffer::IndexType itype)
+	DXGI_FORMAT D3D11Mappings::get(VertexElementType type)
 	{
-		if (itype == IndexBuffer::IT_32BIT)
-		{
-			return sizeof(UINT32);
-		}
-		else
-		{
-			return sizeof(UINT16);
-		}
-	}
-
-	DXGI_FORMAT D3D11Mappings::get(VertexElementType vType)
-	{
-		switch (vType)
+		switch (type)
 		{
 		case VET_COLOR:
 		case VET_COLOR_ABGR:
@@ -315,38 +309,37 @@ namespace BansheeEngine
 			return DXGI_FORMAT_R32G32B32A32_SINT;
 			break;
 		}
-		// to keep compiler happy
+
+		// Unsupported type
 		return DXGI_FORMAT_R32G32B32A32_FLOAT;
 	}
 
 	VertexElementSemantic D3D11Mappings::get(LPCSTR sem)
 	{
-		// todo - add to ogre - POSITIONT and PSIZE ("Transformed vertex position" and "Point size")
-
-		if( strcmp(sem, "BLENDINDICES") == 0 )
+		if(strcmp(sem, "BLENDINDICES") == 0)
 			return VES_BLEND_INDICES;
-		if( strcmp(sem, "BLENDWEIGHT") == 0 )
+		if(strcmp(sem, "BLENDWEIGHT") == 0)
 			return VES_BLEND_WEIGHTS;
-		if( strcmp(sem, "COLOR") == 0 )
+		if(strcmp(sem, "COLOR") == 0)
 			return VES_COLOR;
-		if( strcmp(sem, "NORMAL") == 0 )
+		if(strcmp(sem, "NORMAL") == 0)
 			return VES_NORMAL;
-		if( strcmp(sem, "POSITION") == 0 )
+		if(strcmp(sem, "POSITION") == 0)
 			return VES_POSITION;
-		if( strcmp(sem, "TEXCOORD") == 0 )
+		if(strcmp(sem, "TEXCOORD") == 0)
 			return VES_TEXCOORD;
-		if( strcmp(sem, "BINORMAL") == 0 )
+		if(strcmp(sem, "BINORMAL") == 0)
 			return VES_BITANGENT;
-		if( strcmp(sem, "TANGENT") == 0 )
+		if(strcmp(sem, "TANGENT") == 0)
 			return VES_TANGENT;
-		if( strcmp(sem, "POSITIONT") == 0 )
+		if(strcmp(sem, "POSITIONT") == 0)
 			return VES_POSITIONT;
-		if( strcmp(sem, "PSIZE") == 0 ) 
+		if(strcmp(sem, "PSIZE") == 0) 
 			return VES_PSIZE;
 
 		BS_EXCEPT(RenderingAPIException, "Invalid shader semantic: " + String(sem));
 
-		// to keep compiler happy
+		// Unsupported type
 		return VES_POSITION;
 	}
 
@@ -385,7 +378,8 @@ namespace BansheeEngine
 			return "PSIZE";
 			break;
 		}
-		// to keep compiler happy
+
+		// Unsupported type
 		return "";
 	}
 
@@ -404,7 +398,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11Mappings::get(const Color& inColor, float * outColor)
+	void D3D11Mappings::get(const Color& inColor, float* outColor)
 	{
 		outColor[0] = inColor.r;
 		outColor[1] = inColor.g;
@@ -412,22 +406,9 @@ namespace BansheeEngine
 		outColor[3] = inColor.a;	
 	}
 
-	D3D11_BOX D3D11Mappings::toDx11Box(const PixelVolume &inBox)
+	PixelFormat D3D11Mappings::getPF(DXGI_FORMAT pf)
 	{
-		D3D11_BOX res;
-		res.left	= static_cast<UINT>(inBox.left);
-		res.top		= static_cast<UINT>(inBox.top);
-		res.front	= static_cast<UINT>(inBox.front);
-		res.right	= static_cast<UINT>(inBox.right);
-		res.bottom	= static_cast<UINT>(inBox.bottom);
-		res.back	= static_cast<UINT>(inBox.back);
-
-		return res;
-	}
-
-	PixelFormat D3D11Mappings::_getPF(DXGI_FORMAT d3dPF)
-	{
-		switch(d3dPF)
+		switch(pf)
 		{
 		case DXGI_FORMAT_UNKNOWN:
 			return PF_UNKNOWN;
@@ -624,9 +605,9 @@ namespace BansheeEngine
 		}
 	}
 
-	DXGI_FORMAT D3D11Mappings::_getPF(PixelFormat enginePF, bool gamma)
+	DXGI_FORMAT D3D11Mappings::getPF(PixelFormat pf, bool gamma)
 	{
-		switch(enginePF)
+		switch(pf)
 		{
 		case PF_R8:
 			return DXGI_FORMAT_R8_UNORM;
@@ -696,13 +677,13 @@ namespace BansheeEngine
 		}
 	}
 
-	PixelFormat D3D11Mappings::_getClosestSupportedPF(PixelFormat enginePF, bool hwGamma)
+	PixelFormat D3D11Mappings::getClosestSupportedPF(PixelFormat pf, bool hwGamma)
 	{
-		if (_getPF(enginePF, hwGamma) != DXGI_FORMAT_UNKNOWN)
+		if (getPF(pf, hwGamma) != DXGI_FORMAT_UNKNOWN)
 		{
-			return enginePF;
+			return pf;
 		}
-		switch(enginePF)
+		switch(pf)
 		{
 		case PF_FLOAT16_RGB:
 			return PF_FLOAT16_RGBA;
@@ -726,21 +707,17 @@ namespace BansheeEngine
 		}
 	}
 
-	D3D11_USAGE D3D11Mappings::_getUsage(GpuBufferUsage mUsage)
+	D3D11_USAGE D3D11Mappings::getUsage(GpuBufferUsage usage)
 	{
-		if (_isDynamic(mUsage))
-		{
+		if (isDynamic(usage))
 			return D3D11_USAGE_DYNAMIC;
-		}
 		else
-		{
 			return D3D11_USAGE_DEFAULT;
-		}
 	}
 
-	bool D3D11Mappings::_isDynamic(GpuBufferUsage mUsage)
+	bool D3D11Mappings::isDynamic(GpuBufferUsage usage)
 	{
-		switch ( mUsage)
+		switch (usage)
 		{
 		case GBU_DYNAMIC:
 			return true;
@@ -749,18 +726,12 @@ namespace BansheeEngine
 		return false;
 	}
 
-	bool D3D11Mappings::_isDynamic(int mUsage)
-	{
-		return _isDynamic(static_cast<GpuBufferUsage>(mUsage));
-	}
-
 	bool D3D11Mappings::isMappingWrite(D3D11_MAP map)
 	{
 		if(map == D3D11_MAP_READ)
 			return false;
 
 		return true;
-
 	}
 
 	bool D3D11Mappings::isMappingRead(D3D11_MAP map)
@@ -771,43 +742,14 @@ namespace BansheeEngine
 		return false;
 	}
 
-	D3D11_USAGE D3D11Mappings::_getUsage(int mUsage)
-	{
-		return _getUsage(static_cast<GpuBufferUsage>(mUsage));
-	}
-
-	UINT D3D11Mappings::_getAccessFlags(int mUsage)
-	{
-		return _getAccessFlags(static_cast<GpuBufferUsage>(mUsage));
-	}
-
-	UINT D3D11Mappings::_getAccessFlags(GpuBufferUsage mUsage)
+	UINT D3D11Mappings::getAccessFlags(GpuBufferUsage usage)
 	{
-		if(_isDynamic(mUsage))
+		if(isDynamic(usage))
 			return D3D11_CPU_ACCESS_WRITE;
 		else
 			return 0;
 	}
 
-	TextureType D3D11Mappings::_getTexType(D3D11_SRV_DIMENSION type)
-	{
-		switch(type)
-		{
-		case D3D_SRV_DIMENSION_TEXTURE1D:
-			return TEX_TYPE_1D;
-		case D3D_SRV_DIMENSION_TEXTURE2D:
-		case D3D_SRV_DIMENSION_TEXTURE2DMS:
-			return TEX_TYPE_2D;
-		case D3D_SRV_DIMENSION_TEXTURE3D:
-			return TEX_TYPE_3D;
-		case D3D_SRV_DIMENSION_TEXTURECUBE:
-			return TEX_TYPE_CUBE_MAP;
-		default:
-			// unknown
-			return static_cast<TextureType>(0);
-		}
-	}
-
 	D3D11_PRIMITIVE_TOPOLOGY D3D11Mappings::getPrimitiveType(DrawOperationType type)
 	{
 		switch(type)
@@ -829,10 +771,9 @@ namespace BansheeEngine
 		return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
 	}
 
-	//---------------------------------------------------------------------
-	UINT32 D3D11Mappings::_getSizeInBytes(PixelFormat pf, UINT32 xcount, UINT32 ycount)
+	UINT32 D3D11Mappings::getSizeInBytes(PixelFormat pf, UINT32 width, UINT32 height)
 	{
-		if(xcount == 0 || ycount == 0)
+		if(width == 0 || height == 0)
 			return 0;
 
 		if(PixelUtil::isCompressed(pf))
@@ -841,17 +782,17 @@ namespace BansheeEngine
 			if (pf == PF_BC1 || pf == PF_BC4)
 			{
 				// 64 bits (8 bytes) per 4x4 block
-				return std::max<UINT32>(1, xcount / 4) * std::max<UINT32>(1, ycount / 4) * 8;
+				return std::max<UINT32>(1, width / 4) * std::max<UINT32>(1, height / 4) * 8;
 			}
 			else
 			{
 				// 128 bits (16 bytes) per 4x4 block
-				return std::max<UINT32>(1, xcount / 4) * std::max<UINT32>(1, ycount / 4) * 16;
+				return std::max<UINT32>(1, width / 4) * std::max<UINT32>(1, height / 4) * 16;
 			}
 		}
 		else
 		{
-			return xcount * ycount * PixelUtil::getNumElemBytes(pf);
+			return width * height * PixelUtil::getNumElemBytes(pf);
 		}
 	}
 

+ 16 - 16
BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp

@@ -133,8 +133,8 @@ namespace BansheeEngine
 			D3D11Device& device = rs->getPrimaryDevice();
 
 			UINT subresourceIdx = D3D11CalcSubresource(mipLevel, face, getNumMipmaps()+1);
-			UINT32 rowWidth = D3D11Mappings::_getSizeInBytes(mFormat, src.getWidth());
-			UINT32 sliceWidth = D3D11Mappings::_getSizeInBytes(mFormat, src.getWidth(), src.getHeight());
+			UINT32 rowWidth = D3D11Mappings::getSizeInBytes(mFormat, src.getWidth());
+			UINT32 sliceWidth = D3D11Mappings::getSizeInBytes(mFormat, src.getWidth(), src.getHeight());
 
 			device.getImmediateContext()->UpdateSubresource(mTex, subresourceIdx, nullptr, src.getData(), rowWidth, sliceWidth);
 
@@ -196,9 +196,9 @@ namespace BansheeEngine
 
 		// Determine which D3D11 pixel format we'll use
 		HRESULT hr;
-		DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(mFormat, mHwGamma), mHwGamma);
+		DXGI_FORMAT d3dPF = D3D11Mappings::getPF(D3D11Mappings::getClosestSupportedPF(mFormat, mHwGamma), mHwGamma);
 
-		if (mFormat != D3D11Mappings::_getPF(d3dPF))
+		if (mFormat != D3D11Mappings::getPF(d3dPF))
 		{
 			BS_EXCEPT(RenderingAPIException, "Provided pixel format is not supported by the driver: " + toString(mFormat));
 		}
@@ -225,9 +225,9 @@ namespace BansheeEngine
 		}
 		else
 		{
-			desc.Usage			= D3D11Mappings::_getUsage(mUsage);
+			desc.Usage			= D3D11Mappings::getUsage(mUsage);
 			desc.BindFlags		= D3D11_BIND_SHADER_RESOURCE;
-			desc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage);
+			desc.CPUAccessFlags = D3D11Mappings::getAccessFlags(mUsage);
 
 			// Determine total number of mipmaps including main one (d3d11 convention)
 			UINT32 numMips		= (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > mWidth) ? 0 : mNumMipmaps + 1;
@@ -290,9 +290,9 @@ namespace BansheeEngine
 
 		// Determine which D3D11 pixel format we'll use
 		HRESULT hr;
-		DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(mFormat, mHwGamma), mHwGamma);
+		DXGI_FORMAT d3dPF = D3D11Mappings::getPF(D3D11Mappings::getClosestSupportedPF(mFormat, mHwGamma), mHwGamma);
 
-		if (mFormat != D3D11Mappings::_getPF(d3dPF))
+		if (mFormat != D3D11Mappings::getPF(d3dPF))
 		{
 			BS_EXCEPT(RenderingAPIException, "Provided pixel format is not supported by the driver: " + toString(mFormat));
 		}
@@ -340,9 +340,9 @@ namespace BansheeEngine
 		}
 		else
 		{
-			desc.Usage			= D3D11Mappings::_getUsage(mUsage);
+			desc.Usage			= D3D11Mappings::getUsage(mUsage);
 			desc.BindFlags		= D3D11_BIND_SHADER_RESOURCE;
-			desc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage);
+			desc.CPUAccessFlags = D3D11Mappings::getAccessFlags(mUsage);
 
 			// Determine total number of mipmaps including main one (d3d11 convention)
 			UINT32 numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > mWidth) ? 0 : mNumMipmaps + 1;
@@ -456,9 +456,9 @@ namespace BansheeEngine
 
 		// Determine which D3D11 pixel format we'll use
 		HRESULT hr;
-		DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(mFormat, mHwGamma), mHwGamma);
+		DXGI_FORMAT d3dPF = D3D11Mappings::getPF(D3D11Mappings::getClosestSupportedPF(mFormat, mHwGamma), mHwGamma);
 		
-		if (mFormat != D3D11Mappings::_getPF(d3dPF))
+		if (mFormat != D3D11Mappings::getPF(d3dPF))
 		{
 			BS_EXCEPT(RenderingAPIException, "Provided pixel format is not supported by the driver: " + toString(mFormat));
 		}
@@ -486,9 +486,9 @@ namespace BansheeEngine
 		}
 		else
 		{
-			desc.Usage			= D3D11Mappings::_getUsage(mUsage);
+			desc.Usage			= D3D11Mappings::getUsage(mUsage);
 			desc.BindFlags		= D3D11_BIND_SHADER_RESOURCE;
-			desc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage);
+			desc.CPUAccessFlags = D3D11Mappings::getAccessFlags(mUsage);
 
 			// Determine total number of mipmaps including main one (d3d11 convention)
 			UINT numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > std::max(std::max(mWidth, mHeight), mDepth)) ? 0 : mNumMipmaps + 1;
@@ -619,8 +619,8 @@ namespace BansheeEngine
 
 	void D3D11Texture::unmapstaticbuffer()
 	{
-		UINT32 rowWidth = D3D11Mappings::_getSizeInBytes(mStaticBuffer->getFormat(), mStaticBuffer->getWidth());
-		UINT32 sliceWidth = D3D11Mappings::_getSizeInBytes(mStaticBuffer->getFormat(), mStaticBuffer->getWidth(), mStaticBuffer->getHeight());
+		UINT32 rowWidth = D3D11Mappings::getSizeInBytes(mStaticBuffer->getFormat(), mStaticBuffer->getWidth());
+		UINT32 sliceWidth = D3D11Mappings::getSizeInBytes(mStaticBuffer->getFormat(), mStaticBuffer->getWidth(), mStaticBuffer->getHeight());
 
 		D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
 		D3D11Device& device = rs->getPrimaryDevice();

+ 2 - 2
BansheeD3D11RenderSystem/Source/BsD3D11TextureManager.cpp

@@ -38,8 +38,8 @@ namespace BansheeEngine
 	PixelFormat D3D11TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
 	{
 		// Basic filtering
-		DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(format, hwGamma), hwGamma);
+		DXGI_FORMAT d3dPF = D3D11Mappings::getPF(D3D11Mappings::getClosestSupportedPF(format, hwGamma), hwGamma);
 
-		return D3D11Mappings::_getPF(d3dPF);
+		return D3D11Mappings::getPF(d3dPF);
 	}
 }

+ 16 - 1
Polish.txt

@@ -1,4 +1,19 @@
-
+Polish TODO:
+ - Finish basic example, get a model rendering on screen
+ - Fix FBX importer so proper number of vertices show
+ - Finish and test GPU profiler
+ - Test and fix full-screen transitions
+ - Add virtual input axes
+ - Compress and generate mips for texture on input (testing NVTT stuff)
+ - Add frustum culling and sorting code
+ - Finalize example
+ - Perform optimizations as needed to get reasonable performance
+
+ - Add license text to all files
+ - Make a separate release branch with no editor/script stuff, and without .txt files and other development data
+ - (HIGHLY OPTIONAL) Make a Getting Started guide, along with the example project. Or just finish up the manual.
+
+-----------------
 
 There's still a crash regarding an uninitialized mCachedPtr on a C# class when shutting down. Attempt to find consistent repro steps.
 

+ 0 - 37
Renderer.txt

@@ -18,40 +18,3 @@ Just notes for later potentially:
  - I can only update entire Mesh at once. 
  - I keep bounds for the entire mesh and not per-submesh
  - I don't serialize bounds and they are recalculated whenever a mesh is loaded
-
-
- -------------------------
-
- Texture compression/mipmaps:
-  - Test it out. Especially pontential problems with textures not divisible by 4 for compression, or non-pow2 textures for mipmaps
-
-Add compress(format) functionality to PixelUtil.
-Add calculateMips functionality to PixelUtil. It takes PixelData as parameter, and returns a set of PixelData mips.
-Add Texture import options that allow you to choose format of the texture when loading. Not just compressed/uncompressed but all formats.
- - PixelUtil can convert all normal formats. compress can deal with others.
-Add support for DDS import (also use nvtt?)
-
-IMPLEMENTATION:
-Will likely need CompressionOptions struct since there are so many.
-There are other conversion methods that don't support compression. That's fine, we can do that manually.
-Only 2D and cube input images are supported.
-I won't support BC6 and BC7 initially. Add this to notes.txt
-
-NVTT support:
- - Ensure I disable cuda compression as its enabled by default - compressor.enableCudaAcceleration(false);
- - Create an OutputHandler that can accept multiple calls to writeData
- - Call outputOptions.setOutputHeader(false); to disable header generation since I don't generate dds
- - CompressionOptions needs to have:
-    - Format
-    - Quality
-    - IsTextureSRGB - inputOptions.setGamma(1.0f, 1.0f);
-    - AlphaMode - InputOptions::setAlphaMode(AlphaMode alphaMode);
-
-Mip map options
-    - InputOptions::setMipmapGeneration(bool enabled, int maxLevel);
-    - Mipmaps can only be generated from uncompressed textures
-    - Set if its a normal map and should the mips be renormalized - InputOptions::setNormalMap(bool isNormalMap);, InputOptions::setNormalizeMipmaps(bool normalizeMipmaps);
-    - Rounding modes? Probably not for now
-    - AlphaMode - InputOptions::setAlphaMode(AlphaMode alphaMode);
-
-Check out estimateSize