Skip to content

Commit c1af86d

Browse files
committed
wip: metal support
1 parent 77d8f1d commit c1af86d

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

macos/metal/functions.gen.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// AUTO-GENERATED CODE, DO NOT MODIFY
2+
3+
package metal
4+
5+
// #import <stdlib.h>
6+
// #import <stdint.h>
7+
// #import <stdbool.h>
8+
// #import "Metal/Metal.h"
9+
// void * CreateSystemDefaultDevice();
10+
import "C"
11+
import (
12+
"github.com/progrium/macdriver/objc"
13+
)
14+
15+
// Returns the device instance Metal selects as the default. [Full Topic]
16+
//
17+
// [Full Topic]: https://developer.apple.com/documentation/metal/1433401-mtlcreatesystemdefaultdevice?language=objc
18+
func CreateSystemDefaultDevice() DeviceWrapper {
19+
rv := C.CreateSystemDefaultDevice()
20+
// *typing.ProtocolType
21+
return DeviceWrapper{objc.ObjectFrom(rv)}
22+
}

macos/metal/functions.gen.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// AUTO-GENERATED CODE, DO NOT MODIFY
2+
3+
#import "Metal/Metal.h"
4+
void * CreateSystemDefaultDevice() {
5+
return (void *)MTLCreateSystemDefaultDevice(
6+
);
7+
}

macos/metal/metal_structs.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ type Coordinate2D = SamplePosition
88
type Region struct{}
99
type Origin struct{}
1010
type TextureSwizzleChannels struct{}
11-
type Size struct{}
11+
type Size struct {
12+
Width uint
13+
Height uint
14+
Depth uint
15+
}
1216
type Viewport struct{}
1317
type ScissorRect struct{}
1418
type VertexAmplificationViewMapping struct{}

macos/metal/metal_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ import "testing"
55
func TestMetalValid(t *testing.T) {
66

77
}
8+
9+
func TestCreateSystemDefaultDevice(t *testing.T) {
10+
d := CreateSystemDefaultDevice()
11+
t.Log(d.HasSupportsFamily())
12+
t.Log(d.SupportsFamily(GPUFamily(5001)))
13+
t.Log("MaxThreadgroupMemoryLength", d.MaxThreadgroupMemoryLength())
14+
t.Log("MaxBufferLength", d.MaxBufferLength())
15+
t.Log("MaxThreadsPerThreadgroup", d.MaxThreadsPerThreadgroup())
16+
}

macos/metal/structs.gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// AUTO-GENERATED CODE, DO NOT MODIFY
2+
3+
package metal

0 commit comments

Comments
 (0)