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

D3D11: Fix read-only depth/stencil when only depth is used

BearishSun пре 9 година
родитељ
комит
90723435ec
1 измењених фајлова са 10 додато и 2 уклоњено
  1. 10 2
      Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureView.cpp

+ 10 - 2
Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureView.cpp

@@ -366,10 +366,18 @@ namespace bs { namespace ct
 			BS_EXCEPT(InvalidParametersException, "Invalid texture type for this view type.");
 		}
 
+		desc.Format = texture->getDepthStencilFormat();
+
 		if (readOnly)
-			desc.Flags = D3D11_DSV_READ_ONLY_DEPTH | D3D11_DSV_READ_ONLY_STENCIL;
+		{
+			bool hasStencil = desc.Format == DXGI_FORMAT_D32_FLOAT_S8X24_UINT ||
+				desc.Format == DXGI_FORMAT_D24_UNORM_S8_UINT;
 
-		desc.Format = texture->getDepthStencilFormat();
+			desc.Flags = D3D11_DSV_READ_ONLY_DEPTH;
+
+			if (hasStencil)
+				desc.Flags |= D3D11_DSV_READ_ONLY_STENCIL;
+		}		
 
 		ID3D11DepthStencilView* dsv = nullptr;