Browse Source

Don't try to call managed assembly entry points, as they don't exist
Don't report errors when setting a parameter block that exists in shader, but was optimized out in GPU program
Don't request GPU program parameters that don't exist

BearishSun 9 years ago
parent
commit
ed8fcf6b9f

+ 2 - 1
Source/BansheeCore/Include/BsGpuParamsSet.h

@@ -43,13 +43,14 @@ namespace BansheeEngine
 		struct BlockInfo
 		{
 			BlockInfo(const String& name, const ParamBlockPtrType& buffer, bool shareable)
-				:name(name), buffer(buffer), shareable(shareable), allowUpdate(true)
+				:name(name), buffer(buffer), shareable(shareable), allowUpdate(true), isUsed(true)
 			{ }
 
 			String name;
 			ParamBlockPtrType buffer;
 			bool shareable;
 			bool allowUpdate;
+			bool isUsed;
 		};
 
 		/** Information about how a data parameter maps from a material parameter into a parameter block buffer. */

+ 21 - 0
Source/BansheeCore/Source/BsGpuParamsSet.cpp

@@ -556,6 +556,24 @@ namespace BansheeEngine
 			}
 		}
 
+		// Add buffers defined in shader but not actually used by GPU programs (so we can check if user is providing a
+		// valid buffer name)
+		auto& allParamBlocks = shader->getParamBlocks();
+		for (auto& entry : allParamBlocks)
+		{
+			auto iterFind = std::find_if(mBlocks.begin(), mBlocks.end(), 
+				[&](auto& x)
+			{
+				return x.name == entry.first;
+			});
+
+			if(iterFind == mBlocks.end())
+			{
+				mBlocks.push_back(BlockInfo(entry.first, nullptr, true));
+				mBlocks.back().isUsed = false;
+			}
+		}
+
 		// Generate information about object parameters
 		bs_frame_mark();
 		{
@@ -739,6 +757,9 @@ namespace BansheeEngine
 			return;
 		}
 
+		if (!mBlocks[foundIdx].isUsed)
+			return;
+
 		mBlocks[foundIdx].buffer = paramBlock;
 		mBlocks[foundIdx].allowUpdate = !ignoreInUpdate;
 

+ 0 - 2
Source/BansheeMono/Source/BsMonoAssembly.cpp

@@ -111,8 +111,6 @@ namespace BansheeEngine
 			BS_EXCEPT(InvalidParametersException, "Cannot get script assembly image.");
 		}
 
-		mono_jit_exec(domain, mMonoAssembly, 0, nullptr);
-
 		mIsLoaded = true;
 		mIsDependency = false;
 	}

+ 0 - 6
Source/MBansheeEngine/Interop/Program.cs

@@ -70,13 +70,7 @@ namespace BansheeEngine
     /// </summary>
     class Program
     {
-        /// <summary>
-        /// Assembly entry point. Unused.
-        /// </summary>
-        static void Start()
-        {
 
-        }
     }
 
     /** @endcond */

+ 5 - 12
Source/RenderBeast/Source/BsObjectRendering.cpp

@@ -24,19 +24,18 @@ namespace BansheeEngine
 			return;
 		}
 
+		// Note: Perhaps perform buffer validation to ensure expected buffer has the same size and layout as the provided
+		// buffer, and show a warning otherwise. But this is perhaps better handled on a higher level.
 		const Map<String, SHADER_PARAM_BLOCK_DESC>& paramBlockDescs = shader->getParamBlocks();
-		String perFrameBlockName;
-		String perCameraBlockName;
-		String perObjectBlockName;
 
 		for (auto& paramBlockDesc : paramBlockDescs)
 		{
 			if (paramBlockDesc.second.rendererSemantic == RBS_PerFrame)
-				perFrameBlockName = paramBlockDesc.second.name;
+				element.params->setParamBlockBuffer(paramBlockDesc.second.name, mPerFrameParams.getBuffer(), true);
 			else if (paramBlockDesc.second.rendererSemantic == RBS_PerCamera)
-				perCameraBlockName = paramBlockDesc.second.name;
+				element.params->setParamBlockBuffer(paramBlockDesc.second.name, mPerCameraParams.getBuffer(), true);
 			else if (paramBlockDesc.second.rendererSemantic == RBS_PerObject)
-				perObjectBlockName = paramBlockDesc.second.name;
+				element.params->setParamBlockBuffer(paramBlockDesc.second.name, mPerObjectParams.getBuffer(), true);
 		}
 
 		const Map<String, SHADER_OBJECT_PARAM_DESC>& bufferDescs = shader->getBufferParams();
@@ -48,12 +47,6 @@ namespace BansheeEngine
 				boneMatricesParamName = entry.second.name;
 		}
 		
-		// Note: Perhaps perform buffer validation to ensure expected buffer has the same size and layout as the provided
-		// buffer, and show a warning otherwise. But this is perhaps better handled on a higher level.
-		element.params->setParamBlockBuffer(perFrameBlockName, mPerFrameParams.getBuffer(), true);
-		element.params->setParamBlockBuffer(perCameraBlockName, mPerCameraParams.getBuffer(), true);
-		element.params->setParamBlockBuffer(perObjectBlockName, mPerObjectParams.getBuffer(), true);
-
 		if (!boneMatricesParamName.empty())
 		{
 			// Note: Bone matrices should be shared between all sub-meshes, so maybe it's better to create this buffer

+ 3 - 1
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -349,7 +349,9 @@ namespace BansheeEngine
 
 		SPtr<GpuParamsCore> fragmentParams = mParamsSet->getGpuParams(GPT_FRAGMENT_PROGRAM);
 		fragmentParams->getTextureParam("gInputTex", mInputTex);
-		fragmentParams->getTextureParam("gColorLUT", mColorLUT);
+
+		if(!GammaOnly)
+			fragmentParams->getTextureParam("gColorLUT", mColorLUT);
 	}
 
 	template<bool GammaOnly, bool AutoExposure>