Ver Fonte

Fixing DX9 and DX11 issues where render targets where incorrectly flagged as multi-sampled

Marko Pintera há 10 anos atrás
pai
commit
6d191324b0

+ 9 - 6
BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp

@@ -65,7 +65,10 @@ namespace BansheeEngine
 		D3D11RenderAPI* rs = static_cast<D3D11RenderAPI*>(RenderAPICore::instancePtr());
 		D3D11Device& device = rs->getPrimaryDevice();
 
-		if (mProperties.getMultisampleCount() != target->getProperties().getMultisampleCount()) // Resolving from MS to non-MS texture
+		bool srcHasMultisample = mProperties.getMultisampleCount() > 1;
+		bool destHasMultisample = target->getProperties().getMultisampleCount() > 1;
+
+		if (srcHasMultisample && destHasMultisample && mProperties.getMultisampleCount() != target->getProperties().getMultisampleCount()) // Resolving from MS to non-MS texture
 		{
 			device.getImmediateContext()->ResolveSubresource(other->getDX11Resource(), destResIdx, mTex, srcResIdx, mDXGIFormat);
 		}
@@ -83,7 +86,7 @@ namespace BansheeEngine
 
 	PixelData D3D11TextureCore::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
-		if (mProperties.getMultisampleCount() > 0)
+		if (mProperties.getMultisampleCount() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 #if BS_PROFILING_ENABLED
@@ -149,7 +152,7 @@ namespace BansheeEngine
 
 	void D3D11TextureCore::readData(PixelData& dest, UINT32 mipLevel, UINT32 face)
 	{
-		if (mProperties.getMultisampleCount() > 0)
+		if (mProperties.getMultisampleCount() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		PixelData myData = lock(GBL_READ_ONLY, mipLevel, face);
@@ -171,7 +174,7 @@ namespace BansheeEngine
 	{
 		PixelFormat format = mProperties.getFormat();
 
-		if (mProperties.getMultisampleCount() > 0)
+		if (mProperties.getMultisampleCount() > 1)
 			BS_EXCEPT(InvalidStateException, "Multisampled textures cannot be accessed from the CPU directly.");
 
 		if ((mProperties.getUsage() & TU_DYNAMIC) != 0)
@@ -439,7 +442,7 @@ namespace BansheeEngine
 
 			if((usage & TU_RENDERTARGET) != 0)
 			{
-				if (sampleCount > 0)
+				if (sampleCount > 1)
 				{
 					mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
 					mSRVDesc.Texture2D.MostDetailedMip = 0;
@@ -481,7 +484,7 @@ namespace BansheeEngine
 		}
 		else
 		{
-			if (sampleCount > 0)
+			if (sampleCount > 1)
 				mDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
 			else
 				mDimension = D3D11_SRV_DIMENSION_TEXTURE2D;

+ 3 - 3
BansheeD3D11RenderSystem/Source/BsD3D11TextureView.cpp

@@ -45,7 +45,7 @@ namespace BansheeEngine
 			desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
 			break;
 		case TEX_TYPE_2D:
-			if (texProps.getMultisampleCount() > 0)
+			if (texProps.getMultisampleCount() > 1)
 			{
 				desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
 			}
@@ -100,7 +100,7 @@ namespace BansheeEngine
 			desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D;
 			break;
 		case TEX_TYPE_2D:
-			if (texProps.getMultisampleCount() > 0)
+			if (texProps.getMultisampleCount() > 1)
 			{
 				desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
 			}
@@ -204,7 +204,7 @@ namespace BansheeEngine
 			desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE1D;
 			break;
 		case TEX_TYPE_2D:
-			if (texProps.getMultisampleCount() > 0)
+			if (texProps.getMultisampleCount() > 1)
 			{
 				desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
 			}

+ 1 - 1
BansheeD3D9RenderSystem/Source/BsD3D9RenderAPI.cpp

@@ -2161,7 +2161,7 @@ namespace BansheeEngine
 			}
 			else // !CSAA
 			{
-				*outMultisampleType = (D3DMULTISAMPLE_TYPE)multisampleCount;
+				*outMultisampleType = D3DMULTISAMPLE_NONE;
 				*outMultisampleQuality = 0;
 			}
 

+ 2 - 2
BansheeD3D9RenderSystem/Source/BsD3D9Texture.cpp

@@ -903,7 +903,7 @@ namespace BansheeEngine
 		if ((texUsage & TU_RENDERTARGET) != 0 && (mMultisampleType != D3DMULTISAMPLE_NONE))
 		{
 			assert(textureResources->pMultisampleSurface);
-			assert(texUsage == TEX_TYPE_2D);
+			assert(texType == TEX_TYPE_2D);
 
 			D3D9PixelBuffer* currPixelBuffer = static_cast<D3D9PixelBuffer*>(mSurfaceList[0].get());
 
@@ -912,7 +912,7 @@ namespace BansheeEngine
 		else if ((texUsage & TU_DEPTHSTENCIL) != 0 && (mMultisampleType != D3DMULTISAMPLE_NONE))
 		{
 			assert(textureResources->pDepthStencilSurface);
-			assert(texUsage == TEX_TYPE_2D);
+			assert(texType == TEX_TYPE_2D);
 
 			D3D9PixelBuffer* currPixelBuffer = static_cast<D3D9PixelBuffer*>(mSurfaceList[0].get());
 

+ 2 - 2
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -1216,8 +1216,8 @@ namespace BansheeEngine
 			{ GizmoPickingAlphaPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ SelectionVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ SelectionPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ SceneGridVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ SceneGridPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ SceneGridVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ SceneGridPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
 			{ ShaderDockOverlayVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_2_0,		"hlsl", HLSL9ShaderSubFolder },
 			{ ShaderDockOverlayPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0,		"hlsl", HLSL9ShaderSubFolder },
 			{ PickingVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },

+ 1 - 1
BansheeEditorExec/BsEditorExec.cpp

@@ -65,7 +65,7 @@ int CALLBACK WinMain(
 	InitializeDebugConsole();
 #endif
 
-	EditorApplication::startUp(RenderSystemPlugin::OpenGL);
+	EditorApplication::startUp(RenderSystemPlugin::DX11);
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();