Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private 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
 
- 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
 
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 &samplingOptions, SkTileMode xTileMode, SkTileMode yTileMode)
 

Private Member Functions

void freeGpuData () override
 

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, std::string_view label, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
virtual void invokeReleaseProc ()
 
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 29 of file VulkanSampler.h.

29{}

Member Function Documentation

◆ freeGpuData()

void skgpu::graphite::VulkanSampler::freeGpuData ( )
overrideprivatevirtual

Implements skgpu::graphite::Resource.

Definition at line 102 of file VulkanSampler.cpp.

102 {
103 const VulkanSharedContext* sharedContext =
104 static_cast<const VulkanSharedContext*>(this->sharedContext());
105 SkASSERT(fSampler);
106 VULKAN_CALL(sharedContext->interface(),
107 DestroySampler(sharedContext->device(), fSampler, nullptr));
108 fSampler = VK_NULL_HANDLE;
109}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define VULKAN_CALL(IFACE, X)
const SharedContext * sharedContext() const
Definition Resource.h:187
#define VK_NULL_HANDLE
Definition vulkan_core.h:46

◆ Make()

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

Definition at line 35 of file VulkanSampler.cpp.

38 {
39 VkSamplerCreateInfo samplerInfo;
40 memset(&samplerInfo, 0, sizeof(VkSamplerCreateInfo));
42 samplerInfo.pNext = nullptr;
43 samplerInfo.flags = 0;
44
45 VkFilter minMagFilter = [&] {
46 switch (samplingOptions.filter) {
49 }
51 }();
52
53 VkSamplerMipmapMode mipmapMode = [&] {
54 switch (samplingOptions.mipmap) {
55 // There is no disable mode. We use max level to disable mip mapping.
56 // It may make more sense to use NEAREST for kNone but Chrome pixel tests have
57 // been dependent on subtle rendering differences introduced by switching this.
61 }
63 }();
64
65 samplerInfo.magFilter = minMagFilter;
66 samplerInfo.minFilter = minMagFilter;
67 samplerInfo.mipmapMode = mipmapMode;
68 samplerInfo.addressModeU = tile_mode_to_vk_sampler_address(xTileMode);
69 samplerInfo.addressModeV = tile_mode_to_vk_sampler_address(yTileMode);
71 samplerInfo.mipLodBias = 0;
72 samplerInfo.anisotropyEnable = VK_FALSE;
73 samplerInfo.maxAnisotropy = 1; // TODO: when we start using aniso, need to add to key
74 samplerInfo.compareEnable = VK_FALSE;
75 samplerInfo.compareOp = VK_COMPARE_OP_NEVER;
76 // Vulkan doesn't have a direct mapping to use nearest or linear filters for minFilter since
77 // there is always a mipmapMode. To get the same effect we can set minLod = maxLod = 0.0.
78 // This works since our min and mag filters are the same (this forces us to use mag on the 0
79 // level mip). If the filters weren't the same we could set min = 0 and max = 0.25 to force
80 // the minFilter on mip level 0.
81 samplerInfo.minLod = 0;
82 samplerInfo.maxLod = (samplingOptions.mipmap == SkMipmapMode::kNone) ? 0.0f : VK_LOD_CLAMP_NONE;
85
86 // TODO: Add VkSamplerYcbcrConversion support by adding YCbCr conversion information to the
87 // graphite-level sampler key. Currently, the ResourceProvider only generates a key based on
88 // samplingOptions and tileModes.
89
90 VkSampler sampler;
93 result,
94 CreateSampler(sharedContext->device(), &samplerInfo, nullptr, &sampler));
95 if (result != VK_SUCCESS) {
96 return nullptr;
97 }
98
99 return sk_sp<VulkanSampler>(new VulkanSampler(sharedContext, sampler));
100}
#define SkUNREACHABLE
Definition SkAssert.h:135
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
GAsyncResult * result
static VkSamplerAddressMode tile_mode_to_vk_sampler_address(SkTileMode tileMode)
const SkFilterMode filter
const SkMipmapMode mipmap
VkBool32 unnormalizedCoordinates
VkSamplerAddressMode addressModeU
VkBorderColor borderColor
VkSamplerMipmapMode mipmapMode
VkSamplerAddressMode addressModeW
VkSamplerCreateFlags flags
VkCompareOp compareOp
VkStructureType sType
VkSamplerAddressMode addressModeV
#define VK_LOD_CLAMP_NONE
@ VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
VkSamplerMipmapMode
@ VK_SAMPLER_MIPMAP_MODE_NEAREST
@ VK_SAMPLER_MIPMAP_MODE_LINEAR
@ VK_COMPARE_OP_NEVER
#define VK_FALSE
VkFilter
@ VK_FILTER_NEAREST
@ VK_FILTER_LINEAR
VkResult
@ VK_SUCCESS
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
@ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO

◆ vkSampler()

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

Definition at line 31 of file VulkanSampler.h.

31{ return fSampler; }

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