Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
GrVkImage Class Reference

#include <GrVkImage.h>

Inheritance diagram for GrVkImage:
GrAttachment GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable

Classes

struct  ImageDesc
 

Public Types

typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrAttachment
enum class  UsageFlags : uint8_t { kStencilAttachment = 0x1 , kColorAttachment = 0x2 , kTexture = 0x4 }
 
- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Public Member Functions

 ~GrVkImage () override
 
VkImage image () const
 
const skgpu::VulkanAllocalloc () const
 
const GrVkImageInfovkImageInfo () const
 
VkFormat imageFormat () const
 
GrBackendFormat backendFormat () const override
 
uint32_t mipLevels () const
 
const skgpu::VulkanYcbcrConversionInfoycbcrConversionInfo () const
 
VkImageUsageFlags vkUsageFlags ()
 
bool supportsInputAttachmentUsage () const
 
const GrVkImageViewframebufferView () const
 
const GrVkImageViewtextureView () const
 
gr_rp< const GrVkDescriptorSetinputDescSetForBlending (GrVkGpu *gpu)
 
gr_rp< const GrVkDescriptorSetinputDescSetForMSAALoad (GrVkGpu *gpu)
 
const Resource * resource () const
 
bool isLinearTiled () const
 
bool isBorrowed () const
 
sk_sp< skgpu::MutableTextureStategetMutableState () const
 
VkImageLayout currentLayout () const
 
void setImageLayoutAndQueueIndex (const GrVkGpu *gpu, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion, uint32_t newQueueFamilyIndex)
 
void setImageLayout (const GrVkGpu *gpu, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion)
 
uint32_t currentQueueFamilyIndex () const
 
void setQueueFamilyIndex (uint32_t queueFamilyIndex)
 
void prepareForPresent (GrVkGpu *gpu)
 
void prepareForExternal (GrVkGpu *gpu)
 
void updateImageLayout (VkImageLayout newLayout)
 
void setResourceRelease (sk_sp< RefCntedReleaseProc > releaseHelper)
 
- Public Member Functions inherited from GrAttachment
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (UsageFlags)
 
 ~GrAttachment () override
 
UsageFlags supportedUsages () const
 
int numSamples () const
 
skgpu::Mipmapped mipmapped () const
 
bool hasPerformedInitialClear () const
 
void markHasPerformedInitialClear ()
 
- Public Member Functions inherited from GrSurface
SkISize dimensions () const
 
int width () const
 
int height () const
 
SkRect getBoundsRect () const
 
virtual GrBackendFormat backendFormat () const =0
 
void setRelease (sk_sp< skgpu::RefCntedCallback > releaseHelper)
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
virtual GrTextureasTexture ()
 
virtual const GrTextureasTexture () const
 
virtual GrRenderTargetasRenderTarget ()
 
virtual const GrRenderTargetasRenderTarget () const
 
GrInternalSurfaceFlags flags () const
 
bool readOnly () const
 
bool framebufferOnly () const
 
bool isProtected () const
 
void setFramebufferOnly ()
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 
const GrDirectContextgetContext () const
 
GrDirectContextgetContext ()
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
const skgpu::UniqueKeygetUniqueKey () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ProxyAccess proxyAccess ()
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual const char * getResourceType () const =0
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
bool unique () const
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

static sk_sp< GrVkImageMakeStencil (GrVkGpu *gpu, SkISize dimensions, int sampleCnt, VkFormat format)
 
static sk_sp< GrVkImageMakeMSAA (GrVkGpu *gpu, SkISize dimensions, int numSamples, VkFormat format, GrProtected isProtected, GrMemoryless memoryless)
 
static sk_sp< GrVkImageMakeTexture (GrVkGpu *gpu, SkISize dimensions, VkFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted, GrProtected isProtected)
 
static sk_sp< GrVkImageMakeWrapped (GrVkGpu *gpu, SkISize dimensions, const GrVkImageInfo &, sk_sp< skgpu::MutableTextureState >, UsageFlags attachmentUsages, GrWrapOwnership, GrWrapCacheable, std::string_view label, bool forSecondaryCB=false)
 
static bool InitImageInfo (GrVkGpu *gpu, const ImageDesc &imageDesc, GrVkImageInfo *)
 
static void DestroyImageInfo (const GrVkGpu *gpu, GrVkImageInfo *)
 
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags (const VkImageLayout layout)
 
static VkAccessFlags LayoutToSrcAccessMask (const VkImageLayout layout)
 
- Static Public Member Functions inherited from GrAttachment
static void ComputeSharedAttachmentUniqueKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, GrMemoryless memoryless, skgpu::UniqueKey *key)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected, GrMemoryless, skgpu::ScratchKey *key)
 
- Static Public Member Functions inherited from GrSurface
static size_t ComputeSize (const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
 
- Static Public Member Functions inherited from GrGpuResource
static uint32_t CreateUniqueID ()
 

Friends

class GrVkRenderTarget
 

Additional Inherited Members

- Protected Member Functions inherited from GrAttachment
 GrAttachment (GrGpu *gpu, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, std::string_view label, GrMemoryless memoryless=GrMemoryless::kNo)
 
- Protected Member Functions inherited from GrSurface
void setGLRTFBOIDIs0 ()
 
bool glRTFBOIDis0 () const
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
void setReadOnly ()
 
void setVkRTSupportsInputAttachment ()
 
 GrSurface (GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
 
 ~GrSurface () override
 
void onRelease () override
 
void onAbandon () override
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (skgpu::Budgeted)
 
void registerWithCacheWrapped (GrWrapCacheable)
 
 GrGpuResource (GrGpu *, std::string_view label)
 
virtual ~GrGpuResource ()
 
GrGpugetGpu () const
 
virtual void onRelease ()
 
virtual void onAbandon ()
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 
SkString getResourceName () const
 
void dumpMemoryStatisticsPriv (SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
 GrIORef ()
 
bool internalHasRef () const
 
bool internalHasNoCommandBufferUsages () const
 
void addInitialRef () const
 

Detailed Description

Definition at line 32 of file GrVkImage.h.

Member Typedef Documentation

◆ ReleaseCtx

typedef void* GrVkImage::ReleaseCtx

Definition at line 208 of file GrVkImage.h.

◆ ReleaseProc

typedef void(* GrVkImage::ReleaseProc) (ReleaseCtx)

Definition at line 209 of file GrVkImage.h.

Constructor & Destructor Documentation

◆ ~GrVkImage()

GrVkImage::~GrVkImage ( )
override

Definition at line 582 of file GrVkImage.cpp.

582 {
583 // should have been released first
584 SkASSERT(!fResource);
585 SkASSERT(!fFramebufferView);
586 SkASSERT(!fTextureView);
587}
#define SkASSERT(cond)
Definition: SkAssert.h:116

Member Function Documentation

◆ alloc()

const skgpu::VulkanAlloc & GrVkImage::alloc ( ) const
inline

Definition at line 76 of file GrVkImage.h.

76 {
77 // Should only be called when we have a real fResource object, i.e. never when being used as
78 // a RT in an external secondary command buffer.
79 SkASSERT(fResource);
80 return fInfo.fAlloc;
81 }
skgpu::VulkanAlloc fAlloc
Definition: GrVkTypes.h:27

◆ backendFormat()

GrBackendFormat GrVkImage::backendFormat ( ) const
inlineoverridevirtual

Implements GrSurface.

Definition at line 84 of file GrVkImage.h.

84 {
85 bool usesDRMModifier =
87 if (fResource && this->ycbcrConversionInfo().isValid()) {
88 SkASSERT(this->imageFormat() == this->ycbcrConversionInfo().fFormat);
89 return GrBackendFormats::MakeVk(this->ycbcrConversionInfo(), usesDRMModifier);
90 }
92 return GrBackendFormats::MakeVk(this->imageFormat(), usesDRMModifier);
93 }
VkFormat imageFormat() const
Definition: GrVkImage.h:83
const skgpu::VulkanYcbcrConversionInfo & ycbcrConversionInfo() const
Definition: GrVkImage.h:95
const GrVkImageInfo & vkImageInfo() const
Definition: GrVkImage.h:82
SK_API GrBackendFormat MakeVk(VkFormat format, bool willUseDRMFormatModifiers=false)
VkImageTiling fImageTiling
Definition: GrVkTypes.h:28
@ VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT
Definition: vulkan_core.h:1769
@ VK_FORMAT_UNDEFINED
Definition: vulkan_core.h:1459

◆ currentLayout()

VkImageLayout GrVkImage::currentLayout ( ) const
inline

Definition at line 133 of file GrVkImage.h.

133 {
135 }
T * get() const
Definition: SkRefCnt.h:303
SK_API VkImageLayout GetVkImageLayout(const MutableTextureState &state)

◆ currentQueueFamilyIndex()

uint32_t GrVkImage::currentQueueFamilyIndex ( ) const
inline

Definition at line 153 of file GrVkImage.h.

153 {
155 }
SK_API uint32_t GetVkQueueFamilyIndex(const MutableTextureState &state)

◆ DestroyImageInfo()

void GrVkImage::DestroyImageInfo ( const GrVkGpu gpu,
GrVkImageInfo info 
)
static

Definition at line 577 of file GrVkImage.cpp.

577 {
578 VK_CALL(gpu, DestroyImage(gpu->device(), info->fImage, nullptr));
580}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define VK_CALL(GPU, X)
Definition: GrVkImage.cpp:19
VkDevice device() const
Definition: GrVkGpu.h:71
skgpu::VulkanMemoryAllocator * memoryAllocator() const
Definition: GrVkGpu.h:68
void FreeImageMemory(VulkanMemoryAllocator *, const VulkanAlloc &alloc)

◆ framebufferView()

const GrVkImageView * GrVkImage::framebufferView ( ) const
inline

Definition at line 106 of file GrVkImage.h.

106{ return fFramebufferView.get(); }

◆ getMutableState()

sk_sp< skgpu::MutableTextureState > GrVkImage::getMutableState ( ) const
inline

Definition at line 131 of file GrVkImage.h.

131{ return fMutableState; }

◆ image()

VkImage GrVkImage::image ( ) const
inline

Definition at line 70 of file GrVkImage.h.

70 {
71 // Should only be called when we have a real fResource object, i.e. never when being used as
72 // a RT in an external secondary command buffer.
73 SkASSERT(fResource);
74 return fInfo.fImage;
75 }
VkImage fImage
Definition: GrVkTypes.h:26

◆ imageFormat()

VkFormat GrVkImage::imageFormat ( ) const
inline

Definition at line 83 of file GrVkImage.h.

83{ return fInfo.fFormat; }
VkFormat fFormat
Definition: GrVkTypes.h:30

◆ InitImageInfo()

bool GrVkImage::InitImageInfo ( GrVkGpu gpu,
const ImageDesc imageDesc,
GrVkImageInfo info 
)
static

Definition at line 471 of file GrVkImage.cpp.

471 {
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
490 SkASSERT(VK_IMAGE_TILING_OPTIMAL == imageDesc.fImageTiling ||
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
524 bool forceDedicatedMemory = gpu->vkCaps().shouldAlwaysUseDedicatedImageMemory();
525 bool useLazyAllocation =
526 SkToBool(imageDesc.fUsageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT);
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 =
573 info->fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
574 return true;
575}
#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
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
bool supportsProtectedContent() const
Definition: GrCaps.h:422
bool isProtected() const
Definition: GrSurface.h:87
bool shouldAlwaysUseDedicatedImageMemory() const
Definition: GrVkCaps.h:94
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61
bool protectedContext() const
Definition: GrVkGpu.h:81
bool checkVkResult(VkResult)
Definition: GrVkGpu.cpp:2659
const skgpu::VulkanAlloc & alloc() const
Definition: GrVkImage.h:76
VkImage image() const
Definition: GrVkImage.h:70
GAsyncResult * result
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)
Protected
Definition: GpuTypes.h:61
VkDeviceMemory fMemory
Definition: VulkanTypes.h:39
VkDeviceSize fOffset
Definition: VulkanTypes.h:40
VkImageLayout
Definition: vulkan_core.h:1330
@ VK_IMAGE_LAYOUT_PREINITIALIZED
Definition: vulkan_core.h:1339
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan_core.h:1331
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan_core.h:1813
@ VK_IMAGE_CREATE_PROTECTED_BIT
Definition: vulkan_core.h:2320
@ VK_IMAGE_TILING_OPTIMAL
Definition: vulkan_core.h:1767
@ 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
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

◆ inputDescSetForBlending()

gr_rp< const GrVkDescriptorSet > GrVkImage::inputDescSetForBlending ( GrVkGpu gpu)

Definition at line 670 of file GrVkImage.cpp.

670 {
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}
static void write_input_desc_set(GrVkGpu *gpu, VkImageView view, VkImageLayout layout, VkDescriptorSet descSet)
Definition: GrVkImage.cpp:644
GrVkResourceProvider & resourceProvider()
Definition: GrVkGpu.h:83
const GrVkImageView * framebufferView() const
Definition: GrVkImage.h:106
bool supportsInputAttachmentUsage() const
Definition: GrVkImage.h:102
const GrVkDescriptorSet * getInputDescriptorSet()
@ VK_IMAGE_LAYOUT_GENERAL
Definition: vulkan_core.h:1332

◆ inputDescSetForMSAALoad()

gr_rp< const GrVkDescriptorSet > GrVkImage::inputDescSetForMSAALoad ( GrVkGpu gpu)

Definition at line 691 of file GrVkImage.cpp.

691 {
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}
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan_core.h:1336

◆ isBorrowed()

bool GrVkImage::isBorrowed ( ) const
inline

Definition at line 129 of file GrVkImage.h.

129{ return fIsBorrowed; }

◆ isLinearTiled()

bool GrVkImage::isLinearTiled ( ) const
inline

Definition at line 123 of file GrVkImage.h.

123 {
124 // Should only be called when we have a real fResource object, i.e. never when being used as
125 // a RT in an external secondary command buffer.
126 SkASSERT(fResource);
128 }

◆ LayoutToPipelineSrcStageFlags()

VkPipelineStageFlags GrVkImage::LayoutToPipelineSrcStageFlags ( const VkImageLayout  layout)
static

Definition at line 312 of file GrVkImage.cpp.

312 {
313 if (VK_IMAGE_LAYOUT_GENERAL == layout) {
315 } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout ||
318 } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
323 } else if (VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) {
325 } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
327 } else if (VK_IMAGE_LAYOUT_PRESENT_SRC_KHR == layout) {
329 }
330
333}
@ 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_COLOR_ATTACHMENT_OPTIMAL
Definition: vulkan_core.h:1333
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
Definition: vulkan_core.h:1335
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan_core.h:1338
@ 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 GrVkImage::LayoutToSrcAccessMask ( const VkImageLayout  layout)
static

Definition at line 335 of file GrVkImage.cpp.

335 {
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}
GrInternalSurfaceFlags flags() const
Definition: GrSurface.h:68
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

◆ MakeMSAA()

sk_sp< GrVkImage > GrVkImage::MakeMSAA ( GrVkGpu gpu,
SkISize  dimensions,
int  numSamples,
VkFormat  format,
GrProtected  isProtected,
GrMemoryless  memoryless 
)
static

Definition at line 39 of file GrVkImage.cpp.

44 {
46
48 if (memoryless == GrMemoryless::kYes) {
50 } else {
52 }
53 return GrVkImage::Make(gpu,
57 format,
58 /*mipLevels=*/1,
61 memoryless,
63}
int numSamples() const
Definition: GrAttachment.h:38
SkISize dimensions() const
Definition: GrSurface.h:27
VkImageUsageFlags vkUsageFlags()
Definition: GrVkImage.h:101
uint32_t uint32_t * format
VkFlags VkImageUsageFlags
Definition: vulkan_core.h:2382
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
Definition: vulkan_core.h:2353
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan_core.h:2356
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
Definition: vulkan_core.h:2352

◆ MakeStencil()

sk_sp< GrVkImage > GrVkImage::MakeStencil ( GrVkGpu gpu,
SkISize  dimensions,
int  sampleCnt,
VkFormat  format 
)
static

Definition at line 21 of file GrVkImage.cpp.

◆ MakeTexture()

sk_sp< GrVkImage > GrVkImage::MakeTexture ( GrVkGpu gpu,
SkISize  dimensions,
VkFormat  format,
uint32_t  mipLevels,
GrRenderable  renderable,
int  numSamples,
skgpu::Budgeted  budgeted,
GrProtected  isProtected 
)
static

Definition at line 65 of file GrVkImage.cpp.

72 {
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}
uint32_t mipLevels() const
Definition: GrVkImage.h:94
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan_core.h:2354
@ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
Definition: vulkan_core.h:2359

◆ MakeWrapped()

sk_sp< GrVkImage > GrVkImage::MakeWrapped ( GrVkGpu gpu,
SkISize  dimensions,
const GrVkImageInfo info,
sk_sp< skgpu::MutableTextureState mutableState,
UsageFlags  attachmentUsages,
GrWrapOwnership  ownership,
GrWrapCacheable  cacheable,
std::string_view  label,
bool  forSecondaryCB = false 
)
static

Definition at line 179 of file GrVkImage.cpp.

187 {
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}
@ kBorrow_GrWrapOwnership
Definition: GrTypesPriv.h:79
GrBackendObjectOwnership
Definition: GrTypesPriv.h:496
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
const GrVkImageView * textureView() const
Definition: GrVkImage.h:107

◆ mipLevels()

uint32_t GrVkImage::mipLevels ( ) const
inline

Definition at line 94 of file GrVkImage.h.

94{ return fInfo.fLevelCount; }
uint32_t fLevelCount
Definition: GrVkTypes.h:33

◆ prepareForExternal()

void GrVkImage::prepareForExternal ( GrVkGpu gpu)

Definition at line 601 of file GrVkImage.cpp.

601 {
602 this->setImageLayoutAndQueueIndex(gpu, this->currentLayout(), 0,
604 fInitialQueueFamily);
605}
VkImageLayout currentLayout() const
Definition: GrVkImage.h:133
void setImageLayoutAndQueueIndex(const GrVkGpu *gpu, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion, uint32_t newQueueFamilyIndex)
Definition: GrVkImage.cpp:379
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
Definition: vulkan_core.h:2448

◆ prepareForPresent()

void GrVkImage::prepareForPresent ( GrVkGpu gpu)

Definition at line 589 of file GrVkImage.cpp.

589 {
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}
bool supportsSwapchain() const
Definition: GrVkCaps.h:126
#define VK_QUEUE_FAMILY_FOREIGN_EXT
#define VK_QUEUE_FAMILY_EXTERNAL
Definition: vulkan_core.h:4927

◆ resource()

const Resource * GrVkImage::resource ( ) const
inline

Definition at line 119 of file GrVkImage.h.

119 {
120 SkASSERT(fResource);
121 return fResource;
122 }

◆ setImageLayout()

void GrVkImage::setImageLayout ( const GrVkGpu gpu,
VkImageLayout  newLayout,
VkAccessFlags  dstAccessMask,
VkPipelineStageFlags  dstStageMask,
bool  byRegion 
)
inline

Definition at line 144 of file GrVkImage.h.

148 {
149 this->setImageLayoutAndQueueIndex(gpu, newLayout, dstAccessMask, dstStageMask, byRegion,
151 }

◆ setImageLayoutAndQueueIndex()

void GrVkImage::setImageLayoutAndQueueIndex ( const GrVkGpu gpu,
VkImageLayout  newLayout,
VkAccessFlags  dstAccessMask,
VkPipelineStageFlags  dstStageMask,
bool  byRegion,
uint32_t  newQueueFamilyIndex 
)

Definition at line 379 of file GrVkImage.cpp.

384 {
385// Enable the following block to test new devices to confirm their lazy images stay at 0 memory use.
386#if 0
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}
VkImageAspectFlags vk_format_to_aspect_flags(VkFormat format)
Definition: GrVkImage.cpp:367
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
uint32_t queueIndex() const
Definition: GrVkGpu.h:73
void addImageMemoryBarrier(const GrManagedResource *, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, bool byRegion, VkImageMemoryBarrier *barrier) const
Definition: GrVkGpu.cpp:2164
bool isDeviceLost() const override
Definition: GrVkGpu.h:66
void setQueueFamilyIndex(uint32_t queueFamilyIndex)
Definition: GrVkImage.h:157
static VkAccessFlags LayoutToSrcAccessMask(const VkImageLayout layout)
Definition: GrVkImage.cpp:335
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout)
Definition: GrVkImage.cpp:312
const Resource * resource() const
Definition: GrVkImage.h:119
void updateImageLayout(VkImageLayout newLayout)
Definition: GrVkImage.h:171
uint32_t currentQueueFamilyIndex() const
Definition: GrVkImage.h:153
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
VkSharingMode fSharingMode
Definition: GrVkTypes.h:37
VkAccessFlags srcAccessMask
Definition: vulkan_core.h:2938
VkFlags VkPipelineStageFlags
Definition: vulkan_core.h:2470
@ VK_SHARING_MODE_CONCURRENT
Definition: vulkan_core.h:1814
VkFlags VkImageAspectFlags
Definition: vulkan_core.h:2256
uint64_t VkDeviceSize
Definition: vulkan_core.h:96
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
Definition: vulkan_core.h:247

◆ setQueueFamilyIndex()

void GrVkImage::setQueueFamilyIndex ( uint32_t  queueFamilyIndex)
inline

Definition at line 157 of file GrVkImage.h.

157 {
158 skgpu::MutableTextureStates::SetVkQueueFamilyIndex(fMutableState.get(), queueFamilyIndex);
159 }
void SetVkQueueFamilyIndex(MutableTextureState *state, uint32_t queueFamilyIndex)

◆ setResourceRelease()

void GrVkImage::setResourceRelease ( sk_sp< RefCntedReleaseProc releaseHelper)

Definition at line 628 of file GrVkImage.cpp.

628 {
629 SkASSERT(fResource);
630 // Forward the release proc on to GrVkImage::Resource
631 fResource->setRelease(std::move(releaseHelper));
632}

◆ supportsInputAttachmentUsage()

bool GrVkImage::supportsInputAttachmentUsage ( ) const
inline

Definition at line 102 of file GrVkImage.h.

102 {
104 }
VkImageUsageFlags fImageUsageFlags
Definition: GrVkTypes.h:31

◆ textureView()

const GrVkImageView * GrVkImage::textureView ( ) const
inline

Definition at line 107 of file GrVkImage.h.

107{ return fTextureView.get(); }

◆ updateImageLayout()

void GrVkImage::updateImageLayout ( VkImageLayout  newLayout)
inline

Definition at line 171 of file GrVkImage.h.

171 {
172 // Should only be called when we have a real fResource object, i.e. never when being used as
173 // a RT in an external secondary command buffer.
174 SkASSERT(fResource);
175 skgpu::MutableTextureStates::SetVkImageLayout(fMutableState.get(), newLayout);
176 }
void SetVkImageLayout(MutableTextureState *state, VkImageLayout layout)

◆ vkImageInfo()

const GrVkImageInfo & GrVkImage::vkImageInfo ( ) const
inline

Definition at line 82 of file GrVkImage.h.

82{ return fInfo; }

◆ vkUsageFlags()

VkImageUsageFlags GrVkImage::vkUsageFlags ( )
inline

Definition at line 101 of file GrVkImage.h.

101{ return fInfo.fImageUsageFlags; }

◆ ycbcrConversionInfo()

const skgpu::VulkanYcbcrConversionInfo & GrVkImage::ycbcrConversionInfo ( ) const
inline

Definition at line 95 of file GrVkImage.h.

95 {
96 // Should only be called when we have a real fResource object, i.e. never when being used as
97 // a RT in an external secondary command buffer.
98 SkASSERT(fResource);
99 return fInfo.fYcbcrConversionInfo;
100 }
skgpu::VulkanYcbcrConversionInfo fYcbcrConversionInfo
Definition: GrVkTypes.h:36

Friends And Related Function Documentation

◆ GrVkRenderTarget

friend class GrVkRenderTarget
friend

Definition at line 331 of file GrVkImage.h.


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