Răsfoiți Sursa

Added conservative raster support.

Branimir Karadžić 9 ani în urmă
părinte
comite
acbabdde3b
7 a modificat fișierele cu 119 adăugiri și 64 ștergeri
  1. 3 1
      include/bgfx/bgfxdefines.h
  2. 1 0
      src/bgfx.cpp
  3. 57 16
      src/renderer_d3d11.cpp
  4. 1 1
      src/renderer_d3d11.h
  5. 11 7
      src/renderer_d3d12.cpp
  6. 42 39
      src/renderer_gl.cpp
  7. 4 0
      src/renderer_gl.h

+ 3 - 1
include/bgfx/bgfxdefines.h

@@ -6,7 +6,7 @@
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 
 
-#define BGFX_API_VERSION UINT32_C(12)
+#define BGFX_API_VERSION UINT32_C(13)
 
 
 ///
 ///
 #define BGFX_STATE_RGB_WRITE               UINT64_C(0x0000000000000001) //!< Enable RGB write.
 #define BGFX_STATE_RGB_WRITE               UINT64_C(0x0000000000000001) //!< Enable RGB write.
@@ -74,6 +74,7 @@
 /// MSAA frame buffer.
 /// MSAA frame buffer.
 #define BGFX_STATE_MSAA                    UINT64_C(0x0100000000000000) //!< Enable MSAA rasterization.
 #define BGFX_STATE_MSAA                    UINT64_C(0x0100000000000000) //!< Enable MSAA rasterization.
 #define BGFX_STATE_LINEAA                  UINT64_C(0x0200000000000000) //!< Enable line AA rasterization.
 #define BGFX_STATE_LINEAA                  UINT64_C(0x0200000000000000) //!< Enable line AA rasterization.
+#define BGFX_STATE_CONSERVATIVE_RASTER     UINT64_C(0x0400000000000000) //!< Enable conservative rasterization.
 
 
 /// Do not use!
 /// Do not use!
 #define BGFX_STATE_RESERVED_SHIFT          61                           //!< Internal bits shift.
 #define BGFX_STATE_RESERVED_SHIFT          61                           //!< Internal bits shift.
@@ -383,6 +384,7 @@
 #define BGFX_CAPS_TEXTURE_READ_BACK      UINT64_C(0x0000000000020000) //!< Read-back texture is supported.
 #define BGFX_CAPS_TEXTURE_READ_BACK      UINT64_C(0x0000000000020000) //!< Read-back texture is supported.
 #define BGFX_CAPS_OCCLUSION_QUERY        UINT64_C(0x0000000000040000) //!< Occlusion query is supported.
 #define BGFX_CAPS_OCCLUSION_QUERY        UINT64_C(0x0000000000040000) //!< Occlusion query is supported.
 #define BGFX_CAPS_ALPHA_TO_COVERAGE      UINT64_C(0x0000000000080000) //!< Alpha to coverage is supported.
 #define BGFX_CAPS_ALPHA_TO_COVERAGE      UINT64_C(0x0000000000080000) //!< Alpha to coverage is supported.
+#define BGFX_CAPS_CONSERVATIVE_RASTER    UINT64_C(0x0000000000100000) //!< Conservative rasterization is supported.
 
 
 ///
 ///
 #define BGFX_CAPS_FORMAT_TEXTURE_NONE             UINT16_C(0x0000) //!< Texture format is not supported.
 #define BGFX_CAPS_FORMAT_TEXTURE_NONE             UINT16_C(0x0000) //!< Texture format is not supported.

+ 1 - 0
src/bgfx.cpp

@@ -1085,6 +1085,7 @@ namespace bgfx
 		CAPS_FLAGS(BGFX_CAPS_TEXTURE_READ_BACK),
 		CAPS_FLAGS(BGFX_CAPS_TEXTURE_READ_BACK),
 		CAPS_FLAGS(BGFX_CAPS_OCCLUSION_QUERY),
 		CAPS_FLAGS(BGFX_CAPS_OCCLUSION_QUERY),
 		CAPS_FLAGS(BGFX_CAPS_ALPHA_TO_COVERAGE),
 		CAPS_FLAGS(BGFX_CAPS_ALPHA_TO_COVERAGE),
+		CAPS_FLAGS(BGFX_CAPS_CONSERVATIVE_RASTER),
 #undef CAPS_FLAGS
 #undef CAPS_FLAGS
 	};
 	};
 
 

+ 57 - 16
src/renderer_d3d11.cpp

@@ -997,7 +997,8 @@ namespace bgfx { namespace d3d11
 				for (uint32_t ii = 0; ii < BX_COUNTOF(s_deviceIIDs) && FAILED(hr); ++ii)
 				for (uint32_t ii = 0; ii < BX_COUNTOF(s_deviceIIDs) && FAILED(hr); ++ii)
 				{
 				{
 					hr = m_device->QueryInterface(s_deviceIIDs[ii], (void**)&device);
 					hr = m_device->QueryInterface(s_deviceIIDs[ii], (void**)&device);
-					BX_TRACE("D3D device 11.%d, hr %x", BX_COUNTOF(s_deviceIIDs)-1-ii, hr);
+					m_deviceInterfaceVersion = BX_COUNTOF(s_deviceIIDs)-1-ii;
+					BX_TRACE("D3D device 11.%d, hr %x", m_deviceInterfaceVersion, hr);
 
 
 					if (SUCCEEDED(hr) )
 					if (SUCCEEDED(hr) )
 					{
 					{
@@ -1219,6 +1220,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 					| BGFX_CAPS_TEXTURE_READ_BACK
 					| BGFX_CAPS_TEXTURE_READ_BACK
 					| ( (m_featureLevel >= D3D_FEATURE_LEVEL_9_2) ? BGFX_CAPS_OCCLUSION_QUERY : 0)
 					| ( (m_featureLevel >= D3D_FEATURE_LEVEL_9_2) ? BGFX_CAPS_OCCLUSION_QUERY : 0)
 					| BGFX_CAPS_ALPHA_TO_COVERAGE
 					| BGFX_CAPS_ALPHA_TO_COVERAGE
+					| ( (m_deviceInterfaceVersion >= 3) ? BGFX_CAPS_CONSERVATIVE_RASTER : 0)
 					);
 					);
 
 
 				m_timerQuerySupport = m_featureLevel >= D3D_FEATURE_LEVEL_10_0;
 				m_timerQuerySupport = m_featureLevel >= D3D_FEATURE_LEVEL_10_0;
@@ -2757,7 +2759,12 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 
 
 		void setRasterizerState(uint64_t _state, bool _wireframe = false, bool _scissor = false)
 		void setRasterizerState(uint64_t _state, bool _wireframe = false, bool _scissor = false)
 		{
 		{
-			_state &= BGFX_STATE_CULL_MASK|BGFX_STATE_MSAA|BGFX_STATE_LINEAA;
+			_state &= 0
+				| BGFX_STATE_CULL_MASK
+				| BGFX_STATE_MSAA
+				| BGFX_STATE_LINEAA
+				| BGFX_STATE_CONSERVATIVE_RASTER
+				;
 			_state |= _wireframe ? BGFX_STATE_PT_LINES : BGFX_STATE_NONE;
 			_state |= _wireframe ? BGFX_STATE_PT_LINES : BGFX_STATE_NONE;
 			_state |= _scissor   ? BGFX_STATE_RESERVED_MASK : 0;
 			_state |= _scissor   ? BGFX_STATE_RESERVED_MASK : 0;
 
 
@@ -2766,19 +2773,44 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 			{
 			{
 				uint32_t cull = (_state&BGFX_STATE_CULL_MASK)>>BGFX_STATE_CULL_SHIFT;
 				uint32_t cull = (_state&BGFX_STATE_CULL_MASK)>>BGFX_STATE_CULL_SHIFT;
 
 
-				D3D11_RASTERIZER_DESC desc;
-				desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
-				desc.CullMode = s_cullMode[cull];
-				desc.FrontCounterClockwise = false;
-				desc.DepthBias = 0;
-				desc.DepthBiasClamp = 0.0f;
-				desc.SlopeScaledDepthBias = 0.0f;
-				desc.DepthClipEnable = !m_depthClamp;
-				desc.ScissorEnable = _scissor;
-				desc.MultisampleEnable = !!(_state&BGFX_STATE_MSAA);
-				desc.AntialiasedLineEnable = !!(_state&BGFX_STATE_LINEAA);
+				if (m_deviceInterfaceVersion >= 3)
+				{
+					D3D11_RASTERIZER_DESC2 desc;
+					desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
+					desc.CullMode = s_cullMode[cull];
+					desc.FrontCounterClockwise = false;
+					desc.DepthBias             = 0;
+					desc.DepthBiasClamp        = 0.0f;
+					desc.SlopeScaledDepthBias  = 0.0f;
+					desc.DepthClipEnable       = !m_depthClamp;
+					desc.ScissorEnable         = _scissor;
+					desc.MultisampleEnable     = !!(_state&BGFX_STATE_MSAA);
+					desc.AntialiasedLineEnable = !!(_state&BGFX_STATE_LINEAA);
+					desc.ForcedSampleCount     = 0;
+					desc.ConservativeRaster    = !!(_state&BGFX_STATE_CONSERVATIVE_RASTER)
+						? D3D11_CONSERVATIVE_RASTERIZATION_MODE_ON
+						: D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF
+						;
 
 
-				DX_CHECK(m_device->CreateRasterizerState(&desc, &rs) );
+					ID3D11Device3* device3 = reinterpret_cast<ID3D11Device3*>(m_device);
+					DX_CHECK(device3->CreateRasterizerState2(&desc, reinterpret_cast<ID3D11RasterizerState2**>(&rs) ) );
+				}
+				else
+				{
+					D3D11_RASTERIZER_DESC desc;
+					desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
+					desc.CullMode = s_cullMode[cull];
+					desc.FrontCounterClockwise = false;
+					desc.DepthBias             = 0;
+					desc.DepthBiasClamp        = 0.0f;
+					desc.SlopeScaledDepthBias  = 0.0f;
+					desc.DepthClipEnable       = !m_depthClamp;
+					desc.ScissorEnable         = _scissor;
+					desc.MultisampleEnable     = !!(_state&BGFX_STATE_MSAA);
+					desc.AntialiasedLineEnable = !!(_state&BGFX_STATE_LINEAA);
+
+					DX_CHECK(m_device->CreateRasterizerState(&desc, &rs) );
+				}
 
 
 				m_rasterizerStateCache.add(_state, rs);
 				m_rasterizerStateCache.add(_state, rs);
 			}
 			}
@@ -3444,6 +3476,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		TimerQueryD3D11      m_gpuTimer;
 		TimerQueryD3D11      m_gpuTimer;
 		OcclusionQueryD3D11  m_occlusionQuery;
 		OcclusionQueryD3D11  m_occlusionQuery;
 
 
+		uint32_t m_deviceInterfaceVersion;
+
 		ID3D11RenderTargetView* m_backBufferColor;
 		ID3D11RenderTargetView* m_backBufferColor;
 		ID3D11DepthStencilView* m_backBufferDepthStencil;
 		ID3D11DepthStencilView* m_backBufferDepthStencil;
 		ID3D11RenderTargetView* m_currentColor;
 		ID3D11RenderTargetView* m_currentColor;
@@ -5304,9 +5338,15 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 					 | BGFX_STATE_POINT_SIZE_MASK
 					 | BGFX_STATE_POINT_SIZE_MASK
 					 | BGFX_STATE_MSAA
 					 | BGFX_STATE_MSAA
 					 | BGFX_STATE_LINEAA
 					 | BGFX_STATE_LINEAA
+					 | BGFX_STATE_CONSERVATIVE_RASTER
 					 ) & changedFlags)
 					 ) & changedFlags)
 				{
 				{
-					if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_MSAA|BGFX_STATE_LINEAA) & changedFlags)
+					if ( (0
+						 | BGFX_STATE_CULL_MASK
+						 | BGFX_STATE_MSAA
+						 | BGFX_STATE_LINEAA
+						 | BGFX_STATE_CONSERVATIVE_RASTER
+						 ) & changedFlags)
 					{
 					{
 						setRasterizerState(newFlags, wireframe, scissorEnabled);
 						setRasterizerState(newFlags, wireframe, scissorEnabled);
 					}
 					}
@@ -5725,8 +5765,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 				tvm.clear();
 				tvm.clear();
 				uint16_t pos = 0;
 				uint16_t pos = 0;
 				tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f
 				tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f
-					, " %s (FL %d.%d) / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "
+					, " %s.%d (FL %d.%d) / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "
 					, getRendererName()
 					, getRendererName()
+					, m_deviceInterfaceVersion
 					, (m_featureLevel >> 12) & 0xf
 					, (m_featureLevel >> 12) & 0xf
 					, (m_featureLevel >>  8) & 0xf
 					, (m_featureLevel >>  8) & 0xf
 					);
 					);

+ 1 - 1
src/renderer_d3d11.h

@@ -20,7 +20,7 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4005) // warning C4005: '' : macro redefinitio
 #include <sal.h>
 #include <sal.h>
 #define D3D11_NO_HELPERS
 #define D3D11_NO_HELPERS
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
-#	include <d3d11.h>
+#	include <d3d11_3.h>
 #	include <dxgi1_3.h>
 #	include <dxgi1_3.h>
 #elif BX_PLATFORM_WINRT
 #elif BX_PLATFORM_WINRT
 #	include <d3d11_3.h>
 #	include <d3d11_3.h>

+ 11 - 7
src/renderer_d3d12.cpp

@@ -2059,14 +2059,17 @@ data.NumQualityLevels = 0;
 				;
 				;
 			_desc.CullMode = s_cullMode[cull];
 			_desc.CullMode = s_cullMode[cull];
 			_desc.FrontCounterClockwise = false;
 			_desc.FrontCounterClockwise = false;
-			_desc.DepthBias = 0;
-			_desc.DepthBiasClamp = 0.0f;
-			_desc.SlopeScaledDepthBias = 0.0f;
-			_desc.DepthClipEnable = !m_depthClamp;
-			_desc.MultisampleEnable = !!(_state&BGFX_STATE_MSAA);
+			_desc.DepthBias             = 0;
+			_desc.DepthBiasClamp        = 0.0f;
+			_desc.SlopeScaledDepthBias  = 0.0f;
+			_desc.DepthClipEnable       = !m_depthClamp;
+			_desc.MultisampleEnable     = !!(_state&BGFX_STATE_MSAA);
 			_desc.AntialiasedLineEnable = !!(_state&BGFX_STATE_LINEAA);
 			_desc.AntialiasedLineEnable = !!(_state&BGFX_STATE_LINEAA);
-			_desc.ForcedSampleCount = 0;
-			_desc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
+			_desc.ForcedSampleCount     = 0;
+			_desc.ConservativeRaster    = !!(_state&BGFX_STATE_CONSERVATIVE_RASTER)
+				? D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON
+				: D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF
+				;
 		}
 		}
 
 
 		void setDepthStencilState(D3D12_DEPTH_STENCIL_DESC& _desc, uint64_t _state, uint64_t _stencil = 0)
 		void setDepthStencilState(D3D12_DEPTH_STENCIL_DESC& _desc, uint64_t _state, uint64_t _stencil = 0)
@@ -2215,6 +2218,7 @@ data.NumQualityLevels = 0;
 				| BGFX_STATE_CULL_MASK
 				| BGFX_STATE_CULL_MASK
 				| BGFX_STATE_MSAA
 				| BGFX_STATE_MSAA
 				| BGFX_STATE_LINEAA
 				| BGFX_STATE_LINEAA
+				| BGFX_STATE_CONSERVATIVE_RASTER
 				| BGFX_STATE_PT_MASK
 				| BGFX_STATE_PT_MASK
 				;
 				;
 
 

+ 42 - 39
src/renderer_gl.cpp

@@ -585,6 +585,7 @@ namespace bgfx { namespace gl
 			MOZ_WEBGL_compressed_texture_s3tc,
 			MOZ_WEBGL_compressed_texture_s3tc,
 			MOZ_WEBGL_depth_texture,
 			MOZ_WEBGL_depth_texture,
 
 
+			NV_conservative_raster,
 			NV_copy_image,
 			NV_copy_image,
 			NV_draw_buffers,
 			NV_draw_buffers,
 			NV_occlusion_query,
 			NV_occlusion_query,
@@ -792,6 +793,7 @@ namespace bgfx { namespace gl
 		{ "MOZ_WEBGL_compressed_texture_s3tc",     false,                             true  },
 		{ "MOZ_WEBGL_compressed_texture_s3tc",     false,                             true  },
 		{ "MOZ_WEBGL_depth_texture",               false,                             true  },
 		{ "MOZ_WEBGL_depth_texture",               false,                             true  },
 
 
+		{ "NV_conservative_raster",                false,                             true  },
 		{ "NV_copy_image",                         false,                             true  },
 		{ "NV_copy_image",                         false,                             true  },
 		{ "NV_draw_buffers",                       false,                             true  }, // GLES2 extension.
 		{ "NV_draw_buffers",                       false,                             true  }, // GLES2 extension.
 		{ "NV_occlusion_query",                    false,                             true  },
 		{ "NV_occlusion_query",                    false,                             true  },
@@ -1277,6 +1279,8 @@ namespace bgfx { namespace gl
 			, m_depthTextureSupport(false)
 			, m_depthTextureSupport(false)
 			, m_timerQuerySupport(false)
 			, m_timerQuerySupport(false)
 			, m_occlusionQuerySupport(false)
 			, m_occlusionQuerySupport(false)
+			, m_atocSupport(false)
+			, m_conservativeRasterSupport(false)
 			, m_flip(false)
 			, m_flip(false)
 			, m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
 			, m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
 			, m_backBufferFbo(0)
 			, m_backBufferFbo(0)
@@ -1744,11 +1748,6 @@ namespace bgfx { namespace gl
 				: 0
 				: 0
 				;
 				;
 
 
-			g_caps.supported |= s_extension[Extension::ARB_multisample].m_supported
-				? BGFX_CAPS_ALPHA_TO_COVERAGE
-				: 0
-				;
-
 			const bool drawIndirectSupported = false
 			const bool drawIndirectSupported = false
 				|| s_extension[Extension::AMD_multi_draw_indirect].m_supported
 				|| s_extension[Extension::AMD_multi_draw_indirect].m_supported
 				|| s_extension[Extension::ARB_draw_indirect      ].m_supported
 				|| s_extension[Extension::ARB_draw_indirect      ].m_supported
@@ -1875,19 +1874,15 @@ namespace bgfx { namespace gl
 				&& NULL != glEndQuery
 				&& NULL != glEndQuery
 				;
 				;
 
 
-			g_caps.supported |= m_occlusionQuerySupport
-				? BGFX_CAPS_OCCLUSION_QUERY
-				: 0
-				;
+			m_atocSupport = s_extension[Extension::ARB_multisample].m_supported;
+			m_conservativeRasterSupport = s_extension[Extension::NV_conservative_raster].m_supported;
 
 
-			g_caps.supported |= m_depthTextureSupport
-				? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
-				: 0
-				;
-
-			g_caps.supported |= computeSupport
-				? BGFX_CAPS_COMPUTE
-				: 0
+			g_caps.supported |= 0
+				| (m_atocSupport               ? BGFX_CAPS_ALPHA_TO_COVERAGE      : 0)
+				| (m_conservativeRasterSupport ? BGFX_CAPS_CONSERVATIVE_RASTER    : 0)
+				| (m_occlusionQuerySupport     ? BGFX_CAPS_OCCLUSION_QUERY        : 0)
+				| (m_depthTextureSupport       ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL : 0)
+				| (computeSupport              ? BGFX_CAPS_COMPUTE                : 0)
 				;
 				;
 
 
 			g_caps.supported |= m_glctx.getCaps();
 			g_caps.supported |= m_glctx.getCaps();
@@ -3311,6 +3306,8 @@ namespace bgfx { namespace gl
 		bool m_depthTextureSupport;
 		bool m_depthTextureSupport;
 		bool m_timerQuerySupport;
 		bool m_timerQuerySupport;
 		bool m_occlusionQuerySupport;
 		bool m_occlusionQuerySupport;
+		bool m_atocSupport;
+		bool m_conservativeRasterSupport;
 		bool m_flip;
 		bool m_flip;
 
 
 		uint64_t m_hash;
 		uint64_t m_hash;
@@ -5872,6 +5869,8 @@ namespace bgfx { namespace gl
 					 | BGFX_STATE_PT_MASK
 					 | BGFX_STATE_PT_MASK
 					 | BGFX_STATE_POINT_SIZE_MASK
 					 | BGFX_STATE_POINT_SIZE_MASK
 					 | BGFX_STATE_MSAA
 					 | BGFX_STATE_MSAA
+					 | BGFX_STATE_LINEAA
+					 | BGFX_STATE_CONSERVATIVE_RASTER
 					 ) & changedFlags)
 					 ) & changedFlags)
 				{
 				{
 					if (BGFX_STATE_CULL_MASK & changedFlags)
 					if (BGFX_STATE_CULL_MASK & changedFlags)
@@ -5927,26 +5926,27 @@ namespace bgfx { namespace gl
 
 
 					if (BGFX_STATE_MSAA & changedFlags)
 					if (BGFX_STATE_MSAA & changedFlags)
 					{
 					{
-						if (BGFX_STATE_MSAA & newFlags)
-						{
-							GL_CHECK(glEnable(GL_MULTISAMPLE) );
-						}
-						else
-						{
-							GL_CHECK(glDisable(GL_MULTISAMPLE) );
-						}
+						GL_CHECK(BGFX_STATE_MSAA & newFlags
+							? glEnable(GL_MULTISAMPLE)
+							: glDisable(GL_MULTISAMPLE)
+							);
 					}
 					}
 
 
 					if (BGFX_STATE_LINEAA & changedFlags)
 					if (BGFX_STATE_LINEAA & changedFlags)
 					{
 					{
-						if (BGFX_STATE_LINEAA & newFlags)
-						{
-							GL_CHECK(glEnable(GL_LINE_SMOOTH) );
-						}
-						else
-						{
-							GL_CHECK(glDisable(GL_LINE_SMOOTH) );
-						}
+						GL_CHECK(BGFX_STATE_LINEAA & newFlags
+							? glEnable(GL_LINE_SMOOTH)
+							: glDisable(GL_LINE_SMOOTH)
+							);
+					}
+
+					if (m_conservativeRasterSupport
+					&&  BGFX_STATE_CONSERVATIVE_RASTER & changedFlags)
+					{
+						GL_CHECK(BGFX_STATE_CONSERVATIVE_RASTER & newFlags
+							? glEnable(GL_CONSERVATIVE_RASTERIZATION_NV)
+							: glDisable(GL_CONSERVATIVE_RASTERIZATION_NV)
+							);
 					}
 					}
 #endif // BGFX_CONFIG_RENDERER_OPENGL
 #endif // BGFX_CONFIG_RENDERER_OPENGL
 
 
@@ -5965,13 +5965,16 @@ namespace bgfx { namespace gl
 						) & changedFlags)
 						) & changedFlags)
 					||  blendFactor != draw.m_rgba)
 					||  blendFactor != draw.m_rgba)
 					{
 					{
-						if (BGFX_STATE_BLEND_ALPHA_TO_COVERAGE & newFlags)
+						if (m_atocSupport)
 						{
 						{
-							GL_CHECK(glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE) );
-						}
-						else
-						{
-							GL_CHECK(glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE) );
+							if (BGFX_STATE_BLEND_ALPHA_TO_COVERAGE & newFlags)
+							{
+								GL_CHECK(glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE) );
+							}
+							else
+							{
+								GL_CHECK(glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE) );
+							}
 						}
 						}
 
 
 						if ( ( (0
 						if ( ( (0

+ 4 - 0
src/renderer_gl.h

@@ -787,6 +787,10 @@ typedef uint64_t GLuint64;
 #	define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
 #	define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
 #endif // GL_SAMPLE_ALPHA_TO_COVERAGE
 #endif // GL_SAMPLE_ALPHA_TO_COVERAGE
 
 
+#ifndef GL_CONSERVATIVE_RASTERIZATION_NV
+#	define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346
+#endif // GL_CONSERVATIVE_RASTERIZATION_NV
+
 // _KHR or _ARB...
 // _KHR or _ARB...
 #define GL_DEBUG_OUTPUT_SYNCHRONOUS         0x8242
 #define GL_DEBUG_OUTPUT_SYNCHRONOUS         0x8242
 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243