From 6e3cbe2e336973b59551a513793e84ce159f7c2a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 7 Nov 2020 03:26:35 +0900 Subject: [PATCH] graphicsdriver/metal/mtl: Refactoring --- internal/graphicsdriver/metal/mtl/mtl.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/graphicsdriver/metal/mtl/mtl.go b/internal/graphicsdriver/metal/mtl/mtl.go index 090f25502..0fe4ead98 100644 --- a/internal/graphicsdriver/metal/mtl/mtl.go +++ b/internal/graphicsdriver/metal/mtl/mtl.go @@ -33,11 +33,8 @@ import ( // #cgo !ios CFLAGS: -mmacosx-version-min=10.12 // #cgo LDFLAGS: -framework Metal -framework CoreGraphics -framework Foundation // -// #include // #include "mtl.h" -// struct Library Go_Device_MakeLibrary(void * device, _GoString_ source) { -// return Device_MakeLibrary(device, _GoStringPtr(source), _GoStringLen(source)); -// } +// #include import "C" // FeatureSet defines a specific platform, hardware, and software configuration. @@ -436,7 +433,10 @@ func (d Device) MakeCommandQueue() CommandQueue { // // Reference: https://developer.apple.com/documentation/metal/mtldevice/1433431-makelibrary. func (d Device) MakeLibrary(source string, opt CompileOptions) (Library, error) { - l := C.Go_Device_MakeLibrary(d.device, source) // TODO: opt. + cs := C.CString(source) + defer C.free(unsafe.Pointer(cs)) + + l := C.Device_MakeLibrary(d.device, cs, C.size_t(len(source))) if l.Library == nil { return Library{}, errors.New(C.GoString(l.Error)) }