SortKey: Added static check for overlaps.

This commit is contained in:
Branimir Karadžić 2015-12-09 16:56:56 -08:00
parent d59cf406c0
commit a02086c119

View file

@ -714,14 +714,40 @@ namespace bgfx
#define SORT_KEY_DRAW_PROGRAM_SHIFT 0x20
#define SORT_KEY_DRAW_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_DRAW_PROGRAM_SHIFT)
#define SORT_KEY_COMPUTE_PROGRAM_SHIFT 0x22
#define SORT_KEY_COMPUTE_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_COMPUTE_PROGRAM_SHIFT)
#define SORT_KEY_DRAW_DEPTH_SHIFT 0
#define SORT_KEY_DRAW_DEPTH_MASK ( (uint64_t(UINT32_MAX) )<<SORT_KEY_DRAW_DEPTH_SHIFT)
#define SORT_KEY_COMPUTE_PROGRAM_SHIFT 0x22
#define SORT_KEY_COMPUTE_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_COMPUTE_PROGRAM_SHIFT)
BX_STATIC_ASSERT(BGFX_CONFIG_MAX_VIEWS <= 256);
BX_STATIC_ASSERT( (BGFX_CONFIG_MAX_PROGRAMS & (BGFX_CONFIG_MAX_PROGRAMS-1) ) == 0); // must be power of 2
BX_STATIC_ASSERT( (BGFX_CONFIG_MAX_PROGRAMS & (BGFX_CONFIG_MAX_PROGRAMS-1) ) == 0); // Must be power of 2.
BX_STATIC_ASSERT( (0 // Render key mask shouldn't overlap.
| SORT_KEY_DRAW_BIT
| SORT_KEY_SEQ_MASK
| SORT_KEY_VIEW_MASK
| SORT_KEY_DRAW_TRANS_MASK
| SORT_KEY_DRAW_PROGRAM_MASK
| SORT_KEY_DRAW_DEPTH_MASK
) == (0
^ SORT_KEY_DRAW_BIT
^ SORT_KEY_SEQ_MASK
^ SORT_KEY_VIEW_MASK
^ SORT_KEY_DRAW_TRANS_MASK
^ SORT_KEY_DRAW_PROGRAM_MASK
^ SORT_KEY_DRAW_DEPTH_MASK
) );
BX_STATIC_ASSERT( (0 // Compute key mask shouldn't overlap.
| SORT_KEY_DRAW_BIT
| SORT_KEY_SEQ_MASK
| SORT_KEY_VIEW_MASK
| SORT_KEY_COMPUTE_PROGRAM_MASK
) == (0
^ SORT_KEY_DRAW_BIT
^ SORT_KEY_SEQ_MASK
^ SORT_KEY_VIEW_MASK
^ SORT_KEY_COMPUTE_PROGRAM_MASK
) );
struct SortKey
{