#import <Metal/Metal.h>
#import <objc/runtime.h>

@interface CustomMTLDevice : NSObject <MTLDevice>
@property (nonatomic, strong) id<MTLDevice> originalDevice;
@property (nonatomic, strong) NSString *customName;
- (instancetype)initWithOriginalDevice:(id<MTLDevice>)device customName:(NSString *)name;
@end

@implementation CustomMTLDevice

- (instancetype)initWithOriginalDevice:(id<MTLDevice>)device customName:(NSString *)name {
    if (self = [super init]) {
        _originalDevice = device;
        _customName = name;
    }
    return self;
}

- (NSString *)name {
    return self.customName ?: [self.originalDevice name];
}

- (id)forwardingTargetForSelector:(SEL)aSelector {
    return self.originalDevice;
}

@end