X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fmixer%2Fgpu%2Fogl_device.h;h=d1fb65b2dae6e442bd4220c2387b7a904e8d75c7;hb=116e09a218cf056e4de868454b0fe26dc4db1413;hp=de782bae32d4aa43068622d82c2b21570e2049ba;hpb=ba4563b293f7107519bf116cc28abfc9768bb49b;p=casparcg diff --git a/core/mixer/gpu/ogl_device.h b/core/mixer/gpu/ogl_device.h index de782bae3..d1fb65b2d 100644 --- a/core/mixer/gpu/ogl_device.h +++ b/core/mixer/gpu/ogl_device.h @@ -28,47 +28,97 @@ #include #include +#include #include #include +#include -#include +#include -namespace caspar { namespace mixer { +#include "../../dependencies\SFML-1.6\include\SFML/Window/Context.hpp" -class ogl_device +namespace caspar { namespace core { + +class shader; + +template +struct buffer_pool +{ + tbb::atomic usage_count; + tbb::atomic flush_count; + tbb::concurrent_bounded_queue> items; + + buffer_pool() + { + usage_count = 0; + flush_count = 0; + } +}; + +class ogl_device : boost::noncopyable { + std::unordered_map caps_; + std::array viewport_; + std::array scissor_; + const GLubyte* pattern_; + GLint attached_texture_; + GLint active_shader_; + std::array binded_textures_; + std::array blend_func_; + std::unique_ptr context_; - std::array>>, 4> device_pools_; - std::array>>, 2> host_pools_; + std::array>>, 4> device_pools_; + std::array>>, 2> host_pools_; + + unsigned int fbo_; executor executor_; - + +public: ogl_device(); -public: - virtual ~ogl_device(); + ~ogl_device(); - static safe_ptr create() - { - static safe_ptr instance(new ogl_device()); // Use the same ogl-device for all channels inorder to ensure that frames are always valid for all "context". - return instance; - } + // Not thread-safe, must be called inside of context + void enable(GLenum cap); + void disable(GLenum cap); + void viewport(size_t x, size_t y, size_t width, size_t height); + void scissor(size_t x, size_t y, size_t width, size_t height); + void stipple_pattern(const GLubyte* pattern); + + void attach(device_buffer& texture); + void clear(device_buffer& texture); + + void begin_read(host_buffer& dest, device_buffer& source); + void begin_read(device_buffer& dest, host_buffer& source); + void blend_func(int c1, int c2, int a1, int a2); + void blend_func(int c1, int c2); + + void use(shader& shader); + + void flush(); + + // thread-afe template - auto begin_invoke(Func&& func) -> boost::unique_future // noexcept + auto begin_invoke(Func&& func, task_priority priority = normal_priority) -> boost::unique_future // noexcept { - return executor_.begin_invoke(std::forward(func)); + return executor_.begin_invoke(std::forward(func), priority); } template - auto invoke(Func&& func) -> decltype(func()) + auto invoke(Func&& func, task_priority priority = normal_priority) -> decltype(func()) { - return executor_.invoke(std::forward(func)); + return executor_.invoke(std::forward(func), priority); } safe_ptr create_device_buffer(size_t width, size_t height, size_t stride); safe_ptr create_host_buffer(size_t size, host_buffer::usage_t usage); + void yield(); + boost::unique_future gc(); + + static std::wstring get_version(); }; }} \ No newline at end of file