Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private 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 GrVkYcbcrConversionInfoycbcrConversionInfo () 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
 
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
 
- 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 ()
 

Private Member Functions

void onRelease () override
 
void onAbandon () override
 

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
 
- 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 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 31 of file GrVkImage.h.

Member Typedef Documentation

◆ ReleaseCtx

typedef void* GrVkImage::ReleaseCtx

Definition at line 207 of file GrVkImage.h.

◆ ReleaseProc

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

Definition at line 208 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 75 of file GrVkImage.h.

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

◆ backendFormat()

GrBackendFormat GrVkImage::backendFormat ( ) const
inlineoverridevirtual

Implements GrSurface.

Definition at line 83 of file GrVkImage.h.

83 {
84 bool usesDRMModifier =
86 if (fResource && this->ycbcrConversionInfo().isValid()) {
87 SkASSERT(this->imageFormat() == this->ycbcrConversionInfo().fFormat);
88 return GrBackendFormats::MakeVk(this->ycbcrConversionInfo(), usesDRMModifier);
89 }
91 return GrBackendFormats::MakeVk(this->imageFormat(), usesDRMModifier);
92 }
const GrVkYcbcrConversionInfo & ycbcrConversionInfo() const
Definition GrVkImage.h:94
VkFormat imageFormat() const
Definition GrVkImage.h:82
const GrVkImageInfo & vkImageInfo() const
Definition GrVkImage.h:81
SK_API GrBackendFormat MakeVk(VkFormat format, bool willUseDRMFormatModifiers=false)
VkImageTiling fImageTiling
Definition GrVkTypes.h:28
@ VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT
@ VK_FORMAT_UNDEFINED

◆ currentLayout()

VkImageLayout GrVkImage::currentLayout ( ) const
inline

Definition at line 132 of file GrVkImage.h.

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

◆ currentQueueFamilyIndex()

uint32_t GrVkImage::currentQueueFamilyIndex ( ) const
inline

Definition at line 152 of file GrVkImage.h.

152 {
154 }
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)
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 105 of file GrVkImage.h.

105{ return fFramebufferView.get(); }

◆ getMutableState()

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

Definition at line 130 of file GrVkImage.h.

130{ return fMutableState; }

◆ image()

VkImage GrVkImage::image ( ) const
inline

Definition at line 69 of file GrVkImage.h.

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

◆ imageFormat()

VkFormat GrVkImage::imageFormat ( ) const
inline

Definition at line 82 of file GrVkImage.h.

82{ 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
522 skgpu::Protected isProtected = gpu->protectedContext() ? skgpu::Protected::kYes
523 : skgpu::Protected::kNo;
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 =
572 (createflags & VK_IMAGE_CREATE_PROTECTED_BIT) ? GrProtected::kYes : GrProtected::kNo;
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
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
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:2675
const skgpu::VulkanAlloc & alloc() const
Definition GrVkImage.h:75
VkImage image() const
Definition GrVkImage.h:69
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:38
VkDeviceSize fOffset
Definition VulkanTypes.h:39
VkImageLayout
@ VK_IMAGE_LAYOUT_PREINITIALIZED
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_SHARING_MODE_EXCLUSIVE
@ VK_IMAGE_CREATE_PROTECTED_BIT
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_TILING_LINEAR
@ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
VkSampleCountFlagBits
@ VK_SAMPLE_COUNT_1_BIT
VkFlags VkImageCreateFlags
VkResult
@ VK_SUCCESS
#define VK_NULL_HANDLE
Definition vulkan_core.h:46
#define VK_QUEUE_FAMILY_IGNORED
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO

◆ 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)
GrVkResourceProvider & resourceProvider()
Definition GrVkGpu.h:83
const GrVkImageView * framebufferView() const
Definition GrVkImage.h:105
bool supportsInputAttachmentUsage() const
Definition GrVkImage.h:101
const GrVkDescriptorSet * getInputDescriptorSet()
@ VK_IMAGE_LAYOUT_GENERAL

◆ 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

◆ isBorrowed()

bool GrVkImage::isBorrowed ( ) const
inline

Definition at line 128 of file GrVkImage.h.

128{ return fIsBorrowed; }

◆ isLinearTiled()

bool GrVkImage::isLinearTiled ( ) const
inline

Definition at line 122 of file GrVkImage.h.

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

◆ 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
@ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
@ 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_HOST_BIT
@ VK_PIPELINE_STAGE_TRANSFER_BIT

◆ 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
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
@ VK_ACCESS_TRANSFER_WRITE_BIT
@ VK_ACCESS_HOST_WRITE_BIT
@ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT

◆ 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
SkISize dimensions() const
Definition GrSurface.h:27
VkImageUsageFlags vkUsageFlags()
Definition GrVkImage.h:100
uint32_t uint32_t * format
VkFlags VkImageUsageFlags
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT

◆ MakeStencil()

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

Definition at line 21 of file GrVkImage.cpp.

24 {
27 return GrVkImage::Make(gpu,
30 sampleCnt,
31 format,
32 /*mipLevels=*/1,
34 GrProtected::kNo,
37}
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT

◆ 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:93
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT

◆ 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:78
GrBackendObjectOwnership
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:106

◆ mipLevels()

uint32_t GrVkImage::mipLevels ( ) const
inline

Definition at line 93 of file GrVkImage.h.

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

◆ onAbandon()

void GrVkImage::onAbandon ( )
overrideprivatevirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources. This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrSurface.

Definition at line 623 of file GrVkImage.cpp.

623 {
624 this->releaseImage();
626}
virtual void onAbandon()

◆ onRelease()

void GrVkImage::onRelease ( )
overrideprivatevirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrSurface.

Definition at line 618 of file GrVkImage.cpp.

618 {
619 this->releaseImage();
621}
virtual void onRelease()

◆ 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:132
void setImageLayoutAndQueueIndex(const GrVkGpu *gpu, VkImageLayout newLayout, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, bool byRegion, uint32_t newQueueFamilyIndex)
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT

◆ 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

◆ resource()

const Resource * GrVkImage::resource ( ) const
inline

Definition at line 118 of file GrVkImage.h.

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

◆ setImageLayout()

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

Definition at line 143 of file GrVkImage.h.

147 {
148 this->setImageLayoutAndQueueIndex(gpu, newLayout, dstAccessMask, dstStageMask, byRegion,
150 }

◆ 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)
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:2180
bool isDeviceLost() const override
Definition GrVkGpu.h:66
void setQueueFamilyIndex(uint32_t queueFamilyIndex)
Definition GrVkImage.h:156
static VkAccessFlags LayoutToSrcAccessMask(const VkImageLayout layout)
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout)
const Resource * resource() const
Definition GrVkImage.h:118
void updateImageLayout(VkImageLayout newLayout)
Definition GrVkImage.h:170
uint32_t currentQueueFamilyIndex() const
Definition GrVkImage.h:152
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
VkFlags VkPipelineStageFlags
@ VK_SHARING_MODE_CONCURRENT
VkFlags VkImageAspectFlags
uint64_t VkDeviceSize
Definition vulkan_core.h:96
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER

◆ setQueueFamilyIndex()

void GrVkImage::setQueueFamilyIndex ( uint32_t  queueFamilyIndex)
inline

Definition at line 156 of file GrVkImage.h.

156 {
157 skgpu::MutableTextureStates::SetVkQueueFamilyIndex(fMutableState.get(), queueFamilyIndex);
158 }
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 101 of file GrVkImage.h.

101 {
103 }
VkImageUsageFlags fImageUsageFlags
Definition GrVkTypes.h:31

◆ textureView()

const GrVkImageView * GrVkImage::textureView ( ) const
inline

Definition at line 106 of file GrVkImage.h.

106{ return fTextureView.get(); }

◆ updateImageLayout()

void GrVkImage::updateImageLayout ( VkImageLayout  newLayout)
inline

Definition at line 170 of file GrVkImage.h.

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

◆ vkImageInfo()

const GrVkImageInfo & GrVkImage::vkImageInfo ( ) const
inline

Definition at line 81 of file GrVkImage.h.

81{ return fInfo; }

◆ vkUsageFlags()

VkImageUsageFlags GrVkImage::vkUsageFlags ( )
inline

Definition at line 100 of file GrVkImage.h.

100{ return fInfo.fImageUsageFlags; }

◆ ycbcrConversionInfo()

const GrVkYcbcrConversionInfo & GrVkImage::ycbcrConversionInfo ( ) const
inline

Definition at line 94 of file GrVkImage.h.

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

Friends And Related Symbol Documentation

◆ GrVkRenderTarget

friend class GrVkRenderTarget
friend

Definition at line 330 of file GrVkImage.h.


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