diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7d5c33123..27169f2d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,7 +125,7 @@ jobs: if: steps.cef-cache.outputs.cache-hit != 'true' shell: bash run: | - curl -L -O https://obs-nightly.s3-us-west-2.amazonaws.com/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64.tar.bz2 + curl -L -O https://cdn-fastly.obsproject.com/downloads/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64.tar.bz2 tar -xf ./cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64.tar.bz2 -C ${{ github.workspace }}/cmbuild/ cd ${{ github.workspace }}/cmbuild/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64 sed -i '.orig' '/add_subdirectory(tests\/ceftests)/d' ./CMakeLists.txt diff --git a/CI/full-build-macos.sh b/CI/full-build-macos.sh index 6efc4345f..80a73fc5b 100755 --- a/CI/full-build-macos.sh +++ b/CI/full-build-macos.sh @@ -212,13 +212,13 @@ install_cef() { hr "Building dependency CEF v${1}" ensure_dir ${DEPS_BUILD_DIR} step "Download..." - ${CURLCMD} --progress-bar -L -C - -O https://obs-nightly.s3-us-west-2.amazonaws.com/cef_binary_${1}_macosx64.tar.bz2 + ${CURLCMD} --progress-bar -L -C - -O https://cdn-fastly.obsproject.com/downloads/cef_binary_${1}_macosx64.tar.bz2 step "Unpack..." tar -xf ./cef_binary_${1}_macosx64.tar.bz2 cd ./cef_binary_${1}_macosx64 step "Fix tests..." sed -i '.orig' '/add_subdirectory(tests\/ceftests)/d' ./CMakeLists.txt - sed -i '.orig' s/\"10.9\"/\"${MIN_MACOS_VERSION:-${CI_MIN_MACOS_VERSION}}\"/ ./cmake/cef_variables.cmake + sed -i '.orig' 's/"'$(test "${CEF_BUILD_VERSION:-${CI_CEF_VERSION}}" -le 3770 && echo "10.9" || echo "10.10")'"/"'${MIN_MACOS_VERSION:-${CI_MIN_MACOS_VERSION}}'"/' ./cmake/cef_variables.cmake ensure_dir ./build step "Run CMAKE..." cmake \ diff --git a/libobs-opengl/gl-cocoa.m b/libobs-opengl/gl-cocoa.m index dd2a74969..83a245fe6 100644 --- a/libobs-opengl/gl-cocoa.m +++ b/libobs-opengl/gl-cocoa.m @@ -339,7 +339,7 @@ gs_texture_t *device_texture_create_from_iosurface(gs_device_t *device, tex->base.gl_format = convert_gs_format(color_format); tex->base.gl_internal_format = convert_gs_internal_format(color_format); tex->base.gl_type = GL_UNSIGNED_INT_8_8_8_8_REV; - tex->base.gl_target = GL_TEXTURE_RECTANGLE; + tex->base.gl_target = GL_TEXTURE_RECTANGLE_ARB; tex->base.is_dynamic = false; tex->base.is_render_target = false; tex->base.gen_mipmaps = false; @@ -381,6 +381,20 @@ fail: return NULL; } +gs_texture_t *device_texture_open_shared(gs_device_t *device, uint32_t handle) +{ + gs_texture_t *texture = NULL; + IOSurfaceRef ref = IOSurfaceLookupFromMachPort((mach_port_t)handle); + texture = device_texture_create_from_iosurface(device, ref); + CFRelease(ref); + return texture; +} + +bool device_shared_texture_available(void) +{ + return true; +} + bool gs_texture_rebind_iosurface(gs_texture_t *texture, void *iosurf) { if (!texture) diff --git a/libobs/graphics/graphics-imports.c b/libobs/graphics/graphics-imports.c index 8259366b8..2a68f749f 100644 --- a/libobs/graphics/graphics-imports.c +++ b/libobs/graphics/graphics-imports.c @@ -193,6 +193,8 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, /* OSX/Cocoa specific functions */ #ifdef __APPLE__ + GRAPHICS_IMPORT(device_shared_texture_available); + GRAPHICS_IMPORT_OPTIONAL(device_texture_open_shared); GRAPHICS_IMPORT_OPTIONAL(device_texture_create_from_iosurface); GRAPHICS_IMPORT_OPTIONAL(gs_texture_rebind_iosurface); diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h index 865a3f3ff..230ae6ff1 100644 --- a/libobs/graphics/graphics-internal.h +++ b/libobs/graphics/graphics-internal.h @@ -271,8 +271,11 @@ struct gs_exports { /* OSX/Cocoa specific functions */ gs_texture_t *(*device_texture_create_from_iosurface)(gs_device_t *dev, void *iosurf); + gs_texture_t *(*device_texture_open_shared)(gs_device_t *dev, + uint32_t *handle); bool (*gs_texture_rebind_iosurface)(gs_texture_t *texture, void *iosurf); + bool (*device_shared_texture_available)(void); #elif _WIN32 bool (*device_gdi_texture_available)(void); diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index 5cc55ec71..39e03a3d8 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -2756,6 +2756,26 @@ bool gs_texture_rebind_iosurface(gs_texture_t *texture, void *iosurf) return graphics->exports.gs_texture_rebind_iosurface(texture, iosurf); } +bool gs_shared_texture_available(void) +{ + if (!gs_valid("gs_shared_texture_available")) + return false; + + return thread_graphics->exports.device_shared_texture_available(); +} + +gs_texture_t *gs_texture_open_shared(uint32_t handle) +{ + graphics_t *graphics = thread_graphics; + if (!gs_valid("gs_texture_open_shared")) + return NULL; + + if (graphics->exports.device_texture_open_shared) + return graphics->exports.device_texture_open_shared( + graphics->device, handle); + return NULL; +} + #elif _WIN32 bool gs_gdi_texture_available(void) diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index 2746a87b4..d356175fa 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -831,6 +831,8 @@ EXPORT void gs_debug_marker_end(void); * from shared surface resources */ EXPORT gs_texture_t *gs_texture_create_from_iosurface(void *iosurf); EXPORT bool gs_texture_rebind_iosurface(gs_texture_t *texture, void *iosurf); +EXPORT gs_texture_t *gs_texture_open_shared(uint32_t handle); +EXPORT bool gs_shared_texture_available(void); #elif _WIN32