diff --git a/src/accelerator/CMakeLists.txt b/src/accelerator/CMakeLists.txt index 0ec8ae65b8..3a1b576af4 100644 --- a/src/accelerator/CMakeLists.txt +++ b/src/accelerator/CMakeLists.txt @@ -13,13 +13,6 @@ set(SOURCES accelerator.cpp ) -if (MSVC) - list(APPEND SOURCES - d3d/d3d_device.cpp - d3d/d3d_device_context.cpp - d3d/d3d_texture2d.cpp - ) -endif () set(HEADERS ogl/image/image_kernel.h ogl/image/image_mixer.h @@ -36,13 +29,6 @@ set(HEADERS accelerator.h StdAfx.h ) -if (MSVC) - list(APPEND HEADERS - d3d/d3d_device.h - d3d/d3d_device_context.h - d3d/d3d_texture2d.h - ) -endif () bin2c("ogl/image/shader.vert" "ogl_image_vertex.h" "caspar::accelerator::ogl" "vertex_shader") bin2c("ogl/image/shader.frag" "ogl_image_fragment.h" "caspar::accelerator::ogl" "fragment_shader") @@ -61,6 +47,5 @@ source_group(sources\\cpu\\image cpu/image/.*) source_group(sources\\cpu\\util cpu/util/.*) source_group(sources\\ogl\\image ogl/image/.*) source_group(sources\\ogl\\util ogl/util/.*) -source_group(sources\\d3d d3d/.*) target_link_libraries(accelerator common core) diff --git a/src/accelerator/d3d/d3d_device.cpp b/src/accelerator/d3d/d3d_device.cpp deleted file mode 100644 index aed05529dc..0000000000 --- a/src/accelerator/d3d/d3d_device.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "d3d_device.h" - -#include "d3d_device_context.h" -#include "d3d_texture2d.h" - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include - -namespace caspar { namespace accelerator { namespace d3d { -struct d3d_device::impl : public std::enable_shared_from_this -{ - using texture_queue_t = tbb::concurrent_bounded_queue>; - - mutable std::mutex device_pools_mutex_; - tbb::concurrent_unordered_map device_pools_; - - std::wstring adaptor_name_ = L"N/A"; - std::shared_ptr device_; - std::shared_ptr ctx_; - - impl() - { - HRESULT hr; - - UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; - - D3D_FEATURE_LEVEL feature_levels[] = { - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - }; - UINT num_feature_levels = sizeof(feature_levels) / sizeof(feature_levels[0]); - - D3D_FEATURE_LEVEL selected_level = D3D_FEATURE_LEVEL_9_3; - - ID3D11Device* pdev = nullptr; - ID3D11DeviceContext* pctx = nullptr; - - hr = D3D11CreateDevice(nullptr, - D3D_DRIVER_TYPE_HARDWARE, - nullptr, - flags, - feature_levels, - num_feature_levels, - D3D11_SDK_VERSION, - &pdev, - &selected_level, - &pctx); - - if (hr == E_INVALIDARG) { - // DirectX 11.0 platforms will not recognize D3D_FEATURE_LEVEL_11_1 - // so we need to retry without it - hr = D3D11CreateDevice(nullptr, - D3D_DRIVER_TYPE_HARDWARE, - nullptr, - flags, - &feature_levels[1], - num_feature_levels - 1, - D3D11_SDK_VERSION, - &pdev, - &selected_level, - &pctx); - } - - if (SUCCEEDED(hr)) { - device_ = std::shared_ptr(pdev, [](ID3D11Device* p) { - if (p) - p->Release(); - }); - ctx_ = std::make_shared(pctx); - - CComQIPtr d3d11_1(device_.get()); - if (!d3d11_1) { - return; - } - - /* needs to support extended resource sharing */ - D3D11_FEATURE_DATA_D3D11_OPTIONS opts = {}; - hr = d3d11_1->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &opts, sizeof(opts)); - if (FAILED(hr) || !opts.ExtendedResourceSharing) { - CASPAR_THROW_EXCEPTION(bad_alloc() << msg_info(L"Device does not support ExtendedResourceSharing")); - } - - { - CComQIPtr dxgi_dev = device_.get(); - if (dxgi_dev) { - IDXGIAdapter* dxgi_adapt = nullptr; - hr = dxgi_dev->GetAdapter(&dxgi_adapt); - if (SUCCEEDED(hr)) { - DXGI_ADAPTER_DESC desc; - hr = dxgi_adapt->GetDesc(&desc); - dxgi_adapt->Release(); - if (SUCCEEDED(hr)) { - adaptor_name_ = u16(desc.Description); - } - } - } - } - - CASPAR_LOG(info) << L"D3D11: Selected adapter: " << adaptor_name_; - - CASPAR_LOG(info) << L"D3D11: Selected feature level: " << selected_level; - } else - CASPAR_THROW_EXCEPTION(bad_alloc() << msg_info(L"Failed to create d3d11 device")); - } - - std::shared_ptr open_shared_texture(void* handle) - { - ID3D11Texture2D* tex = nullptr; - - CComQIPtr dev = device_.get(); - if (dev) { - auto hr = dev->OpenSharedResource1((HANDLE)(uintptr_t)handle, __uuidof(ID3D11Texture2D), (void**)(&tex)); - if (SUCCEEDED(hr)) - return std::make_shared(tex); - } - - return nullptr; - } -}; - -d3d_device::d3d_device() - : impl_(new impl()) -{ -} - -d3d_device::~d3d_device() {} - -std::wstring d3d_device::adapter_name() const { return impl_->adaptor_name_; } - -void* d3d_device::device() const { return impl_->device_.get(); } - -std::shared_ptr d3d_device::immedidate_context() { return impl_->ctx_; } - -std::shared_ptr d3d_device::open_shared_texture(void* handle) -{ - return impl_->open_shared_texture(handle); -} - -const std::shared_ptr& d3d_device::get_device() -{ - static std::shared_ptr device = []() -> std::shared_ptr { - if (!WGLEW_NV_DX_interop2) { - // Device doesn't support the extension, so skip - return nullptr; - } - - try { - return std::make_shared(); - } catch (...) { - CASPAR_LOG_CURRENT_EXCEPTION(); - } - - return nullptr; - }(); - - return device; -} -}}} // namespace caspar::accelerator::d3d diff --git a/src/accelerator/d3d/d3d_device.h b/src/accelerator/d3d/d3d_device.h deleted file mode 100644 index ee8cf98542..0000000000 --- a/src/accelerator/d3d/d3d_device.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include - -namespace caspar { namespace accelerator { namespace d3d { -class d3d_device -{ - public: - d3d_device(); - ~d3d_device(); - - d3d_device(const d3d_device&) = delete; - d3d_device& operator=(const d3d_device&) = delete; - - std::wstring adapter_name() const; - - void* device() const; - - std::shared_ptr immedidate_context(); - - std::shared_ptr open_shared_texture(void* handle); - - static const std::shared_ptr& get_device(); - - private: - struct impl; - std::shared_ptr impl_; -}; -}}} // namespace caspar::accelerator::d3d diff --git a/src/accelerator/d3d/d3d_device_context.cpp b/src/accelerator/d3d/d3d_device_context.cpp deleted file mode 100644 index 90e2afe5c9..0000000000 --- a/src/accelerator/d3d/d3d_device_context.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "d3d_device_context.h" - -namespace caspar { namespace accelerator { namespace d3d { -d3d_device_context::d3d_device_context(ID3D11DeviceContext* ctx) - : ctx_(std::shared_ptr(ctx, [](ID3D11DeviceContext* p) { - if (p) - p->Release(); - })) -{ -} -}}} // namespace caspar::accelerator::d3d diff --git a/src/accelerator/d3d/d3d_device_context.h b/src/accelerator/d3d/d3d_device_context.h deleted file mode 100644 index 770f38a4a7..0000000000 --- a/src/accelerator/d3d/d3d_device_context.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#undef NOMINMAX -#define NOMINMAX - -#include - -#include - -namespace caspar { namespace accelerator { namespace d3d { -class d3d_device_context -{ - public: - d3d_device_context(ID3D11DeviceContext* ctx); - - d3d_device_context(const d3d_device_context&) = delete; - d3d_device_context& operator=(const d3d_device_context&) = delete; - - ID3D11DeviceContext* context() const { return ctx_.get(); } - - private: - std::shared_ptr const ctx_; -}; -}}} // namespace caspar::accelerator::d3d diff --git a/src/accelerator/d3d/d3d_texture2d.cpp b/src/accelerator/d3d/d3d_texture2d.cpp deleted file mode 100644 index 9f02f2839e..0000000000 --- a/src/accelerator/d3d/d3d_texture2d.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "d3d_texture2d.h" - -#include - -#include -#include -#include - -#include "../ogl/util/device.h" - -namespace caspar { namespace accelerator { namespace d3d { - -d3d_texture2d::d3d_texture2d(ID3D11Texture2D* tex) - : texture_(tex) -{ - share_handle_ = nullptr; - - D3D11_TEXTURE2D_DESC desc; - texture_->GetDesc(&desc); - width_ = desc.Width; - height_ = desc.Height; - format_ = desc.Format; - - if ((desc.MiscFlags & D3D11_RESOURCE_MISC_SHARED_NTHANDLE) == 0) { - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("D3D texture is not sharable.")); - } - - { - CComQIPtr res = texture_; - if (res) { - res->CreateSharedHandle(nullptr, DXGI_SHARED_RESOURCE_READ, nullptr, &share_handle_); - } - } - - if (share_handle_ == nullptr || !wglDXSetResourceShareHandleNV(texture_, share_handle_)) { - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to setup shared d3d texture.")); - } -} - -d3d_texture2d::~d3d_texture2d() -{ - const std::shared_ptr ogl = ogl_.lock(); - if (ogl != nullptr) { - // The cleanup must happen be done on the opengl thread - ogl->dispatch_sync([&] { - const std::shared_ptr interop = ogl->d3d_interop(); - if (texture_handle_ != nullptr && interop != nullptr) { - wglDXUnlockObjectsNV(interop.get(), 1, &texture_handle_); - wglDXUnregisterObjectNV(interop.get(), texture_handle_); - texture_handle_ = nullptr; - } - - if (gl_texture_id_ != 0) { - GL(glDeleteTextures(1, &gl_texture_id_)); - gl_texture_id_ = 0; - } - - // TODO: This appears to be leaking something opengl, but it is not clear what that is. - - if (share_handle_ != nullptr) { - CloseHandle(share_handle_); - share_handle_ = nullptr; - } - }); - } - - if (texture_ != nullptr) { - texture_->Release(); - texture_ = nullptr; - } -} - -void d3d_texture2d::gen_gl_texture(std::shared_ptr ogl) -{ - if (gl_texture_id_ != 0 || texture_ == nullptr) - return; - - ogl_ = ogl; - - const std::shared_ptr interop = ogl->d3d_interop(); - if (!interop) { - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("d3d interop not setup to bind shared d3d texture.")); - } - - ogl->dispatch_sync([&] { - GL(glGenTextures(1, &gl_texture_id_)); - - texture_handle_ = - wglDXRegisterObjectNV(interop.get(), texture_, gl_texture_id_, GL_TEXTURE_2D, WGL_ACCESS_READ_ONLY_NV); - if (!texture_handle_) { - GL(glDeleteTextures(1, &gl_texture_id_)); - gl_texture_id_ = 0; - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to bind shared d3d texture.")); - } - - if (!wglDXLockObjectsNV(interop.get(), 1, &texture_handle_)) { - wglDXUnregisterObjectNV(interop.get(), texture_handle_); - texture_handle_ = nullptr; - GL(glDeleteTextures(1, &gl_texture_id_)); - gl_texture_id_ = 0; - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to lock shared d3d texture.")); - } - }); -} - -}}} // namespace caspar::accelerator::d3d diff --git a/src/accelerator/d3d/d3d_texture2d.h b/src/accelerator/d3d/d3d_texture2d.h deleted file mode 100644 index 61fe4dc09a..0000000000 --- a/src/accelerator/d3d/d3d_texture2d.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#undef NOMINMAX -#define NOMINMAX - -#include - -#include - -namespace caspar { namespace accelerator { namespace d3d { - -class d3d_texture2d -{ - public: - d3d_texture2d(ID3D11Texture2D* tex); - - ~d3d_texture2d(); - - d3d_texture2d(const d3d_texture2d&) = delete; - d3d_texture2d& operator=(const d3d_texture2d&) = delete; - - uint32_t width() const { return width_; } - - uint32_t height() const { return height_; } - - DXGI_FORMAT format() const { return format_; } - - void* share_handle() const { return share_handle_; } - - ID3D11Texture2D* texture() const { return texture_; } - - uint32_t gl_texture_id() const { return gl_texture_id_; } - - void gen_gl_texture(std::shared_ptr); - - private: - HANDLE share_handle_; - - ID3D11Texture2D* texture_; - uint32_t width_ = 0; - uint32_t height_ = 0; - DXGI_FORMAT format_ = DXGI_FORMAT::DXGI_FORMAT_UNKNOWN; - - std::weak_ptr ogl_; - HANDLE texture_handle_ = nullptr; - uint32_t gl_texture_id_ = 0; -}; -}}} // namespace caspar::accelerator::d3d diff --git a/src/accelerator/ogl/image/image_mixer.cpp b/src/accelerator/ogl/image/image_mixer.cpp index 77f314a37c..56212e239f 100644 --- a/src/accelerator/ogl/image/image_mixer.cpp +++ b/src/accelerator/ogl/image/image_mixer.cpp @@ -38,10 +38,6 @@ #include -#ifdef WIN32 -#include "../../d3d/d3d_texture2d.h" -#endif - #include #include @@ -331,49 +327,6 @@ struct image_mixer::impl return std::make_shared(std::move(textures)); }); } - -#ifdef WIN32 - core::const_frame import_d3d_texture(const void* tag, - const std::shared_ptr& d3d_texture, - bool vflip, - core::pixel_format format) override - { - // map directx texture with wgl texture - if (d3d_texture->gl_texture_id() == 0) - d3d_texture->gen_gl_texture(ogl_); - - // copy directx texture to gl texture - auto gl_texture = ogl_->dispatch_sync([=] { - return ogl_->copy_async(d3d_texture->gl_texture_id(), d3d_texture->width(), d3d_texture->height(), 4); - }); - - // make gl texture to draw - std::vector textures{make_ready_future(gl_texture.get())}; - - std::weak_ptr weak_self = shared_from_this(); - core::pixel_format_desc desc(core::pixel_format::bgra); - desc.planes.push_back(core::pixel_format_desc::plane(d3d_texture->width(), d3d_texture->height(), 4)); - auto frame = core::mutable_frame( - tag, - std::vector>{}, - array{}, - desc, - [weak_self, texs = std::move(textures)](std::vector> image_data) -> boost::any { - auto self = weak_self.lock(); - if (!self) { - return boost::any{}; - } - - return std::make_shared(std::move(texs)); - }); - - if (vflip) { - frame.geometry() = core::frame_geometry::get_default_vflip(); - } - - return core::const_frame(std::move(frame)); - } -#endif }; image_mixer::image_mixer(const spl::shared_ptr& ogl, const int channel_id, const size_t max_frame_size) @@ -393,13 +346,4 @@ core::mutable_frame image_mixer::create_frame(const void* tag, const core::pixel return impl_->create_frame(tag, desc); } -#ifdef WIN32 -core::const_frame image_mixer::import_d3d_texture(const void* tag, - const std::shared_ptr& d3d_texture, - bool vflip, - core::pixel_format format) -{ - return impl_->import_d3d_texture(tag, d3d_texture, vflip, format); -} -#endif }}} // namespace caspar::accelerator::ogl diff --git a/src/accelerator/ogl/image/image_mixer.h b/src/accelerator/ogl/image/image_mixer.h index 89539eed34..c9034238d8 100644 --- a/src/accelerator/ogl/image/image_mixer.h +++ b/src/accelerator/ogl/image/image_mixer.h @@ -45,12 +45,6 @@ class image_mixer final : public core::image_mixer std::future> operator()(const core::video_format_desc& format_desc) override; core::mutable_frame create_frame(const void* tag, const core::pixel_format_desc& desc) override; -#ifdef WIN32 - core::const_frame import_d3d_texture(const void* tag, - const std::shared_ptr& d3d_texture, - bool vflip, - core::pixel_format format) override; -#endif // core::image_mixer diff --git a/src/accelerator/ogl/util/device.cpp b/src/accelerator/ogl/util/device.cpp index 523dba6624..29eabf6bf6 100644 --- a/src/accelerator/ogl/util/device.cpp +++ b/src/accelerator/ogl/util/device.cpp @@ -36,7 +36,6 @@ #include #ifdef WIN32 -#include "../../d3d/d3d_device.h" #include #endif @@ -74,11 +73,6 @@ struct device::impl : public std::enable_shared_from_this std::wstring version_; -#ifdef WIN32 - std::shared_ptr d3d_device_; - std::shared_ptr interop_handle_; -#endif - io_context service_; decltype(make_work_guard(service_)) work_; std::thread thread_; @@ -118,21 +112,6 @@ struct device::impl : public std::enable_shared_from_this device_.setActive(false); -#ifdef WIN32 - if (env::properties().get(L"configuration.html.enable-gpu", false)) { - d3d_device_ = d3d::d3d_device::get_device(); - } - if (d3d_device_) { - interop_handle_ = std::shared_ptr(wglDXOpenDeviceNV(d3d_device_->device()), [](void* p) { - if (p) - wglDXCloseDeviceNV(p); - }); - - if (!interop_handle_) - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to initialize d3d interop.")); - } -#endif - thread_ = std::thread([&] { device_.setActive(true); set_thread_name(L"OpenGL Device"); @@ -455,13 +434,6 @@ std::future> device::copy_async(const std::shared_ptrcopy_async(source); } -#ifdef WIN32 -std::shared_ptr device::d3d_interop() const { return impl_->interop_handle_; } -std::future> device::copy_async(GLuint source, int width, int height, int stride) -{ - return impl_->copy_async(source, width, height, stride); -} -#endif void device::dispatch(std::function func) { boost::asio::dispatch(impl_->service_, std::move(func)); } std::wstring device::version() const { return impl_->version(); } boost::property_tree::wptree device::info() const { return impl_->info(); } diff --git a/src/accelerator/ogl/util/device.h b/src/accelerator/ogl/util/device.h index ff8a50714d..d7f1cef1a4 100644 --- a/src/accelerator/ogl/util/device.h +++ b/src/accelerator/ogl/util/device.h @@ -51,10 +51,6 @@ class device final std::future> copy_async(const array& source, int width, int height, int stride); std::future> copy_async(const std::shared_ptr& source); -#ifdef WIN32 - std::shared_ptr d3d_interop() const; - std::future> copy_async(GLuint source, int width, int height, int stride); -#endif template auto dispatch_async(Func&& func) { diff --git a/src/core/frame/frame_factory.h b/src/core/frame/frame_factory.h index 016c2cbcf3..06268a3b6c 100644 --- a/src/core/frame/frame_factory.h +++ b/src/core/frame/frame_factory.h @@ -21,13 +21,6 @@ #pragma once -#ifdef WIN32 -#include -#include -#include -FORWARD3(caspar, accelerator, d3d, class d3d_texture2d); -#endif - namespace caspar { namespace core { class frame_factory @@ -41,12 +34,6 @@ class frame_factory virtual class mutable_frame create_frame(const void* video_stream_tag, const struct pixel_format_desc& desc) = 0; -#ifdef WIN32 - virtual class const_frame import_d3d_texture(const void* video_stream_tag, - const std::shared_ptr& d3d_texture, - bool vflip, - core::pixel_format format) = 0; -#endif }; }} // namespace caspar::core diff --git a/src/core/mixer/image/image_mixer.h b/src/core/mixer/image/image_mixer.h index 3092bce2ac..0922e38261 100644 --- a/src/core/mixer/image/image_mixer.h +++ b/src/core/mixer/image/image_mixer.h @@ -48,13 +48,6 @@ class image_mixer virtual std::future> operator()(const struct video_format_desc& format_desc) = 0; class mutable_frame create_frame(const void* tag, const struct pixel_format_desc& desc) override = 0; - -#ifdef WIN32 - class const_frame import_d3d_texture(const void* tag, - const std::shared_ptr& d3d_texture, - bool vflip, - core::pixel_format format) override = 0; -#endif }; }} // namespace caspar::core diff --git a/src/modules/html/html.cpp b/src/modules/html/html.cpp index 7a401a1f13..4711a51aa3 100644 --- a/src/modules/html/html.cpp +++ b/src/modules/html/html.cpp @@ -44,10 +44,6 @@ #include #pragma warning(pop) -#ifdef WIN32 -#include -#endif - namespace caspar { namespace html { std::unique_ptr g_cef_executor; @@ -213,14 +209,6 @@ void init(const core::module_dependencies& dependencies) #endif const bool enable_gpu = env::properties().get(L"configuration.html.enable-gpu", false); -#ifdef WIN32 - if (enable_gpu) { - auto dev = accelerator::d3d::d3d_device::get_device(); - if (!dev) - CASPAR_LOG(warning) << L"Failed to create directX device for cef gpu acceleration"; - } -#endif - CefSettings settings; settings.command_line_args_disabled = false; settings.no_sandbox = true; diff --git a/src/modules/html/producer/html_producer.cpp b/src/modules/html/producer/html_producer.cpp index e9f7231682..148db9d881 100644 --- a/src/modules/html/producer/html_producer.cpp +++ b/src/modules/html/producer/html_producer.cpp @@ -63,12 +63,6 @@ #include "../html.h" -#ifdef WIN32 -#include -#include -#include -#endif - namespace caspar { namespace html { class html_client @@ -89,7 +83,7 @@ class html_client spl::shared_ptr frame_factory_; core::video_format_desc format_desc_; - bool shared_texture_enable_; + bool gpu_enabled_; tbb::concurrent_queue javascript_before_load_; std::atomic loaded_; std::queue frames_; @@ -100,25 +94,17 @@ class html_client CefRefPtr browser_; -#ifdef WIN32 - std::shared_ptr const d3d_device_; - std::shared_ptr d3d_shared_buffer_; -#endif - public: html_client(spl::shared_ptr frame_factory, const spl::shared_ptr& graph, core::video_format_desc format_desc, - bool shared_texture_enable, + bool gpu_enabled, std::wstring url) : url_(std::move(url)) , graph_(graph) , frame_factory_(std::move(frame_factory)) , format_desc_(std::move(format_desc)) - , shared_texture_enable_(shared_texture_enable) -#ifdef WIN32 - , d3d_device_(accelerator::d3d::d3d_device::get_device()) -#endif + , gpu_enabled_(gpu_enabled) { graph_->set_color("browser-tick-time", diagnostics::color(0.1f, 1.0f, 0.1f)); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); @@ -240,9 +226,6 @@ class html_client int width, int height) override { - if (shared_texture_enable_) - return; - graph_->set_value("browser-tick-time", paint_timer_.elapsed() * format_desc_.fps * 0.5); paint_timer_.restart(); CASPAR_ASSERT(CefCurrentlyOn(TID_UI)); @@ -259,9 +242,12 @@ class html_client auto dst = reinterpret_cast(frame.image_data(0).begin()); auto chunksize = height * width; test_timer_.restart(); - //std::memcpy(dst, src, width * height *4); - tbb::parallel_for(0, 4, [&](int y) { std::memcpy(dst + y * chunksize, src + y * chunksize, chunksize); }); + if (gpu_enabled_) { + tbb::parallel_for(0, 4, [&](int y) { std::memcpy(dst + y * chunksize, src + y * chunksize, chunksize); }); + } else { + std::memcpy(dst, src, width * height * 4); + } graph_->set_value("memcpy", test_timer_.elapsed() * format_desc_.fps * 0.5 * 5); @@ -278,123 +264,6 @@ class html_client } } -#ifdef WIN32 - /* - * This is the old implementation, based on the original patch and not the obs variant. - * It is kept here for when something gets merged upstream as this might be the needed implementation - void OnAcceleratedPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - void* shared_handle) override - { - try { - if (!shared_texture_enable_) - return; - - graph_->set_value("browser-tick-time", paint_timer_.elapsed() * format_desc_.fps * 0.5); - paint_timer_.restart(); - CASPAR_ASSERT(CefCurrentlyOn(TID_UI)); - - if (type != PET_VIEW) - return; - - if (d3d_shared_buffer_) { - if (shared_handle != d3d_shared_buffer_->share_handle()) - d3d_shared_buffer_.reset(); - } - - if (!d3d_shared_buffer_) { - d3d_shared_buffer_ = d3d_device_->open_shared_texture(shared_handle); - if (!d3d_shared_buffer_) - CASPAR_LOG(error) << print() << L" could not open shared texture!"; - } - - if (d3d_shared_buffer_ && d3d_shared_buffer_->format() == DXGI_FORMAT_B8G8R8A8_UNORM) { - auto frame = frame_factory_->import_d3d_texture(this, d3d_shared_buffer_, true); - core::draw_frame dframe(std::move(frame)); - - { - std::lock_guard lock(frames_mutex_); - - frames_.push(dframe); - while (frames_.size() > frames_max_size_) { - frames_.pop(); - graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame"); - } - - graph_->set_value("buffered-frames", (double)frames_.size() / frames_max_size_); - } - } - } catch (...) { - CASPAR_LOG_CURRENT_EXCEPTION(); - } - } - */ - - /* - * This is where the shared textures get fed into. It is specific to the obs builds (hence the 2 suffix), so might - * be removed/renamed when the change is accepted upstream - */ - /* - void OnAcceleratedPaint2(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - void* shared_handle, - bool new_texture) override - { - try { - if (!shared_texture_enable_) - return; - - graph_->set_value("browser-tick-time", paint_timer_.elapsed() * format_desc_.fps * 0.5); - paint_timer_.restart(); - CASPAR_ASSERT(CefCurrentlyOn(TID_UI)); - - if (type != PET_VIEW) - return; - - if (new_texture && d3d_shared_buffer_) { - d3d_shared_buffer_.reset(); - } - - if (!d3d_shared_buffer_) { - d3d_shared_buffer_ = d3d_device_->open_shared_texture(shared_handle); - if (!d3d_shared_buffer_) - CASPAR_LOG(error) << print() << L" could not open shared texture!"; - } - - if (d3d_shared_buffer_) { - core::pixel_format format = core::pixel_format::invalid; - if (d3d_shared_buffer_->format() == DXGI_FORMAT_B8G8R8A8_UNORM) { - format = core::pixel_format::bgra; - } else if (d3d_shared_buffer_->format() == DXGI_FORMAT_R8G8B8A8_UNORM) { - format = core::pixel_format::rgba; - } - - if (format != core::pixel_format::invalid) { - auto frame = frame_factory_->import_d3d_texture(this, d3d_shared_buffer_, true, format); - core::draw_frame dframe(std::move(frame)); - - { - std::lock_guard lock(frames_mutex_); - - frames_.push(dframe); - while (frames_.size() > frames_max_size_) { - frames_.pop(); - graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame"); - } - graph_->set_value("buffered-frames", (double)frames_.size() / frames_max_size_); - } - } - } - - } catch (...) { - CASPAR_LOG_CURRENT_EXCEPTION(); - } - } - */ -#endif - void OnAfterCreated(CefRefPtr browser) override { CASPAR_ASSERT(CefCurrentlyOn(TID_UI)); @@ -526,20 +395,13 @@ class html_producer : public core::frame_producer { html::invoke([&] { const bool enable_gpu = env::properties().get(L"configuration.html.enable-gpu", false); - bool shared_texture_enable = false; - -#ifdef WIN32 - // This is not currently implemented by CEF - // shared_texture_enable = enable_gpu && accelerator::d3d::d3d_device::get_device(); -#endif - client_ = new html_client(frame_factory, graph_, format_desc, shared_texture_enable, url_); + client_ = new html_client(frame_factory, graph_, format_desc, enable_gpu, url_); CefWindowInfo window_info; window_info.bounds.width = format_desc.square_width; window_info.bounds.height = format_desc.square_height; window_info.windowless_rendering_enabled = true; - window_info.shared_texture_enabled = shared_texture_enable; CefBrowserSettings browser_settings; browser_settings.webgl = enable_gpu ? cef_state_t::STATE_ENABLED : cef_state_t::STATE_DISABLED; diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index ff1cce406d..12f85fb1bb 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -74,10 +74,6 @@ if (MSVC) avdevice.lib swscale.lib swresample.lib - - d3d9.lib - d3d11.lib - dxgi.lib ) else () target_link_libraries(casparcg