From e051ed4feba65896cd6486de5f46162a49694cc2 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sat, 27 Sep 2014 20:43:05 +0200 Subject: [PATCH] Removed bgfx::*Mask() API. --- examples/13-stencil/stencil.cpp | 39 +++++++++++++++-- examples/14-shadowvolumes/shadowvolumes.cpp | 47 ++++++++++++++++----- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index 39ee78f5..cdaaa31f 100644 --- a/examples/13-stencil/stencil.cpp +++ b/examples/13-stencil/stencil.cpp @@ -215,6 +215,39 @@ static bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName) return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */); } +void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) +{ + for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + view += ntz; + + bgfx::setViewClear( (uint8_t)view, _flags, _rgba, _depth, _stencil); + } +} + +void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj) +{ + for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + view += ntz; + + bgfx::setViewTransform( (uint8_t)view, _view, _proj); + } +} + +void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + view += ntz; + + bgfx::setViewRect( (uint8_t)view, _x, _y, _width, _height); + } +} + void mtxReflected(float*__restrict _result , const float* __restrict _p /* plane */ , const float* __restrict _n /* normal */ @@ -619,7 +652,7 @@ void clearView(uint8_t _id, uint8_t _flags, const ClearValues& _clearValues) void clearViewMask(uint32_t _viewMask, uint8_t _flags, const ClearValues& _clearValues) { - bgfx::setViewClearMask(_viewMask + setViewClearMask(_viewMask , _flags , _clearValues.m_clearRgba , _clearValues.m_clearDepth @@ -1429,8 +1462,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) ); // Setup view rect and transform for all used views. - bgfx::setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height); - bgfx::setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj); + setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height); + setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj); s_viewMask = 0; // Advance to next frame. Rendering thread will be kicked to diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index d60747bb..f703d057 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -188,6 +188,39 @@ static bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName) return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */); } +void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) +{ + for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + view += ntz; + + bgfx::setViewClear( (uint8_t)view, _flags, _rgba, _depth, _stencil); + } +} + +void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj) +{ + for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + view += ntz; + + bgfx::setViewTransform( (uint8_t)view, _view, _proj); + } +} + +void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + view += ntz; + + bgfx::setViewRect( (uint8_t)view, _x, _y, _width, _height); + } +} + void mtxBillboard(float* __restrict _result , const float* __restrict _view , const float* __restrict _pos @@ -619,14 +652,6 @@ void submit(uint8_t _id, int32_t _depth = 0) s_viewMask |= 1 << _id; } -void submitMask(uint32_t _viewMask, int32_t _depth = 0) -{ - bgfx::submitMask(_viewMask, _depth); - - // Keep track of submited view ids. - s_viewMask |= _viewMask; -} - struct Aabb { float m_min[3]; @@ -2866,8 +2891,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) } // Setup view rect and transform for all used views. - bgfx::setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height); - bgfx::setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj); + setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height); + setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj); s_viewMask = 0; // Advance to next frame. Rendering thread will be kicked to @@ -2878,7 +2903,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) s_svAllocator.swap(); // Reset clear values. - bgfx::setViewClearMask(UINT32_MAX + setViewClearMask(UINT32_MAX , BGFX_CLEAR_NONE , clearValues.m_clearRgba , clearValues.m_clearDepth