]> git.sesse.net Git - casparcg/blobdiff - core/mixer/gpu/ogl_device.cpp
2.0. Fixed mix transition.
[casparcg] / core / mixer / gpu / ogl_device.cpp
index 34b5366f66697f25cf91bb70531f3107668385d3..ba7db7ea09cddd89d066145584038999c299057e 100644 (file)
@@ -44,6 +44,7 @@ ogl_device::ogl_device()
        std::fill(binded_textures_.begin(), binded_textures_.end(), 0);\r
        std::fill(viewport_.begin(), viewport_.end(), 0);\r
        std::fill(scissor_.begin(), scissor_.end(), 0);\r
+       std::fill(blend_func_.begin(), blend_func_.end(), 0);\r
        \r
        invoke([=]\r
        {\r
@@ -83,7 +84,6 @@ safe_ptr<device_buffer> ogl_device::create_device_buffer(size_t width, size_t he
        std::shared_ptr<device_buffer> buffer;\r
        if(!pool->items.try_pop(buffer))                \r
        {\r
-               ++pool->total_count;\r
                executor_.invoke([&]\r
                {       \r
                        try\r
@@ -103,7 +103,6 @@ safe_ptr<device_buffer> ogl_device::create_device_buffer(size_t width, size_t he
                                catch(...)\r
                                {\r
                                        CASPAR_LOG(error) << L"ogl: create_device_buffer failed!";\r
-                                       --pool->total_count;\r
                                        throw;\r
                                }\r
                        }\r
@@ -126,7 +125,6 @@ safe_ptr<host_buffer> ogl_device::create_host_buffer(size_t size, host_buffer::u
        std::shared_ptr<host_buffer> buffer;\r
        if(!pool->items.try_pop(buffer))\r
        {\r
-               ++pool->total_count;\r
                executor_.invoke([&]\r
                {\r
                        try\r
@@ -154,7 +152,6 @@ safe_ptr<host_buffer> ogl_device::create_host_buffer(size_t size, host_buffer::u
                                catch(...)\r
                                {\r
                                        CASPAR_LOG(error) << L"ogl: create_host_buffer failed!";\r
-                                       --pool->total_count;\r
                                        throw;          \r
                                }\r
                        }\r
@@ -180,14 +177,13 @@ safe_ptr<host_buffer> ogl_device::create_host_buffer(size_t size, host_buffer::u
 template<typename T>\r
 void flush_pool(buffer_pool<T>& pool)\r
 {      \r
-       if(pool.flush_count.fetch_and_increment() < 3)\r
+       if(pool.flush_count.fetch_and_increment() < 16)\r
                return;\r
 \r
        if(pool.usage_count.fetch_and_store(0) < pool.items.size())\r
        {\r
                std::shared_ptr<T> buffer;\r
-               if(pool.items.try_pop(buffer))\r
-                       --pool.total_count;\r
+               pool.items.try_pop(buffer);\r
        }\r
 \r
        pool.flush_count = 0;\r
@@ -233,22 +229,12 @@ boost::unique_future<void> ogl_device::gc()
                        BOOST_FOREACH(auto& pools, device_pools_)\r
                        {\r
                                BOOST_FOREACH(auto& pool, pools)\r
-                               {\r
-                                       auto size = pool.second->items.size();\r
-                                       std::shared_ptr<device_buffer> buffer;\r
-                                       for(int n = 0; n < size && pool.second->items.try_pop(buffer); ++n)\r
-                                               --pool.second->total_count;\r
-                               }\r
+                                       pool.second->items.clear();\r
                        }\r
                        BOOST_FOREACH(auto& pools, host_pools_)\r
                        {\r
                                BOOST_FOREACH(auto& pool, pools)\r
-                               {\r
-                                       auto size = pool.second->items.size();\r
-                                       std::shared_ptr<host_buffer> buffer;\r
-                                       for(int n = 0; n < size && pool.second->items.try_pop(buffer); ++n)\r
-                                               --pool.second->total_count;\r
-                               }\r
+                                       pool.second->items.clear();\r
                        }\r
                }\r
                catch(...)\r
@@ -350,5 +336,21 @@ void ogl_device::use(shader& shader)
        }\r
 }\r
 \r
+void ogl_device::blend_func(int c1, int c2, int a1, int a2)\r
+{\r
+       std::array<int, 4> func = {c1, c2, a1, a2};\r
+\r
+       if(blend_func_ != func)\r
+       {\r
+               blend_func_ = func;\r
+               GL(glBlendFuncSeparate(c1, c2, a1, a2));\r
+       }\r
+}\r
+\r
+void ogl_device::blend_func(int c1, int c2)\r
+{\r
+       blend_func(c1, c2, c1, c2);\r
+}\r
+\r
 }}\r
 \r