12 SamplerLibraryMTL::SamplerLibraryMTL(id<MTLDevice> device) : device_(device) {}
16 std::shared_ptr<const Sampler> SamplerLibraryMTL::GetSampler(
17 SamplerDescriptor descriptor) {
18 auto found = samplers_.find(descriptor);
19 if (found != samplers_.end()) {
25 auto desc = [[MTLSamplerDescriptor alloc] init];
32 if (@available(iOS 14.0, macos 10.12, *)) {
33 desc.borderColor = MTLSamplerBorderColorTransparentBlack;
35 if (!descriptor.label.empty()) {
36 desc.label = @(descriptor.label.c_str());
39 auto mtl_sampler = [device_ newSamplerStateWithDescriptor:desc];
44 std::shared_ptr<SamplerMTL>(
new SamplerMTL(descriptor, mtl_sampler));
45 if (!sampler->IsValid()) {
48 samplers_[descriptor] = sampler;