Fixed blit key encoding.
This commit is contained in:
parent
ae5706693f
commit
36be8a72cc
24
src/bgfx_p.h
24
src/bgfx_p.h
@ -1232,27 +1232,33 @@ namespace bgfx
|
|||||||
};
|
};
|
||||||
#undef SORT_KEY_RENDER_DRAW
|
#undef SORT_KEY_RENDER_DRAW
|
||||||
|
|
||||||
|
constexpr uint8_t kBlitKeyViewShift = 32-kSortKeyViewNumBits;
|
||||||
|
constexpr uint32_t kBlitKeyViewMask = uint32_t(BGFX_CONFIG_MAX_VIEWS-1)<<kBlitKeyViewShift;
|
||||||
|
constexpr uint8_t kBlitKeyItemShift = 0;
|
||||||
|
constexpr uint32_t kBlitKeyItemMask = UINT16_MAX;
|
||||||
|
|
||||||
struct BlitKey
|
struct BlitKey
|
||||||
{
|
{
|
||||||
uint32_t encode()
|
uint32_t encode()
|
||||||
{
|
{
|
||||||
return 0
|
const uint32_t view = (uint32_t(m_view) << kBlitKeyViewShift) & kBlitKeyViewMask;
|
||||||
| (uint32_t(m_view) << 24)
|
const uint32_t item = (uint32_t(m_item) << kBlitKeyItemShift) & kBlitKeyItemMask;
|
||||||
| uint32_t(m_item)
|
const uint64_t key = view|item;
|
||||||
;
|
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decode(uint32_t _key)
|
void decode(uint32_t _key)
|
||||||
{
|
{
|
||||||
m_item = uint16_t(_key & UINT16_MAX);
|
m_item = uint16_t( (_key & kBlitKeyItemMask) >> kBlitKeyItemShift);
|
||||||
m_view = ViewId(_key >> 24);
|
m_view = ViewId( (_key & kBlitKeyViewMask) >> kBlitKeyViewShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t remapView(uint32_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS])
|
static uint32_t remapView(uint32_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS])
|
||||||
{
|
{
|
||||||
const ViewId oldView = ViewId(_key >> 24);
|
const ViewId oldView = ViewId( (_key & kBlitKeyViewMask) >> kBlitKeyViewShift);
|
||||||
const uint32_t view = uint32_t(_viewRemap[oldView]) << 24;
|
const uint32_t view = uint32_t( (_viewRemap[oldView] << kBlitKeyViewShift) & kBlitKeyViewMask);
|
||||||
const uint32_t key = (_key & ~UINT32_C(0xff000000) ) | view;
|
const uint32_t key = (_key & ~kBlitKeyViewMask) | view;
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user