diff --git a/.github/workflows/linux-system.yml b/.github/workflows/linux-system.yml index ed6342b7d4..07e4993711 100644 --- a/.github/workflows/linux-system.yml +++ b/.github/workflows/linux-system.yml @@ -35,13 +35,6 @@ jobs: libpostproc-dev \ libswresample-dev - - name: Extract docker dependencies - run: | - ./tools/linux/ensure-base-images - sudo ./tools/linux/extract-deps-from-docker - env: - CI: 1 - - name: Run build run: | diff --git a/BUILDING.md b/BUILDING.md index 931a43736b..fc5e181b10 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -52,7 +52,7 @@ _Note: if you ran docker with sudo, CasparCG server will not be able to run with 2. `git clone --single-branch --branch master https://github.com/CasparCG/server casparcg-server-master` 3. `cd casparcg-server-master` 4. Install dependencies, this can be done with `sudo ./tools/linux/install-dependencies` -5. Extract Boost, FFmpeg and CEF from the docker images via `sudo ./tools/linux/extract-deps-from-docker`. Alternatively these can be prepared manually by following the steps laid out in each Dockerfile +5. Extract Boost and FFmpeg from the docker images via `sudo ./tools/linux/extract-deps-from-docker`. Alternatively these can be prepared manually by following the steps laid out in each Dockerfile 6. `mkdir build && cd build` 7. `cmake ../src` 8. `make -j8` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3435a3f775..aa0dcb3a8e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,7 @@ SET (CONFIG_VERSION_TAG "NRK-Dev") option(ENABLE_HTML "Enable HTML module, require CEF" ON) # Add custom cmake modules path +SET (CASPARCG_PATCH_DIR ${CMAKE_SOURCE_DIR}/CMakeModules/patches) LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules) if (MSVC) diff --git a/src/CMakeModules/Bootstrap_Linux.cmake b/src/CMakeModules/Bootstrap_Linux.cmake index 0268a6916c..978e445f5f 100644 --- a/src/CMakeModules/Bootstrap_Linux.cmake +++ b/src/CMakeModules/Bootstrap_Linux.cmake @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 3.16) +include(ExternalProject) + # Determine build (target) platform INCLUDE (PlatformIntrospection) _DETERMINE_PLATFORM (CONFIG_PLATFORM) @@ -47,8 +49,30 @@ FIND_PACKAGE (SFML 2 COMPONENTS graphics window system REQUIRED) FIND_PACKAGE (X11 REQUIRED) if (ENABLE_HTML) - SET(CEF_ROOT_DIR "/opt/cef" CACHE STRING "Path to CEF") - FIND_PACKAGE (CEF REQUIRED) + #casparcg_add_external_project(cef) + ExternalProject_Add(cef + URL https://cef-builds.spotifycdn.com/cef_binary_117.2.5%2Bgda4c36a%2Bchromium-117.0.5938.152_linux64_minimal.tar.bz2 + URL_HASH SHA1=7e6c9cf591cf3b1dabe65a7611f5fc166df2ec1e + DOWNLOAD_DIR ${CASPARCG_DOWNLOAD_CACHE} + CMAKE_ARGS -DUSE_SANDBOX=Off + INSTALL_COMMAND "" + PATCH_COMMAND git apply ${CASPARCG_PATCH_DIR}/cef117.patch + BUILD_BYPRODUCTS + "/Release/libcef.so" + "/libcef_dll_wrapper/libcef_dll_wrapper.a" + ) + ExternalProject_Get_Property(cef SOURCE_DIR) + ExternalProject_Get_Property(cef BINARY_DIR) + + # Note: All of these must be referenced in the BUILD_BYPRODUCTS above, to satisfy ninja + set(CEF_LIB + "${SOURCE_DIR}/Release/libcef.so" + "${BINARY_DIR}/libcef_dll_wrapper/libcef_dll_wrapper.a" + ) + + set(CEF_INCLUDE_PATH "${SOURCE_DIR}") + set(CEF_BIN_PATH "${SOURCE_DIR}/Release") + set(CEF_RESOURCE_PATH "${SOURCE_DIR}/Resources") endif () SET (BOOST_INCLUDE_PATH "${Boost_INCLUDE_DIRS}") @@ -58,10 +82,6 @@ SET (SFML_INCLUDE_PATH "${SFML_INCLUDE_DIR}") SET (FFMPEG_INCLUDE_PATH "${FFMPEG_INCLUDE_DIRS}") SET (FREEIMAGE_INCLUDE_PATH "${FreeImage_INCLUDE_DIRS}") -set(CEF_INCLUDE_PATH "${CEF_ROOT_DIR}") -set(CEF_BIN_PATH "${CEF_ROOT_DIR}/Release") -set(CEF_RESOURCE_PATH "${CEF_ROOT_DIR}/Resources") - SET_PROPERTY (GLOBAL PROPERTY USE_FOLDERS ON) ADD_DEFINITIONS (-DSFML_STATIC) diff --git a/src/CMakeModules/Bootstrap_Windows.cmake b/src/CMakeModules/Bootstrap_Windows.cmake index 1c79dbaa1c..009cf829be 100644 --- a/src/CMakeModules/Bootstrap_Windows.cmake +++ b/src/CMakeModules/Bootstrap_Windows.cmake @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 3.16) +include(ExternalProject) + find_package(Git) set(CONFIG_VERSION_GIT_HASH "N/A") @@ -159,20 +161,30 @@ casparcg_add_runtime_dependency("${LIBERATION_FONTS_BIN_PATH}/LiberationMono-Reg # CEF if (ENABLE_HTML) - set(CEF_INCLUDE_PATH "${NUGET_PACKAGES_FOLDER}/cef.sdk.3.3578.1870/CEF") - set(CEF_BIN_PATH "${NUGET_PACKAGES_FOLDER}/cef.redist.x64.3.3578.1870/CEF") - set(CEF_RESOURCE_PATH "${NUGET_PACKAGES_FOLDER}/cef.redist.x64.3.3578.1870/CEF") - link_directories("${NUGET_PACKAGES_FOLDER}/cef.sdk.3.3578.1870/CEF/x64") + # casparcg_add_external_project(cef) + ExternalProject_Add(cef + URL https://cef-builds.spotifycdn.com/cef_binary_117.2.5%2Bgda4c36a%2Bchromium-117.0.5938.152_windows64_minimal.tar.bz2 + URL_HASH MD5=cff21bce81bada2a9e5f0afbec0858f0 + DOWNLOAD_DIR ${CASPARCG_DOWNLOAD_CACHE} + CMAKE_ARGS -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD + INSTALL_COMMAND "" + PATCH_COMMAND git apply ${CASPARCG_PATCH_DIR}/cef117.patch + ) + ExternalProject_Get_Property(cef SOURCE_DIR) + ExternalProject_Get_Property(cef BINARY_DIR) + + set(CEF_INCLUDE_PATH ${SOURCE_DIR}) + set(CEF_BIN_PATH ${SOURCE_DIR}/Release) + set(CEF_RESOURCE_PATH ${SOURCE_DIR}/Resources) + link_directories(${SOURCE_DIR}/Release) + link_directories(${BINARY_DIR}/libcef_dll_wrapper) casparcg_add_runtime_dependency_dir("${CEF_RESOURCE_PATH}/locales") - casparcg_add_runtime_dependency_dir("${CEF_RESOURCE_PATH}/swiftshader") - casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/cef.pak") - casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/cef_100_percent.pak") - casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/cef_200_percent.pak") - casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/cef_extensions.pak") - casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/devtools_resources.pak") + casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/chrome_100_percent.pak") + casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/chrome_200_percent.pak") + casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/resources.pak") casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/icudtl.dat") - casparcg_add_runtime_dependency("${CEF_BIN_PATH}/natives_blob.bin") + casparcg_add_runtime_dependency("${CEF_BIN_PATH}/snapshot_blob.bin") casparcg_add_runtime_dependency("${CEF_BIN_PATH}/v8_context_snapshot.bin") casparcg_add_runtime_dependency("${CEF_BIN_PATH}/libcef.dll") @@ -180,6 +192,9 @@ if (ENABLE_HTML) casparcg_add_runtime_dependency("${CEF_BIN_PATH}/d3dcompiler_47.dll") casparcg_add_runtime_dependency("${CEF_BIN_PATH}/libEGL.dll") casparcg_add_runtime_dependency("${CEF_BIN_PATH}/libGLESv2.dll") + casparcg_add_runtime_dependency("${CEF_BIN_PATH}/vk_swiftshader.dll") + casparcg_add_runtime_dependency("${CEF_BIN_PATH}/vk_swiftshader_icd.json") + casparcg_add_runtime_dependency("${CEF_BIN_PATH}/vulkan-1.dll") endif () set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/src/CMakeModules/FindCEF.cmake b/src/CMakeModules/FindCEF.cmake deleted file mode 100644 index 7528879cff..0000000000 --- a/src/CMakeModules/FindCEF.cmake +++ /dev/null @@ -1,69 +0,0 @@ -include(FindPackageHandleStandardArgs) - -SET(CEF_ROOT_DIR "" CACHE PATH "Path to a CEF distributed build") - -message(STATUS "Looking for Chromium Embedded Framework in ${CEF_ROOT_DIR}") - -find_path(CEF_INCLUDE_DIR "include/cef_version.h" - HINTS ${CEF_ROOT_DIR}) - -if(APPLE) - find_library(CEF_LIBRARY - NAMES cef libcef cef.lib libcef.o "Chromium Embedded Framework" - NO_DEFAULT_PATH - PATHS ${CEF_ROOT_DIR} ${CEF_ROOT_DIR}/Release) - find_library(CEFWRAPPER_LIBRARY - NAMES cef_dll_wrapper libcef_dll_wrapper - NO_DEFAULT_PATH - PATHS ${CEF_ROOT_DIR}/build/libcef_dll/Release - ${CEF_ROOT_DIR}/build/libcef_dll_wrapper/Release - ${CEF_ROOT_DIR}/build/libcef_dll - ${CEF_ROOT_DIR}/build/libcef_dll_wrapper) -else() - find_library(CEF_LIBRARY - NAMES cef libcef cef.lib libcef.o "Chromium Embedded Framework" - PATHS ${CEF_ROOT_DIR} ${CEF_ROOT_DIR}/Release) - find_library(CEFWRAPPER_LIBRARY - NAMES cef_dll_wrapper libcef_dll_wrapper - PATHS ${CEF_ROOT_DIR}/build/libcef_dll/Release - ${CEF_ROOT_DIR}/build/libcef_dll_wrapper/Release - ${CEF_ROOT_DIR}/build/libcef_dll - ${CEF_ROOT_DIR}/build/libcef_dll_wrapper - ${CEF_ROOT_DIR}/Release) - if(WIN32) - find_library(CEFWRAPPER_LIBRARY_DEBUG - NAMES cef_dll_wrapper libcef_dll_wrapper - PATHS ${CEF_ROOT_DIR}/build/libcef_dll/Debug ${CEF_ROOT_DIR}/build/libcef_dll_wrapper/Debug) - endif() -endif() - -if(NOT CEF_LIBRARY) - set(CEF_FOUND FALSE) - message(FATAL_ERROR "Could not find the CEF shared library" ) - return() -endif() - -if(NOT CEFWRAPPER_LIBRARY) -set(CEF_FOUND FALSE) - message(FATAL_ERROR "Could not find the CEF wrapper library" ) - return() -endif() - -if(WIN32) - set(CEF_LIBRARIES - ${CEF_LIBRARY} - optimized ${CEFWRAPPER_LIBRARY}) - if (CEFWRAPPER_LIBRARY_DEBUG) - list(APPEND CEF_LIBRARIES - debug ${CEFWRAPPER_LIBRARY_DEBUG}) - endif() -else() - set(CEF_LIBRARIES - ${CEF_LIBRARY} - ${CEFWRAPPER_LIBRARY}) -endif() - -find_package_handle_standard_args(CEF DEFAULT_MSG CEF_LIBRARY - CEFWRAPPER_LIBRARY CEF_INCLUDE_DIR) -mark_as_advanced(CEF_LIBRARY CEF_WRAPPER_LIBRARY CEF_LIBRARIES - CEF_INCLUDE_DIR) diff --git a/src/CMakeModules/patches/cef117.patch b/src/CMakeModules/patches/cef117.patch new file mode 100644 index 0000000000..9b4b7ea7e7 --- /dev/null +++ b/src/CMakeModules/patches/cef117.patch @@ -0,0 +1,16 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -132,11 +132,8 @@ + # Global setup. + # + +-# For VS2022 and Xcode 12+ support. +-cmake_minimum_required(VERSION 3.21) +- +-# Only generate Debug and Release configuration types. +-set(CMAKE_CONFIGURATION_TYPES Debug Release) ++# VS2022 and Xcode 12+ support needs 3.21, but ubuntu22.04 ships with 3.20 ++cmake_minimum_required(VERSION 3.20) + + # Project name. + # TODO: Change this line to match your project name when you copy this file. diff --git a/src/accelerator/CMakeLists.txt b/src/accelerator/CMakeLists.txt index 73118dd86f..c3141fd76f 100644 --- a/src/accelerator/CMakeLists.txt +++ b/src/accelerator/CMakeLists.txt @@ -13,13 +13,6 @@ set(SOURCES accelerator.cpp ) -if (MSVC) - set(WIN32_SPECIFIC_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,19 +29,12 @@ set(HEADERS accelerator.h StdAfx.h ) -if (MSVC) - set(WIN32_SPECIFIC_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") -add_library(accelerator ${SOURCES} ${HEADERS} ${WIN32_SPECIFIC_SOURCES} ${WIN32_SPECIFIC_HEADERS}) -target_compile_features(accelerator PRIVATE cxx_std_14) +add_library(accelerator ${SOURCES} ${HEADERS}) +target_compile_features(accelerator PRIVATE cxx_std_17) target_include_directories(accelerator PRIVATE .. ${CMAKE_CURRENT_BINARY_DIR} @@ -66,6 +52,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 fe078f5d7e..0000000000 --- a/src/accelerator/d3d/d3d_device.cpp +++ /dev/null @@ -1,159 +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 - -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, - D3D_FEATURE_LEVEL_9_3, - }; - 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); - - { - IDXGIDevice* dxgi_dev = nullptr; - hr = device_->QueryInterface(__uuidof(dxgi_dev), (void**)&dxgi_dev); - if (SUCCEEDED(hr)) { - IDXGIAdapter* dxgi_adapt = nullptr; - hr = dxgi_dev->GetAdapter(&dxgi_adapt); - dxgi_dev->Release(); - 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; - auto hr = device_->OpenSharedResource(handle, __uuidof(ID3D11Texture2D), (void**)(&tex)); - if (FAILED(hr)) - return nullptr; - - return std::make_shared(tex); - } -}; - -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 6a4e4f045e..0000000000 --- a/src/accelerator/d3d/d3d_texture2d.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "d3d_texture2d.h" - -#include - -#include -#include - -namespace caspar { namespace accelerator { namespace d3d { -d3d_texture2d::d3d_texture2d(ID3D11Texture2D* tex) - : texture_(std::shared_ptr(tex, [](ID3D11Texture2D* p) { - if (p) - p->Release(); - })) -{ - share_handle_ = nullptr; - - IDXGIResource* res = nullptr; - if (SUCCEEDED(texture_->QueryInterface(__uuidof(IDXGIResource), reinterpret_cast(&res)))) { - res->GetSharedHandle(&share_handle_); - res->Release(); - } - - D3D11_TEXTURE2D_DESC desc; - texture_->GetDesc(&desc); - width_ = desc.Width; - height_ = desc.Height; - format_ = desc.Format; -} - -d3d_texture2d::~d3d_texture2d() -{ - if (gl_texture_id_ != 0) - glDeleteTextures(1, &gl_texture_id_); -} - -void d3d_texture2d::gen_gl_texture(const std::shared_ptr& interop) -{ - if (gl_texture_id_ == 0) { - GL(glGenTextures(1, &gl_texture_id_)); - void* tex_handle = wglDXRegisterObjectNV( - interop.get(), texture_.get(), gl_texture_id_, GL_TEXTURE_2D, WGL_ACCESS_READ_ONLY_NV); - if (!tex_handle) - CASPAR_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to bind shared d3d texture.")); - - texture_handle_ = std::shared_ptr(tex_handle, [=](void* p) { - wglDXUnlockObjectsNV(interop.get(), 1, &p); - wglDXUnregisterObjectNV(interop.get(), p); - }); - - if (!wglDXLockObjectsNV(interop.get(), 1, &tex_handle)) - 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 0ff4a1cf10..0000000000 --- a/src/accelerator/d3d/d3d_texture2d.h +++ /dev/null @@ -1,46 +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_.get(); } - - uint32_t gl_texture_id() const { return gl_texture_id_; } - - void gen_gl_texture(const std::shared_ptr& interop); - - private: - HANDLE share_handle_; - - std::shared_ptr const texture_; - uint32_t width_ = 0; - uint32_t height_ = 0; - DXGI_FORMAT format_ = DXGI_FORMAT::DXGI_FORMAT_UNKNOWN; - - std::shared_ptr texture_handle_; - 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 debe2c5520..3a43864709 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,47 +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) override - { - // map directx texture with wgl texture - if (d3d_texture->gl_texture_id() == 0) - ogl_->dispatch_sync([=] { d3d_texture->gen_gl_texture(ogl_->d3d_interop()); }); - - // 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) @@ -391,11 +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) -{ - return impl_->import_d3d_texture(tag, d3d_texture, vflip); -} -#endif }}} // namespace caspar::accelerator::ogl diff --git a/src/accelerator/ogl/image/image_mixer.h b/src/accelerator/ogl/image/image_mixer.h index fdabeda6cf..c9034238d8 100644 --- a/src/accelerator/ogl/image/image_mixer.h +++ b/src/accelerator/ogl/image/image_mixer.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -44,10 +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) 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/common/CMakeLists.txt b/src/common/CMakeLists.txt index 88baccb199..0db801a3b7 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -59,7 +59,7 @@ set(HEADERS ) add_library(common ${SOURCES} ${HEADERS} ${OS_SPECIFIC_SOURCES}) -target_compile_features(common PRIVATE cxx_std_14) +target_compile_features(common PRIVATE cxx_std_17) target_include_directories(common PRIVATE .. ${BOOST_INCLUDE_PATH} diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8adb77820b..cdc9d3d402 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -74,7 +74,7 @@ set(HEADERS ) add_library(core ${SOURCES} ${HEADERS}) -target_compile_features(core PRIVATE cxx_std_14) +target_compile_features(core PRIVATE cxx_std_17) target_include_directories(core PRIVATE .. ${BOOST_INCLUDE_PATH} diff --git a/src/core/frame/frame_factory.h b/src/core/frame/frame_factory.h index 3ce9621c2b..06268a3b6c 100644 --- a/src/core/frame/frame_factory.h +++ b/src/core/frame/frame_factory.h @@ -21,12 +21,6 @@ #pragma once -#ifdef WIN32 -#include -#include -FORWARD3(caspar, accelerator, d3d, class d3d_texture2d); -#endif - namespace caspar { namespace core { class frame_factory @@ -40,11 +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 = false) = 0; -#endif }; }} // namespace caspar::core diff --git a/src/core/mixer/image/image_mixer.h b/src/core/mixer/image/image_mixer.h index daac935ea6..0922e38261 100644 --- a/src/core/mixer/image/image_mixer.h +++ b/src/core/mixer/image/image_mixer.h @@ -48,12 +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) override = 0; -#endif }; }} // namespace caspar::core diff --git a/src/modules/bluefish/CMakeLists.txt b/src/modules/bluefish/CMakeLists.txt index 3c2d81ab93..6fb2c3936f 100644 --- a/src/modules/bluefish/CMakeLists.txt +++ b/src/modules/bluefish/CMakeLists.txt @@ -17,7 +17,7 @@ set(HEADERS ) add_library(bluefish ${SOURCES} ${HEADERS}) -target_compile_features(bluefish PRIVATE cxx_std_14) +target_compile_features(bluefish PRIVATE cxx_std_17) target_include_directories(bluefish PRIVATE .. ../.. diff --git a/src/modules/decklink/CMakeLists.txt b/src/modules/decklink/CMakeLists.txt index b67e91abbc..ac30bd119e 100644 --- a/src/modules/decklink/CMakeLists.txt +++ b/src/modules/decklink/CMakeLists.txt @@ -50,7 +50,7 @@ else() endif () add_library(decklink ${SOURCES} ${HEADERS} ${OS_SPECIFIC_SOURCES}) -target_compile_features(decklink PRIVATE cxx_std_14) +target_compile_features(decklink PRIVATE cxx_std_17) target_include_directories(decklink PRIVATE .. ../.. diff --git a/src/modules/ffmpeg/CMakeLists.txt b/src/modules/ffmpeg/CMakeLists.txt index 9689fd43cc..a4905a40ed 100644 --- a/src/modules/ffmpeg/CMakeLists.txt +++ b/src/modules/ffmpeg/CMakeLists.txt @@ -23,7 +23,7 @@ set(HEADERS ) add_library(ffmpeg ${SOURCES} ${HEADERS}) -target_compile_features(ffmpeg PRIVATE cxx_std_14) +target_compile_features(ffmpeg PRIVATE cxx_std_17) target_include_directories(ffmpeg PRIVATE .. ../.. diff --git a/src/modules/html/CMakeLists.txt b/src/modules/html/CMakeLists.txt index 1b38e469c6..3240a6a4e6 100644 --- a/src/modules/html/CMakeLists.txt +++ b/src/modules/html/CMakeLists.txt @@ -15,7 +15,7 @@ set(HEADERS ) add_library(html ${SOURCES} ${HEADERS}) -target_compile_features(html PRIVATE cxx_std_14) +target_compile_features(html PRIVATE cxx_std_17) target_include_directories(html PRIVATE .. ../.. @@ -24,6 +24,7 @@ target_include_directories(html PRIVATE ${CEF_INCLUDE_PATH} ) configure_file("${PROJECT_SOURCE_DIR}/packages.config" "${CMAKE_CURRENT_BINARY_DIR}/packages.config") +add_dependencies(html cef) set_target_properties(html PROPERTIES FOLDER modules) @@ -36,18 +37,13 @@ if(MSVC) core accelerator - optimized release/libcef - optimized release/VS2015/libcef_dll_wrapper - debug debug/libcef - debug debug/VS2015/libcef_dll_wrapper + libcef + optimized Release/libcef_dll_wrapper + debug Debug/libcef_dll_wrapper ) else() target_link_libraries(html - common - core - - ${CEF_BIN_PATH}/libcef.so - ${CEF_BIN_PATH}/libcef_dll_wrapper.a + ${CEF_LIB} ) endif() diff --git a/src/modules/html/html.cpp b/src/modules/html/html.cpp index 9e49f38aa9..4711a51aa3 100644 --- a/src/modules/html/html.cpp +++ b/src/modules/html/html.cpp @@ -44,13 +44,6 @@ #include #pragma warning(pop) -#pragma comment(lib, "libcef.lib") -#pragma comment(lib, "libcef_dll_wrapper.lib") - -#ifdef WIN32 -#include -#endif - namespace caspar { namespace html { std::unique_ptr g_cef_executor; @@ -63,7 +56,11 @@ void caspar_log(const CefRefPtr& browser, auto msg = CefProcessMessage::Create(LOG_MESSAGE_NAME); msg->GetArgumentList()->SetInt(0, level); msg->GetArgumentList()->SetString(1, message); - browser->SendProcessMessage(PID_BROWSER, msg); + + CefRefPtr mainFrame = browser->GetMainFrame(); + if (mainFrame) { + mainFrame->SendProcessMessage(PID_BROWSER, msg); + } } } @@ -87,7 +84,10 @@ class remove_handler : public CefV8Handler return false; } - browser_->SendProcessMessage(PID_BROWSER, CefProcessMessage::Create(REMOVE_MESSAGE_NAME)); + CefRefPtr mainFrame = browser_->GetMainFrame(); + if (mainFrame) { + mainFrame->SendProcessMessage(PID_BROWSER, CefProcessMessage::Create(REMOVE_MESSAGE_NAME)); + } return true; } @@ -162,8 +162,12 @@ class renderer_application { if (enable_gpu_) { command_line->AppendSwitch("enable-webgl"); + + // This gives better performance on the gpu->cpu readback + command_line->AppendSwitchWithValue("use-angle", "gl"); } + command_line->AppendSwitch("disable-web-security"); command_line->AppendSwitch("enable-begin-frame-scheduling"); command_line->AppendSwitch("enable-media-stream"); command_line->AppendSwitch("use-fake-ui-for-media-stream"); @@ -172,6 +176,7 @@ class renderer_application if (process_type.empty() && !enable_gpu_) { // This gives more performance, but disabled gpu effects. Without it a single 1080p producer cannot be run // smoothly + command_line->AppendSwitch("disable-gpu"); command_line->AppendSwitch("disable-gpu-compositing"); command_line->AppendSwitchWithValue("disable-gpu-vsync", "gpu"); @@ -204,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/packages.config b/src/modules/html/packages.config index 3143d116bd..c57d4708b5 100644 --- a/src/modules/html/packages.config +++ b/src/modules/html/packages.config @@ -1,6 +1,4 @@  - - - \ No newline at end of file + diff --git a/src/modules/html/producer/html_producer.cpp b/src/modules/html/producer/html_producer.cpp index f42c2e18ca..44780ac48a 100644 --- a/src/modules/html/producer/html_producer.cpp +++ b/src/modules/html/producer/html_producer.cpp @@ -63,15 +63,6 @@ #include "../html.h" -#ifdef WIN32 -#include -#include -#include -#endif - -#pragma comment(lib, "libcef.lib") -#pragma comment(lib, "libcef_dll_wrapper.lib") - namespace caspar { namespace html { class html_client @@ -88,10 +79,11 @@ class html_client caspar::timer tick_timer_; caspar::timer frame_timer_; caspar::timer paint_timer_; + caspar::timer test_timer_; 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_; @@ -103,25 +95,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)); @@ -223,17 +207,18 @@ class html_client } } - bool OnBeforePopup(CefRefPtr browser, - CefRefPtr frame, - const CefString& target_url, - const CefString& target_frame_name, - WindowOpenDisposition target_disposition, - bool user_gesture, - const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, - CefRefPtr& client, - CefBrowserSettings& settings, - bool* no_javascript_access) override + bool OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, + const CefString& target_url, + const CefString& target_frame_name, + WindowOpenDisposition target_disposition, + bool user_gesture, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + CefRefPtr& client, + CefBrowserSettings& settings, + CefRefPtr& dict, + bool* no_javascript_access) override { // This blocks popup windows from opening, as they dont make sense and hit an exception in get_browser_host upon // closing @@ -275,7 +260,7 @@ class html_client int width, int height) override { - if (shared_texture_enable_ || closing_) + if (closing_) return; graph_->set_value("browser-tick-time", paint_timer_.elapsed() * format_desc_.fps * 0.5); @@ -285,14 +270,28 @@ class html_client if (type != PET_VIEW) return; - core::pixel_format_desc pixel_desc; - pixel_desc.format = core::pixel_format::bgra; - pixel_desc.planes.push_back(core::pixel_format_desc::plane(width, height, 4)); + core::pixel_format_desc pixel_desc(core::pixel_format::bgra); + pixel_desc.planes.emplace_back(width, height, 4); - auto frame = frame_factory_->create_frame(this, pixel_desc); - auto src = (char*)buffer; - auto dst = reinterpret_cast(frame.image_data(0).begin()); + core::mutable_frame frame = frame_factory_->create_frame(this, pixel_desc); + char* src = (char*)buffer; + char* dst = reinterpret_cast(frame.image_data(0).begin()); + test_timer_.restart(); + +#ifdef WIN32 + if (gpu_enabled_) { + int chunksize = height * width; + tbb::parallel_for(0, 4, [&](int y) { std::memcpy(dst + y * chunksize, src + y * chunksize, chunksize); }); + } else { + std::memcpy(dst, src, width * height * 4); + } +#else + // On my one test linux machine, doing a single memcpy doesn't have the same cost as windows, + // making using tbb excessive std::memcpy(dst, src, width * height * 4); +#endif + + graph_->set_value("memcpy", test_timer_.elapsed() * format_desc_.fps * 0.5 * 5); { std::lock_guard lock(frames_mutex_); @@ -306,55 +305,6 @@ class html_client } } -#ifdef WIN32 - void OnAcceleratedPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - void* shared_handle) override - { - try { - if (!shared_texture_enable_ || closing_) - 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(std::make_pair(now(), std::move(dframe))); - while (frames_.size() > 4) { - frames_.pop(); - graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame"); - } - graph_->set_value("output-buffer", static_cast(frames_.size()) / static_cast(4)); - } - } - } catch (...) { - CASPAR_LOG_CURRENT_EXCEPTION(); - } - } -#endif - void OnAfterCreated(CefRefPtr browser) override { CASPAR_ASSERT(CefCurrentlyOn(TID_UI)); @@ -410,6 +360,7 @@ class html_client } bool OnProcessMessageReceived(CefRefPtr browser, + CefRefPtr frame, CefProcessId source_process, CefRefPtr message) override { @@ -485,26 +436,19 @@ 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 - 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.width = format_desc.square_width; - window_info.height = format_desc.square_height; + 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.web_security = cef_state_t::STATE_DISABLED; - browser_settings.webgl = enable_gpu ? cef_state_t::STATE_ENABLED : cef_state_t::STATE_DISABLED; - double fps = format_desc.fps; + browser_settings.webgl = enable_gpu ? cef_state_t::STATE_ENABLED : cef_state_t::STATE_DISABLED; + double fps = format_desc.fps; browser_settings.windowless_frame_rate = int(ceil(fps)); - CefBrowserHost::CreateBrowser(window_info, client_.get(), url, browser_settings, nullptr); + CefBrowserHost::CreateBrowser(window_info, client_.get(), url, browser_settings, nullptr, nullptr); }); } diff --git a/src/modules/image/CMakeLists.txt b/src/modules/image/CMakeLists.txt index 50f2d806f5..93eacb4673 100644 --- a/src/modules/image/CMakeLists.txt +++ b/src/modules/image/CMakeLists.txt @@ -28,7 +28,7 @@ set(HEADERS ) add_library(image ${SOURCES} ${HEADERS}) -target_compile_features(image PRIVATE cxx_std_14) +target_compile_features(image PRIVATE cxx_std_17) target_include_directories(image PRIVATE .. ../.. diff --git a/src/modules/newtek/CMakeLists.txt b/src/modules/newtek/CMakeLists.txt index b09f23694d..de2965b7f7 100644 --- a/src/modules/newtek/CMakeLists.txt +++ b/src/modules/newtek/CMakeLists.txt @@ -43,7 +43,7 @@ if (MSVC) endif() add_library(newtek ${SOURCES} ${HEADERS}) -target_compile_features(newtek PRIVATE cxx_std_14) +target_compile_features(newtek PRIVATE cxx_std_17) target_include_directories(newtek PRIVATE .. ../.. diff --git a/src/modules/oal/CMakeLists.txt b/src/modules/oal/CMakeLists.txt index 7756360760..a7da33c587 100644 --- a/src/modules/oal/CMakeLists.txt +++ b/src/modules/oal/CMakeLists.txt @@ -13,7 +13,7 @@ set(HEADERS ) add_library(oal ${SOURCES} ${HEADERS}) -target_compile_features(oal PRIVATE cxx_std_14) +target_compile_features(oal PRIVATE cxx_std_17) target_include_directories(oal PRIVATE .. ../.. diff --git a/src/modules/screen/CMakeLists.txt b/src/modules/screen/CMakeLists.txt index f09e6ff02d..45601cc604 100644 --- a/src/modules/screen/CMakeLists.txt +++ b/src/modules/screen/CMakeLists.txt @@ -29,7 +29,7 @@ else () endif () add_library(screen ${SOURCES} ${OS_SPECIFIC_SOURCES} ${HEADERS} ${OS_SPECIFIC_HEADERS}) -target_compile_features(screen PRIVATE cxx_std_14) +target_compile_features(screen PRIVATE cxx_std_17) target_include_directories(screen PRIVATE .. ../.. diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt index 9d65c3c8ed..310fb71439 100644 --- a/src/protocol/CMakeLists.txt +++ b/src/protocol/CMakeLists.txt @@ -59,7 +59,7 @@ set(HEADERS ) add_library(protocol ${SOURCES} ${HEADERS}) -target_compile_features(protocol PRIVATE cxx_std_14) +target_compile_features(protocol PRIVATE cxx_std_17) target_include_directories(protocol PRIVATE .. ${BOOST_INCLUDE_PATH} diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index 9450b93c3b..240374feda 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -31,7 +31,7 @@ set(HEADERS ) add_executable(casparcg ${SOURCES} ${HEADERS} ${OS_SPECIFIC_SOURCES}) -target_compile_features(casparcg PRIVATE cxx_std_14) +target_compile_features(casparcg PRIVATE cxx_std_17) target_include_directories(casparcg PRIVATE .. ${BOOST_INCLUDE_PATH} @@ -39,6 +39,7 @@ target_include_directories(casparcg PRIVATE ) source_group(sources ./*) +add_dependencies(casparcg cef) target_link_libraries(casparcg accelerator @@ -74,10 +75,6 @@ if (MSVC) avdevice.lib swscale.lib swresample.lib - - d3d9.lib - d3d11.lib - dxgi.lib ) else () target_link_libraries(casparcg @@ -101,6 +98,7 @@ else () endif () add_custom_target(casparcg_copy_dependencies ALL) +add_dependencies(casparcg_copy_dependencies cef) set(OUTPUT_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") add_custom_command(TARGET casparcg_copy_dependencies POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory \"${OUTPUT_FOLDER}\") @@ -128,19 +126,20 @@ else () # Disabled as HTML module is disabled if (ENABLE_HTML) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CEF_RESOURCE_PATH}/locales ${CMAKE_BINARY_DIR}/staging/bin/locales) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/cef.pak ${CMAKE_BINARY_DIR}/staging/bin/cef.pak) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/cef_100_percent.pak ${CMAKE_BINARY_DIR}/staging/bin/cef_100_percent.pak) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/cef_200_percent.pak ${CMAKE_BINARY_DIR}/staging/bin/cef_200_percent.pak) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/cef_extensions.pak ${CMAKE_BINARY_DIR}/staging/bin/cef_extensions.pak) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/devtools_resources.pak ${CMAKE_BINARY_DIR}/staging/bin/devtools_resources.pak) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/icudtl.dat ${CMAKE_BINARY_DIR}/staging/bin/icudtl.dat) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CEF_BIN_PATH}/swiftshader ${CMAKE_BINARY_DIR}/staging/bin/swiftshader) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/natives_blob.bin ${CMAKE_BINARY_DIR}/staging/bin/natives_blob.bin) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/snapshot_blob.bin ${CMAKE_BINARY_DIR}/staging/bin/snapshot_blob.bin) - ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/v8_context_snapshot.bin ${CMAKE_BINARY_DIR}/staging/bin/v8_context_snapshot.bin) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CEF_RESOURCE_PATH}/locales ${CMAKE_BINARY_DIR}/staging/lib/locales) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/chrome_100_percent.pak ${CMAKE_BINARY_DIR}/staging/lib/chrome_100_percent.pak) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/chrome_200_percent.pak ${CMAKE_BINARY_DIR}/staging/lib/chrome_200_percent.pak) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/icudtl.dat ${CMAKE_BINARY_DIR}/staging/lib/icudtl.dat) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_RESOURCE_PATH}/resources.pak ${CMAKE_BINARY_DIR}/staging/lib/resources.pak) + + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/chrome-sandbox ${CMAKE_BINARY_DIR}/staging/lib/chrome-sandbox) ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/libcef.so ${CMAKE_BINARY_DIR}/staging/lib/libcef.so) ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/libEGL.so ${CMAKE_BINARY_DIR}/staging/lib/libEGL.so) ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/libGLESv2.so ${CMAKE_BINARY_DIR}/staging/lib/libGLESv2.so) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/libvk_swiftshader.so ${CMAKE_BINARY_DIR}/staging/lib/libvk_swiftshader.so) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/libvulkan.so.1 ${CMAKE_BINARY_DIR}/staging/lib/libvulkan.so.1) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/snapshot_blob.bin ${CMAKE_BINARY_DIR}/staging/lib/snapshot_blob.bin) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/v8_context_snapshot.bin ${CMAKE_BINARY_DIR}/staging/lib/v8_context_snapshot.bin) + ADD_CUSTOM_COMMAND (TARGET casparcg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CEF_BIN_PATH}/vk_swiftshader_icd.json ${CMAKE_BINARY_DIR}/staging/lib/vk_swiftshader_icd.json) endif () endif () diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 3bc1d380bc..200ba110ca 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.16) add_executable(bin2c bin2c.cpp) -target_compile_features(bin2c PRIVATE cxx_std_14) +target_compile_features(bin2c PRIVATE cxx_std_17) target_include_directories(bin2c PRIVATE ..) diff --git a/tools/linux/Dockerfile b/tools/linux/Dockerfile index 292af505d8..48f872e8c6 100644 --- a/tools/linux/Dockerfile +++ b/tools/linux/Dockerfile @@ -1,16 +1,13 @@ ARG IMAGE_BASE ARG IMAGE_BOOST ARG IMAGE_FFMPEG -ARG IMAGE_CEF FROM ${IMAGE_BOOST} as boost FROM ${IMAGE_FFMPEG} as ffmpeg -FROM ${IMAGE_CEF} as cef FROM ${IMAGE_BASE} as build-casparcg COPY --from=boost /opt/boost /opt/boost COPY --from=ffmpeg /opt/ffmpeg /opt/ffmpeg - COPY --from=cef /opt/cef /opt/cef RUN mkdir /source && mkdir /build && mkdir /install diff --git a/tools/linux/build-base-images b/tools/linux/build-base-images index a6deab5b49..769aa8a19f 100755 --- a/tools/linux/build-base-images +++ b/tools/linux/build-base-images @@ -2,6 +2,6 @@ source $(dirname "$0")/image-versions -docker rmi $IMAGE_BASE $IMAGE_CEF $IMAGE_BOOST $IMAGE_FFMPEG +docker rmi $IMAGE_BASE $IMAGE_BOOST $IMAGE_FFMPEG $(dirname "$0")/ensure-base-images diff --git a/tools/linux/build-in-docker b/tools/linux/build-in-docker index 745764f4c4..c53f0e7fb4 100755 --- a/tools/linux/build-in-docker +++ b/tools/linux/build-in-docker @@ -10,7 +10,6 @@ docker build -t casparcg/server \ --build-arg PROC_COUNT \ --build-arg GIT_HASH \ --build-arg IMAGE_BASE \ - --build-arg IMAGE_CEF \ --build-arg IMAGE_BOOST \ --build-arg IMAGE_FFMPEG \ -f $PWD/tools/linux/Dockerfile $PWD diff --git a/tools/linux/cef/Dockerfile b/tools/linux/cef/Dockerfile deleted file mode 100644 index 34bf3f200a..0000000000 --- a/tools/linux/cef/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -ARG IMAGE_BASE - -FROM ${IMAGE_BASE} as BUILD - ARG PROC_COUNT=8 - - ADD https://cef-builds.spotifycdn.com/cef_binary_3.3578.1870.gc974488_linux64_minimal.tar.bz2 /opt/cef.tar.bz2 - WORKDIR /opt - RUN tar -jxf cef.tar.bz2 && mv /opt/cef_binary_* /opt/cef - RUN mkdir /opt/build - WORKDIR /opt/build - RUN cmake /opt/cef -DCEF_CXX_COMPILER_FLAGS="-Wno-attributes" && make -j $PROC_COUNT - RUN cp /opt/build/libcef_dll_wrapper/libcef_dll_wrapper.a /opt/cef/Release/ - RUN strip /opt/cef/Release/libcef.so - -FROM scratch - COPY --from=BUILD /opt/cef /opt/cef diff --git a/tools/linux/ensure-base-images b/tools/linux/ensure-base-images index 8b4b7f425a..e087b343ea 100755 --- a/tools/linux/ensure-base-images +++ b/tools/linux/ensure-base-images @@ -3,13 +3,11 @@ source $(dirname "$0")/image-versions docker pull $IMAGE_BASE || docker build --pull -f tools/linux/base/Dockerfile -t $IMAGE_BASE tools/linux -docker pull $IMAGE_CEF || docker build -t $IMAGE_CEF --build-arg PROC_COUNT --build-arg IMAGE_BASE tools/linux/cef docker pull $IMAGE_BOOST || docker build -t $IMAGE_BOOST --build-arg PROC_COUNT --build-arg IMAGE_BASE tools/linux/boost docker pull $IMAGE_FFMPEG || docker build -t $IMAGE_FFMPEG --build-arg PROC_COUNT --build-arg IMAGE_BASE tools/linux/ffmpeg if [ "$CASPARCG_PUSH_IMAGES" = true ]; then docker push $IMAGE_BASE - docker push $IMAGE_CEF docker push $IMAGE_BOOST docker push $IMAGE_FFMPEG fi diff --git a/tools/linux/extract-deps-from-docker b/tools/linux/extract-deps-from-docker index d0155d2c65..0be143bf90 100755 --- a/tools/linux/extract-deps-from-docker +++ b/tools/linux/extract-deps-from-docker @@ -2,13 +2,6 @@ source $(dirname "$0")/image-versions -# CEF -echo "Extracting CEF" -rm -Rf /opt/cef -tempContainer=$(docker create $IMAGE_CEF sh) -docker cp $tempContainer:/opt/cef /opt/cef -docker rm -v $tempContainer - # FFmpeg echo "Extracting FFmpeg" rm -Rf /opt/ffmpeg diff --git a/tools/linux/image-versions b/tools/linux/image-versions index e4bc706190..994afb6efa 100644 --- a/tools/linux/image-versions +++ b/tools/linux/image-versions @@ -3,6 +3,5 @@ export IMAGE_PREFIX=ghcr.io/casparcg/server/ export IMAGE_BASE=${IMAGE_PREFIX}base:jammy-0 -export IMAGE_CEF=${IMAGE_PREFIX}cef:3.3578.1870-5 export IMAGE_BOOST=${IMAGE_PREFIX}boost:1.67-2 export IMAGE_FFMPEG=${IMAGE_PREFIX}ffmpeg:5.1.3-1