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];
33 if (!descriptor.label.empty()) {
34 desc.label = @(descriptor.label.c_str());
37 auto mtl_sampler = [device_ newSamplerStateWithDescriptor:desc];
42 std::shared_ptr<SamplerMTL>(
new SamplerMTL(descriptor, mtl_sampler));
43 if (!sampler->IsValid()) {
46 samplers_[descriptor] = sampler;