12SamplerLibraryMTL::SamplerLibraryMTL(id<MTLDevice>
device) : device_(
device) {}
14SamplerLibraryMTL::~SamplerLibraryMTL() =
default;
18const std::unique_ptr<const Sampler>& SamplerLibraryMTL::GetSampler(
20 auto found = samplers_.find(descriptor);
21 if (found != samplers_.end()) {
27 auto desc = [[MTLSamplerDescriptor alloc]
init];
34 if (@available(iOS 14.0, macos 10.12, *)) {
35 desc.borderColor = MTLSamplerBorderColorTransparentBlack;
37 if (!descriptor.
label.empty()) {
41 auto mtl_sampler = [device_ newSamplerStateWithDescriptor:
desc];
46 std::unique_ptr<SamplerMTL>(
new SamplerMTL(descriptor, mtl_sampler));
48 return (samplers_[descriptor] = std::move(sampler));
constexpr MTLSamplerMipFilter ToMTLSamplerMipFilter(MipFilter filter)
constexpr MTLSamplerAddressMode ToMTLSamplerAddressMode(SamplerAddressMode mode)
constexpr MTLSamplerMinMagFilter ToMTLSamplerMinMagFilter(MinMagFilter filter)
static const std::unique_ptr< const Sampler > kNullSampler
SamplerAddressMode depth_address_mode
SamplerAddressMode width_address_mode
SamplerAddressMode height_address_mode