Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
skgpu::graphite::DawnTexture Class Reference

#include <DawnTexture.h>

Inheritance diagram for skgpu::graphite::DawnTexture:
skgpu::graphite::Texture skgpu::graphite::Resource

Public Member Functions

 ~DawnTexture () override
 
const wgpu::Texture & dawnTexture () const
 
const wgpu::TextureView & sampleTextureView () const
 
const wgpu::TextureView & renderTextureView () const
 
- Public Member Functions inherited from skgpu::graphite::Texture
 ~Texture () override
 
int numSamples () const
 
Mipmapped mipmapped () const
 
SkISize dimensions () const
 
const TextureInfotextureInfo () const
 
void setReleaseCallback (sk_sp< RefCntedCallback >)
 
const char * getResourceType () const override
 
- Public Member Functions inherited from skgpu::graphite::Resource
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
Resourceoperator= (const Resource &)=delete
 
Resourceoperator= (Resource &&)=delete
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
Ownership ownership () const
 
skgpu::Budgeted budgeted () const
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
bool wasDestroyed () const
 
const GraphiteResourceKeykey () const
 
void setKey (const GraphiteResourceKey &key)
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual void prepareForReturnToCache (const std::function< void()> &takeRef)
 

Static Public Member Functions

static wgpu::Texture MakeDawnTexture (const DawnSharedContext *, SkISize dimensions, const TextureInfo &)
 
static sk_sp< TextureMake (const DawnSharedContext *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted)
 
static sk_sp< TextureMakeWrapped (const DawnSharedContext *, SkISize dimensions, const TextureInfo &, wgpu::Texture)
 
static sk_sp< TextureMakeWrapped (const DawnSharedContext *, SkISize dimensions, const TextureInfo &, const wgpu::TextureView &)
 

Private Member Functions

void freeGpuData () override
 
void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const override
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::Texture
 Texture (const SharedContext *, SkISize dimensions, const TextureInfo &info, sk_sp< MutableTextureState > mutableState, Ownership, skgpu::Budgeted)
 
MutableTextureStatemutableState () const
 
void invokeReleaseProc () override
 
void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const override
 
- Protected Member Functions inherited from skgpu::graphite::Resource
 Resource (const SharedContext *, Ownership, skgpu::Budgeted, size_t gpuMemorySize, std::string_view label, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
void setDeleteASAP ()
 

Detailed Description

Definition at line 19 of file DawnTexture.h.

Constructor & Destructor Documentation

◆ ~DawnTexture()

skgpu::graphite::DawnTexture::~DawnTexture ( )
inlineoverride

Definition at line 40 of file DawnTexture.h.

40{}

Member Function Documentation

◆ dawnTexture()

const wgpu::Texture & skgpu::graphite::DawnTexture::dawnTexture ( ) const
inline

Definition at line 42 of file DawnTexture.h.

42{ return fTexture; }

◆ freeGpuData()

void skgpu::graphite::DawnTexture::freeGpuData ( )
overrideprivatevirtual

Implements skgpu::graphite::Resource.

Definition at line 218 of file DawnTexture.cpp.

218 {
219 if (this->ownership() != Ownership::kWrapped && fTexture) {
220 // Destroy the texture even if it is still referenced by other BindGroup or views.
221 // Graphite should already guarantee that all command buffers using this texture (indirectly
222 // via BindGroup or views) are already completed.
223 fTexture.Destroy();
224 }
225 fTexture = nullptr;
226 fSampleTextureView = nullptr;
227 fRenderTextureView = nullptr;
228}
Ownership ownership() const
Definition Resource.h:98

◆ Make()

sk_sp< Texture > skgpu::graphite::DawnTexture::Make ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
skgpu::Budgeted  budgeted 
)
static

Definition at line 161 of file DawnTexture.cpp.

164 {
166 if (!texture) {
167 return {};
168 }
169 auto [sampleTextureView, renderTextureView] = CreateTextureViews(texture, info);
170 return sk_sp<Texture>(new DawnTexture(sharedContext,
172 info,
173 std::move(texture),
174 std::move(sampleTextureView),
175 std::move(renderTextureView),
177 budgeted));
178}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static wgpu::Texture MakeDawnTexture(const DawnSharedContext *, SkISize dimensions, const TextureInfo &)
const wgpu::TextureView & renderTextureView() const
Definition DawnTexture.h:44
const wgpu::TextureView & sampleTextureView() const
Definition DawnTexture.h:43
skgpu::Budgeted budgeted() const
Definition Resource.h:100
const SharedContext * sharedContext() const
Definition Resource.h:187
SkISize dimensions() const
Definition Texture.h:31
FlTexture * texture

◆ MakeDawnTexture()

wgpu::Texture skgpu::graphite::DawnTexture::MakeDawnTexture ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info 
)
static

Definition at line 49 of file DawnTexture.cpp.

51 {
52 const Caps* caps = sharedContext->caps();
53 if (dimensions.width() > caps->maxTextureSize() ||
54 dimensions.height() > caps->maxTextureSize()) {
55 SKGPU_LOG_E("Texture creation failure: dimensions %d x %d too large.",
57 return {};
58 }
59
60 const DawnTextureSpec& dawnSpec = info.dawnTextureSpec();
61
62 if (dawnSpec.fUsage & wgpu::TextureUsage::TextureBinding && !caps->isTexturable(info)) {
63 return {};
64 }
65
66 if (dawnSpec.fUsage & wgpu::TextureUsage::RenderAttachment &&
67 !(caps->isRenderable(info) || DawnFormatIsDepthOrStencil(dawnSpec.fFormat))) {
68 return {};
69 }
70
71 if (dawnSpec.fUsage & wgpu::TextureUsage::StorageBinding && !caps->isStorage(info)) {
72 return {};
73 }
74
75 int numMipLevels = 1;
76 if (info.mipmapped() == Mipmapped::kYes) {
78 }
79
80 wgpu::TextureDescriptor desc;
81#ifdef SK_DEBUG
82 desc.label = texture_info_to_label(info, dawnSpec);
83#endif
84 desc.usage = dawnSpec.fUsage;
85 desc.dimension = wgpu::TextureDimension::e2D;
86 desc.size.width = dimensions.width();
87 desc.size.height = dimensions.height();
88 desc.size.depthOrArrayLayers = 1;
89 desc.format = dawnSpec.fFormat;
90 desc.mipLevelCount = numMipLevels;
91 desc.sampleCount = info.numSamples();
92 desc.viewFormatCount = 0;
93 desc.viewFormats = nullptr;
94
95 auto texture = sharedContext->device().CreateTexture(&desc);
96 if (!texture) {
97 return {};
98 }
99
100 return texture;
101}
#define SKGPU_LOG_E(fmt,...)
Definition Log.h:38
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition SkMipmap.cpp:134
const Caps * caps() const
bool DawnFormatIsDepthOrStencil(wgpu::TextureFormat format)
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ MakeWrapped() [1/2]

sk_sp< Texture > skgpu::graphite::DawnTexture::MakeWrapped ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
const wgpu::TextureView &  textureView 
)
static

Definition at line 200 of file DawnTexture.cpp.

203 {
204 if (!textureView) {
205 SKGPU_LOG_E("No valid texture view passed into MakeWrapped\n");
206 return {};
207 }
208 return sk_sp<Texture>(new DawnTexture(sharedContext,
210 info,
211 /*texture=*/nullptr,
212 /*sampleTextureView=*/textureView,
213 /*renderTextureView=*/textureView,
216}

◆ MakeWrapped() [2/2]

sk_sp< Texture > skgpu::graphite::DawnTexture::MakeWrapped ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
wgpu::Texture  texture 
)
static

Definition at line 180 of file DawnTexture.cpp.

183 {
184 if (!texture) {
185 SKGPU_LOG_E("No valid texture passed into MakeWrapped\n");
186 return {};
187 }
188
189 auto [sampleTextureView, renderTextureView] = CreateTextureViews(texture, info);
190 return sk_sp<Texture>(new DawnTexture(sharedContext,
192 info,
193 std::move(texture),
194 std::move(sampleTextureView),
195 std::move(renderTextureView),
198}

◆ onDumpMemoryStatistics()

void skgpu::graphite::DawnTexture::onDumpMemoryStatistics ( SkTraceMemoryDump traceMemoryDump,
const char *  dumpName 
) const
overrideprivatevirtual

Reimplemented from skgpu::graphite::Resource.

Definition at line 230 of file DawnTexture.cpp.

231 {
232 Texture::onDumpMemoryStatistics(traceMemoryDump, dumpName);
233 traceMemoryDump->dumpStringValue(
234 dumpName,
235 "backend_label",
236 texture_info_to_label(this->textureInfo(), this->textureInfo().dawnTextureSpec()));
237}
virtual void dumpStringValue(const char *, const char *, const char *)
void onDumpMemoryStatistics(SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const override
Definition Texture.cpp:51
const TextureInfo & textureInfo() const
Definition Texture.h:32

◆ renderTextureView()

const wgpu::TextureView & skgpu::graphite::DawnTexture::renderTextureView ( ) const
inline

Definition at line 44 of file DawnTexture.h.

44{ return fRenderTextureView; }

◆ sampleTextureView()

const wgpu::TextureView & skgpu::graphite::DawnTexture::sampleTextureView ( ) const
inline

Definition at line 43 of file DawnTexture.h.

43{ return fSampleTextureView; }

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