Browse Source

Fix bug when sampler min/mag is anisotropic but mip is point (#2609)

Gary Hsu 4 years ago
parent
commit
79d1b4db56
1 changed files with 7 additions and 6 deletions
  1. 7 6
      src/renderer_d3d11.cpp

+ 7 - 6
src/renderer_d3d11.cpp

@@ -2976,11 +2976,12 @@ namespace bgfx { namespace d3d11
 			const uint32_t index = (_flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 			const uint32_t index = (_flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 			_flags &= BGFX_SAMPLER_BITS_MASK;
 			_flags &= BGFX_SAMPLER_BITS_MASK;
 
 
-			// Force both min+max anisotropic, can't be set individually.
-			_flags |= 0 != (_flags & (BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC) )
-					? BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC
-					: 0
-					;
+			// Force min+mag anisotropic (can't be set individually) and remove mip (not supported).
+			if (0 != (_flags & (BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC)))
+			{
+				_flags |= BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC;
+				_flags &= ~BGFX_SAMPLER_MIP_MASK;
+			}
 
 
 			uint32_t hash;
 			uint32_t hash;
 			ID3D11SamplerState* sampler;
 			ID3D11SamplerState* sampler;
@@ -3041,7 +3042,7 @@ namespace bgfx { namespace d3d11
 				sd.MinLOD = 0;
 				sd.MinLOD = 0;
 				sd.MaxLOD = D3D11_FLOAT32_MAX;
 				sd.MaxLOD = D3D11_FLOAT32_MAX;
 
 
-				m_device->CreateSamplerState(&sd, &sampler);
+				DX_CHECK(m_device->CreateSamplerState(&sd, &sampler));
 				DX_CHECK_REFCOUNT(sampler, 1);
 				DX_CHECK_REFCOUNT(sampler, 1);
 
 
 				m_samplerStateCache.add(hash, sampler);
 				m_samplerStateCache.add(hash, sampler);