25 return MTLSamplerAddressModeClampToEdge;
27 return MTLSamplerAddressModeRepeat;
29 return MTLSamplerAddressModeMirrorRepeat;
36 if (@available(macOS 10.12, iOS 14.0, tvOS 14.0, *)) {
38 return MTLSamplerAddressModeClampToBorderColor;
41 return MTLSamplerAddressModeClampToZero;
51 sk_cfp<MTLSamplerDescriptor*> desc([[MTLSamplerDescriptor alloc] init]);
53 MTLSamplerMinMagFilter minMagFilter = [&] {
54 switch (samplingOptions.
filter) {
61 MTLSamplerMipFilter mipFilter = [&] {
62 switch (samplingOptions.
mipmap) {
70 (*desc).rAddressMode = MTLSamplerAddressModeClampToEdge;
73 (*desc).magFilter = minMagFilter;
74 (*desc).minFilter = minMagFilter;
75 (*desc).mipFilter = mipFilter;
76 (*desc).lodMinClamp = 0.0f;
77 (*desc).lodMaxClamp = FLT_MAX;
78 (*desc).maxAnisotropy = 1;
79 (*desc).normalizedCoordinates =
true;
80 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
81 (*desc).compareFunction = MTLCompareFunctionNever;
83#ifdef SK_ENABLE_MTL_DEBUG_INFO
84 NSString* tileModeLabels[] = {
90 NSString* minMagFilterLabels[] = {
94 NSString* mipFilterLabels[] = {
100 (*desc).label = [NSString stringWithFormat:
@"X%@Y%@%@%@",
101 tileModeLabels[(
int)xTileMode],
102 tileModeLabels[(
int)yTileMode],
103 minMagFilterLabels[(
int)samplingOptions.
filter],
104 mipFilterLabels[(
int)samplingOptions.
mipmap]];
107 sk_cfp<id<MTLSamplerState>> sampler(
108 [sharedContext->
device() newSamplerStateWithDescriptor:desc.get()]);
const MtlCaps & mtlCaps() const
id< MTLDevice > device() const