Selaa lähdekoodia

Vulkan spot light shadows functional

BearishSun 8 vuotta sitten
vanhempi
sitoutus
7cf6abe4a5

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

@@ -105,7 +105,7 @@ namespace bs { namespace ct
 		GpuParamBlockDesc generateParamBlockDesc(const String& name, Vector<GpuParamDataDesc>& params) override;
 		GpuParamBlockDesc generateParamBlockDesc(const String& name, Vector<GpuParamDataDesc>& params) override;
 
 
 		/************************************************************************/
 		/************************************************************************/
-		/* 				Internal use by DX11 RenderSystem only                  */
+		/* 				Internal use by DX11 backend only						*/
 		/************************************************************************/
 		/************************************************************************/
 
 
 		/**
 		/**
@@ -138,50 +138,6 @@ namespace bs { namespace ct
 		/** @copydoc RenderAPI::destroyCore */
 		/** @copydoc RenderAPI::destroyCore */
 		void destroyCore() override;
 		void destroyCore() override;
 
 
-		/**
-		 * Sets a sampler state for the specified texture unit. 
-		 *
-		 * @param[in]	gptype			Determines to which GPU program slot to bind the sampler state.
-		 * @param[in]	texUnit			Texture unit index to bind the state to.
-		 * @param[in]	samplerState	Sampler state to bind, or null to unbind.
-		 *
-		 * @see		SamplerState
-		 */
-		void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SPtr<SamplerState>& samplerState);
-
-		/**
-		 * Binds a texture to the pipeline for the specified GPU program type at the specified slot. If the slot matches 
-		 * the one configured in the GPU program the program will be able to access this texture on the GPU.
-		 *
-		 * @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]	texture			Texture to bind.
-		 */
-		void setTexture(GpuProgramType gptype, UINT16 texUnit, const SPtr<Texture>& texture);
-
-		/**	
-		 * Binds a texture that can be used for random load/store operations from a GPU program. 
-		 *
-		 * @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]	texture			Texture to bind.
-		 * @param[in]	surface			Determines which surface of the texture to bind.
-		 */
-		void setLoadStoreTexture(GpuProgramType gptype, UINT16 texUnit, const SPtr<Texture>& texture, 
-			const TextureSurface& surface);
-
-		/**
-		 * Binds a buffer that can be used for read or write operations on the GPU.
-		 *
-		 * @param[in]	gptype			Determines to which GPU program slot to bind the buffer.
-		 * @param[in]	unit			GPU program unit index to bind the buffer to.
-		 * @param[in]	buffer			Buffer to bind.
-		 * @param[in]	loadStore		If true the buffer will be bound with support for unordered reads and writes, 
-		 *								otherwise it will only be bound for reads.
-		 */
-		void setBuffer(GpuProgramType gptype, UINT16 unit, const SPtr<GpuBuffer>& buffer, 
-			bool loadStore = false);
-
 		/**
 		/**
 		 * Creates or retrieves a proper input layout depending on the currently set vertex shader and vertex buffer.
 		 * Creates or retrieves a proper input layout depending on the currently set vertex shader and vertex buffer.
 		 *
 		 *

+ 6 - 0
Source/BansheeVulkanRenderAPI/Source/BsVulkanCommandBuffer.cpp

@@ -1474,6 +1474,9 @@ namespace bs { namespace ct
 			mDescriptorSetsBindState.unset(DescriptorSetBindFlag::Graphics);
 			mDescriptorSetsBindState.unset(DescriptorSetBindFlag::Graphics);
 		}
 		}
 
 
+		if (instanceCount <= 0)
+			instanceCount = 1;
+
 		vkCmdDraw(mCmdBuffer, vertexCount, instanceCount, vertexOffset, 0);
 		vkCmdDraw(mCmdBuffer, vertexCount, instanceCount, vertexOffset, 0);
 	}
 	}
 
 
@@ -1511,6 +1514,9 @@ namespace bs { namespace ct
 			mDescriptorSetsBindState.unset(DescriptorSetBindFlag::Graphics);
 			mDescriptorSetsBindState.unset(DescriptorSetBindFlag::Graphics);
 		}
 		}
 
 
+		if (instanceCount <= 0)
+			instanceCount = 1;
+
 		vkCmdDrawIndexed(mCmdBuffer, indexCount, instanceCount, startIndex, vertexOffset, 0);
 		vkCmdDrawIndexed(mCmdBuffer, indexCount, instanceCount, startIndex, vertexOffset, 0);
 	}
 	}
 
 

+ 2 - 2
Source/BansheeVulkanRenderAPI/Source/BsVulkanGpuPipelineState.cpp

@@ -395,7 +395,7 @@ namespace bs { namespace ct
 		VkStencilOp oldBackFailOp = mDepthStencilInfo.back.failOp;
 		VkStencilOp oldBackFailOp = mDepthStencilInfo.back.failOp;
 		VkStencilOp oldBackZFailOp = mDepthStencilInfo.back.depthFailOp;
 		VkStencilOp oldBackZFailOp = mDepthStencilInfo.back.depthFailOp;
 
 
-		if((readOnlyFlags & FBT_STENCIL) == 1)
+		if((readOnlyFlags & FBT_STENCIL) != 0)
 		{
 		{
 			// Disable any stencil writes
 			// Disable any stencil writes
 			mDepthStencilInfo.front.passOp = VK_STENCIL_OP_KEEP;
 			mDepthStencilInfo.front.passOp = VK_STENCIL_OP_KEEP;
@@ -418,7 +418,7 @@ namespace bs { namespace ct
 		if (framebuffer->hasDepthAttachment())
 		if (framebuffer->hasDepthAttachment())
 		{
 		{
 			mPipelineInfo.pDepthStencilState = &mDepthStencilInfo;
 			mPipelineInfo.pDepthStencilState = &mDepthStencilInfo;
-			depthReadOnly = (readOnlyFlags & FBT_DEPTH) == 1;
+			depthReadOnly = (readOnlyFlags & FBT_DEPTH) != 0;
 		}
 		}
 		else
 		else
 		{
 		{

+ 1 - 4
Source/RenderBeast/Source/BsRenderBeast.cpp

@@ -620,10 +620,7 @@ namespace bs { namespace ct
 		// If we're using flattened framebuffer for MSAA we need to copy its contents to the MSAA scene texture before
 		// If we're using flattened framebuffer for MSAA we need to copy its contents to the MSAA scene texture before
 		// continuing
 		// continuing
 		if(isMSAA)
 		if(isMSAA)
-		{
-			mFlatFramebufferToTextureMat->execute(renderTargets->getSceneColorBuffer(), 
-												  renderTargets->getSceneColor());
-		}
+			mFlatFramebufferToTextureMat->execute(renderTargets->getSceneColorBuffer(), renderTargets->getSceneColor());
 
 
 		// Render skybox (if any)
 		// Render skybox (if any)
 		if (mSkyboxTexture != nullptr)
 		if (mSkyboxTexture != nullptr)

+ 7 - 3
Source/RenderBeast/Source/BsShadowRendering.cpp

@@ -688,9 +688,13 @@ namespace bs { namespace ct
 		RenderAPI& rapi = RenderAPI::instance();
 		RenderAPI& rapi = RenderAPI::instance();
 		const RenderAPIInfo& rapiInfo = rapi.getAPIInfo();
 		const RenderAPIInfo& rapiInfo = rapi.getAPIInfo();
 
 
+		float flipY = 1.0f;
+		if (rapiInfo.isFlagSet(RenderAPIFeatureFlag::NDCYAxisDown))
+			flipY = -1.0f;
+
 		AABox frustumCube(
 		AABox frustumCube(
-			Vector3(-1, -1, rapiInfo.getMinimumDepthInputValue()),
-			Vector3(1, 1, rapiInfo.getMaximumDepthInputValue())
+			Vector3(-1, -1 * flipY, rapiInfo.getMinimumDepthInputValue()),
+			Vector3(1, 1 * flipY, rapiInfo.getMaximumDepthInputValue())
 		);
 		);
 
 
 		for(size_t i = 0; i < output.size(); i++)
 		for(size_t i = 0; i < output.size(); i++)
@@ -930,7 +934,7 @@ namespace bs { namespace ct
 					*renderTargets);
 					*renderTargets);
 				mProjectMaterials.bind(effectiveShadowQuality, isCSM, viewProps.numSamples > 1, shadowParams);
 				mProjectMaterials.bind(effectiveShadowQuality, isCSM, viewProps.numSamples > 1, shadowParams);
 
 
-				if(!isCSM)
+				if (!isCSM)
 					drawFrustum(frustumVertices);
 					drawFrustum(frustumVertices);
 				else
 				else
 					gRendererUtility().drawScreenQuad();
 					gRendererUtility().drawScreenQuad();