diff --git a/src/vulkan/wsi/wsi_common_metal.c b/src/vulkan/wsi/wsi_common_metal.c index d7f6f804072..16dede98600 100644 --- a/src/vulkan/wsi/wsi_common_metal.c +++ b/src/vulkan/wsi/wsi_common_metal.c @@ -252,7 +252,7 @@ wsi_metal_surface_get_present_rectangles(VkIcdSurfaceBase *surface, struct wsi_metal_image { struct wsi_image base; - CAMetalDrawable *drawable; + CAMetalDrawableBridged *drawable; }; struct wsi_metal_swapchain { @@ -302,7 +302,7 @@ wsi_metal_swapchain_acquire_next_image(struct wsi_swapchain *wsi_chain, while (1) { /* Try to acquire an drawable. Unfortunately we might block for up to 1 second. */ - CAMetalDrawable *drawable = wsi_metal_layer_acquire_drawable(chain->surface->pLayer); + CAMetalDrawableBridged *drawable = wsi_metal_layer_acquire_drawable(chain->surface->pLayer); if (drawable) { uint32_t i = (chain->current_image_index++) % chain->base.image_count; *image_index = i; diff --git a/src/vulkan/wsi/wsi_common_metal_layer.h b/src/vulkan/wsi/wsi_common_metal_layer.h index cd88cbe3409..f70104f17fe 100644 --- a/src/vulkan/wsi/wsi_common_metal_layer.h +++ b/src/vulkan/wsi/wsi_common_metal_layer.h @@ -12,12 +12,10 @@ #ifdef __OBJC__ @class CAMetalLayer; -@class CAMetalDrawable; typedef unsigned long NSUInteger; typedef enum MTLPixelFormat : NSUInteger MTLPixelFormat; #else typedef void CAMetalLayer; -typedef void CAMetalDrawable; typedef enum MTLPixelFormat : unsigned long { MTLPixelFormatBGRA8Unorm = 80, @@ -28,6 +26,8 @@ typedef enum MTLPixelFormat : unsigned long } MTLPixelFormat; #endif +typedef void CAMetalDrawableBridged; + void wsi_metal_layer_size(const CAMetalLayer *metal_layer, uint32_t *width, uint32_t *height); @@ -37,7 +37,7 @@ wsi_metal_layer_configure(const CAMetalLayer *metal_layer, uint32_t width, uint32_t height, uint32_t image_count, MTLPixelFormat format, bool enable_opaque, bool enable_immediate); -CAMetalDrawable * +CAMetalDrawableBridged * wsi_metal_layer_acquire_drawable(const CAMetalLayer *metal_layer); struct wsi_metal_layer_blit_context; @@ -49,10 +49,12 @@ void wsi_destroy_metal_layer_blit_context(struct wsi_metal_layer_blit_context *context); void -wsi_metal_layer_blit_and_present(struct wsi_metal_layer_blit_context *context, CAMetalDrawable **drawable_ptr, - void *buffer, uint32_t width, uint32_t height, uint32_t row_pitch); +wsi_metal_layer_blit_and_present(struct wsi_metal_layer_blit_context *context, + CAMetalDrawableBridged **drawable_ptr, void *buffer, + uint32_t width, uint32_t height, uint32_t row_pitch); void -wsi_metal_layer_cancel_present(struct wsi_metal_layer_blit_context *context, CAMetalDrawable **drawable_ptr); +wsi_metal_layer_cancel_present(struct wsi_metal_layer_blit_context *context, + CAMetalDrawableBridged **drawable_ptr); #endif // WSI_COMMON_METAL_LAYER_H diff --git a/src/vulkan/wsi/wsi_common_metal_layer.m b/src/vulkan/wsi/wsi_common_metal_layer.m index 9613253637f..6765d2b3244 100644 --- a/src/vulkan/wsi/wsi_common_metal_layer.m +++ b/src/vulkan/wsi/wsi_common_metal_layer.m @@ -45,12 +45,12 @@ wsi_metal_layer_configure(const CAMetalLayer *metal_layer, } } -CAMetalDrawable * +CAMetalDrawableBridged * wsi_metal_layer_acquire_drawable(const CAMetalLayer *metal_layer) { @autoreleasepool { id drawable = [metal_layer nextDrawable]; - return (CAMetalDrawable *)drawable; + return (__bridge_retained CAMetalDrawableBridged *)drawable; } } @@ -84,11 +84,12 @@ wsi_destroy_metal_layer_blit_context(struct wsi_metal_layer_blit_context *contex } void -wsi_metal_layer_blit_and_present(struct wsi_metal_layer_blit_context *context, CAMetalDrawable **drawable_ptr, - void *buffer, uint32_t width, uint32_t height, uint32_t row_pitch) +wsi_metal_layer_blit_and_present(struct wsi_metal_layer_blit_context *context, + CAMetalDrawableBridged **drawable_ptr, void *buffer, + uint32_t width, uint32_t height, uint32_t row_pitch) { @autoreleasepool { - id drawable = (id)*drawable_ptr; + id drawable = (__bridge_transfer id)*drawable_ptr; id commandBuffer = [context->commandQueue commandBuffer]; id commandEncoder = [commandBuffer blitCommandEncoder]; @@ -117,10 +118,11 @@ wsi_metal_layer_blit_and_present(struct wsi_metal_layer_blit_context *context, C } void -wsi_metal_layer_cancel_present(struct wsi_metal_layer_blit_context *context, CAMetalDrawable **drawable_ptr) +wsi_metal_layer_cancel_present(struct wsi_metal_layer_blit_context *context, + CAMetalDrawableBridged **drawable_ptr) { @autoreleasepool { - id drawable = (id)*drawable_ptr; + id drawable = (__bridge_transfer id)*drawable_ptr; if (drawable == nil) return;