Flutter Impeller
sampler_library_vk.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
9 
10 namespace impeller {
11 
13  const std::weak_ptr<DeviceHolderVK>& device_holder)
14  : device_holder_(device_holder) {}
15 
17 
19  mips_disabled_workaround_ = workarounds.broken_mipmap_generation;
20 }
21 
22 raw_ptr<const Sampler> SamplerLibraryVK::GetSampler(
23  const SamplerDescriptor& desc) {
24  SamplerDescriptor desc_copy = desc;
25  if (mips_disabled_workaround_) {
26  desc_copy.mip_filter = MipFilter::kBase;
27  }
28 
29  uint64_t p_key = SamplerDescriptor::ToKey(desc_copy);
30  for (const auto& [key, value] : samplers_) {
31  if (key == p_key) {
32  return raw_ptr(value);
33  }
34  }
35  auto device_holder = device_holder_.lock();
36  if (!device_holder || !device_holder->GetDevice()) {
37  return raw_ptr<const Sampler>(nullptr);
38  }
39  samplers_.push_back(std::make_pair(
40  p_key,
41  std::make_shared<SamplerVK>(device_holder->GetDevice(), desc_copy)));
42  return raw_ptr(samplers_.back().second);
43 }
44 
45 } // namespace impeller
SamplerLibraryVK(const std::weak_ptr< DeviceHolderVK > &device_holder)
void ApplyWorkarounds(const WorkaroundsVK &workarounds)
A wrapper around a raw ptr that adds additional unopt mode only checks.
Definition: raw_ptr.h:15
int32_t value
@ kBase
The texture is sampled as if it only had a single mipmap level.
static uint64_t ToKey(const SamplerDescriptor &d)
A non-exhaustive set of driver specific workarounds.