Sfoglia il codice sorgente

Fixed CheckFeatureSupport with DXGI_FEATURE_PRESENT_ALLOW_TEARING crash on Windows 7. Issue #1356.

Branimir Karadžić 7 anni fa
parent
commit
fc133a2f7a
3 ha cambiato i file con 18 aggiunte e 11 eliminazioni
  1. 0 9
      src/bgfx.cpp
  2. 11 0
      src/bgfx_p.h
  3. 7 2
      src/dxgi.cpp

+ 0 - 9
src/bgfx.cpp

@@ -2028,15 +2028,6 @@ namespace bgfx
 	};
 	BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count);
 
-	struct Condition
-	{
-		enum Enum
-		{
-			LessEqual,
-			GreaterEqual,
-		};
-	};
-
 	bool windowsVersionIs(Condition::Enum _op, uint32_t _version)
 	{
 #if BX_PLATFORM_WINDOWS

+ 11 - 0
src/bgfx_p.h

@@ -308,6 +308,17 @@ namespace bgfx
 		return 0 != _decl.m_stride;
 	}
 
+	struct Condition
+	{
+		enum Enum
+		{
+			LessEqual,
+			GreaterEqual,
+		};
+	};
+
+	bool windowsVersionIs(Condition::Enum _op, uint32_t _version);
+
 	struct Clear
 	{
 		void set(uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)

+ 7 - 2
src/dxgi.cpp

@@ -402,8 +402,13 @@ namespace bgfx
 		bool allowTearing = false;
 
 #if BX_PLATFORM_WINDOWS
-		hr = m_factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(allowTearing) );
-		BX_TRACE("Allow tearing is %ssupported.", allowTearing ? "" : "not ");
+		if (windowsVersionIs(Condition::GreaterEqual, 0x0602) )
+		{
+			// BK - CheckFeatureSupport with DXGI_FEATURE_PRESENT_ALLOW_TEARING
+			//      will crash on pre Windows 8. Issue #1356.
+			hr = m_factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(allowTearing) );
+			BX_TRACE("Allow tearing is %ssupported.", allowTearing ? "" : "not ");
+		}
 
 		DXGI_SWAP_CHAIN_DESC scd;
 		scd.BufferDesc.Width  = _scd.width;