1 /* 2 * Copyright 2023 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef skgpu_graphite_VulkanSampler_DEFINED 9 #define skgpu_graphite_VulkanSampler_DEFINED 10 11 #include "src/gpu/graphite/Sampler.h" 12 #include "src/gpu/graphite/vk/VulkanSharedContext.h" 13 #include "src/gpu/graphite/vk/VulkanYcbcrConversion.h" 14 15 #include "include/core/SkRefCnt.h" 16 #include "include/core/SkTileMode.h" 17 18 struct SkSamplingOptions; 19 20 namespace skgpu::graphite { 21 22 class VulkanSampler : public Sampler { 23 public: 24 static sk_sp<VulkanSampler> Make(const VulkanSharedContext*, 25 const SamplerDesc&, 26 sk_sp<VulkanYcbcrConversion> ycbcrConversion = nullptr); ~VulkanSampler()27 ~VulkanSampler() override {} 28 vkSampler()29 VkSampler vkSampler() const { return fSampler; } 30 ycbcrConversion()31 const VulkanYcbcrConversion* ycbcrConversion() const { return fYcbcrConversion.get(); } 32 samplerDesc()33 const SamplerDesc& samplerDesc() const { return fDesc; } 34 constVkSamplerPtr()35 const VkSampler* constVkSamplerPtr() const { return &fSampler; } 36 37 private: 38 VulkanSampler(const VulkanSharedContext*, 39 const SamplerDesc&, 40 VkSampler, 41 sk_sp<VulkanYcbcrConversion>); 42 43 void freeGpuData() override; 44 45 // It's helpful to store the sampler desc such that when we create a descriptor for this sampler 46 // we can easily access the numerical sampler representation. 47 const SamplerDesc fDesc; 48 49 VkSampler fSampler; 50 sk_sp<VulkanYcbcrConversion> fYcbcrConversion; 51 }; 52 53 } // namepsace skgpu::graphite 54 55 #endif // skgpu_graphite_VulkanSampler_DEFINED 56