Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::VulkanSampler Class Reference

#include <VulkanSampler.h>

Inheritance diagram for skgpu::graphite::VulkanSampler:
skgpu::graphite::Sampler skgpu::graphite::Resource

Public Member Functions

 ~VulkanSampler () override
 
VkSampler vkSampler () const
 
const VulkanYcbcrConversionycbcrConversion () const
 
- Public Member Functions inherited from skgpu::graphite::Sampler
 ~Sampler () override
 
const char * getResourceType () const override
 
- Public Member Functions inherited from skgpu::graphite::Resource
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
Resourceoperator= (const Resource &)=delete
 
Resourceoperator= (Resource &&)=delete
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
Ownership ownership () const
 
skgpu::Budgeted budgeted () const
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
virtual const char * getResourceType () const =0
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
bool wasDestroyed () const
 
const GraphiteResourceKeykey () const
 
void setKey (const GraphiteResourceKey &key)
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual void prepareForReturnToCache (const std::function< void()> &takeRef)
 

Static Public Member Functions

static sk_sp< VulkanSamplerMake (const VulkanSharedContext *, const SkSamplingOptions &, SkTileMode xTileMode, SkTileMode yTileMode, sk_sp< VulkanYcbcrConversion > ycbcrConversion=nullptr)
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::Sampler
 Sampler (const SharedContext *)
 
- Protected Member Functions inherited from skgpu::graphite::Resource
 Resource (const SharedContext *, Ownership, skgpu::Budgeted, size_t gpuMemorySize, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
virtual void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const
 
void setDeleteASAP ()
 

Detailed Description

Definition at line 22 of file VulkanSampler.h.

Constructor & Destructor Documentation

◆ ~VulkanSampler()

skgpu::graphite::VulkanSampler::~VulkanSampler ( )
inlineoverride

Definition at line 30 of file VulkanSampler.h.

30{}

Member Function Documentation

◆ Make()

sk_sp< VulkanSampler > skgpu::graphite::VulkanSampler::Make ( const VulkanSharedContext sharedContext,
const SkSamplingOptions samplingOptions,
SkTileMode  xTileMode,
SkTileMode  yTileMode,
sk_sp< VulkanYcbcrConversion ycbcrConversion = nullptr 
)
static

Definition at line 37 of file VulkanSampler.cpp.

42 {
43
44 VkSamplerCreateInfo samplerInfo;
45 memset(&samplerInfo, 0, sizeof(VkSamplerCreateInfo));
47 // TODO(b/311392779): If a ycbcrConversion is passed in, assign pNext to
48 // VkSamplerYcbcrConversion.
49 samplerInfo.pNext = nullptr;
50 samplerInfo.flags = 0;
51
52 VkFilter minMagFilter = [&] {
53 switch (samplingOptions.filter) {
56 }
58 }();
59
60 VkSamplerMipmapMode mipmapMode = [&] {
61 switch (samplingOptions.mipmap) {
62 // There is no disable mode. We use max level to disable mip mapping.
63 // It may make more sense to use NEAREST for kNone but Chrome pixel tests have
64 // been dependent on subtle rendering differences introduced by switching this.
68 }
70 }();
71
72 samplerInfo.magFilter = minMagFilter;
73 samplerInfo.minFilter = minMagFilter;
74 samplerInfo.mipmapMode = mipmapMode;
75 samplerInfo.addressModeU = tile_mode_to_vk_sampler_address(xTileMode);
76 samplerInfo.addressModeV = tile_mode_to_vk_sampler_address(yTileMode);
78 samplerInfo.mipLodBias = 0;
79 samplerInfo.anisotropyEnable = VK_FALSE;
80 samplerInfo.maxAnisotropy = 1; // TODO: when we start using aniso, need to add to key
81 samplerInfo.compareEnable = VK_FALSE;
82 samplerInfo.compareOp = VK_COMPARE_OP_NEVER;
83 // Vulkan doesn't have a direct mapping to use nearest or linear filters for minFilter since
84 // there is always a mipmapMode. To get the same effect we can set minLod = maxLod = 0.0.
85 // This works since our min and mag filters are the same (this forces us to use mag on the 0
86 // level mip). If the filters weren't the same we could set min = 0 and max = 0.25 to force
87 // the minFilter on mip level 0.
88 samplerInfo.minLod = 0;
89 samplerInfo.maxLod = (samplingOptions.mipmap == SkMipmapMode::kNone) ? 0.0f : VK_LOD_CLAMP_NONE;
92
93 VkSampler sampler;
96 result,
97 CreateSampler(sharedContext->device(), &samplerInfo, nullptr, &sampler));
98 if (result != VK_SUCCESS) {
99 return nullptr;
100 }
101
102 return sk_sp<VulkanSampler>(new VulkanSampler(sharedContext,
103 sampler,
104 std::move(ycbcrConversion)));
105}
#define SkUNREACHABLE
Definition: SkAssert.h:135
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
const SharedContext * sharedContext() const
Definition: Resource.h:189
const VulkanYcbcrConversion * ycbcrConversion() const
Definition: VulkanSampler.h:34
GAsyncResult * result
static vk::UniqueSampler CreateSampler(const vk::Device &device, const SamplerDescriptor &desc, const std::shared_ptr< YUVConversionVK > &yuv_conversion)
Definition: sampler_vk.cc:14
static VkSamplerAddressMode tile_mode_to_vk_sampler_address(SkTileMode tileMode)
const SkFilterMode filter
const SkMipmapMode mipmap
VkBool32 unnormalizedCoordinates
Definition: vulkan_core.h:3722
VkSamplerAddressMode addressModeU
Definition: vulkan_core.h:3711
VkBool32 anisotropyEnable
Definition: vulkan_core.h:3715
VkBorderColor borderColor
Definition: vulkan_core.h:3721
const void * pNext
Definition: vulkan_core.h:3706
VkSamplerMipmapMode mipmapMode
Definition: vulkan_core.h:3710
VkSamplerAddressMode addressModeW
Definition: vulkan_core.h:3713
VkSamplerCreateFlags flags
Definition: vulkan_core.h:3707
VkCompareOp compareOp
Definition: vulkan_core.h:3718
VkStructureType sType
Definition: vulkan_core.h:3705
VkSamplerAddressMode addressModeV
Definition: vulkan_core.h:3712
#define VK_LOD_CLAMP_NONE
Definition: vulkan_core.h:126
@ VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
Definition: vulkan_core.h:2089
VkSamplerMipmapMode
Definition: vulkan_core.h:2118
@ VK_SAMPLER_MIPMAP_MODE_NEAREST
Definition: vulkan_core.h:2119
@ VK_SAMPLER_MIPMAP_MODE_LINEAR
Definition: vulkan_core.h:2120
@ VK_COMPARE_OP_NEVER
Definition: vulkan_core.h:1919
#define VK_FALSE
Definition: vulkan_core.h:125
VkFilter
Definition: vulkan_core.h:2100
@ VK_FILTER_NEAREST
Definition: vulkan_core.h:2101
@ VK_FILTER_LINEAR
Definition: vulkan_core.h:2102
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
Definition: vulkan_core.h:2111
@ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
Definition: vulkan_core.h:233

◆ vkSampler()

VkSampler skgpu::graphite::VulkanSampler::vkSampler ( ) const
inline

Definition at line 32 of file VulkanSampler.h.

32{ return fSampler; }

◆ ycbcrConversion()

const VulkanYcbcrConversion * skgpu::graphite::VulkanSampler::ycbcrConversion ( ) const
inline

Definition at line 34 of file VulkanSampler.h.

34{ return fYcbcrConversion.get(); }

The documentation for this class was generated from the following files: