Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrVkImage.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
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
9
18
19#define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
20
22 SkISize dimensions,
23 int sampleCnt,
27 return GrVkImage::Make(gpu,
30 sampleCnt,
31 format,
32 /*mipLevels=*/1,
34 GrProtected::kNo,
37}
38
40 SkISize dimensions,
41 int numSamples,
43 GrProtected isProtected,
44 GrMemoryless memoryless) {
46
48 if (memoryless == GrMemoryless::kYes) {
50 } else {
52 }
53 return GrVkImage::Make(gpu,
57 format,
58 /*mipLevels=*/1,
61 memoryless,
63}
64
66 SkISize dimensions,
68 uint32_t mipLevels,
69 GrRenderable renderable,
70 int numSamples,
71 skgpu::Budgeted budgeted,
72 GrProtected isProtected) {
76 if (renderable == GrRenderable::kYes) {
77 usageFlags |= UsageFlags::kColorAttachment;
79 // We always make our render targets support being used as input attachments
81 }
82
83 return GrVkImage::Make(gpu,
85 usageFlags,
87 format,
92 budgeted);
93}
94
95static bool make_views(GrVkGpu* gpu,
96 const GrVkImageInfo& info,
97 GrAttachment::UsageFlags attachmentUsages,
98 sk_sp<const GrVkImageView>* framebufferView,
99 sk_sp<const GrVkImageView>* textureView) {
100 GrVkImageView::Type viewType;
101 if (attachmentUsages & GrAttachment::UsageFlags::kStencilAttachment) {
102 // If we have stencil usage then we shouldn't have any other usages
105 } else {
107 }
108
111 // Attachments can only have a mip level of 1
112 *framebufferView = GrVkImageView::Make(
113 gpu, info.fImage, info.fFormat, viewType, 1, info.fYcbcrConversionInfo);
114 if (!*framebufferView) {
115 return false;
116 }
117 }
118
119 if (attachmentUsages & GrAttachment::UsageFlags::kTexture) {
120 *textureView = GrVkImageView::Make(gpu,
121 info.fImage,
122 info.fFormat,
123 viewType,
124 info.fLevelCount,
125 info.fYcbcrConversionInfo);
126 if (!*textureView) {
127 return false;
128 }
129 }
130 return true;
131}
132
133sk_sp<GrVkImage> GrVkImage::Make(GrVkGpu* gpu,
134 SkISize dimensions,
135 UsageFlags attachmentUsages,
136 int sampleCnt,
138 uint32_t mipLevels,
139 VkImageUsageFlags vkUsageFlags,
140 GrProtected isProtected,
141 GrMemoryless memoryless,
142 skgpu::Budgeted budgeted) {
143 GrVkImage::ImageDesc imageDesc;
144 imageDesc.fImageType = VK_IMAGE_TYPE_2D;
145 imageDesc.fFormat = format;
146 imageDesc.fWidth = dimensions.width();
147 imageDesc.fHeight = dimensions.height();
148 imageDesc.fLevels = mipLevels;
149 imageDesc.fSamples = sampleCnt;
151 imageDesc.fUsageFlags = vkUsageFlags;
152 imageDesc.fIsProtected = isProtected;
153
155 if (!GrVkImage::InitImageInfo(gpu, imageDesc, &info)) {
156 return nullptr;
157 }
158
161 if (!make_views(gpu, info, attachmentUsages, &framebufferView, &textureView)) {
163 return nullptr;
164 }
165
166 auto mutableState = sk_make_sp<skgpu::MutableTextureState>(
167 skgpu::MutableTextureStates::MakeVulkan(info.fImageLayout, info.fCurrentQueueFamily));
168 return sk_sp<GrVkImage>(new GrVkImage(gpu,
170 attachmentUsages,
171 info,
172 std::move(mutableState),
173 std::move(framebufferView),
174 std::move(textureView),
175 budgeted,
176 /*label=*/"MakeVkImage"));
177}
178
180 SkISize dimensions,
181 const GrVkImageInfo& info,
183 UsageFlags attachmentUsages,
184 GrWrapOwnership ownership,
185 GrWrapCacheable cacheable,
186 std::string_view label,
187 bool forSecondaryCB) {
190 if (!forSecondaryCB) {
191 if (!make_views(gpu, info, attachmentUsages, &framebufferView, &textureView)) {
192 return nullptr;
193 }
194 }
195
196 GrBackendObjectOwnership backendOwnership = kBorrow_GrWrapOwnership == ownership
199
200 return sk_sp<GrVkImage>(new GrVkImage(gpu,
202 attachmentUsages,
203 info,
204 std::move(mutableState),
205 std::move(framebufferView),
206 std::move(textureView),
207 backendOwnership,
208 cacheable,
209 forSecondaryCB,
210 label));
211}
212
213GrVkImage::GrVkImage(GrVkGpu* gpu,
214 SkISize dimensions,
215 UsageFlags supportedUsages,
216 const GrVkImageInfo& info,
218 sk_sp<const GrVkImageView> framebufferView,
219 sk_sp<const GrVkImageView> textureView,
220 skgpu::Budgeted budgeted,
221 std::string_view label)
222 : GrAttachment(gpu,
223 dimensions,
224 supportedUsages,
225 info.fSampleCount,
226 info.fLevelCount > 1 ? skgpu::Mipmapped::kYes : skgpu::Mipmapped::kNo,
227 info.fProtected,
228 label,
229 info.fAlloc.fFlags & skgpu::VulkanAlloc::kLazilyAllocated_Flag
231 : GrMemoryless::kNo)
232 , fInfo(info)
233 , fInitialQueueFamily(info.fCurrentQueueFamily)
234 , fMutableState(std::move(mutableState))
235 , fFramebufferView(std::move(framebufferView))
236 , fTextureView(std::move(textureView))
237 , fIsBorrowed(false) {
238 this->init(gpu, false);
239 this->registerWithCache(budgeted);
240}
241
242GrVkImage::GrVkImage(GrVkGpu* gpu,
243 SkISize dimensions,
244 UsageFlags supportedUsages,
245 const GrVkImageInfo& info,
247 sk_sp<const GrVkImageView> framebufferView,
248 sk_sp<const GrVkImageView> textureView,
249 GrBackendObjectOwnership ownership,
250 GrWrapCacheable cacheable,
251 bool forSecondaryCB,
252 std::string_view label)
253 : GrAttachment(gpu,
254 dimensions,
255 supportedUsages,
256 info.fSampleCount,
257 info.fLevelCount > 1 ? skgpu::Mipmapped::kYes : skgpu::Mipmapped::kNo,
258 info.fProtected,
259 label)
260 , fInfo(info)
261 , fInitialQueueFamily(info.fCurrentQueueFamily)
262 , fMutableState(std::move(mutableState))
263 , fFramebufferView(std::move(framebufferView))
264 , fTextureView(std::move(textureView))
265 , fIsBorrowed(GrBackendObjectOwnership::kBorrowed == ownership) {
266 this->init(gpu, forSecondaryCB);
267 this->registerWithCacheWrapped(cacheable);
268}
269
270void GrVkImage::init(GrVkGpu* gpu, bool forSecondaryCB) {
273#ifdef SK_DEBUG
276 } else {
281 } else {
285 }
286 }
287 // We can't transfer from the non graphics queue to the graphics queue since we can't
288 // release the image from the original queue without having that queue. This limits us in terms
289 // of the types of queue indices we can handle.
294 if (fInfo.fCurrentQueueFamily != gpu->queueIndex()) {
295 SkASSERT(false);
296 }
297 } else {
298 SkASSERT(false);
299 }
300 }
301#endif
302 if (forSecondaryCB) {
303 fResource = nullptr;
304 } else if (fIsBorrowed) {
305 fResource = new BorrowedResource(gpu, fInfo.fImage, fInfo.fAlloc, fInfo.fImageTiling);
306 } else {
308 fResource = new Resource(gpu, fInfo.fImage, fInfo.fAlloc, fInfo.fImageTiling);
309 }
310}
311
334
336 // Currently we assume we will never being doing any explict shader writes (this doesn't include
337 // color attachment or depth/stencil writes). So we will ignore the
338 // VK_MEMORY_OUTPUT_SHADER_WRITE_BIT.
339
340 // We can only directly access the host memory if we are in preinitialized or general layout,
341 // and the image is linear.
342 // TODO: Add check for linear here so we are not always adding host to general, and we should
343 // only be in preinitialized if we are linear
345 if (VK_IMAGE_LAYOUT_GENERAL == layout) {
350 } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
352 } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
356 } else if (VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == layout) {
358 } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout ||
361 // There are no writes that need to be made available
362 flags = 0;
363 }
364 return flags;
365}
366
378
380 VkImageLayout newLayout,
381 VkAccessFlags dstAccessMask,
382 VkPipelineStageFlags dstStageMask,
383 bool byRegion,
384 uint32_t newQueueFamilyIndex) {
385// Enable the following block to test new devices to confirm their lazy images stay at 0 memory use.
386#if 0
388 VkDeviceSize size;
389 VK_CALL(gpu, GetDeviceMemoryCommitment(gpu->device(), fInfo.fAlloc.fMemory, &size));
390
391 SkDebugf("Lazy Image. This: %p, image: %d, size: %d\n", this, fInfo.fImage, size);
392 }
393#endif
394 SkASSERT(!gpu->isDeviceLost());
395 SkASSERT(newLayout == this->currentLayout() ||
396 (VK_IMAGE_LAYOUT_UNDEFINED != newLayout &&
397 VK_IMAGE_LAYOUT_PREINITIALIZED != newLayout));
399 uint32_t currentQueueIndex = this->currentQueueFamilyIndex();
400
401#ifdef SK_DEBUG
403 if (newQueueFamilyIndex == VK_QUEUE_FAMILY_IGNORED) {
404 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED ||
405 currentQueueIndex == VK_QUEUE_FAMILY_EXTERNAL ||
406 currentQueueIndex == VK_QUEUE_FAMILY_FOREIGN_EXT);
407 } else {
408 SkASSERT(newQueueFamilyIndex == VK_QUEUE_FAMILY_EXTERNAL ||
409 newQueueFamilyIndex == VK_QUEUE_FAMILY_FOREIGN_EXT);
410 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED);
411 }
412 } else {
414 if (newQueueFamilyIndex == VK_QUEUE_FAMILY_IGNORED ||
415 currentQueueIndex == gpu->queueIndex()) {
416 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED ||
417 currentQueueIndex == VK_QUEUE_FAMILY_EXTERNAL ||
418 currentQueueIndex == VK_QUEUE_FAMILY_FOREIGN_EXT ||
419 currentQueueIndex == gpu->queueIndex());
420 } else if (newQueueFamilyIndex == VK_QUEUE_FAMILY_EXTERNAL ||
421 newQueueFamilyIndex == VK_QUEUE_FAMILY_FOREIGN_EXT) {
422 SkASSERT(currentQueueIndex == VK_QUEUE_FAMILY_IGNORED ||
423 currentQueueIndex == gpu->queueIndex());
424 }
425 }
426#endif
427
429 if (newQueueFamilyIndex == VK_QUEUE_FAMILY_IGNORED) {
430 newQueueFamilyIndex = gpu->queueIndex();
431 }
432 if (currentQueueIndex == VK_QUEUE_FAMILY_IGNORED) {
433 currentQueueIndex = gpu->queueIndex();
434 }
435 }
436
437 // If the old and new layout are the same and the layout is a read only layout, there is no need
438 // to put in a barrier unless we also need to switch queues.
439 if (newLayout == currentLayout && currentQueueIndex == newQueueFamilyIndex &&
443 return;
444 }
445
448
450
451 VkImageMemoryBarrier imageMemoryBarrier = {
453 nullptr, // pNext
454 srcAccessMask, // srcAccessMask
455 dstAccessMask, // dstAccessMask
456 currentLayout, // oldLayout
457 newLayout, // newLayout
458 currentQueueIndex, // srcQueueFamilyIndex
459 newQueueFamilyIndex, // dstQueueFamilyIndex
460 fInfo.fImage, // image
461 { aspectFlags, 0, fInfo.fLevelCount, 0, 1 } // subresourceRange
462 };
463 SkASSERT(srcAccessMask == imageMemoryBarrier.srcAccessMask);
464 gpu->addImageMemoryBarrier(this->resource(), srcStageMask, dstStageMask, byRegion,
465 &imageMemoryBarrier);
466
467 this->updateImageLayout(newLayout);
468 this->setQueueFamilyIndex(newQueueFamilyIndex);
469}
470
472 if (0 == imageDesc.fWidth || 0 == imageDesc.fHeight) {
473 return false;
474 }
475 if ((imageDesc.fIsProtected == GrProtected::kYes) &&
477 return false;
478 }
479
480 bool isLinear = VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling;
481 VkImageLayout initialLayout = isLinear ? VK_IMAGE_LAYOUT_PREINITIALIZED
483
484 // Create Image
485 VkSampleCountFlagBits vkSamples;
486 if (!skgpu::SampleCountToVkSampleCount(imageDesc.fSamples, &vkSamples)) {
487 return false;
488 }
489
491 VK_SAMPLE_COUNT_1_BIT == vkSamples);
492
493 VkImageCreateFlags createflags = 0;
494 if (imageDesc.fIsProtected == GrProtected::kYes || gpu->protectedContext()) {
495 createflags |= VK_IMAGE_CREATE_PROTECTED_BIT;
496 }
497 const VkImageCreateInfo imageCreateInfo = {
499 nullptr, // pNext
500 createflags, // VkImageCreateFlags
501 imageDesc.fImageType, // VkImageType
502 imageDesc.fFormat, // VkFormat
503 { imageDesc.fWidth, imageDesc.fHeight, 1 }, // VkExtent3D
504 imageDesc.fLevels, // mipLevels
505 1, // arrayLayers
506 vkSamples, // samples
507 imageDesc.fImageTiling, // VkImageTiling
508 imageDesc.fUsageFlags, // VkImageUsageFlags
509 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode
510 0, // queueFamilyCount
511 nullptr, // pQueueFamilyIndices
512 initialLayout // initialLayout
513 };
514
515 VkImage image = VK_NULL_HANDLE;
517 GR_VK_CALL_RESULT(gpu, result, CreateImage(gpu->device(), &imageCreateInfo, nullptr, &image));
518 if (result != VK_SUCCESS) {
519 return false;
520 }
521
522 skgpu::Protected isProtected = gpu->protectedContext() ? skgpu::Protected::kYes
523 : skgpu::Protected::kNo;
524 bool forceDedicatedMemory = gpu->vkCaps().shouldAlwaysUseDedicatedImageMemory();
525 bool useLazyAllocation =
527
528 auto checkResult = [gpu, isProtected, forceDedicatedMemory, useLazyAllocation](
530 GR_VK_LOG_IF_NOT_SUCCESS(gpu, result, "skgpu::VulkanMemory::AllocImageMemory"
531 " (isProtected:%d, forceDedicatedMemory:%d, useLazyAllocation:%d)",
532 (int)isProtected, (int)forceDedicatedMemory,
533 (int)useLazyAllocation);
534 return gpu->checkVkResult(result);
535 };
536 auto allocator = gpu->memoryAllocator();
539 image,
541 forceDedicatedMemory,
542 useLazyAllocation,
543 checkResult,
544 &alloc) ||
545 (useLazyAllocation &&
547 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
548 return false;
549 }
550
551 // Bind buffer
552 GR_VK_CALL_RESULT(gpu, result, BindImageMemory(gpu->device(),
553 image,
555 alloc.fOffset));
556 if (result) {
558 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
559 return false;
560 }
561
562 info->fImage = image;
563 info->fAlloc = alloc;
564 info->fImageTiling = imageDesc.fImageTiling;
565 info->fImageLayout = initialLayout;
566 info->fFormat = imageDesc.fFormat;
567 info->fImageUsageFlags = imageDesc.fUsageFlags;
568 info->fSampleCount = imageDesc.fSamples;
569 info->fLevelCount = imageDesc.fLevels;
570 info->fCurrentQueueFamily = VK_QUEUE_FAMILY_IGNORED;
571 info->fProtected =
572 (createflags & VK_IMAGE_CREATE_PROTECTED_BIT) ? GrProtected::kYes : GrProtected::kNo;
573 info->fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
574 return true;
575}
576
578 VK_CALL(gpu, DestroyImage(gpu->device(), info->fImage, nullptr));
580}
581
583 // should have been released first
584 SkASSERT(!fResource);
585 SkASSERT(!fFramebufferView);
586 SkASSERT(!fTextureView);
587}
588
590 VkImageLayout layout = this->currentLayout();
591 if (fInitialQueueFamily != VK_QUEUE_FAMILY_EXTERNAL &&
592 fInitialQueueFamily != VK_QUEUE_FAMILY_FOREIGN_EXT) {
593 if (gpu->vkCaps().supportsSwapchain()) {
595 }
596 }
598 fInitialQueueFamily);
599}
600
602 this->setImageLayoutAndQueueIndex(gpu, this->currentLayout(), 0,
604 fInitialQueueFamily);
605}
606
607void GrVkImage::releaseImage() {
608 if (fResource) {
609 fResource->unref();
610 fResource = nullptr;
611 }
612 fFramebufferView.reset();
613 fTextureView.reset();
614 fCachedBlendingInputDescSet.reset();
615 fCachedMSAALoadInputDescSet.reset();
616}
617
619 this->releaseImage();
621}
622
624 this->releaseImage();
626}
627
629 SkASSERT(fResource);
630 // Forward the release proc on to GrVkImage::Resource
631 fResource->setRelease(std::move(releaseHelper));
632}
633
634void GrVkImage::Resource::freeGPUData() const {
635 this->invokeReleaseProc();
636 VK_CALL(fGpu, DestroyImage(fGpu->device(), fImage, nullptr));
637 skgpu::VulkanMemory::FreeImageMemory(fGpu->memoryAllocator(), fAlloc);
638}
639
640void GrVkImage::BorrowedResource::freeGPUData() const {
641 this->invokeReleaseProc();
642}
643
645 VkImageView view,
646 VkImageLayout layout,
647 VkDescriptorSet descSet) {
648 VkDescriptorImageInfo imageInfo;
649 memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo));
650 imageInfo.sampler = VK_NULL_HANDLE;
651 imageInfo.imageView = view;
652 imageInfo.imageLayout = layout;
653
654 VkWriteDescriptorSet writeInfo;
655 memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet));
657 writeInfo.pNext = nullptr;
658 writeInfo.dstSet = descSet;
660 writeInfo.dstArrayElement = 0;
661 writeInfo.descriptorCount = 1;
663 writeInfo.pImageInfo = &imageInfo;
664 writeInfo.pBufferInfo = nullptr;
665 writeInfo.pTexelBufferView = nullptr;
666
667 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), 1, &writeInfo, 0, nullptr));
668}
669
671 if (!this->supportsInputAttachmentUsage()) {
672 return nullptr;
673 }
674 if (fCachedBlendingInputDescSet) {
675 return fCachedBlendingInputDescSet;
676 }
677
678 fCachedBlendingInputDescSet.reset(gpu->resourceProvider().getInputDescriptorSet());
679 if (!fCachedBlendingInputDescSet) {
680 return nullptr;
681 }
682
684 this->framebufferView()->imageView(),
686 *fCachedBlendingInputDescSet->descriptorSet());
687
688 return fCachedBlendingInputDescSet;
689}
690
692 if (!this->supportsInputAttachmentUsage()) {
693 return nullptr;
694 }
695 if (fCachedMSAALoadInputDescSet) {
696 return fCachedMSAALoadInputDescSet;
697 }
698
699 fCachedMSAALoadInputDescSet.reset(gpu->resourceProvider().getInputDescriptorSet());
700 if (!fCachedMSAALoadInputDescSet) {
701 return nullptr;
702 }
703
705 this->framebufferView()->imageView(),
707 *fCachedMSAALoadInputDescSet->descriptorSet());
708
709 return fCachedMSAALoadInputDescSet;
710}
711
712GrVkGpu* GrVkImage::getVkGpu() const {
713 SkASSERT(!this->wasDestroyed());
714 return static_cast<GrVkGpu*>(this->getGpu());
715}
716
717#if defined(GR_TEST_UTILS)
718void GrVkImage::setCurrentQueueFamilyToGraphicsQueue(GrVkGpu* gpu) {
720}
721#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
GrWrapCacheable
Definition GrTypesPriv.h:84
GrWrapOwnership
Definition GrTypesPriv.h:76
@ kBorrow_GrWrapOwnership
Definition GrTypesPriv.h:78
GrMemoryless
GrBackendObjectOwnership
#define VK_CALL(GPU, X)
#define VK_CALL(GPU, X)
Definition GrVkImage.cpp:19
VkImageAspectFlags vk_format_to_aspect_flags(VkFormat format)
static void write_input_desc_set(GrVkGpu *gpu, VkImageView view, VkImageLayout layout, VkDescriptorSet descSet)
static bool make_views(GrVkGpu *gpu, const GrVkImageInfo &info, GrAttachment::UsageFlags attachmentUsages, sk_sp< const GrVkImageView > *framebufferView, sk_sp< const GrVkImageView > *textureView)
Definition GrVkImage.cpp:95
#define GR_VK_CALL(IFACE, X)
Definition GrVkUtil.h:24
#define GR_VK_LOG_IF_NOT_SUCCESS(GPU, RESULT, X,...)
Definition GrVkUtil.h:28
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition GrVkUtil.h:35
uint16_t fFlags
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
int numSamples() const
bool supportsProtectedContent() const
Definition GrCaps.h:422
virtual void onAbandon()
GrGpu * getGpu() const
bool wasDestroyed() const
void registerWithCacheWrapped(GrWrapCacheable)
void registerWithCache(skgpu::Budgeted)
virtual void onRelease()
SkISize dimensions() const
Definition GrSurface.h:27
bool isProtected() const
Definition GrSurface.h:87
GrInternalSurfaceFlags flags() const
Definition GrSurface.h:68
bool shouldAlwaysUseDedicatedImageMemory() const
Definition GrVkCaps.h:94
bool supportsSwapchain() const
Definition GrVkCaps.h:126
uint32_t queueIndex() const
Definition GrVkGpu.h:73
const GrVkCaps & vkCaps() const
Definition GrVkGpu.h:61
void addImageMemoryBarrier(const GrManagedResource *, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, bool byRegion, VkImageMemoryBarrier *barrier) const
Definition GrVkGpu.cpp:2180
const skgpu::VulkanInterface * vkInterface() const
Definition GrVkGpu.h:60
VkDevice device() const
Definition GrVkGpu.h:71
GrVkResourceProvider & resourceProvider()
Definition GrVkGpu.h:83
bool isDeviceLost() const override
Definition GrVkGpu.h:66
bool protectedContext() const
Definition GrVkGpu.h:81
bool checkVkResult(VkResult)
Definition GrVkGpu.cpp:2675
skgpu::VulkanMemoryAllocator * memoryAllocator() const
Definition GrVkGpu.h:68
static sk_sp< const GrVkImageView > Make(GrVkGpu *gpu, VkImage image, VkFormat format, Type viewType, uint32_t miplevels, const GrVkYcbcrConversionInfo &ycbcrInfo)
const GrVkImageView * framebufferView() const
Definition GrVkImage.h:105
void prepareForPresent(GrVkGpu *gpu)
static sk_sp< GrVkImage > MakeStencil(GrVkGpu *gpu, SkISize dimensions, int sampleCnt, VkFormat format)
Definition GrVkImage.cpp:21
const GrVkImageView * textureView() const
Definition GrVkImage.h:106
void setQueueFamilyIndex(uint32_t queueFamilyIndex)
Definition GrVkImage.h:156
static VkAccessFlags LayoutToSrcAccessMask(const VkImageLayout layout)
uint32_t mipLevels() const
Definition GrVkImage.h:93
static void DestroyImageInfo(const GrVkGpu *gpu, GrVkImageInfo *)
void onAbandon() override
bool supportsInputAttachmentUsage() const
Definition GrVkImage.h:101
static sk_sp< GrVkImage > MakeMSAA(GrVkGpu *gpu, SkISize dimensions, int numSamples, VkFormat format, GrProtected isProtected, GrMemoryless memoryless)
Definition GrVkImage.cpp:39
VkImageLayout currentLayout() const
Definition GrVkImage.h:132
VkImageUsageFlags vkUsageFlags()
Definition GrVkImage.h:100
static sk_sp< GrVkImage > MakeWrapped(GrVkGpu *gpu, SkISize dimensions, const GrVkImageInfo &, sk_sp< skgpu::MutableTextureState >, UsageFlags attachmentUsages, GrWrapOwnership, GrWrapCacheable, std::string_view label, bool forSecondaryCB=false)
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout)
const Resource * resource() const
Definition GrVkImage.h:118
void prepareForExternal(GrVkGpu *gpu)
~GrVkImage() override
const skgpu::VulkanAlloc & alloc() const
Definition GrVkImage.h:75
void updateImageLayout(VkImageLayout newLayout)
Definition GrVkImage.h:170
static sk_sp< GrVkImage > MakeTexture(GrVkGpu *gpu, SkISize dimensions, VkFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted, GrProtected isProtected)
Definition GrVkImage.cpp:65
gr_rp< const GrVkDescriptorSet > inputDescSetForMSAALoad(GrVkGpu *gpu)
uint32_t currentQueueFamilyIndex() const
Definition GrVkImage.h:152
gr_rp< const GrVkDescriptorSet > inputDescSetForBlending(GrVkGpu *gpu)
void setResourceRelease(sk_sp< RefCntedReleaseProc > releaseHelper)
void setImageLayoutAndQueueIndex(const GrVkGpu *gpu, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion, uint32_t newQueueFamilyIndex)
VkImage image() const
Definition GrVkImage.h:69
void onRelease() override
static bool InitImageInfo(GrVkGpu *gpu, const ImageDesc &imageDesc, GrVkImageInfo *)
const GrVkDescriptorSet * getInputDescriptorSet()
T * get() const
Definition SkRefCnt.h:303
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310
GAsyncResult * result
uint32_t uint32_t * format
SK_API uint32_t GetVkQueueFamilyIndex(const MutableTextureState &state)
SK_API MutableTextureState MakeVulkan(VkImageLayout layout, uint32_t queueFamilyIndex)
void SetVkQueueFamilyIndex(MutableTextureState *state, uint32_t queueFamilyIndex)
SK_API VkImageLayout GetVkImageLayout(const MutableTextureState &state)
void FreeImageMemory(VulkanMemoryAllocator *, const VulkanAlloc &alloc)
bool AllocImageMemory(VulkanMemoryAllocator *, VkImage image, skgpu::Protected isProtected, bool forceDedicatedMemory, bool useLazyAllocation, const std::function< CheckResult > &, VulkanAlloc *alloc)
Budgeted
Definition GpuTypes.h:35
Renderable
Definition GpuTypes.h:69
Mipmapped
Definition GpuTypes.h:53
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
Protected
Definition GpuTypes.h:61
Definition ref_ptr.h:256
VkImage fImage
Definition GrVkTypes.h:26
VkSharingMode fSharingMode
Definition GrVkTypes.h:37
skgpu::VulkanAlloc fAlloc
Definition GrVkTypes.h:27
uint32_t fCurrentQueueFamily
Definition GrVkTypes.h:34
VkFormat fFormat
Definition GrVkTypes.h:30
uint32_t fLevelCount
Definition GrVkTypes.h:33
VkImageLayout fImageLayout
Definition GrVkTypes.h:29
VkImageUsageFlags fImageUsageFlags
Definition GrVkTypes.h:31
VkImageTiling fImageTiling
Definition GrVkTypes.h:28
VkImageUsageFlags fUsageFlags
Definition GrVkImage.h:185
VkImageType fImageType
Definition GrVkImage.h:178
GrProtected fIsProtected
Definition GrVkImage.h:187
VkImageTiling fImageTiling
Definition GrVkImage.h:184
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37
VkImageLayout imageLayout
VkAccessFlags srcAccessMask
const VkBufferView * pTexelBufferView
VkStructureType sType
const VkDescriptorImageInfo * pImageInfo
const VkDescriptorBufferInfo * pBufferInfo
VkDescriptorSet dstSet
VkDescriptorType descriptorType
VkDeviceMemory fMemory
Definition VulkanTypes.h:38
VkDeviceSize fOffset
Definition VulkanTypes.h:39
VkFlags VkPipelineStageFlags
VkImageLayout
@ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
@ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ VK_IMAGE_LAYOUT_PREINITIALIZED
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
@ VK_IMAGE_LAYOUT_GENERAL
@ VK_SHARING_MODE_CONCURRENT
@ VK_SHARING_MODE_EXCLUSIVE
VkFlags VkImageAspectFlags
VkFlags VkAccessFlags
VkFlags VkImageUsageFlags
uint64_t VkDeviceSize
Definition vulkan_core.h:96
@ VK_IMAGE_CREATE_PROTECTED_BIT
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_TILING_LINEAR
@ VK_IMAGE_ASPECT_COLOR_BIT
@ VK_IMAGE_ASPECT_STENCIL_BIT
@ VK_IMAGE_ASPECT_DEPTH_BIT
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
@ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
VkSampleCountFlagBits
@ VK_SAMPLE_COUNT_1_BIT
#define VK_QUEUE_FAMILY_FOREIGN_EXT
@ VK_IMAGE_TYPE_2D
VkFlags VkImageCreateFlags
VkResult
@ VK_SUCCESS
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
@ VK_ACCESS_TRANSFER_WRITE_BIT
@ VK_ACCESS_HOST_WRITE_BIT
@ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
@ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
#define VK_NULL_HANDLE
Definition vulkan_core.h:46
#define VK_QUEUE_FAMILY_EXTERNAL
VkFormat
@ VK_FORMAT_D24_UNORM_S8_UINT
@ VK_FORMAT_S8_UINT
@ VK_FORMAT_D32_SFLOAT_S8_UINT
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
@ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
@ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
@ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
@ VK_PIPELINE_STAGE_HOST_BIT
@ VK_PIPELINE_STAGE_TRANSFER_BIT
#define VK_QUEUE_FAMILY_IGNORED
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
@ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER