Просмотр исходного кода

Cleaning up the render API a bit

BearishSun 9 лет назад
Родитель
Сommit
2a2a859d95

+ 2 - 19
Source/BansheeCore/Include/BsRenderAPI.h

@@ -34,20 +34,12 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT RenderAPI
 	{
 	public:
-		/** 
-		 * @copydoc RenderAPICore::disableTextureUnit()
-		 *
-		 * @param[in]	accessor	Accessor on which will this command be queued for execution.
-		 */
-		static void disableTextureUnit(CoreAccessor& accessor, GpuProgramType gptype, UINT16 texUnit);
-
 		/**  
 		 * @copydoc RenderAPICore::setTexture()
 		 *
 		 * @param[in]	accessor	Accessor on which will this command be queued for execution.
 		 */
-		static void setTexture(CoreAccessor& accessor, GpuProgramType gptype, UINT16 texUnit, bool enabled, 
-			const SPtr<Texture> &texPtr);
+		static void setTexture(CoreAccessor& accessor, GpuProgramType gptype, UINT16 texUnit, const SPtr<Texture>& texture);
 
 		/**  
 		 * @copydoc RenderAPICore::setLoadStoreTexture()
@@ -392,18 +384,9 @@ namespace BansheeEngine
 		 *
 		 * @param[in]	gptype			Determines to which GPU program slot to bind the texture.
 		 * @param[in]	texUnit			Texture unit index to bind the texture to.
-		 * @param[in]	enabled			True to bind the texture at the specified unit, false to unbind.
 		 * @param[in]	texPtr			Texture to bind.
 		 */
-		virtual void setTexture(GpuProgramType gptype, UINT16 texUnit, bool enabled, const SPtr<TextureCore>& texPtr) = 0;
-
-		/**	
-		 * Removes a texture at the specified texture unit.
-		 *
-		 * @param[in]	gptype			Determines at which GPU program slot to unbind the texture.
-		 * @param[in]	texUnit			Texture unit index to unbind the texture from.
-		 */
-		virtual void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
+		virtual void setTexture(GpuProgramType gptype, UINT16 texUnit, const SPtr<TextureCore>& texPtr) = 0;
 
 		/**	
 		 * Binds a texture that can be used for random load/store operations from a GPU program. 

+ 3 - 18
Source/BansheeCore/Source/BsRenderAPI.cpp

@@ -21,14 +21,9 @@ using namespace std::placeholders;
 
 namespace BansheeEngine 
 {
-	void RenderAPI::disableTextureUnit(CoreAccessor& accessor, GpuProgramType gptype, UINT16 texUnit)
+	void RenderAPI::setTexture(CoreAccessor& accessor, GpuProgramType gptype, UINT16 unit, const SPtr<Texture> &texPtr)
 	{
-		accessor.queueCommand(std::bind(&RenderAPICore::disableTextureUnit, RenderAPICore::instancePtr(), gptype, texUnit));
-	}
-
-	void RenderAPI::setTexture(CoreAccessor& accessor, GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<Texture> &texPtr)
-	{
-		accessor.queueCommand(std::bind(&RenderAPICore::setTexture, RenderAPICore::instancePtr(), gptype, unit, enabled, texPtr->getCore()));
+		accessor.queueCommand(std::bind(&RenderAPICore::setTexture, RenderAPICore::instancePtr(), gptype, unit, texPtr->getCore()));
 	}
 
 	void RenderAPI::setLoadStoreTexture(CoreAccessor& accessor, GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<Texture>& texPtr,
@@ -282,13 +277,6 @@ namespace BansheeEngine
 		return mDriverVersion; 
 	}
 
-    void RenderAPICore::disableTextureUnit(GpuProgramType gptype, UINT16 texUnit)
-    {
-		THROW_IF_NOT_CORE_THREAD;
-
-		setTexture(gptype, texUnit, false, SPtr<TextureCore>());
-    }
-
 	void RenderAPICore::addClipPlane(const Plane &p)
 	{
 		THROW_IF_NOT_CORE_THREAD;
@@ -420,10 +408,7 @@ namespace BansheeEngine
 		{
 			SPtr<TextureCore> texture = params->getTexture(iter->second.slot);
 
-			if (texture == nullptr)
-				setTexture(gptype, iter->second.slot, false, nullptr);
-			else
-				setTexture(gptype, iter->second.slot, true, texture);
+			setTexture(gptype, iter->second.slot, texture);
 		}
 
 		for (auto iter = paramDesc.loadStoreTextures.begin(); iter != paramDesc.loadStoreTextures.end(); ++iter)

+ 1 - 4
Source/BansheeD3D11RenderAPI/Include/BsD3D11RenderAPI.h

@@ -37,7 +37,7 @@ namespace BansheeEngine
 		void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SPtr<SamplerStateCore>& samplerState) override;
 
 		/** @copydoc RenderAPICore::setTexture */
-		void setTexture(GpuProgramType gptype, UINT16 texUnit, bool enabled, const SPtr<TextureCore>& texPtr) override;
+		void setTexture(GpuProgramType gptype, UINT16 texUnit, const SPtr<TextureCore>& texPtr) override;
 
 		/** @copydoc RenderAPICore::setLoadStoreTexture */
 		void setLoadStoreTexture(GpuProgramType gptype, UINT16 texUnit, bool enabled, const SPtr<TextureCore>& texPtr,
@@ -46,9 +46,6 @@ namespace BansheeEngine
 		/** @copydoc RenderAPICore::setBuffer */
 		void setBuffer(GpuProgramType gptype, UINT16 unit, const SPtr<GpuBufferCore>& buffer, bool loadStore = false) override;
 
-		/** @copydoc RenderAPICore::disableTextureUnit */
-		void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit) override;
-
 		/** @copydoc RenderAPICore::beginFrame */
 		void beginFrame() override;
 

+ 2 - 9
Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderAPI.cpp

@@ -271,7 +271,7 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT(NumDepthStencilStateChanges);
 	}
 
-	void D3D11RenderAPI::setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr)
+	void D3D11RenderAPI::setTexture(GpuProgramType gptype, UINT16 unit, const SPtr<TextureCore>& texPtr)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
@@ -279,7 +279,7 @@ namespace BansheeEngine
 		//  and then set them all up at once before rendering? Needs testing
 
 		ID3D11ShaderResourceView* viewArray[1];
-		if(texPtr != nullptr && enabled)
+		if(texPtr != nullptr)
 		{
 			D3D11TextureCore* d3d11Texture = static_cast<D3D11TextureCore*>(texPtr.get());
 			viewArray[0] = d3d11Texture->getSRV();
@@ -425,13 +425,6 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT(NumTextureBinds);
 	}
 
-	void D3D11RenderAPI::disableTextureUnit(GpuProgramType gptype, UINT16 texUnit)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		setTexture(gptype, texUnit, false, nullptr);
-	}
-
 	void D3D11RenderAPI::beginFrame()
 	{
 		// Not used

+ 1 - 1
Source/BansheeD3D9RenderAPI/Include/BsD3D9RenderAPI.h

@@ -52,7 +52,7 @@ namespace BansheeEngine
 		void setDrawOperation(DrawOperationType op) override;
 
 		/** @copydoc RenderAPICore::setTexture() */
-		void setTexture(GpuProgramType gptype, UINT16 texUnit, bool enabled, const SPtr<TextureCore>& texPtr) override;
+		void setTexture(GpuProgramType gptype, UINT16 texUnit, const SPtr<TextureCore>& texPtr) override;
 
 		/** @copydoc RenderAPICore::setBuffer */
 		void setBuffer(GpuProgramType gptype, UINT16 unit, const SPtr<GpuBufferCore>& buffer, bool loadStore = false) override;

+ 2 - 2
Source/BansheeD3D9RenderAPI/Source/BsD3D9RenderAPI.cpp

@@ -400,7 +400,7 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT(NumGpuParamBufferBinds);
 	}
 
-	void D3D9RenderAPI::setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& tex)
+	void D3D9RenderAPI::setTexture(GpuProgramType gptype, UINT16 unit, const SPtr<TextureCore>& tex)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
@@ -420,7 +420,7 @@ namespace BansheeEngine
 
 		HRESULT hr;
 		SPtr<D3D9TextureCore> dt = std::static_pointer_cast<D3D9TextureCore>(tex);
-		if (enabled && (dt != nullptr))
+		if (dt != nullptr)
 		{
 			IDirect3DBaseTexture9 *pTex = dt->getTexture_internal();
 			if (mTexStageDesc[unit].pTex != pTex)

+ 1 - 16
Source/BansheeGLRenderAPI/Include/BsGLRenderAPI.h

@@ -46,7 +46,7 @@ namespace BansheeEngine
 		void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) override;
 
 		/** @copydoc RenderAPICore::setTexture() */
-		void setTexture(GpuProgramType gptype, UINT16 texUnit, bool enabled, const SPtr<TextureCore>& texPtr) override;
+		void setTexture(GpuProgramType gptype, UINT16 texUnit, const SPtr<TextureCore>& texPtr) override;
 
 		/** @copydoc RenderAPICore::setLoadStoreTexture */
 		void setLoadStoreTexture(GpuProgramType gptype, UINT16 texUnit, bool enabled, const SPtr<TextureCore>& texPtr,
@@ -148,21 +148,6 @@ namespace BansheeEngine
 		/**	Set up clip planes against which all geometry will get clipped. */
 		void setClipPlanesImpl(const PlaneList& clipPlanes) override;
 
-		/**
-		 * 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);
-
-		/**
-		 * 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);
-
 		/** 
 		 * Changes the currently active texture unit. Any texture related operations will then be performed on this unit. 
 		 */

+ 7 - 7
Source/BansheeGLRenderAPI/Source/BsGLRenderAPI.cpp

@@ -382,7 +382,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GLRenderAPI::setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr)
+	void GLRenderAPI::setTexture(GpuProgramType gptype, UINT16 unit, const SPtr<TextureCore>& texPtr)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
@@ -391,7 +391,7 @@ namespace BansheeEngine
 			return;
 
 		SPtr<GLTextureCore> tex = std::static_pointer_cast<GLTextureCore>(texPtr);
-		if (enabled && tex)
+		if (tex != nullptr)
 		{
 			mTextureTypes[unit] = tex->getGLTextureTarget();
 			glBindTexture(mTextureTypes[unit], tex->getGLID());
@@ -1380,11 +1380,11 @@ namespace BansheeEngine
 		if (!activateGLTextureUnit(unit))
 			return;
 
-		GLfloat largest_supported_anisotropy = 0;
-		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
-		if (maxAnisotropy > largest_supported_anisotropy)
-			maxAnisotropy = largest_supported_anisotropy ? 
-			static_cast<UINT32>(largest_supported_anisotropy) : 1;
+		GLfloat maxSupportAnisotropy = 0;
+		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxSupportAnisotropy);
+		if (maxAnisotropy > maxSupportAnisotropy)
+			maxAnisotropy = maxSupportAnisotropy ? 
+			static_cast<UINT32>(maxSupportAnisotropy) : 1;
 
 		if(maxAnisotropy < 1)
 			maxAnisotropy = 1;

+ 3 - 3
Source/RenderBeast/Source/BsRenderBeast.cpp

@@ -557,7 +557,7 @@ namespace BansheeEngine
 		camData.target->allocate();
 		camData.target->bindGBuffer();
 
-		// Trigger pre-scene callbacks
+		//// Trigger pre-scene callbacks
 		auto iterCameraCallbacks = mRenderCallbacks.find(camera);
 		if (iterCameraCallbacks != mRenderCallbacks.end())
 		{
@@ -575,7 +575,7 @@ namespace BansheeEngine
 			}
 		}
 		
-		// Render base pass
+		//// Render base pass
 		const Vector<RenderQueueElement>& opaqueElements = camData.opaqueQueue->getSortedElements();
 		for (auto iter = opaqueElements.begin(); iter != opaqueElements.end(); ++iter)
 		{
@@ -607,7 +607,7 @@ namespace BansheeEngine
 
 		camData.target->bindSceneColor(true);
 
-		// Render light pass
+		//// Render light pass
 		{
 			SPtr<GpuParamBlockBufferCore> perCameraBuffer = mStaticHandler->getPerCameraParams().getBuffer();