19#define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
27 return GrVkImage::Make(gpu,
53 return GrVkImage::Make(gpu,
83 return GrVkImage::Make(gpu,
113 gpu,
info.fImage,
info.fFormat, viewType, 1,
info.fYcbcrConversionInfo);
114 if (!*framebufferView) {
125 info.fYcbcrConversionInfo);
135 UsageFlags attachmentUsages,
166 auto mutableState = sk_make_sp<skgpu::MutableTextureState>(
172 std::move(mutableState),
186 std::string_view label,
187 bool forSecondaryCB) {
190 if (!forSecondaryCB) {
204 std::move(mutableState),
213GrVkImage::GrVkImage(
GrVkGpu* gpu,
215 UsageFlags supportedUsages,
221 std::string_view label)
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);
242GrVkImage::GrVkImage(
GrVkGpu* gpu,
244 UsageFlags supportedUsages,
252 std::string_view label)
261 , fInitialQueueFamily(
info.fCurrentQueueFamily)
262 , fMutableState(
std::move(mutableState))
263 , fFramebufferView(
std::move(framebufferView))
264 , fTextureView(
std::move(textureView))
266 this->init(gpu, forSecondaryCB);
270void GrVkImage::init(
GrVkGpu* gpu,
bool forSecondaryCB) {
302 if (forSecondaryCB) {
304 }
else if (fIsBorrowed) {
384 uint32_t newQueueFamilyIndex) {
439 if (newLayout ==
currentLayout && currentQueueIndex == newQueueFamilyIndex &&
465 &imageMemoryBarrier);
525 bool useLazyAllocation =
528 auto checkResult = [gpu,
isProtected, forceDedicatedMemory, useLazyAllocation](
531 " (isProtected:%d, forceDedicatedMemory:%d, useLazyAllocation:%d)",
533 (
int)useLazyAllocation);
541 forceDedicatedMemory,
545 (useLazyAllocation &&
565 info->fImageLayout = initialLayout;
598 fInitialQueueFamily);
604 fInitialQueueFamily);
607void GrVkImage::releaseImage() {
612 fFramebufferView.
reset();
613 fTextureView.
reset();
614 fCachedBlendingInputDescSet.reset();
615 fCachedMSAALoadInputDescSet.reset();
618void GrVkImage::onRelease() {
619 this->releaseImage();
623void GrVkImage::onAbandon() {
624 this->releaseImage();
631 fResource->setRelease(std::move(releaseHelper));
634void GrVkImage::Resource::freeGPUData()
const {
635 this->invokeReleaseProc();
636 VK_CALL(fGpu, DestroyImage(fGpu->device(), fImage,
nullptr));
640void GrVkImage::BorrowedResource::freeGPUData()
const {
641 this->invokeReleaseProc();
647 VkDescriptorSet descSet) {
657 writeInfo.
pNext =
nullptr;
658 writeInfo.
dstSet = descSet;
674 if (fCachedBlendingInputDescSet) {
675 return fCachedBlendingInputDescSet;
679 if (!fCachedBlendingInputDescSet) {
686 *fCachedBlendingInputDescSet->descriptorSet());
688 return fCachedBlendingInputDescSet;
695 if (fCachedMSAALoadInputDescSet) {
696 return fCachedMSAALoadInputDescSet;
700 if (!fCachedMSAALoadInputDescSet) {
707 *fCachedMSAALoadInputDescSet->descriptorSet());
709 return fCachedMSAALoadInputDescSet;
712GrVkGpu* GrVkImage::getVkGpu()
const {
717#if defined(GR_TEST_UTILS)
718void GrVkImage::setCurrentQueueFamilyToGraphicsQueue(
GrVkGpu* gpu) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kBorrow_GrWrapOwnership
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)
#define GR_VK_CALL(IFACE, X)
#define GR_VK_LOG_IF_NOT_SUCCESS(GPU, RESULT, X,...)
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
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)
bool supportsProtectedContent() const
bool wasDestroyed() const
void registerWithCacheWrapped(GrWrapCacheable)
void registerWithCache(skgpu::Budgeted)
SkISize dimensions() const
void onAbandon() override
void onRelease() override
GrInternalSurfaceFlags flags() const
bool shouldAlwaysUseDedicatedImageMemory() const
bool supportsSwapchain() const
uint32_t queueIndex() const
const GrVkCaps & vkCaps() const
void addImageMemoryBarrier(const GrManagedResource *, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, bool byRegion, VkImageMemoryBarrier *barrier) const
const skgpu::VulkanInterface * vkInterface() const
GrVkResourceProvider & resourceProvider()
bool isDeviceLost() const override
bool protectedContext() const
bool checkVkResult(VkResult)
skgpu::VulkanMemoryAllocator * memoryAllocator() const
static sk_sp< const GrVkImageView > Make(GrVkGpu *gpu, VkImage image, VkFormat format, Type viewType, uint32_t miplevels, const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
const GrVkImageView * framebufferView() const
void prepareForPresent(GrVkGpu *gpu)
static sk_sp< GrVkImage > MakeStencil(GrVkGpu *gpu, SkISize dimensions, int sampleCnt, VkFormat format)
const GrVkImageView * textureView() const
void setQueueFamilyIndex(uint32_t queueFamilyIndex)
static VkAccessFlags LayoutToSrcAccessMask(const VkImageLayout layout)
uint32_t mipLevels() const
static void DestroyImageInfo(const GrVkGpu *gpu, GrVkImageInfo *)
bool supportsInputAttachmentUsage() const
static sk_sp< GrVkImage > MakeMSAA(GrVkGpu *gpu, SkISize dimensions, int numSamples, VkFormat format, GrProtected isProtected, GrMemoryless memoryless)
VkImageLayout currentLayout() const
VkImageUsageFlags vkUsageFlags()
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
void prepareForExternal(GrVkGpu *gpu)
const skgpu::VulkanAlloc & alloc() const
void updateImageLayout(VkImageLayout newLayout)
static sk_sp< GrVkImage > MakeTexture(GrVkGpu *gpu, SkISize dimensions, VkFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted, GrProtected isProtected)
gr_rp< const GrVkDescriptorSet > inputDescSetForMSAALoad(GrVkGpu *gpu)
uint32_t currentQueueFamilyIndex() const
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)
static bool InitImageInfo(GrVkGpu *gpu, const ImageDesc &imageDesc, GrVkImageInfo *)
const GrVkDescriptorSet * getInputDescriptorSet()
void reset(T *ptr=nullptr)
uint32_t uint32_t * format
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
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)
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
VkSharingMode fSharingMode
skgpu::VulkanAlloc fAlloc
uint32_t fCurrentQueueFamily
VkImageLayout fImageLayout
VkImageUsageFlags fImageUsageFlags
VkImageTiling fImageTiling
VkImageUsageFlags fUsageFlags
VkImageTiling fImageTiling
constexpr int32_t width() const
constexpr int32_t height() const
VkImageLayout imageLayout
VkAccessFlags srcAccessMask
const VkBufferView * pTexelBufferView
const VkDescriptorImageInfo * pImageInfo
const VkDescriptorBufferInfo * pBufferInfo
VkDescriptorType descriptorType
VkFlags VkPipelineStageFlags
@ 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 VkImageUsageFlags
@ VK_IMAGE_CREATE_PROTECTED_BIT
@ VK_IMAGE_TILING_OPTIMAL
@ 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
#define VK_QUEUE_FAMILY_FOREIGN_EXT
VkFlags VkImageCreateFlags
@ 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_QUEUE_FAMILY_EXTERNAL
@ VK_FORMAT_D24_UNORM_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