From bdafb3564f3ac2f8f0c5a0fcafd4959bbb8f7d16 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 23 Sep 2021 15:30:56 +0200 Subject: [PATCH] gpu,app: [Metal] don't store CFTypeRef values in pointer types CFTypeRefs may not always contain valid pointers, so they must not be stored in pointer types lest the Go runtime treats them as such. Signed-off-by: Elias Naur --- app/metal_darwin.go | 7 +++---- gpu/headless/headless_darwin.go | 5 ++--- gpu/internal/driver/api.go | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/metal_darwin.go b/app/metal_darwin.go index 012bd2fc..06b89f3b 100644 --- a/app/metal_darwin.go +++ b/app/metal_darwin.go @@ -7,7 +7,6 @@ package app import ( "errors" - "unsafe" "gioui.org/gpu" ) @@ -123,14 +122,14 @@ func (c *mtlContext) RenderTarget() (gpu.RenderTarget, error) { return nil, errors.New("metal: CADrawable.texture is nil") } return gpu.MetalRenderTarget{ - Texture: unsafe.Pointer(c.texture), + Texture: uintptr(c.texture), }, nil } func (c *mtlContext) API() gpu.API { return gpu.Metal{ - Device: unsafe.Pointer(c.dev), - Queue: unsafe.Pointer(c.queue), + Device: uintptr(c.dev), + Queue: uintptr(c.queue), PixelFormat: int(C.MTLPixelFormatBGRA8Unorm_sRGB), } } diff --git a/gpu/headless/headless_darwin.go b/gpu/headless/headless_darwin.go index 9a61f95f..6be7fddc 100644 --- a/gpu/headless/headless_darwin.go +++ b/gpu/headless/headless_darwin.go @@ -4,7 +4,6 @@ package headless import ( "errors" - "unsafe" "gioui.org/gpu" _ "gioui.org/internal/cocoainit" @@ -54,8 +53,8 @@ func init() { func (c *mtlContext) API() gpu.API { return gpu.Metal{ - Device: unsafe.Pointer(c.dev), - Queue: unsafe.Pointer(c.queue), + Device: uintptr(c.dev), + Queue: uintptr(c.queue), PixelFormat: int(C.MTLPixelFormatRGBA8Unorm_sRGB), } } diff --git a/gpu/internal/driver/api.go b/gpu/internal/driver/api.go index a0297430..12b4e1a9 100644 --- a/gpu/internal/driver/api.go +++ b/gpu/internal/driver/api.go @@ -28,7 +28,7 @@ type Direct3D11RenderTarget struct { type MetalRenderTarget struct { // Texture is a MTLTexture. - Texture unsafe.Pointer + Texture uintptr } type VulkanRenderTarget struct { @@ -59,9 +59,9 @@ type Direct3D11 struct { type Metal struct { // Device is an MTLDevice. - Device unsafe.Pointer + Device uintptr // Queue is a MTLCommandQueue. - Queue unsafe.Pointer + Queue uintptr // PixelFormat is the MTLPixelFormat of the default framebuffer. PixelFormat int }