| 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
5 #include "impeller/renderer/backend/vulkan/sampler_library_vk.h"
6
7 #include "impeller/core/formats.h"
8 #include "impeller/renderer/backend/vulkan/sampler_vk.h"
9
10 namespace impeller {
11
12 SamplerLibraryVK::SamplerLibraryVK(
13 const std::weak_ptr<DeviceHolderVK>& device_holder)
14 : device_holder_(device_holder) {}
15
16 SamplerLibraryVK::~SamplerLibraryVK() = default;
17
18 void SamplerLibraryVK::ApplyWorkarounds(const WorkaroundsVK& workarounds) {
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
impeller::MipFilter::kBase
@ kBase
The texture is sampled as if it only had a single mipmap level.
value
int32_t value
Definition: dl_golden_unittests.cc:444
impeller::SamplerLibraryVK::SamplerLibraryVK
SamplerLibraryVK(const std::weak_ptr< DeviceHolderVK > &device_holder)
Definition: sampler_library_vk.cc:12
formats.h
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::SamplerDescriptor::ToKey
static uint64_t ToKey(const SamplerDescriptor &d)
Definition: sampler_descriptor.h:32
impeller::SamplerDescriptor::mip_filter
MipFilter mip_filter
Definition: sampler_descriptor.h:17
impeller::WorkaroundsVK
A non-exhaustive set of driver specific workarounds.
Definition: workarounds_vk.h:13
impeller::raw_ptr
A wrapper around a raw ptr that adds additional unopt mode only checks.
Definition: raw_ptr.h:15
sampler_vk.h
sampler_library_vk.h
impeller::SamplerLibraryVK::~SamplerLibraryVK
~SamplerLibraryVK() override
impeller
Definition: allocation.cc:12
impeller::SamplerLibraryVK::ApplyWorkarounds
void ApplyWorkarounds(const WorkaroundsVK &workarounds)
Definition: sampler_library_vk.cc:18
impeller::WorkaroundsVK::broken_mipmap_generation
bool broken_mipmap_generation
Definition: workarounds_vk.h:36