Added alpha to coverage and anti-aliased lines support.

This commit is contained in:
Branimir Karadžić 2016-03-16 15:09:15 -07:00
parent 9853b5b8f6
commit 8955ebc6c8
11 changed files with 147 additions and 71 deletions

View File

@ -1234,7 +1234,7 @@ private:
bgfx::setVertexBuffer(m_vbh, mesh.m_startVertex, mesh.m_numVertices);
bgfx::setState(0
| attrib.m_state
| (_wireframe ? BGFX_STATE_PT_LINES : 0)
| (_wireframe ? BGFX_STATE_PT_LINES|BGFX_STATE_LINEAA|BGFX_STATE_BLEND_ALPHA : 0)
);
bgfx::submit(m_viewId, m_program[_wireframe ? Program::Fill : Program::FillLit]);
}
@ -1268,7 +1268,8 @@ private:
| BGFX_STATE_PT_LINES
| BGFX_STATE_DEPTH_TEST_LEQUAL
| BGFX_STATE_DEPTH_WRITE
// | BGFX_STATE_BLEND_ALPHA
| BGFX_STATE_LINEAA
| BGFX_STATE_BLEND_ALPHA
);
bgfx::setTransform(m_mtx);
bgfx::ProgramHandle program = m_program[m_attrib[m_stack].m_stipple ? 1 : 0];

View File

@ -6,80 +6,82 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_API_VERSION UINT32_C(11)
#define BGFX_API_VERSION UINT32_C(12)
///
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000002) //!< Enable alpha write.
#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000004) //!< Enable depth write.
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000002) //!< Enable alpha write.
#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000004) //!< Enable depth write.
#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010) //!< Enable depth test, less.
#define BGFX_STATE_DEPTH_TEST_LEQUAL UINT64_C(0x0000000000000020) //!< Enable depth test, less equal.
#define BGFX_STATE_DEPTH_TEST_EQUAL UINT64_C(0x0000000000000030) //!< Enable depth test, equal.
#define BGFX_STATE_DEPTH_TEST_GEQUAL UINT64_C(0x0000000000000040) //!< Enable depth test, greater equal.
#define BGFX_STATE_DEPTH_TEST_GREATER UINT64_C(0x0000000000000050) //!< Enable depth test, greater.
#define BGFX_STATE_DEPTH_TEST_NOTEQUAL UINT64_C(0x0000000000000060) //!< Enable depth test, not equal.
#define BGFX_STATE_DEPTH_TEST_NEVER UINT64_C(0x0000000000000070) //!< Enable depth test, never.
#define BGFX_STATE_DEPTH_TEST_ALWAYS UINT64_C(0x0000000000000080) //!< Enable depth test, always.
#define BGFX_STATE_DEPTH_TEST_SHIFT 4 //!< Depth test state bit shift.
#define BGFX_STATE_DEPTH_TEST_MASK UINT64_C(0x00000000000000f0) //!< Depth test state bit mask.
#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010) //!< Enable depth test, less.
#define BGFX_STATE_DEPTH_TEST_LEQUAL UINT64_C(0x0000000000000020) //!< Enable depth test, less equal.
#define BGFX_STATE_DEPTH_TEST_EQUAL UINT64_C(0x0000000000000030) //!< Enable depth test, equal.
#define BGFX_STATE_DEPTH_TEST_GEQUAL UINT64_C(0x0000000000000040) //!< Enable depth test, greater equal.
#define BGFX_STATE_DEPTH_TEST_GREATER UINT64_C(0x0000000000000050) //!< Enable depth test, greater.
#define BGFX_STATE_DEPTH_TEST_NOTEQUAL UINT64_C(0x0000000000000060) //!< Enable depth test, not equal.
#define BGFX_STATE_DEPTH_TEST_NEVER UINT64_C(0x0000000000000070) //!< Enable depth test, never.
#define BGFX_STATE_DEPTH_TEST_ALWAYS UINT64_C(0x0000000000000080) //!< Enable depth test, always.
#define BGFX_STATE_DEPTH_TEST_SHIFT 4 //!< Depth test state bit shift.
#define BGFX_STATE_DEPTH_TEST_MASK UINT64_C(0x00000000000000f0) //!< Depth test state bit mask.
#define BGFX_STATE_BLEND_ZERO UINT64_C(0x0000000000001000) //!<
#define BGFX_STATE_BLEND_ONE UINT64_C(0x0000000000002000) //!<
#define BGFX_STATE_BLEND_SRC_COLOR UINT64_C(0x0000000000003000) //!<
#define BGFX_STATE_BLEND_INV_SRC_COLOR UINT64_C(0x0000000000004000) //!<
#define BGFX_STATE_BLEND_SRC_ALPHA UINT64_C(0x0000000000005000) //!<
#define BGFX_STATE_BLEND_INV_SRC_ALPHA UINT64_C(0x0000000000006000) //!<
#define BGFX_STATE_BLEND_DST_ALPHA UINT64_C(0x0000000000007000) //!<
#define BGFX_STATE_BLEND_INV_DST_ALPHA UINT64_C(0x0000000000008000) //!<
#define BGFX_STATE_BLEND_DST_COLOR UINT64_C(0x0000000000009000) //!<
#define BGFX_STATE_BLEND_INV_DST_COLOR UINT64_C(0x000000000000a000) //!<
#define BGFX_STATE_BLEND_SRC_ALPHA_SAT UINT64_C(0x000000000000b000) //!<
#define BGFX_STATE_BLEND_FACTOR UINT64_C(0x000000000000c000) //!<
#define BGFX_STATE_BLEND_INV_FACTOR UINT64_C(0x000000000000d000) //!<
#define BGFX_STATE_BLEND_SHIFT 12 //!< Blend state bit shift.
#define BGFX_STATE_BLEND_MASK UINT64_C(0x000000000ffff000) //!< Blend state bit mask.
#define BGFX_STATE_BLEND_ZERO UINT64_C(0x0000000000001000) //!<
#define BGFX_STATE_BLEND_ONE UINT64_C(0x0000000000002000) //!<
#define BGFX_STATE_BLEND_SRC_COLOR UINT64_C(0x0000000000003000) //!<
#define BGFX_STATE_BLEND_INV_SRC_COLOR UINT64_C(0x0000000000004000) //!<
#define BGFX_STATE_BLEND_SRC_ALPHA UINT64_C(0x0000000000005000) //!<
#define BGFX_STATE_BLEND_INV_SRC_ALPHA UINT64_C(0x0000000000006000) //!<
#define BGFX_STATE_BLEND_DST_ALPHA UINT64_C(0x0000000000007000) //!<
#define BGFX_STATE_BLEND_INV_DST_ALPHA UINT64_C(0x0000000000008000) //!<
#define BGFX_STATE_BLEND_DST_COLOR UINT64_C(0x0000000000009000) //!<
#define BGFX_STATE_BLEND_INV_DST_COLOR UINT64_C(0x000000000000a000) //!<
#define BGFX_STATE_BLEND_SRC_ALPHA_SAT UINT64_C(0x000000000000b000) //!<
#define BGFX_STATE_BLEND_FACTOR UINT64_C(0x000000000000c000) //!<
#define BGFX_STATE_BLEND_INV_FACTOR UINT64_C(0x000000000000d000) //!<
#define BGFX_STATE_BLEND_SHIFT 12 //!< Blend state bit shift.
#define BGFX_STATE_BLEND_MASK UINT64_C(0x000000000ffff000) //!< Blend state bit mask.
#define BGFX_STATE_BLEND_EQUATION_ADD UINT64_C(0x0000000000000000) //!<
#define BGFX_STATE_BLEND_EQUATION_SUB UINT64_C(0x0000000010000000) //!<
#define BGFX_STATE_BLEND_EQUATION_REVSUB UINT64_C(0x0000000020000000) //!<
#define BGFX_STATE_BLEND_EQUATION_MIN UINT64_C(0x0000000030000000) //!<
#define BGFX_STATE_BLEND_EQUATION_MAX UINT64_C(0x0000000040000000) //!<
#define BGFX_STATE_BLEND_EQUATION_SHIFT 28 //!< Blend equation bit shift.
#define BGFX_STATE_BLEND_EQUATION_MASK UINT64_C(0x00000003f0000000) //!< Blend equation bit mask.
#define BGFX_STATE_BLEND_EQUATION_ADD UINT64_C(0x0000000000000000) //!<
#define BGFX_STATE_BLEND_EQUATION_SUB UINT64_C(0x0000000010000000) //!<
#define BGFX_STATE_BLEND_EQUATION_REVSUB UINT64_C(0x0000000020000000) //!<
#define BGFX_STATE_BLEND_EQUATION_MIN UINT64_C(0x0000000030000000) //!<
#define BGFX_STATE_BLEND_EQUATION_MAX UINT64_C(0x0000000040000000) //!<
#define BGFX_STATE_BLEND_EQUATION_SHIFT 28 //!< Blend equation bit shift.
#define BGFX_STATE_BLEND_EQUATION_MASK UINT64_C(0x00000003f0000000) //!< Blend equation bit mask.
#define BGFX_STATE_BLEND_INDEPENDENT UINT64_C(0x0000000400000000) //!< Enable blend independent.
#define BGFX_STATE_BLEND_INDEPENDENT UINT64_C(0x0000000400000000) //!< Enable blend independent.
#define BGFX_STATE_BLEND_ALPHA_TO_COVERAGE UINT64_C(0x0000000800000000) //!< Enable alpha to coverage.
#define BGFX_STATE_CULL_CW UINT64_C(0x0000001000000000) //!< Cull clockwise triangles.
#define BGFX_STATE_CULL_CCW UINT64_C(0x0000002000000000) //!< Cull counter-clockwise triangles.
#define BGFX_STATE_CULL_SHIFT 36 //!< Culling mode bit shift.
#define BGFX_STATE_CULL_MASK UINT64_C(0x0000003000000000) //!< Culling mode bit mask.
#define BGFX_STATE_CULL_CW UINT64_C(0x0000001000000000) //!< Cull clockwise triangles.
#define BGFX_STATE_CULL_CCW UINT64_C(0x0000002000000000) //!< Cull counter-clockwise triangles.
#define BGFX_STATE_CULL_SHIFT 36 //!< Culling mode bit shift.
#define BGFX_STATE_CULL_MASK UINT64_C(0x0000003000000000) //!< Culling mode bit mask.
/// See BGFX_STATE_ALPHA_REF(_ref) helper macro.
#define BGFX_STATE_ALPHA_REF_SHIFT 40 //!< Alpha reference bit shift.
#define BGFX_STATE_ALPHA_REF_MASK UINT64_C(0x0000ff0000000000) //!< Alpha reference bit mask.
#define BGFX_STATE_ALPHA_REF_SHIFT 40 //!< Alpha reference bit shift.
#define BGFX_STATE_ALPHA_REF_MASK UINT64_C(0x0000ff0000000000) //!< Alpha reference bit mask.
#define BGFX_STATE_PT_TRISTRIP UINT64_C(0x0001000000000000) //!< Tristrip.
#define BGFX_STATE_PT_LINES UINT64_C(0x0002000000000000) //!< Lines.
#define BGFX_STATE_PT_LINESTRIP UINT64_C(0x0003000000000000) //!< Line strip.
#define BGFX_STATE_PT_POINTS UINT64_C(0x0004000000000000) //!< Points.
#define BGFX_STATE_PT_SHIFT 48 //!< Primitive type bit shift.
#define BGFX_STATE_PT_MASK UINT64_C(0x0007000000000000) //!< Primitive type bit mask.
#define BGFX_STATE_PT_TRISTRIP UINT64_C(0x0001000000000000) //!< Tristrip.
#define BGFX_STATE_PT_LINES UINT64_C(0x0002000000000000) //!< Lines.
#define BGFX_STATE_PT_LINESTRIP UINT64_C(0x0003000000000000) //!< Line strip.
#define BGFX_STATE_PT_POINTS UINT64_C(0x0004000000000000) //!< Points.
#define BGFX_STATE_PT_SHIFT 48 //!< Primitive type bit shift.
#define BGFX_STATE_PT_MASK UINT64_C(0x0007000000000000) //!< Primitive type bit mask.
#define BGFX_STATE_POINT_SIZE_SHIFT 52 //!< Point size bit shift.
#define BGFX_STATE_POINT_SIZE_MASK UINT64_C(0x0ff0000000000000) //!< Point size bit mask.
#define BGFX_STATE_POINT_SIZE_SHIFT 52 //!< Point size bit shift.
#define BGFX_STATE_POINT_SIZE_MASK UINT64_C(0x00f0000000000000) //!< Point size bit mask.
/// Enable MSAA write when writing into MSAA frame buffer. This flag is ignored when not writing into
/// MSAA frame buffer.
#define BGFX_STATE_MSAA UINT64_C(0x1000000000000000) //!< Enable MSAA rasterization.
#define BGFX_STATE_MSAA UINT64_C(0x0100000000000000) //!< Enable MSAA rasterization.
#define BGFX_STATE_LINEAA UINT64_C(0x0200000000000000) //!< Enable line AA rasterization.
/// Do not use!
#define BGFX_STATE_RESERVED_SHIFT 61 //!< Internal bits shift.
#define BGFX_STATE_RESERVED_MASK UINT64_C(0xe000000000000000) //!< Internal bits mask.
#define BGFX_STATE_RESERVED_SHIFT 61 //!< Internal bits shift.
#define BGFX_STATE_RESERVED_MASK UINT64_C(0xe000000000000000) //!< Internal bits mask.
/// See BGFX_STATE_POINT_SIZE(_size) helper macro.
#define BGFX_STATE_NONE UINT64_C(0x0000000000000000) //!< No state.
#define BGFX_STATE_MASK UINT64_C(0xffffffffffffffff) //!< State mask.
#define BGFX_STATE_NONE UINT64_C(0x0000000000000000) //!< No state.
#define BGFX_STATE_MASK UINT64_C(0xffffffffffffffff) //!< State mask.
/// Default state is write to RGB, alpha, and depth with depth test less enabled, with clockwise
/// culling and MSAA (when writing into MSAA frame buffer, otherwise this flag is ignored).
@ -380,6 +382,7 @@
#define BGFX_CAPS_TEXTURE_BLIT UINT64_C(0x0000000000010000) //!< Texture blit 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_ALPHA_TO_COVERAGE UINT64_C(0x0000000000080000) //!< Alpha to coverage is supported.
///
#define BGFX_CAPS_FORMAT_TEXTURE_NONE UINT16_C(0x0000) //!< Texture format is not supported.

View File

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

View File

@ -2269,9 +2269,9 @@ namespace bgfx
VertexDeclHandle declHandle = m_declRef.release(_handle);
if (isValid(declHandle) )
{
m_vertexDeclHandle.free(declHandle.idx);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
cmdbuf.write(declHandle);
m_submit->free(declHandle);
}
m_vertexBufferHandle.free(_handle.idx);
@ -2562,9 +2562,9 @@ namespace bgfx
VertexDeclHandle declHandle = m_declRef.release(dvb.m_handle);
if (isValid(declHandle) )
{
m_vertexDeclHandle.free(declHandle.idx);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
cmdbuf.write(declHandle);
m_submit->free(declHandle);
}
if (0 != (dvb.m_flags & BGFX_BUFFER_COMPUTE_WRITE) )

View File

@ -1218,6 +1218,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
| BGFX_CAPS_TEXTURE_BLIT
| BGFX_CAPS_TEXTURE_READ_BACK
| ( (m_featureLevel >= D3D_FEATURE_LEVEL_9_2) ? BGFX_CAPS_OCCLUSION_QUERY : 0)
| BGFX_CAPS_ALPHA_TO_COVERAGE
);
m_timerQuerySupport = m_featureLevel >= D3D_FEATURE_LEVEL_10_0;
@ -2605,7 +2606,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (NULL == bs)
{
D3D11_BLEND_DESC desc;
memset(&desc, 0, sizeof(desc) );
desc.AlphaToCoverageEnable = !!(BGFX_STATE_BLEND_ALPHA_TO_COVERAGE & _state);
desc.IndependentBlendEnable = !!(BGFX_STATE_BLEND_INDEPENDENT & _state);
D3D11_RENDER_TARGET_BLEND_DESC* drt = &desc.RenderTarget[0];
@ -2756,7 +2757,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
void setRasterizerState(uint64_t _state, bool _wireframe = false, bool _scissor = false)
{
_state &= BGFX_STATE_CULL_MASK|BGFX_STATE_MSAA;
_state &= BGFX_STATE_CULL_MASK|BGFX_STATE_MSAA|BGFX_STATE_LINEAA;
_state |= _wireframe ? BGFX_STATE_PT_LINES : BGFX_STATE_NONE;
_state |= _scissor ? BGFX_STATE_RESERVED_MASK : 0;
@ -2775,7 +2776,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
desc.DepthClipEnable = !m_depthClamp;
desc.ScissorEnable = _scissor;
desc.MultisampleEnable = !!(_state&BGFX_STATE_MSAA);
desc.AntialiasedLineEnable = false;
desc.AntialiasedLineEnable = !!(_state&BGFX_STATE_LINEAA);
DX_CHECK(m_device->CreateRasterizerState(&desc, &rs) );
@ -5302,9 +5303,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
| BGFX_STATE_PT_MASK
| BGFX_STATE_POINT_SIZE_MASK
| BGFX_STATE_MSAA
| BGFX_STATE_LINEAA
) & changedFlags)
{
if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_MSAA) & changedFlags)
if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_MSAA|BGFX_STATE_LINEAA) & changedFlags)
{
setRasterizerState(newFlags, wireframe, scissorEnabled);
}

View File

@ -47,6 +47,7 @@ BX_PRAGMA_DIAGNOSTIC_POP()
| BGFX_STATE_BLEND_MASK \
| BGFX_STATE_BLEND_EQUATION_MASK \
| BGFX_STATE_BLEND_INDEPENDENT \
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE \
| BGFX_STATE_ALPHA_WRITE \
| BGFX_STATE_RGB_WRITE \
)

View File

@ -908,6 +908,7 @@ namespace bgfx { namespace d3d12
| BGFX_CAPS_TEXTURE_BLIT
| BGFX_CAPS_TEXTURE_READ_BACK
| BGFX_CAPS_OCCLUSION_QUERY
| BGFX_CAPS_ALPHA_TO_COVERAGE
);
g_caps.maxTextureSize = 16384;
g_caps.maxFBAttachments = uint8_t(bx::uint32_min(16, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
@ -1973,7 +1974,7 @@ data.NumQualityLevels = 0;
void setBlendState(D3D12_BLEND_DESC& _desc, uint64_t _state, uint32_t _rgba = 0)
{
_desc.AlphaToCoverageEnable = false;
_desc.AlphaToCoverageEnable = !!(BGFX_STATE_BLEND_ALPHA_TO_COVERAGE & _state);
_desc.IndependentBlendEnable = !!(BGFX_STATE_BLEND_INDEPENDENT & _state);
D3D12_RENDER_TARGET_BLEND_DESC* drt = &_desc.RenderTarget[0];
@ -2210,6 +2211,7 @@ data.NumQualityLevels = 0;
| BGFX_STATE_BLEND_MASK
| BGFX_STATE_BLEND_EQUATION_MASK
| BGFX_STATE_BLEND_INDEPENDENT
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
| BGFX_STATE_CULL_MASK
| BGFX_STATE_MSAA
| BGFX_STATE_PT_MASK

View File

@ -261,6 +261,7 @@ namespace bgfx { namespace d3d9
{ D3DFMT_NULL, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, false },
{ D3DFMT_RESZ, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, false },
{ D3DFMT_RAWZ, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, false },
{ D3DFMT_ATOC, 0, D3DRTYPE_SURFACE, false },
};
static const GUID IID_IDirect3D9 = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } };
@ -288,9 +289,10 @@ namespace bgfx { namespace d3d9
, m_initialized(false)
, m_amd(false)
, m_nvidia(false)
, m_atocSupport(false)
, m_instancingSupport(false)
, m_timerQuerySupport(false)
, m_occlusionQuerySupport(false)
, m_timerQuerySupport(false)
, m_rtMsaa(false)
{
}
@ -598,6 +600,10 @@ namespace bgfx { namespace d3d9
|| (m_caps.VertexShaderVersion >= D3DVS_VERSION(3, 0) )
;
m_atocSupport = false
|| s_extendedFormats[ExtendedFormat::Atoc].m_supported
;
if (m_amd
&& s_extendedFormats[ExtendedFormat::Inst].m_supported)
{ // AMD only
@ -613,7 +619,8 @@ namespace bgfx { namespace d3d9
s_textureFormat[TextureFormat::BC4].m_fmt = s_extendedFormats[ExtendedFormat::Ati1].m_supported ? D3DFMT_ATI1 : D3DFMT_UNKNOWN;
s_textureFormat[TextureFormat::BC5].m_fmt = s_extendedFormats[ExtendedFormat::Ati2].m_supported ? D3DFMT_ATI2 : D3DFMT_UNKNOWN;
g_caps.supported |= m_instancingSupport ? BGFX_CAPS_INSTANCING : 0;
g_caps.supported |= m_instancingSupport ? BGFX_CAPS_INSTANCING : 0;
g_caps.supported |= m_atocSupport ? BGFX_CAPS_ALPHA_TO_COVERAGE : 0;
}
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
@ -2066,9 +2073,10 @@ namespace bgfx { namespace d3d9
bool m_initialized;
bool m_amd;
bool m_nvidia;
bool m_atocSupport;
bool m_instancingSupport;
bool m_timerQuerySupport;
bool m_occlusionQuerySupport;
bool m_timerQuerySupport;
D3DFORMAT m_fmtDepth;
@ -3844,6 +3852,11 @@ namespace bgfx { namespace d3d9
DX_CHECK(device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, (newFlags&BGFX_STATE_MSAA) == BGFX_STATE_MSAA) );
}
if (BGFX_STATE_LINEAA & changedFlags)
{
DX_CHECK(m_device->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, !!(newFlags&BGFX_STATE_LINEAA) ) );
}
if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags)
{
uint32_t writeEnable = (newFlags&BGFX_STATE_ALPHA_WRITE) ? D3DCOLORWRITEENABLE_ALPHA : 0;
@ -3851,12 +3864,26 @@ namespace bgfx { namespace d3d9
DX_CHECK(device->SetRenderState(D3DRS_COLORWRITEENABLE, writeEnable) );
}
if ( (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK) & changedFlags
if ( ( (0
| BGFX_STATE_BLEND_MASK
| BGFX_STATE_BLEND_EQUATION_MASK
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
) & changedFlags)
|| blendFactor != draw.m_rgba)
{
bool enabled = !!(BGFX_STATE_BLEND_MASK & newFlags);
DX_CHECK(device->SetRenderState(D3DRS_ALPHABLENDENABLE, enabled) );
if (m_atocSupport
&& BGFX_STATE_BLEND_ALPHA_TO_COVERAGE & changedFlags)
{
DX_CHECK(m_device->SetRenderState(D3DRS_ADAPTIVETESS_Y
, !!(newFlags&BGFX_STATE_BLEND_ALPHA_TO_COVERAGE)
? D3DFMT_ATOC
: 0
) );
}
if (enabled)
{
const uint32_t blend = uint32_t( (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT);

View File

@ -107,6 +107,7 @@ namespace bgfx { namespace d3d9
Null,
Resz,
Rawz,
Atoc,
Count,
};

View File

@ -1744,6 +1744,11 @@ namespace bgfx { namespace gl
: 0
;
g_caps.supported |= s_extension[Extension::ARB_multisample].m_supported
? BGFX_CAPS_ALPHA_TO_COVERAGE
: 0
;
const bool drawIndirectSupported = false
|| s_extension[Extension::AMD_multi_draw_indirect].m_supported
|| s_extension[Extension::ARB_draw_indirect ].m_supported
@ -5931,6 +5936,18 @@ namespace bgfx { namespace gl
GL_CHECK(glDisable(GL_MULTISAMPLE) );
}
}
if (BGFX_STATE_LINEAA & changedFlags)
{
if (BGFX_STATE_LINEAA & newFlags)
{
GL_CHECK(glEnable(GL_LINE_SMOOTH) );
}
else
{
GL_CHECK(glDisable(GL_LINE_SMOOTH) );
}
}
#endif // BGFX_CONFIG_RENDERER_OPENGL
if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags)
@ -5940,10 +5957,27 @@ namespace bgfx { namespace gl
GL_CHECK(glColorMask(rgb, rgb, rgb, alpha) );
}
if ( (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_BLEND_INDEPENDENT) & changedFlags
if ( ( (0
| BGFX_STATE_BLEND_MASK
| BGFX_STATE_BLEND_EQUATION_MASK
| BGFX_STATE_BLEND_INDEPENDENT
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
) & changedFlags)
|| blendFactor != draw.m_rgba)
{
if ( (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_BLEND_INDEPENDENT) & newFlags
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
| BGFX_STATE_BLEND_MASK
| BGFX_STATE_BLEND_EQUATION_MASK
| BGFX_STATE_BLEND_INDEPENDENT) & newFlags)
|| blendFactor != draw.m_rgba)
{
const bool enabled = !!(BGFX_STATE_BLEND_MASK & newFlags);

View File

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