]> git.sesse.net Git - casparcg/blobdiff - accelerator/ogl/util/device.cpp
2.1.0: array: Added "cacheable" property.
[casparcg] / accelerator / ogl / util / device.cpp
index 3b20deef8c8401055f492f243f0d66da36f18e13..706e6119a8c18721a1668606f9fc70d1c4adfc7f 100644 (file)
 #include <common/assert.h>\r
 #include <common/except.h>\r
 #include <common/concurrency/async.h>\r
+#include <common/memory/array.h>\r
 #include <common/gl/gl_check.h>\r
 #include <common/os/windows/windows.h>\r
 \r
+\r
 #include <boost/foreach.hpp>\r
 \r
 #include <gl/glew.h>\r
@@ -209,12 +211,12 @@ struct device::impl : public std::enable_shared_from_this<impl>
        core::mutable_array create_array(int size)\r
        {               \r
                auto buf = create_buffer(size, buffer::usage::write_only);\r
-               return core::mutable_array(buf->data(), buf->size(), buf);\r
+               return core::mutable_array(buf->data(), buf->size(), false, buf);\r
        }\r
 \r
-       boost::unique_future<spl::shared_ptr<texture>> copy_async(const core::mutable_array& source, int width, int height, int stride)\r
+       boost::unique_future<spl::shared_ptr<texture>> copy_async(const core::const_array& source, int width, int height, int stride)\r
        {\r
-               auto buf = boost::any_cast<spl::shared_ptr<buffer>>(source.storage());\r
+               auto buf = source.storage<spl::shared_ptr<buffer>>();\r
                                \r
                return render_executor_.begin_invoke([=]() -> spl::shared_ptr<texture>\r
                {\r
@@ -234,18 +236,18 @@ struct device::impl : public std::enable_shared_from_this<impl>
 \r
        boost::unique_future<core::const_array> copy_async(const spl::shared_ptr<texture>& source)\r
        {\r
-               return fold(render_executor_.begin_invoke([=]() -> boost::shared_future<core::const_array>\r
+               return flatten(render_executor_.begin_invoke([=]() -> boost::shared_future<core::const_array>\r
                {\r
                        auto buffer = create_buffer(source->size(), buffer::usage::read_only); \r
                        source->copy_to(*buffer);       \r
 \r
-                       return make_shared(async(launch_policy::deferred, [=]() mutable -> core::const_array\r
+                       return make_shared(async(launch::deferred, [=]() mutable -> core::const_array\r
                        {\r
                                const auto& buf = buffer.get();\r
                                if(!buf->data())\r
                                        alloc_executor_.invoke(std::bind(&buffer::map, std::ref(buf))); // Defer blocking "map" call until data is needed.\r
 \r
-                               return core::const_array(buf->data(), buf->size(), buffer);\r
+                               return core::const_array(buf->data(), buf->size(), true, buffer);\r
                        }));\r
                }, task_priority::high_priority));\r
        }\r
@@ -259,7 +261,7 @@ device::device()
 device::~device(){}    \r
 spl::shared_ptr<texture>                                                       device::create_texture(int width, int height, int stride){return impl_->create_texture(width, height, stride);}\r
 core::mutable_array                                                                    device::create_array(int size){return impl_->create_array(size);}\r
-boost::unique_future<spl::shared_ptr<texture>>         device::copy_async(const core::mutable_array& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);}\r
+boost::unique_future<spl::shared_ptr<texture>>         device::copy_async(const core::const_array& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);}\r
 boost::unique_future<core::const_array>                                device::copy_async(const spl::shared_ptr<texture>& source){return impl_->copy_async(source);}\r
 std::wstring                                                                           device::version(){return impl_->version();}\r
 \r