|
| 1 | +// Copyright (C) 2019 - DevSH Graphics Programming Sp. z O.O. |
| 2 | +// For conditions of distribution and use, see copyright notice in nabla.h |
| 3 | +// See the original file in irrlicht source for authors |
| 4 | + |
| 5 | +#ifndef __NBL_SCENE_I_ANIMATION_BLEND_MANAGER_H_INCLUDED__ |
| 6 | +#define __NBL_SCENE_I_ANIMATION_BLEND_MANAGER_H_INCLUDED__ |
| 7 | + |
| 8 | +#include "nbl/core/core.h" |
| 9 | +#include "nbl/video/video.h" |
| 10 | + |
| 11 | +#include "nbl/scene/ITransformTreeManager.h" |
| 12 | + |
| 13 | +namespace nbl |
| 14 | +{ |
| 15 | +namespace scene |
| 16 | +{ |
| 17 | + |
| 18 | +class IAnimationBlendManager : public virtual core::IReferenceCounted |
| 19 | +{ |
| 20 | + public: |
| 21 | + using blend_t = uint32_t; |
| 22 | + |
| 23 | + // creation (TODO: should we support adding and removing animation libraries at runtime?) |
| 24 | + static inline core::smart_refctd_ptr<ITransformTreeManager> create(video::IVideoDriver* _driver, core::smart_refctd_ptr<video::IGPUAnimationLibrary>&& _animationLibrary) |
| 25 | + { |
| 26 | + if (true) // TODO: some checks and validation before creating? |
| 27 | + return nullptr; |
| 28 | + |
| 29 | + auto* abm = new IAnimationBlendManager(_driver,std::move(_animationLibrary)); |
| 30 | + return core::smart_refctd_ptr<IAnimationBlendManager>(abm,core::dont_grab); |
| 31 | + } |
| 32 | + |
| 33 | + // TODO: we should probably group blends of different update frequencies separately |
| 34 | + void registerBlends(blend_t* blendsOut) |
| 35 | + { |
| 36 | + // TODO: register animation blends as <video::IGPUAnimationLibrary::animation_t,<updateFrequency,finishAndPause/finish/loop/<pingpongCurrFWD,pingpongCurrBWD>>,target node_t> (use a pool allocator) |
| 37 | + } |
| 38 | + |
| 39 | + // add to a contiguous list in GPU memory |
| 40 | + void startBlends(const blend_t* begin, const blend_t* end) |
| 41 | + { |
| 42 | + // easy enough, just add the uints to the back of a GPU buffer and increment the counter used in dispatch indirect buffer |
| 43 | + } |
| 44 | + // remove from a contiguous list in GPU memory |
| 45 | + void pauseBlends(const blend_t* begin, const blend_t* end) |
| 46 | + { |
| 47 | + } |
| 48 | + |
| 49 | + // |
| 50 | + void seekBlends(const blend_t* begin, const blend_t* end, const ITransformTreeManager::timestamp_t* timestamps) |
| 51 | + { |
| 52 | + } |
| 53 | + |
| 54 | + // need to pause the blends first |
| 55 | + void deregisterBlends(const blend_t* begin, const blend_t* end) |
| 56 | + { |
| 57 | + } |
| 58 | + |
| 59 | + void computeBlends(ITransformTreeManager::timestamp_t newTimestamp, |
| 60 | + const asset::SBufferBinding<video::IGPUBuffer>& relativeTformUpdateIndirectParameters, |
| 61 | + const asset::SBufferBinding<video::IGPUBuffer>& nodeIDBuffer, // first uint in the nodeIDBuffer is used to denote how many requests we have |
| 62 | + const asset::SBufferBinding<video::IGPUBuffer>& modificationRequestBuffer, |
| 63 | + const asset::SBufferBinding<video::IGPUBuffer>& modificationRequestTimestampBuffer) |
| 64 | + { |
| 65 | + m_driver->bindComputePipeline(m_computeBlendsPipeline.get()); |
| 66 | + // TODO: bind descriptor sets |
| 67 | + m_driver->dispatchIndirect(m_dispatchIndirectCommandBuffer.get(),0u); |
| 68 | + // TODO: pipeline barrier for SSBO and TBO and COMMAND_BIT too |
| 69 | + } |
| 70 | + protected: |
| 71 | + IAnimationBlendManager(video::IVideoDriver* _driver, core::smart_refctd_ptr<video::IGPUAnimationLibrary>&& _animationLibrary) : m_driver(_driver), m_animationLibrary(std::move(_animationLibrary)) |
| 72 | + { |
| 73 | + } |
| 74 | + ~IAnimationBlendManager() |
| 75 | + { |
| 76 | + // everything drops itself automatically |
| 77 | + } |
| 78 | + |
| 79 | + video::IVideoDriver* m_driver; |
| 80 | + core::smart_refctd_ptr<video::IGPUAnimationLibrary> m_animationLibrary; |
| 81 | + core::smart_refctd_ptr<video::IGPUComputePipeline> m_computeBlendsPipeline; |
| 82 | + core::smart_refctd_ptr<video::IGPUDescriptorSet> m_animationDS; // animation library (keyframes + animations) + registered blends + active blends |
| 83 | + core::smart_refctd_ptr<video::IGPUBuffer> m_dispatchIndirectCommandBuffer; |
| 84 | +}; |
| 85 | + |
| 86 | + |
| 87 | +} // end namespace scene |
| 88 | +} // end namespace nbl |
| 89 | + |
| 90 | +#endif |
| 91 | + |
0 commit comments