]> git.sesse.net Git - casparcg/blobdiff - core/mixer/gpu/ogl_device.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / mixer / gpu / ogl_device.h
index efb188a43e41e6c6d4652ea8d79548ababd09f82..6c44257609e2bb6f48294229a1055ea05d27fe19 100644 (file)
@@ -42,6 +42,22 @@ namespace caspar { namespace core {
 \r
 class shader;\r
 \r
+template<typename T>\r
+struct buffer_pool\r
+{\r
+       tbb::atomic<int> total_count;\r
+       tbb::atomic<int> usage_count;\r
+       tbb::atomic<int> flush_count;\r
+       tbb::concurrent_bounded_queue<std::shared_ptr<T>> items;\r
+\r
+       buffer_pool()\r
+       {\r
+               total_count = 0;\r
+               usage_count = 0;\r
+               flush_count = 0;\r
+       }\r
+};\r
+\r
 class ogl_device : boost::noncopyable\r
 {      \r
        std::unordered_map<GLenum, bool> caps_;\r
@@ -54,8 +70,8 @@ class ogl_device : boost::noncopyable
 \r
        std::unique_ptr<sf::Context> context_;\r
        \r
-       std::array<tbb::concurrent_unordered_map<size_t, safe_ptr<tbb::concurrent_bounded_queue<std::shared_ptr<device_buffer>>>>, 4> device_pools_;\r
-       std::array<tbb::concurrent_unordered_map<size_t, safe_ptr<tbb::concurrent_bounded_queue<std::shared_ptr<host_buffer>>>>, 2> host_pools_;\r
+       std::array<tbb::concurrent_unordered_map<size_t, safe_ptr<buffer_pool<device_buffer>>>, 4> device_pools_;\r
+       std::array<tbb::concurrent_unordered_map<size_t, safe_ptr<buffer_pool<host_buffer>>>, 2> host_pools_;\r
        \r
        unsigned int fbo_;\r
 \r
@@ -80,6 +96,8 @@ public:
        \r
        void use(shader& shader);\r
 \r
+       void flush();\r
+\r
        // thread-afe\r
        template<typename Func>\r
        auto begin_invoke(Func&& func, task_priority priority = normal_priority) -> boost::unique_future<decltype(func())> // noexcept\r