From 36be8a72cc87e72bc640947e18f81c5d8635ce25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 14 May 2022 21:26:20 -0700 Subject: [PATCH] Fixed blit key encoding. --- src/bgfx_p.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index c5c06fe99..bc710a040 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1232,27 +1232,33 @@ namespace bgfx }; #undef SORT_KEY_RENDER_DRAW + constexpr uint8_t kBlitKeyViewShift = 32-kSortKeyViewNumBits; + constexpr uint32_t kBlitKeyViewMask = uint32_t(BGFX_CONFIG_MAX_VIEWS-1)<> 24); + m_item = uint16_t( (_key & kBlitKeyItemMask) >> kBlitKeyItemShift); + m_view = ViewId( (_key & kBlitKeyViewMask) >> kBlitKeyViewShift); } static uint32_t remapView(uint32_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS]) { - const ViewId oldView = ViewId(_key >> 24); - const uint32_t view = uint32_t(_viewRemap[oldView]) << 24; - const uint32_t key = (_key & ~UINT32_C(0xff000000) ) | view; + const ViewId oldView = ViewId( (_key & kBlitKeyViewMask) >> kBlitKeyViewShift); + const uint32_t view = uint32_t( (_viewRemap[oldView] << kBlitKeyViewShift) & kBlitKeyViewMask); + const uint32_t key = (_key & ~kBlitKeyViewMask) | view; return key; }