From 3533da7225dcecbbae19e426489c4fa3d77a742e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 27 Nov 2017 16:34:27 -0800 Subject: [PATCH] Fixed view id remapping. --- examples/09-hdr/hdr.cpp | 22 +++++++++++----------- src/bgfx.cpp | 6 +++--- src/bgfx_p.h | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index f01ec53df..500acf056 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -378,19 +378,19 @@ public: m_time += (float)(frameTime*m_speed/freq); - uint8_t shuffle[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + bgfx::ViewId shuffle[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; bx::shuffle(&m_rng, shuffle, BX_COUNTOF(shuffle) ); - uint8_t hdrSkybox = shuffle[0]; - uint8_t hdrMesh = shuffle[1]; - uint8_t hdrLuminance = shuffle[2]; - uint8_t hdrLumScale0 = shuffle[3]; - uint8_t hdrLumScale1 = shuffle[4]; - uint8_t hdrLumScale2 = shuffle[5]; - uint8_t hdrLumScale3 = shuffle[6]; - uint8_t hdrBrightness = shuffle[7]; - uint8_t hdrVBlur = shuffle[8]; - uint8_t hdrHBlurTonemap = shuffle[9]; + bgfx::ViewId hdrSkybox = shuffle[0]; + bgfx::ViewId hdrMesh = shuffle[1]; + bgfx::ViewId hdrLuminance = shuffle[2]; + bgfx::ViewId hdrLumScale0 = shuffle[3]; + bgfx::ViewId hdrLumScale1 = shuffle[4]; + bgfx::ViewId hdrLumScale2 = shuffle[5]; + bgfx::ViewId hdrLumScale3 = shuffle[6]; + bgfx::ViewId hdrBrightness = shuffle[7]; + bgfx::ViewId hdrVBlur = shuffle[8]; + bgfx::ViewId hdrHBlurTonemap = shuffle[9]; // Set views. bgfx::setViewName(hdrSkybox, "Skybox"); diff --git a/src/bgfx.cpp b/src/bgfx.cpp index d449da8f1..64970cb7e 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1050,7 +1050,7 @@ namespace bgfx ViewId viewRemap[BGFX_CONFIG_MAX_VIEWS]; for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { - viewRemap[m_viewRemap[ii] ] = uint8_t(ii); + viewRemap[m_viewRemap[ii] ] = ViewId(ii); } for (uint32_t ii = 0, num = m_numRenderItems; ii < num; ++ii) @@ -1418,12 +1418,12 @@ namespace bgfx for (uint32_t ii = 0; ii < BX_COUNTOF(m_viewRemap); ++ii) { - m_viewRemap[ii] = uint8_t(ii); + m_viewRemap[ii] = ViewId(ii); } for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { - resetView(uint8_t(ii) ); + resetView(ViewId(ii) ); } for (uint32_t ii = 0; ii < BX_COUNTOF(m_clearColor); ++ii) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index c388f4646..ab4a0a206 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1021,15 +1021,15 @@ namespace bgfx return true; // compute } - static uint8_t decodeView(uint64_t _key) + static ViewId decodeView(uint64_t _key) { - return uint8_t( (_key & SORT_KEY_VIEW_MASK) >> SORT_KEY_VIEW_SHIFT); + return ViewId( (_key & SORT_KEY_VIEW_MASK) >> SORT_KEY_VIEW_SHIFT); } static uint64_t remapView(uint64_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS]) { - const uint8_t oldView = uint8_t( (_key & SORT_KEY_VIEW_MASK) >> SORT_KEY_VIEW_SHIFT); - const uint64_t view = uint64_t(_viewRemap[oldView]) << SORT_KEY_VIEW_SHIFT; + const ViewId oldView = decodeView(_key); + const uint64_t view = uint64_t(_viewRemap[oldView]) << SORT_KEY_VIEW_SHIFT; const uint64_t key = (_key & ~SORT_KEY_VIEW_MASK) | view; return key; } @@ -1064,7 +1064,7 @@ namespace bgfx void decode(uint32_t _key) { m_item = uint16_t(_key & UINT16_MAX); - m_view = uint8_t(_key >> 24); + m_view = ViewId(_key >> 24); } static uint32_t remapView(uint32_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS]) @@ -4321,7 +4321,7 @@ namespace bgfx } else { - bx::memCopy(&m_viewRemap[_id], _order, num); + bx::memCopy(&m_viewRemap[_id], _order, num*sizeof(ViewId) ); } }