Преглед изворни кода

Better render texture suface compatibility checking

BearishSun пре 9 година
родитељ
комит
7038a31ea9

+ 23 - 5
Source/BansheeCore/Source/BsMultiRenderTexture.cpp

@@ -144,15 +144,24 @@ namespace BansheeEngine
 			const TextureProperties& curTexProps = mColorSurfaces[i]->getTexture()->getProperties();
 			const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
 
+			UINT32 curMsCount = curTexProps.getMultisampleCount();
+			UINT32 firstMsCount = firstTexProps.getMultisampleCount();
+
+			if (curMsCount == 0)
+				curMsCount = 1;
+
+			if (firstMsCount == 0)
+				firstMsCount = 1;
+
 			if (curTexProps.getWidth() != firstTexProps.getWidth() ||
 				curTexProps.getHeight() != firstTexProps.getHeight() ||
-				curTexProps.getMultisampleCount() != firstTexProps.getMultisampleCount())
+				curMsCount != firstMsCount)
 			{
 				String errorInfo = "\nWidth: " + toString(curTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
 				errorInfo += "\nHeight: " + toString(curTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
-				errorInfo += "\nMultisample Count: " + toString(curTexProps.getMultisampleCount()) + "/" + toString(firstTexProps.getMultisampleCount());
+				errorInfo += "\nMultisample Count: " + toString(curMsCount) + "/" + toString(firstMsCount);
 
-				BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
+				BS_EXCEPT(InvalidParametersException, "Provided color textures don't match!" + errorInfo);
 			}
 		}
 
@@ -185,13 +194,22 @@ namespace BansheeEngine
 				return;
 
 			const TextureProperties& depthTexProps = mDepthStencilSurface->getTexture()->getProperties();
+			UINT32 depthMsCount = depthTexProps.getMultisampleCount();
+			UINT32 colorMsCount = firstTexProps.getMultisampleCount();
+
+			if (depthMsCount == 0)
+				depthMsCount = 1;
+
+			if (colorMsCount == 0)
+				colorMsCount = 1;
+
 			if (depthTexProps.getWidth() != firstTexProps.getWidth() ||
 				depthTexProps.getHeight() != firstTexProps.getHeight() ||
-				depthTexProps.getMultisampleCount() != firstTexProps.getMultisampleCount())
+				depthMsCount != colorMsCount)
 			{
 				String errorInfo = "\nWidth: " + toString(depthTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
 				errorInfo += "\nHeight: " + toString(depthTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
-				errorInfo += "\nMultisample Count: " + toString(depthTexProps.getMultisampleCount()) + "/" + toString(firstTexProps.getMultisampleCount());
+				errorInfo += "\nMultisample Count: " + toString(depthMsCount) + "/" + toString(colorMsCount);
 
 				BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
 			}

+ 11 - 2
Source/BansheeCore/Source/BsRenderTexture.cpp

@@ -148,13 +148,22 @@ namespace BansheeEngine
 		const TextureProperties& colorProps = mColorSurface->getTexture()->getProperties();
 		const TextureProperties& depthProps = mDepthStencilSurface->getTexture()->getProperties();
 
+		UINT32 colorMsCount = colorProps.getMultisampleCount();
+		UINT32 depthMsCount = depthProps.getMultisampleCount();
+
+		if (colorMsCount == 0)
+			colorMsCount = 1;
+
+		if (depthMsCount == 0)
+			depthMsCount = 1;
+
 		if (colorProps.getWidth() != depthProps.getWidth() ||
 			colorProps.getHeight() != depthProps.getHeight() ||
-			colorProps.getMultisampleCount() != depthProps.getMultisampleCount())
+			colorMsCount != depthMsCount)
 		{
 			String errorInfo = "\nWidth: " + toString(colorProps.getWidth()) + "/" + toString(depthProps.getWidth());
 			errorInfo += "\nHeight: " + toString(colorProps.getHeight()) + "/" + toString(depthProps.getHeight());
-			errorInfo += "\nMultisample Count: " + toString(colorProps.getMultisampleCount()) + "/" + toString(depthProps.getMultisampleCount());
+			errorInfo += "\nMultisample Count: " + toString(colorMsCount) + "/" + toString(depthMsCount);
 
 			BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
 		}