Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrVkTexture.h
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
8#ifndef GrVkTexture_DEFINED
9#define GrVkTexture_DEFINED
10
13#include "src/core/SkLRUCache.h"
17
19class GrVkGpu;
20class GrVkImageView;
21struct GrVkImageInfo;
22
23class GrVkTexture : public GrTexture {
24public:
26 skgpu::Budgeted budgeted,
29 uint32_t mipLevels,
32 std::string_view label);
33
39 const GrVkImageInfo&,
41
42 ~GrVkTexture() override;
43
44 GrBackendTexture getBackendTexture() const override;
45
46 GrBackendFormat backendFormat() const override { return fTexture->backendFormat(); }
47
48 void textureParamsModified() override {}
49
50 GrVkImage* textureImage() const { return fTexture.get(); }
52
53 // For each GrVkTexture, there is a cache of GrVkDescriptorSets which only contain a single
54 // texture/sampler descriptor. If there is a cached descriptor set that matches the passed in
55 // GrSamplerState, then a pointer to it is returned. The ref count is not incremented on the
56 // returned pointer, thus the caller must call ref it if they wish to keep ownership of the
57 // GrVkDescriptorSet.
59
61
62protected:
67 std::string_view label);
68
69 GrVkGpu* getVkGpu() const;
70
71 void onAbandon() override;
72 void onRelease() override;
73
77
78 // In Vulkan we call the release proc after we are finished with the underlying
79 // GrVkImage::Resource object (which occurs after the GPU has finished all work on it).
80 void onSetRelease(sk_sp<RefCntedReleaseProc> releaseHelper) override {
81 // Forward the release proc onto the fTexture's GrVkImage
82 fTexture->setResourceRelease(std::move(releaseHelper));
83 }
84
85private:
88 SkISize,
91 std::string_view label);
95 bool isExternal,
96 std::string_view label);
97
98 void onSetLabel() override{}
99
100 sk_sp<GrVkImage> fTexture;
101
102 struct SamplerHash {
103 uint32_t operator()(GrSamplerState state) const {
104 // In VK the max aniso value is specified in addition to min/mag/mip filters and the
105 // driver is encouraged to consider the other filter settings when doing aniso.
106 return state.asKey(/*anisoIsOrthogonal=*/true);
107 }
108 };
109 struct DescriptorCacheEntry;
111 fDescSetCache;
112 static constexpr int kMaxCachedDescSets = 8;
113};
114
115#endif
GrWrapCacheable
Definition GrTypesPriv.h:84
GrIOType
GrMipmapStatus
GrWrapOwnership
Definition GrTypesPriv.h:76
SkISize dimensions() const
Definition GrSurface.h:27
GrBackendFormat backendFormat() const override
Definition GrVkImage.h:83
void setResourceRelease(sk_sp< RefCntedReleaseProc > releaseHelper)
GrBackendTexture getBackendTexture() const override
void onRelease() override
const GrVkImageView * textureView()
void onSetLabel() override
Definition GrVkTexture.h:98
void textureParamsModified() override
Definition GrVkTexture.h:48
GrVkImage * textureImage() const
Definition GrVkTexture.h:50
GrBackendFormat backendFormat() const override
Definition GrVkTexture.h:46
GrVkGpu * getVkGpu() const
~GrVkTexture() override
void onAbandon() override
const GrVkDescriptorSet * cachedSingleDescSet(GrSamplerState)
void addDescriptorSetToCache(const GrVkDescriptorSet *, GrSamplerState)
static sk_sp< GrVkTexture > MakeWrappedTexture(GrVkGpu *, SkISize dimensions, GrWrapOwnership, GrWrapCacheable, GrIOType, const GrVkImageInfo &, sk_sp< skgpu::MutableTextureState >)
bool onStealBackendTexture(GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
Definition GrVkTexture.h:74
static sk_sp< GrVkTexture > MakeNewTexture(GrVkGpu *, skgpu::Budgeted budgeted, SkISize dimensions, VkFormat format, uint32_t mipLevels, GrProtected, GrMipmapStatus, std::string_view label)
void onSetRelease(sk_sp< RefCntedReleaseProc > releaseHelper) override
Definition GrVkTexture.h:80
T * get() const
Definition SkRefCnt.h:303
AtkStateType state
uint32_t uint32_t * format
FlTexture * texture
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Budgeted
Definition GpuTypes.h:35
Protected
Definition GpuTypes.h:61
VkFormat