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

#include <VulkanYcbcrConversion.h>

Inheritance diagram for skgpu::graphite::VulkanYcbcrConversion:
skgpu::graphite::Resource

Public Member Functions

VkSamplerYcbcrConversion ycbcrConversion () const
 
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< VulkanYcbcrConversionMake (const VulkanSharedContext *, const VulkanYcbcrConversionInfo &)
 
static sk_sp< VulkanYcbcrConversionMake (const VulkanSharedContext *, uint32_t nonFormatInfo, uint64_t format)
 
static GraphiteResourceKey MakeYcbcrConversionKey (const VulkanSharedContext *, const VulkanYcbcrConversionInfo &)
 
static GraphiteResourceKey GetKeyFromSamplerDesc (const SamplerDesc &samplerDesc)
 

Additional Inherited Members

- 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 26 of file VulkanYcbcrConversion.h.

Member Function Documentation

◆ GetKeyFromSamplerDesc()

GraphiteResourceKey skgpu::graphite::VulkanYcbcrConversion::GetKeyFromSamplerDesc ( const SamplerDesc samplerDesc)
static

Definition at line 157 of file VulkanYcbcrConversion.cpp.

157 {
158 GraphiteResourceKey key;
159 const SkSpan<const uint32_t>& samplerData = samplerDesc.asSpan();
160 GraphiteResourceKey::Builder builder(&key, conversion_rsrc_type(), samplerData.size(),
162
163 // The first index of sampler data (sampler desc value) includes non-ycbcr information
164 // that needs to be shifted past in order to isolate the ycbcr information for this key.
166 for (size_t i = 1; i < samplerData.size(); i++) {
167 builder[i] = samplerData[i];
168 }
169
170 builder.finish();
171 return key;
172}
constexpr size_t size() const
Definition: SkSpan_impl.h:95
const GraphiteResourceKey & key() const
Definition: Resource.h:156
DlVertices::Builder Builder
static constexpr int kImmutableSamplerInfoShift

◆ getResourceType()

const char * skgpu::graphite::VulkanYcbcrConversion::getResourceType ( ) const
inlineoverridevirtual

Implements skgpu::graphite::Resource.

Definition at line 44 of file VulkanYcbcrConversion.h.

44{ return "Vulkan YCbCr Conversion"; }

◆ Make() [1/2]

sk_sp< VulkanYcbcrConversion > skgpu::graphite::VulkanYcbcrConversion::Make ( const VulkanSharedContext context,
const VulkanYcbcrConversionInfo conversionInfo 
)
static

Definition at line 17 of file VulkanYcbcrConversion.cpp.

18 {
19 if (!context->vulkanCaps().supportsYcbcrConversion()) {
20 return nullptr;
21 }
22
24 skgpu::SetupSamplerYcbcrConversionInfo(&ycbcrCreateInfo, conversionInfo);
25
26#ifdef SK_BUILD_FOR_ANDROID
27 VkExternalFormatANDROID externalFormat;
28 if (conversionInfo.fExternalFormat) {
29 // Format must not be specified for external images.
30 SkASSERT(conversionInfo.fFormat == VK_FORMAT_UNDEFINED);
32 externalFormat.pNext = nullptr;
33 externalFormat.externalFormat = conversionInfo.fExternalFormat;
34 SkASSERT(ycbcrCreateInfo.pNext == nullptr);
35 ycbcrCreateInfo.pNext = &externalFormat;
36 }
37#else
38 // External images are supported only on Android.
39 SkASSERT(!conversionInfo.fExternalFormat);
40#endif
41
42 if (!conversionInfo.fExternalFormat) {
43 SkASSERT(conversionInfo.fFormat != VK_FORMAT_UNDEFINED);
44 }
45
46 VkSamplerYcbcrConversion conversion;
48 VULKAN_CALL_RESULT(context,
49 result,
50 CreateSamplerYcbcrConversion(
51 context->device(), &ycbcrCreateInfo, nullptr, &conversion));
52 if (result != VK_SUCCESS) {
53 return nullptr;
54 }
55 return sk_sp<VulkanYcbcrConversion>(new VulkanYcbcrConversion(context, conversion));
56}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
GAsyncResult * result
void SetupSamplerYcbcrConversionInfo(VkSamplerYcbcrConversionCreateInfo *outInfo, const VulkanYcbcrConversionInfo &conversionInfo)
VkStructureType sType
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
@ VK_FORMAT_UNDEFINED
Definition: vulkan_core.h:1459
@ VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID
Definition: vulkan_core.h:647

◆ Make() [2/2]

sk_sp< VulkanYcbcrConversion > skgpu::graphite::VulkanYcbcrConversion::Make ( const VulkanSharedContext context,
uint32_t  nonFormatInfo,
uint64_t  format 
)
static

Definition at line 58 of file VulkanYcbcrConversion.cpp.

60 {
62
63 bool useExternalFormat = static_cast<bool>(
66
68 ycbcrCreateInfo.pNext = nullptr;
69 ycbcrCreateInfo.format = useExternalFormat ? VK_FORMAT_UNDEFINED
70 : static_cast<VkFormat>(format);
71
72 ycbcrCreateInfo.ycbcrModel = static_cast<VkSamplerYcbcrModelConversion>(
73 (nonFormatInfo & ycbcrPackaging::kYcbcrModelMask) >>
75 ycbcrCreateInfo.ycbcrRange = static_cast<VkSamplerYcbcrRange>(
76 (nonFormatInfo & ycbcrPackaging::kYcbcrRangeMask) >>
78 ycbcrCreateInfo.components = {
79 static_cast<VkComponentSwizzle>(
80 (nonFormatInfo & ycbcrPackaging::kComponentRMask) >>
82 static_cast<VkComponentSwizzle>(
83 (nonFormatInfo & ycbcrPackaging::kComponentGMask) >>
85 static_cast<VkComponentSwizzle>(
86 (nonFormatInfo & ycbcrPackaging::kComponentBMask) >>
88 static_cast<VkComponentSwizzle>(
89 (nonFormatInfo & ycbcrPackaging::kComponentAMask) >>
91 ycbcrCreateInfo.xChromaOffset = static_cast<VkChromaLocation>(
92 (nonFormatInfo & ycbcrPackaging::kXChromaOffsetMask) >>
94 ycbcrCreateInfo.yChromaOffset = static_cast<VkChromaLocation>(
95 (nonFormatInfo & ycbcrPackaging::kYChromaOffsetMask) >>
97 ycbcrCreateInfo.chromaFilter = static_cast<VkFilter>(
98 (nonFormatInfo & ycbcrPackaging::kChromaFilterMask) >>
100 ycbcrCreateInfo.forceExplicitReconstruction = static_cast<VkBool32>(
101 (nonFormatInfo & ycbcrPackaging::kForceExplicitReconMask) >>
103
104#ifdef SK_BUILD_FOR_ANDROID
105 VkExternalFormatANDROID externalFormat;
106 if (useExternalFormat) {
108 externalFormat.pNext = nullptr;
109 externalFormat.externalFormat = format;
110 SkASSERT(ycbcrCreateInfo.pNext == nullptr);
111 ycbcrCreateInfo.pNext = &externalFormat;
112 }
113#endif
114
115 VkSamplerYcbcrConversion conversion;
117 VULKAN_CALL_RESULT(context,
118 result,
119 CreateSamplerYcbcrConversion(
120 context->device(), &ycbcrCreateInfo, nullptr, &conversion));
121 if (result != VK_SUCCESS) {
122 return nullptr;
123 }
124 return sk_sp<VulkanYcbcrConversion>(new VulkanYcbcrConversion(context, conversion));
125}
uint32_t uint32_t * format
static constexpr uint32_t kYChromaOffsetMask
static constexpr uint32_t kComponentAMask
static constexpr uint32_t kYcbcrRangeMask
static constexpr uint32_t kComponentGMask
static constexpr uint32_t kXChromaOffsetMask
static constexpr uint32_t kUseExternalFormatMask
static constexpr uint32_t kYcbcrModelMask
static constexpr int kUsesExternalFormatShift
static constexpr int kForceExplicitReconShift
static constexpr uint32_t kChromaFilterMask
static constexpr uint32_t kForceExplicitReconMask
static constexpr uint32_t kComponentRMask
static constexpr uint32_t kComponentBMask
VkSamplerYcbcrModelConversion ycbcrModel
Definition: vulkan_core.h:5426
VkSamplerYcbcrModelConversion
Definition: vulkan_core.h:4945
VkChromaLocation
Definition: vulkan_core.h:4967
VkComponentSwizzle
Definition: vulkan_core.h:1818
VkSamplerYcbcrRange
Definition: vulkan_core.h:4959
VkFilter
Definition: vulkan_core.h:2100
VkFormat
Definition: vulkan_core.h:1458
uint32_t VkBool32
Definition: vulkan_core.h:94
@ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO
Definition: vulkan_core.h:292

◆ MakeYcbcrConversionKey()

GraphiteResourceKey skgpu::graphite::VulkanYcbcrConversion::MakeYcbcrConversionKey ( const VulkanSharedContext context,
const VulkanYcbcrConversionInfo info 
)
static

Definition at line 135 of file VulkanYcbcrConversion.cpp.

136 {
137 bool useExternalFormat = info.fFormat == VK_FORMAT_UNDEFINED;
138 GraphiteResourceKey key;
140 conversion_rsrc_type(),
143 int i = 0;
145 if (useExternalFormat) {
146 builder[i++] = (uint32_t)info.fExternalFormat;
147 builder[i++] = (uint32_t)(info.fExternalFormat >> 32);
148 } else {
149 builder[i++] = (uint32_t)info.fFormat;
150 }
152
153 builder.finish();
154 return key;
155}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
int numInt32sNeeded(const VulkanYcbcrConversionInfo &conversionInfo)
uint32_t nonFormatInfoAsUInt32(const VulkanYcbcrConversionInfo &conversionInfo)

◆ ycbcrConversion()

VkSamplerYcbcrConversion skgpu::graphite::VulkanYcbcrConversion::ycbcrConversion ( ) const
inline

Definition at line 42 of file VulkanYcbcrConversion.h.

42{ return fYcbcrConversion; }

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