]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 21 Jan 2012 03:55:53 +0000 (03:55 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 21 Jan 2012 03:55:53 +0000 (03:55 +0000)
core/mixer/gpu/ogl_device.cpp
core/mixer/gpu/ogl_device.h
core/mixer/image/image_mixer.cpp

index 584038fbc58eac6e0b193b63340f589b58e461b4..2699f50a0e35f44b473e2fc06b0b82242220f08e 100644 (file)
@@ -113,7 +113,7 @@ safe_ptr<device_buffer> ogl_device::allocate_device_buffer(int width, int height
        return make_safe_ptr(buffer);\r
 }\r
                                \r
-safe_ptr<device_buffer> ogl_device::create_device_buffer(int width, int height, int stride, bool zero)\r
+safe_ptr<device_buffer> ogl_device::create_device_buffer(int width, int height, int stride)\r
 {\r
        CASPAR_VERIFY(stride > 0 && stride < 5);\r
        CASPAR_VERIFY(width > 0 && height > 0);\r
@@ -121,23 +121,17 @@ safe_ptr<device_buffer> ogl_device::create_device_buffer(int width, int height,
        std::shared_ptr<device_buffer> buffer;\r
                \r
        if(!pool->items.try_pop(buffer))                        \r
-               buffer =  executor_.invoke([&]{return allocate_device_buffer(width, height, stride);});\r
-\r
-       if(zero)\r
+               buffer = executor_.invoke([&]{return allocate_device_buffer(width, height, stride);});\r
+               \r
+       return safe_ptr<device_buffer>(buffer.get(), [=](device_buffer*) mutable\r
        {               \r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
-                       scoped_state scope(*this);\r
-                       attach(*buffer);\r
+                       auto prev = attach(buffer->id());\r
                        glClear(GL_COLOR_BUFFER_BIT);\r
-               }, high_priority);      \r
-       }               \r
-       \r
-       //++pool->usage_count;\r
-\r
-       return safe_ptr<device_buffer>(buffer.get(), [=](device_buffer*) mutable\r
-       {               \r
-               pool->items.push(buffer);       \r
+                       attach(prev);\r
+                       pool->items.push(buffer);\r
+               }, high_priority);              \r
        });\r
 }\r
 \r
@@ -391,8 +385,9 @@ void ogl_device::stipple_pattern(const std::array<GLubyte, 32*32>& pattern)
        }\r
 }\r
 \r
-void ogl_device::attach(GLint id)\r
+GLint ogl_device::attach(GLint id)\r
 {      \r
+       auto prev = state_.attached_texture;\r
        if(id != state_.attached_texture)\r
        {\r
                GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 0, GL_TEXTURE_2D, id, 0));\r
@@ -400,6 +395,7 @@ void ogl_device::attach(GLint id)
 \r
                state_.attached_texture = id;\r
        }\r
+       return prev;\r
 }\r
 \r
 void ogl_device::attach(const device_buffer& texture)\r
index 75de06991f29196150e16865f41ab10bdc74ca8b..0a6a7980fb4dc2b410f32faf315ebbddc0825f08 100644 (file)
@@ -99,11 +99,12 @@ class ogl_device : public std::enable_shared_from_this<ogl_device>
        ogl_device();\r
 \r
        void use(GLint id);\r
-       void attach(GLint id);\r
+       GLint attach(GLint id);\r
        void bind(GLint id, int index); \r
        void flush();\r
        \r
        friend class scoped_state;\r
+       \r
 public:                \r
        void push_state();\r
        state pop_state();\r
@@ -128,7 +129,6 @@ public:
 \r
        void bind(const device_buffer& texture, int index);\r
 \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
@@ -142,7 +142,7 @@ public:
                return executor_.invoke(std::forward<Func>(func), priority);\r
        }\r
                \r
-       safe_ptr<device_buffer> create_device_buffer(int width, int height, int stride, bool zero = false);\r
+       safe_ptr<device_buffer> create_device_buffer(int width, int height, int stride);\r
        safe_ptr<host_buffer> create_host_buffer(int size, host_buffer::usage_t usage);\r
 \r
        boost::unique_future<safe_ptr<host_buffer>> transfer(const safe_ptr<device_buffer>& source);\r
index 7164330fee9e2737147a7b4593464ad44b669c8a..b514dafb08286bb9b93a1e69ac7597f0e6c843a3 100644 (file)
@@ -68,7 +68,7 @@ public:
        \r
        boost::unique_future<safe_ptr<host_buffer>> operator()(std::vector<layer>&& layers, const video_format_desc& format_desc)\r
        {               \r
-               auto draw_buffer = ogl_->create_device_buffer(format_desc.width, format_desc.height, 4, true);\r
+               auto draw_buffer = ogl_->create_device_buffer(format_desc.width, format_desc.height, 4);\r
                        \r
                if(format_desc.field_mode != field_mode::progressive)\r
                {\r
@@ -125,7 +125,7 @@ private:
                                \r
                if(layer.first != blend_mode::normal)\r
                {\r
-                       auto layer_draw_buffer = ogl_->create_device_buffer(format_desc.width, format_desc.height, 4, true);\r
+                       auto layer_draw_buffer = ogl_->create_device_buffer(format_desc.width, format_desc.height, 4);\r
 \r
                        BOOST_FOREACH(auto& item, layer.second)\r
                                draw_item(std::move(item), layer_draw_buffer, layer_key_buffer, local_key_buffer, local_mix_buffer, format_desc);       \r
@@ -161,7 +161,7 @@ private:
 \r
                if(item.transform.is_key)\r
                {\r
-                       local_key_buffer = local_key_buffer ? local_key_buffer : ogl_->create_device_buffer(format_desc.width, format_desc.height, 4, true);\r
+                       local_key_buffer = local_key_buffer ? local_key_buffer : ogl_->create_device_buffer(format_desc.width, format_desc.height, 4);\r
 \r
                        draw_params.background                  = local_key_buffer;\r
                        draw_params.local_key                   = nullptr;\r
@@ -171,7 +171,7 @@ private:
                }\r
                else if(item.transform.is_mix)\r
                {\r
-                       local_mix_buffer = local_mix_buffer ? local_mix_buffer : ogl_->create_device_buffer(format_desc.width, format_desc.height, 4, true);\r
+                       local_mix_buffer = local_mix_buffer ? local_mix_buffer : ogl_->create_device_buffer(format_desc.width, format_desc.height, 4);\r
 \r
                        draw_params.background                  = local_mix_buffer;\r
                        draw_params.local_key                   = std::move(local_key_buffer);\r