Skip to content

Commit

Permalink
Added more info about transparency sort table.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Dec 26, 2021
1 parent 946852c commit 99a7af7
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/bgfx_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -2397,12 +2397,30 @@ namespace bgfx

void setState(uint64_t _state, uint32_t _rgba)
{
uint8_t blend = ( (_state&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT)&0xff;
uint8_t alphaRef = ( (_state&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT)&0xff;
// transparency sort order table
const uint8_t blend = ( (_state&BGFX_STATE_BLEND_MASK )>>BGFX_STATE_BLEND_SHIFT )&0xff;
const uint8_t alphaRef = ( (_state&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT)&0xff;

// Transparency sort order table:
//
// +----------------------------------------- BGFX_STATE_BLEND_ZERO
// | +-------------------------------------- BGFX_STATE_BLEND_ONE
// | | +----------------------------------- BGFX_STATE_BLEND_SRC_COLOR
// | | | +-------------------------------- BGFX_STATE_BLEND_INV_SRC_COLOR
// | | | | +----------------------------- BGFX_STATE_BLEND_SRC_ALPHA
// | | | | | +-------------------------- BGFX_STATE_BLEND_INV_SRC_ALPHA
// | | | | | | +----------------------- BGFX_STATE_BLEND_DST_ALPHA
// | | | | | | | +-------------------- BGFX_STATE_BLEND_INV_DST_ALPHA
// | | | | | | | | +----------------- BGFX_STATE_BLEND_DST_COLOR
// | | | | | | | | | +-------------- BGFX_STATE_BLEND_INV_DST_COLOR
// | | | | | | | | | | +----------- BGFX_STATE_BLEND_SRC_ALPHA_SAT
// | | | | | | | | | | | +-------- BGFX_STATE_BLEND_FACTOR
// | | | | | | | | | | | | +----- BGFX_STATE_BLEND_INV_FACTOR
// | | | | | | | | | | | | |
// x | | | | | | | | | | | | | x x x x x
m_key.m_blend = "\x0\x2\x2\x3\x3\x2\x3\x2\x3\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2"[( (blend)&0xf) + (!!blend)] + !!alphaRef;

m_draw.m_stateFlags = _state;
m_draw.m_rgba = _rgba;
m_draw.m_rgba = _rgba;
}

void setCondition(OcclusionQueryHandle _handle, bool _visible)
Expand Down

0 comments on commit 99a7af7

Please sign in to comment.