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

#include <VulkanTexture.h>

Inheritance diagram for skgpu::graphite::VulkanTexture:
skgpu::graphite::Texture skgpu::graphite::Resource

Classes

struct  CreatedImageInfo
 

Public Member Functions

 ~VulkanTexture () override
 
VkImage vkImage () const
 
void setImageLayout (VulkanCommandBuffer *buffer, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion) const
 
void setImageLayoutAndQueueIndex (VulkanCommandBuffer *, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion, uint32_t newQueueFamilyIndex) const
 
void updateImageLayout (VkImageLayout)
 
VkImageLayout currentLayout () const
 
uint32_t currentQueueFamilyIndex () const
 
const VulkanImageViewgetImageView (VulkanImageView::Usage) const
 
bool supportsInputAttachmentUsage () const
 
- Public Member Functions inherited from skgpu::graphite::Texture
 ~Texture () override
 
int numSamples () const
 
Mipmapped mipmapped () const
 
SkISize dimensions () const
 
const TextureInfotextureInfo () const
 
void setReleaseCallback (sk_sp< RefCntedCallback >)
 
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 bool MakeVkImage (const VulkanSharedContext *, SkISize dimensions, const TextureInfo &, CreatedImageInfo *outInfo)
 
static sk_sp< TextureMake (const VulkanSharedContext *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted, sk_sp< VulkanYcbcrConversion >)
 
static sk_sp< TextureMakeWrapped (const VulkanSharedContext *, SkISize dimensions, const TextureInfo &, sk_sp< MutableTextureState >, VkImage, const VulkanAlloc &, sk_sp< VulkanYcbcrConversion >)
 
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags (const VkImageLayout layout)
 
static VkAccessFlags LayoutToSrcAccessMask (const VkImageLayout layout)
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::Texture
 Texture (const SharedContext *, SkISize dimensions, const TextureInfo &info, sk_sp< MutableTextureState > mutableState, Ownership, skgpu::Budgeted)
 
MutableTextureStatemutableState () const
 
void invokeReleaseProc () override
 
void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const override
 
- 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 27 of file VulkanTexture.h.

Constructor & Destructor Documentation

◆ ~VulkanTexture()

skgpu::graphite::VulkanTexture::~VulkanTexture ( )
inlineoverride

Definition at line 54 of file VulkanTexture.h.

54{}

Member Function Documentation

◆ currentLayout()

VkImageLayout skgpu::graphite::VulkanTexture::currentLayout ( ) const

Definition at line 337 of file VulkanTexture.cpp.

337 {
339}
MutableTextureState * mutableState() const
Definition: Texture.cpp:44
SK_API VkImageLayout GetVkImageLayout(const MutableTextureState &state)

◆ currentQueueFamilyIndex()

uint32_t skgpu::graphite::VulkanTexture::currentQueueFamilyIndex ( ) const

Definition at line 341 of file VulkanTexture.cpp.

341 {
343}
SK_API uint32_t GetVkQueueFamilyIndex(const MutableTextureState &state)

◆ getImageView()

const VulkanImageView * skgpu::graphite::VulkanTexture::getImageView ( VulkanImageView::Usage  usage) const

Definition at line 400 of file VulkanTexture.cpp.

400 {
401 for (int i = 0; i < fImageViews.size(); ++i) {
402 if (fImageViews[i]->usage() == usage) {
403 return fImageViews[i].get();
404 }
405 }
406
407 auto sharedContext = static_cast<const VulkanSharedContext*>(this->sharedContext());
408 VulkanTextureInfo vkTexInfo;
409 this->textureInfo().getVulkanTextureInfo(&vkTexInfo);
410 int miplevels = this->textureInfo().mipmapped() == Mipmapped::kYes
412 this->dimensions().height()) + 1
413 : 1;
414 auto imageView = VulkanImageView::Make(sharedContext,
415 fImage,
416 vkTexInfo.fFormat,
417 usage,
418 miplevels,
419 fYcbcrConversion);
420 return fImageViews.push_back(std::move(imageView)).get();
421}
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition: SkMipmap.cpp:134
const SharedContext * sharedContext() const
Definition: Resource.h:189
Mipmapped mipmapped() const
Definition: TextureInfo.h:79
SkISize dimensions() const
Definition: Texture.h:31
const TextureInfo & textureInfo() const
Definition: Texture.h:32
static std::unique_ptr< const VulkanImageView > Make(const VulkanSharedContext *sharedContext, VkImage image, VkFormat format, Usage usage, uint32_t miplevels, sk_sp< VulkanYcbcrConversion >)
int32_t height
int32_t width
static void usage(char *argv0)

◆ LayoutToPipelineSrcStageFlags()

VkPipelineStageFlags skgpu::graphite::VulkanTexture::LayoutToPipelineSrcStageFlags ( const VkImageLayout  layout)
static

Definition at line 345 of file VulkanTexture.cpp.

345 {
346 if (VK_IMAGE_LAYOUT_GENERAL == layout) {
348 } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout ||
351 } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
356 } else if (VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) {
358 } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
360 } else if (VK_IMAGE_LAYOUT_PRESENT_SRC_KHR == layout) {
362 }
363
366}
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
Definition: vulkan_core.h:1337
@ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
Definition: vulkan_core.h:1348
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
Definition: vulkan_core.h:1334
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan_core.h:1336
@ VK_IMAGE_LAYOUT_PREINITIALIZED
Definition: vulkan_core.h:1339
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
Definition: vulkan_core.h:1333
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
Definition: vulkan_core.h:1335
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan_core.h:1331
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan_core.h:1338
@ VK_IMAGE_LAYOUT_GENERAL
Definition: vulkan_core.h:1332
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
Definition: vulkan_core.h:2442
@ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
Definition: vulkan_core.h:2435
@ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
Definition: vulkan_core.h:2445
@ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
Definition: vulkan_core.h:2444
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
Definition: vulkan_core.h:2451
@ VK_PIPELINE_STAGE_HOST_BIT
Definition: vulkan_core.h:2449
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan_core.h:2447

◆ LayoutToSrcAccessMask()

VkAccessFlags skgpu::graphite::VulkanTexture::LayoutToSrcAccessMask ( const VkImageLayout  layout)
static

Definition at line 368 of file VulkanTexture.cpp.

368 {
369 // Currently we assume we will never being doing any explict shader writes (this doesn't include
370 // color attachment or depth/stencil writes). So we will ignore the
371 // VK_MEMORY_OUTPUT_SHADER_WRITE_BIT.
372
373 // We can only directly access the host memory if we are in preinitialized or general layout,
374 // and the image is linear.
375 // TODO: Add check for linear here so we are not always adding host to general, and we should
376 // only be in preinitialized if we are linear
378 if (VK_IMAGE_LAYOUT_GENERAL == layout) {
383 } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
385 } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
389 } else if (VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == layout) {
391 } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout ||
394 // There are no writes that need to be made available
395 flags = 0;
396 }
397 return flags;
398}
FlutterSemanticsFlag flags
VkFlags VkAccessFlags
Definition: vulkan_core.h:2235
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
Definition: vulkan_core.h:2210
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan_core.h:2212
@ VK_ACCESS_HOST_WRITE_BIT
Definition: vulkan_core.h:2214
@ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
Definition: vulkan_core.h:2208

◆ Make()

sk_sp< Texture > skgpu::graphite::VulkanTexture::Make ( const VulkanSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
skgpu::Budgeted  budgeted,
sk_sp< VulkanYcbcrConversion ycbcrConversion 
)
static

Definition at line 149 of file VulkanTexture.cpp.

153 {
154 CreatedImageInfo imageInfo;
155 if (!MakeVkImage(sharedContext, dimensions, info, &imageInfo)) {
156 return nullptr;
157 }
158
159 return sk_sp<Texture>(new VulkanTexture(sharedContext,
161 info,
162 std::move(imageInfo.fMutableState),
163 imageInfo.fImage,
164 imageInfo.fMemoryAlloc,
166 budgeted,
167 std::move(ycbcrConversion)));
168}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
skgpu::Budgeted budgeted() const
Definition: Resource.h:100
static bool MakeVkImage(const VulkanSharedContext *, SkISize dimensions, const TextureInfo &, CreatedImageInfo *outInfo)

◆ MakeVkImage()

bool skgpu::graphite::VulkanTexture::MakeVkImage ( const VulkanSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
CreatedImageInfo outInfo 
)
static

Definition at line 24 of file VulkanTexture.cpp.

27 {
28 SkASSERT(outInfo);
29 const VulkanCaps& caps = sharedContext->vulkanCaps();
30
31 if (dimensions.isEmpty()) {
32 SKGPU_LOG_E("Tried to create VkImage with empty dimensions.");
33 return false;
34 }
35 if (dimensions.width() > caps.maxTextureSize() ||
36 dimensions.height() > caps.maxTextureSize()) {
37 SKGPU_LOG_E("Tried to create VkImage with too large a size.");
38 return false;
39 }
40
41 if ((info.isProtected() == Protected::kYes) != caps.protectedSupport()) {
42 SKGPU_LOG_E("Tried to create %s VkImage in %s Context.",
43 info.isProtected() == Protected::kYes ? "protected" : "unprotected",
44 caps.protectedSupport() ? "protected" : "unprotected");
45 return false;
46 }
47
48 const VulkanTextureSpec& spec = info.vulkanTextureSpec();
49
50 bool isLinear = spec.fImageTiling == VK_IMAGE_TILING_LINEAR;
51 VkImageLayout initialLayout = isLinear ? VK_IMAGE_LAYOUT_PREINITIALIZED
53
54 // Create Image
55 VkSampleCountFlagBits vkSamples;
56 if (!SampleCountToVkSampleCount(info.numSamples(), &vkSamples)) {
57 SKGPU_LOG_E("Failed creating VkImage because we could not covert the number of samples: "
58 "%u to a VkSampleCountFlagBits.", info.numSamples());
59 return false;
60 }
61
62 SkASSERT(!isLinear || vkSamples == VK_SAMPLE_COUNT_1_BIT);
63
64 VkImageCreateFlags createflags = 0;
65 if (info.isProtected() == Protected::kYes && caps.protectedSupport()) {
66 createflags |= VK_IMAGE_CREATE_PROTECTED_BIT;
67 }
68
69 uint32_t numMipLevels = 1;
70 if (info.mipmapped() == Mipmapped::kYes) {
72 }
73
74 uint32_t width = static_cast<uint32_t>(dimensions.fWidth);
75 uint32_t height = static_cast<uint32_t>(dimensions.fHeight);
76
77 const VkImageCreateInfo imageCreateInfo = {
79 nullptr, // pNext
80 createflags, // VkImageCreateFlags
81 VK_IMAGE_TYPE_2D, // VkImageType
82 spec.fFormat, // VkFormat
83 { width, height, 1 }, // VkExtent3D
84 numMipLevels, // mipLevels
85 1, // arrayLayers
86 vkSamples, // samples
87 spec.fImageTiling, // VkImageTiling
88 spec.fImageUsageFlags, // VkImageUsageFlags
89 spec.fSharingMode, // VkSharingMode
90 0, // queueFamilyCount
91 nullptr, // pQueueFamilyIndices
92 initialLayout // initialLayout
93 };
94
95 auto device = sharedContext->device();
96
97 VkImage image = VK_NULL_HANDLE;
100 sharedContext, result, CreateImage(device, &imageCreateInfo, nullptr, &image));
101 if (result != VK_SUCCESS) {
102 SKGPU_LOG_E("Failed call to vkCreateImage with error: %d", result);
103 return false;
104 }
105
106 auto allocator = sharedContext->memoryAllocator();
107 bool forceDedicatedMemory = caps.shouldAlwaysUseDedicatedImageMemory();
108 bool useLazyAllocation =
109 SkToBool(spec.fImageUsageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT);
110
111 auto checkResult = [sharedContext](VkResult result) {
112 return sharedContext->checkVkResult(result);
113 };
115 image,
116 info.isProtected(),
117 forceDedicatedMemory,
118 useLazyAllocation,
119 checkResult,
120 &outInfo->fMemoryAlloc)) {
121 VULKAN_CALL(sharedContext->interface(), DestroyImage(device, image, nullptr));
122 return false;
123 }
124
125 if (useLazyAllocation &&
126 !SkToBool(outInfo->fMemoryAlloc.fFlags & skgpu::VulkanAlloc::kLazilyAllocated_Flag)) {
127 SKGPU_LOG_E("Failed allocate lazy vulkan memory when requested");
128 skgpu::VulkanMemory::FreeImageMemory(allocator, outInfo->fMemoryAlloc);
129 return false;
130 }
131
134 result,
135 BindImageMemory(
136 device, image, outInfo->fMemoryAlloc.fMemory, outInfo->fMemoryAlloc.fOffset));
137 if (result != VK_SUCCESS) {
138 skgpu::VulkanMemory::FreeImageMemory(allocator, outInfo->fMemoryAlloc);
139 VULKAN_CALL(sharedContext->interface(), DestroyImage(device, image, nullptr));
140 return false;
141 }
142
143 outInfo->fImage = image;
144 outInfo->fMutableState = sk_make_sp<MutableTextureState>(
146 return true;
147}
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
#define VULKAN_CALL(IFACE, X)
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
VkDevice device
Definition: main.cc:53
GAsyncResult * result
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API MutableTextureState MakeVulkan(VkImageLayout layout, uint32_t queueFamilyIndex)
void FreeImageMemory(VulkanMemoryAllocator *, const VulkanAlloc &alloc)
bool AllocImageMemory(VulkanMemoryAllocator *, VkImage image, skgpu::Protected isProtected, bool forceDedicatedMemory, bool useLazyAllocation, const std::function< CheckResult > &, VulkanAlloc *alloc)
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
bool isEmpty() const
Definition: SkSize.h:31
int32_t fHeight
Definition: SkSize.h:18
int32_t fWidth
Definition: SkSize.h:17
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37
VkImageLayout
Definition: vulkan_core.h:1330
@ VK_IMAGE_CREATE_PROTECTED_BIT
Definition: vulkan_core.h:2320
@ VK_IMAGE_TILING_LINEAR
Definition: vulkan_core.h:1768
@ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
Definition: vulkan_core.h:2358
VkSampleCountFlagBits
Definition: vulkan_core.h:2339
@ VK_SAMPLE_COUNT_1_BIT
Definition: vulkan_core.h:2340
@ VK_IMAGE_TYPE_2D
Definition: vulkan_core.h:1775
VkFlags VkImageCreateFlags
Definition: vulkan_core.h:2337
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan_core.h:127
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Definition: vulkan_core.h:216

◆ MakeWrapped()

sk_sp< Texture > skgpu::graphite::VulkanTexture::MakeWrapped ( const VulkanSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
sk_sp< MutableTextureState mutableState,
VkImage  image,
const VulkanAlloc alloc,
sk_sp< VulkanYcbcrConversion ycbcrConversion 
)
static

Definition at line 170 of file VulkanTexture.cpp.

176 {
177 return sk_sp<Texture>(new VulkanTexture(sharedContext,
179 info,
180 std::move(mutableState),
181 image,
182 alloc,
185 std::move(ycbcrConversion)));
186}

◆ setImageLayout()

void skgpu::graphite::VulkanTexture::setImageLayout ( VulkanCommandBuffer buffer,
VkImageLayout  newLayout,
VkAccessFlags  dstAccessMask,
VkPipelineStageFlags  dstStageMask,
bool  byRegion 
) const
inline

Definition at line 58 of file VulkanTexture.h.

62 {
63 this->setImageLayoutAndQueueIndex(buffer, newLayout, dstAccessMask, dstStageMask, byRegion,
65 }
void setImageLayoutAndQueueIndex(VulkanCommandBuffer *, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion, uint32_t newQueueFamilyIndex) const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ setImageLayoutAndQueueIndex()

void skgpu::graphite::VulkanTexture::setImageLayoutAndQueueIndex ( VulkanCommandBuffer cmdBuffer,
VkImageLayout  newLayout,
VkAccessFlags  dstAccessMask,
VkPipelineStageFlags  dstStageMask,
bool  byRegion,
uint32_t  newQueueFamilyIndex 
) const

Definition at line 205 of file VulkanTexture.cpp.

210 {
211
212 SkASSERT(newLayout == this->currentLayout() ||
213 (VK_IMAGE_LAYOUT_UNDEFINED != newLayout &&
214 VK_IMAGE_LAYOUT_PREINITIALIZED != newLayout));
216 uint32_t currentQueueIndex = this->currentQueueFamilyIndex();
217
218 VulkanTextureInfo textureInfo;
219 this->textureInfo().getVulkanTextureInfo(&textureInfo);
220 auto sharedContext = static_cast<const VulkanSharedContext*>(this->sharedContext());
221
222 // Enable the following block on new devices to test that their lazy images stay at 0 memory use
223#if 0
224 auto device = sharedContext->device();
225 if (fAlloc.fFlags & skgpu::VulkanAlloc::kLazilyAllocated_Flag) {
227 VULKAN_CALL(sharedContext->interface(), GetDeviceMemoryCommitment(device, fAlloc.fMemory, &size));
228
229 SkDebugf("Lazy Image. This: %p, image: %d, size: %d\n", this, fImage, size);
230 }
231#endif
232#ifdef SK_DEBUG
233 if (textureInfo.fSharingMode == VK_SHARING_MODE_CONCURRENT) {
234 if (newQueueFamilyIndex == VK_QUEUE_FAMILY_IGNORED) {
235 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED ||
236 currentQueueIndex == VK_QUEUE_FAMILY_EXTERNAL ||
237 currentQueueIndex == VK_QUEUE_FAMILY_FOREIGN_EXT);
238 } else {
239 SkASSERT(newQueueFamilyIndex == VK_QUEUE_FAMILY_EXTERNAL ||
240 newQueueFamilyIndex == VK_QUEUE_FAMILY_FOREIGN_EXT);
241 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED);
242 }
243 } else {
245 if (newQueueFamilyIndex == VK_QUEUE_FAMILY_IGNORED ||
246 currentQueueIndex == sharedContext->queueIndex()) {
247 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED ||
248 currentQueueIndex == VK_QUEUE_FAMILY_EXTERNAL ||
249 currentQueueIndex == VK_QUEUE_FAMILY_FOREIGN_EXT ||
250 currentQueueIndex == sharedContext->queueIndex());
251 } else if (newQueueFamilyIndex == VK_QUEUE_FAMILY_EXTERNAL ||
252 newQueueFamilyIndex == VK_QUEUE_FAMILY_FOREIGN_EXT) {
253 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED ||
254 currentQueueIndex == sharedContext->queueIndex());
255 }
256 }
257#endif
258
259 if (textureInfo.fSharingMode == VK_SHARING_MODE_EXCLUSIVE) {
260 if (newQueueFamilyIndex == VK_QUEUE_FAMILY_IGNORED) {
261 newQueueFamilyIndex = sharedContext->queueIndex();
262 }
263 if (currentQueueIndex == VK_QUEUE_FAMILY_IGNORED) {
264 currentQueueIndex = sharedContext->queueIndex();
265 }
266 }
267
268 // If the old and new layout are the same and the layout is a read only layout, there is no need
269 // to put in a barrier unless we also need to switch queues.
270 if (newLayout == currentLayout && currentQueueIndex == newQueueFamilyIndex &&
274 return;
275 }
276
279
281 uint32_t numMipLevels = 1;
282 SkISize dimensions = this->dimensions();
283 if (this->mipmapped() == Mipmapped::kYes) {
285 }
286 VkImageMemoryBarrier imageMemoryBarrier = {
288 nullptr, // pNext
289 srcAccessMask, // srcAccessMask
290 dstAccessMask, // dstAccessMask
291 currentLayout, // oldLayout
292 newLayout, // newLayout
293 currentQueueIndex, // srcQueueFamilyIndex
294 newQueueFamilyIndex, // dstQueueFamilyIndex
295 fImage, // image
296 { aspectFlags, 0, numMipLevels, 0, 1 } // subresourceRange
297 };
298 SkASSERT(srcAccessMask == imageMemoryBarrier.srcAccessMask);
299 cmdBuffer->addImageMemoryBarrier(this, srcStageMask, dstStageMask, byRegion,
300 &imageMemoryBarrier);
301
304}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
Mipmapped mipmapped() const
Definition: Texture.h:29
uint32_t currentQueueFamilyIndex() const
static VkAccessFlags LayoutToSrcAccessMask(const VkImageLayout layout)
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout)
VkImageLayout currentLayout() const
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
void SetVkImageLayout(MutableTextureState *state, VkImageLayout layout)
void SetVkQueueFamilyIndex(MutableTextureState *state, uint32_t queueFamilyIndex)
VkImageAspectFlags vk_format_to_aspect_flags(VkFormat format)
Definition: SkSize.h:16
VkAccessFlags srcAccessMask
Definition: vulkan_core.h:2938
VkFlags VkPipelineStageFlags
Definition: vulkan_core.h:2470
@ VK_SHARING_MODE_CONCURRENT
Definition: vulkan_core.h:1814
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan_core.h:1813
VkFlags VkImageAspectFlags
Definition: vulkan_core.h:2256
uint64_t VkDeviceSize
Definition: vulkan_core.h:96
#define VK_QUEUE_FAMILY_FOREIGN_EXT
#define VK_QUEUE_FAMILY_EXTERNAL
Definition: vulkan_core.h:4927
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
Definition: vulkan_core.h:247

◆ supportsInputAttachmentUsage()

bool skgpu::graphite::VulkanTexture::supportsInputAttachmentUsage ( ) const
inline

Definition at line 87 of file VulkanTexture.h.

87 {
88 return (this->textureInfo().vulkanTextureSpec().fImageUsageFlags &
90 }
@ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
Definition: vulkan_core.h:2359

◆ updateImageLayout()

void skgpu::graphite::VulkanTexture::updateImageLayout ( VkImageLayout  newLayout)

Definition at line 333 of file VulkanTexture.cpp.

333 {
335}

◆ vkImage()

VkImage skgpu::graphite::VulkanTexture::vkImage ( ) const
inline

Definition at line 56 of file VulkanTexture.h.

56{ return fImage; }

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