dmitri.shuralyov.com/gpu/mtl/...

deprecate FeatureSet and Device.SupportsFeatureSet

The upstream Metal API has deprecated this part of its API.
Explicitly ignore a compilation warning about the deprecation.
dmitshur committed 2 months ago commit b78c9fe623cca0431d866c9e206d3f83665bcf8b
cmd/mtlinfo/main.go
@@ -69,11 +69,11 @@ func printDeviceInfo(d mtl.Device) {
	fmt.Println("	• Common family 1:", supported(d.SupportsFamily(mtl.GPUFamilyCommon1)))
	fmt.Println("	• Common family 2:", supported(d.SupportsFamily(mtl.GPUFamilyCommon2)))
	fmt.Println("	• Common family 3:", supported(d.SupportsFamily(mtl.GPUFamilyCommon3)))
	fmt.Println("	• Metal 3 features:", supported(d.SupportsFamily(mtl.GPUFamilyMetal3)))
	fmt.Println()
	fmt.Println("	Feature Sets:")
	fmt.Println("	Feature Sets (deprecated):")
	fmt.Println("	• macOS GPU family 1, version 1:", supported(d.SupportsFeatureSet(mtl.MacOSGPUFamily1V1)))
	fmt.Println("	• macOS GPU family 1, version 2:", supported(d.SupportsFeatureSet(mtl.MacOSGPUFamily1V2)))
	fmt.Println("	• macOS read-write texture, tier 2:", supported(d.SupportsFeatureSet(mtl.MacOSReadWriteTextureTier2)))
	fmt.Println("	• macOS GPU family 1, version 3:", supported(d.SupportsFeatureSet(mtl.MacOSGPUFamily1V3)))
	fmt.Println("	• macOS GPU family 1, version 4:", supported(d.SupportsFeatureSet(mtl.MacOSGPUFamily1V4)))
mtl.go
@@ -50,10 +50,12 @@ const (
	GPUFamilyMetal3  GPUFamily = 5001 // Metal 3 features.
)

// FeatureSet defines a specific platform, hardware, and software configuration.
//
// Deprecated: Use GPUFamily instead.
//
// Reference: https://developer.apple.com/documentation/metal/mtlfeatureset.
type FeatureSet uint16

// The device feature sets that define specific platform, hardware, and software configurations.
const (
@@ -365,10 +367,12 @@ func (d Device) SupportsFamily(gf GPUFamily) bool {
	return bool(C.Device_SupportsFamily(d.device, C.uint16_t(gf)))
}

// SupportsFeatureSet reports whether device d supports feature set fs.
//
// Deprecated: Use SupportsFamily instead.
//
// Reference: https://developer.apple.com/documentation/metal/mtldevice/1433418-supportsfeatureset.
func (d Device) SupportsFeatureSet(fs FeatureSet) bool {
	return bool(C.Device_SupportsFeatureSet(d.device, C.uint16_t(fs)))
}

mtl.m
@@ -44,13 +44,16 @@ bool Device_SupportsFamily(void * device, uint16_t gpuFamily) {
		return [(id<MTLDevice>)device supportsFamily:gpuFamily];
	}
	@throw @"API not available";
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
bool Device_SupportsFeatureSet(void * device, uint16_t featureSet) {
	return [(id<MTLDevice>)device supportsFeatureSet:featureSet];
}
#pragma clang diagnostic pop

void * Device_MakeCommandQueue(void * device) {
	return [(id<MTLDevice>)device newCommandQueue];
}