17 const std::shared_ptr<YUVConversionVK>& yuv_conversion) {
25 vk::StructureChain<vk::SamplerCreateInfo,
27 vk::SamplerYcbcrConversionInfo>
30 auto& sampler_info = sampler_chain.get();
32 sampler_info.magFilter = mag_filter;
33 sampler_info.minFilter = min_filter;
34 sampler_info.addressModeU = address_mode_u;
35 sampler_info.addressModeV = address_mode_v;
36 sampler_info.addressModeW = address_mode_w;
37 sampler_info.borderColor = vk::BorderColor::eFloatTransparentBlack;
41 switch (
desc.mip_filter) {
43 sampler_info.mipmapMode = vk::SamplerMipmapMode::eNearest;
44 sampler_info.minLod = sampler_info.maxLod = 0.0f;
47 sampler_info.mipmapMode = vk::SamplerMipmapMode::eNearest;
50 sampler_info.mipmapMode = vk::SamplerMipmapMode::eLinear;
54 if (yuv_conversion && yuv_conversion->IsValid()) {
55 sampler_chain.get<vk::SamplerYcbcrConversionInfo>().conversion =
56 yuv_conversion->GetConversion();
77 sampler_info.magFilter = vk::Filter::eNearest;
78 sampler_info.minFilter = vk::Filter::eNearest;
87 sampler_info.addressModeU = vk::SamplerAddressMode::eClampToEdge;
88 sampler_info.addressModeV = vk::SamplerAddressMode::eClampToEdge;
89 sampler_info.addressModeW = vk::SamplerAddressMode::eClampToEdge;
90 sampler_info.anisotropyEnable =
false;
91 sampler_info.unnormalizedCoordinates =
false;
93 sampler_chain.unlink<vk::SamplerYcbcrConversionInfo>();
96 auto sampler =
device.createSamplerUnique(sampler_chain.get());
97 if (sampler.result != vk::Result::eSuccess) {
103 if (!
desc.label.empty()) {
107 return std::move(sampler.value);
112 std::shared_ptr<YUVConversionVK> yuv_conversion)
117 yuv_conversion_(
std::move(yuv_conversion)) {
118 is_valid_ = sampler_ && !!sampler_->Get();
128 std::shared_ptr<YUVConversionVK> conversion)
const {
129 if (!conversion || !is_valid_) {
132 return std::make_shared<SamplerVK>(device_,
desc_, std::move(conversion));
136 return yuv_conversion_;
bool SetDebugName(T handle, std::string_view label) const
vk::Sampler GetSampler() const
SamplerVK(const vk::Device &device, SamplerDescriptor desc, std::shared_ptr< YUVConversionVK > yuv_conversion={})
std::shared_ptr< SamplerVK > CreateVariantForConversion(std::shared_ptr< YUVConversionVK > conversion) const
const std::shared_ptr< YUVConversionVK > & GetYUVConversion() const
std::function< ProfileSample(void)> Sampler
Sampler is run during SamplingProfiler::SampleRepeatedly. Each platform should implement its version ...
constexpr vk::SamplerAddressMode ToVKSamplerAddressMode(SamplerAddressMode mode)
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
@ kBase
The texture is sampled as if it only had a single mipmap level.
@ kNearest
The nearst mipmap level is selected.
constexpr vk::Filter ToVKSamplerMinMagFilter(MinMagFilter filter)
auto MakeSharedVK(vk::UniqueHandle< T, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE > handle)
static vk::UniqueSampler CreateSampler(const vk::Device &device, const SamplerDescriptor &desc, const std::shared_ptr< YUVConversionVK > &yuv_conversion)
static SkString to_string(int n)
#define VK_LOD_CLAMP_NONE