Browse Source

Various fixes for the new shader parsing logic

BearishSun 8 years ago
parent
commit
729a9cd7b7

+ 0 - 1
Data/Raw/Engine/Includes/PerCameraData.bslinc

@@ -2,7 +2,6 @@ mixin PerCameraData
 {
 	code 
 	{
-		[internal]
 		cbuffer PerCamera
 		{
 			float3	 gViewDir;

+ 0 - 1
Data/Raw/Engine/Shaders/PPTonemapping.bsl

@@ -44,7 +44,6 @@ technique PPTonemapping
 		SamplerState gColorLUTSamp;
 		Texture3D gColorLUT;
 		
-		[internal]
 		cbuffer Input
 		{
 			float gRawGamma;

+ 1 - 0
Source/BansheeD3D11RenderAPI/Source/BsD3D11HLSLParamParser.cpp

@@ -345,6 +345,7 @@ namespace bs { namespace ct
 			{
 				switch(varTypeDesc.Type)
 				{
+				case D3D_SVT_UINT:
 				case D3D_SVT_INT:
 					{
 						switch(varTypeDesc.Columns)

+ 12 - 8
Source/BansheeSL/Source/BsSLFXCompiler.cpp

@@ -488,7 +488,7 @@ namespace bs
 			{
 				GpuParamDataType type = ReflTypeToDataType((Xsc::Reflection::DataType)entry.baseType);
 				if((entry.flags & Xsc::Reflection::Uniform::Flags::Color) != 0 && 
-					entry.baseType == GPDT_FLOAT3 || entry.baseType == GPDT_FLOAT4)
+				   (entry.baseType == GPDT_FLOAT3 || entry.baseType == GPDT_FLOAT4))
 				{
 					type = GPDT_COLOR;
 				}
@@ -576,6 +576,7 @@ namespace bs
 		if (!Xsc::CompileShader(inputDesc, outputDesc, &log, &reflectionData))
 		{
 			// If enabled, don't fail if entry point isn't found
+			bool done = true;
 			if(optionalEntry)
 			{
 				bool entryFound = false;
@@ -589,14 +590,17 @@ namespace bs
 				}
 
 				if (!entryFound)
-					return "";
+					done = false;
 			}
 
-			StringStream logOutput;
-			log.getMessages(logOutput);
+			if (done)
+			{
+				StringStream logOutput;
+				log.getMessages(logOutput);
 
-			LOGERR("Shader cross compilation failed. Log: \n\n" + logOutput.str());
-			return "";
+				LOGERR("Shader cross compilation failed. Log: \n\n" + logOutput.str());
+				return "";
+			}
 		}
 
 		for (auto& entry : reflectionData.constantBuffers)
@@ -1343,7 +1347,7 @@ namespace bs
 
 	void BSLFXCompiler::parseTechnique(ASTFXNode* techniqueNode, const Vector<String>& codeBlocks, TechniqueData& techniqueData)
 	{
-		if (techniqueNode == nullptr || techniqueNode->type != NT_Technique)
+		if (techniqueNode == nullptr || (techniqueNode->type != NT_Technique && techniqueNode->type != NT_Mixin))
 			return;
 
 		// There must always be at least one pass
@@ -1600,7 +1604,7 @@ namespace bs
 				PassData& vkslPassData = vkslTechnique.passes[j];
 
 				// Clean non-standard HLSL 
-				static const std::regex regex("\\[.*layout.*\\(.*\\).*\\]|\\[.*internal.*\\]|\\[.*color.*\\]");
+				static const std::regex regex("\\[\\s*layout\\s*\\(.*\\)\\s*\\]|\\[\\s*internal\\s*\\]|\\[\\s*color\\s*\\]");
 				hlslPassData.code = regex_replace(hlslPassData.code, regex, "");
 
 				// Find valid entry points and parameters

+ 1 - 1
Source/External/XShaderCompiler

@@ -1 +1 @@
-Subproject commit 928e46ab50197ef1d453621eb223133f614ec8c9
+Subproject commit 0c647c10285510918afd49523dde7ed7d8fda631