Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
GrD3DTexture Class Reference

#include <GrD3DTexture.h>

Inheritance diagram for GrD3DTexture:
GrTexture GrD3DTextureResource GrSurface SkNoncopyable GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrD3DTextureRenderTarget

Public Member Functions

 ~GrD3DTexture () override
 
GrBackendTexture getBackendTexture () const override
 
GrBackendFormat backendFormat () const override
 
D3D12_CPU_DESCRIPTOR_HANDLE shaderResourceView ()
 
void textureParamsModified () override
 
- Public Member Functions inherited from GrTexture
GrTextureasTexture () override
 
const GrTextureasTexture () const override
 
virtual GrBackendTexture getBackendTexture () const =0
 
virtual void textureParamsModified ()=0
 
GrTextureType textureType () const
 
bool hasRestrictedSampling () const
 
void markMipmapsDirty ()
 
void markMipmapsClean ()
 
skgpu::Mipmapped mipmapped () const
 
bool mipmapsAreDirty () const
 
GrMipmapStatus mipmapStatus () const
 
int maxMipmapLevel () const
 
- 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
 
- Public Member Functions inherited from GrD3DTextureResource
 GrD3DTextureResource (const GrD3DTextureResourceInfo &info, sk_sp< GrD3DResourceState > state)
 
virtual ~GrD3DTextureResource ()
 
ID3D12Resource * d3dResource () const
 
DXGI_FORMAT dxgiFormat () const
 
GrBackendFormat getBackendFormat () const
 
sk_sp< Resource > resource () const
 
uint32_t mipLevels () const
 
sk_sp< GrD3DResourceStategrD3DResourceState () const
 
D3D12_RESOURCE_STATES currentState () const
 
void setResourceState (const GrD3DGpu *gpu, D3D12_RESOURCE_STATES newResourceState, unsigned int subresource=D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES)
 
void prepareForPresent (GrD3DGpu *gpu)
 
unsigned int sampleQualityPattern () const
 
void updateResourceState (D3D12_RESOURCE_STATES newState)
 
void setResourceRelease (sk_sp< GrSurface::RefCntedReleaseProc > releaseHelper)
 

Static Public Member Functions

static sk_sp< GrD3DTextureMakeNewTexture (GrD3DGpu *, skgpu::Budgeted, SkISize dimensions, const D3D12_RESOURCE_DESC &, GrProtected, GrMipmapStatus, std::string_view label)
 
static sk_sp< GrD3DTextureMakeWrappedTexture (GrD3DGpu *, SkISize dimensions, GrWrapCacheable, GrIOType, const GrD3DTextureResourceInfo &, sk_sp< GrD3DResourceState >)
 
static sk_sp< GrD3DTextureMakeAliasingTexture (GrD3DGpu *, sk_sp< GrD3DTexture >, const D3D12_RESOURCE_DESC &newDesc, D3D12_RESOURCE_STATES)
 
- Static Public Member Functions inherited from GrTexture
static bool StealBackendTexture (sk_sp< GrTexture >, GrBackendTexture *, SkImages::BackendTextureReleaseProc *)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, 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 ()
 
- Static Public Member Functions inherited from GrD3DTextureResource
static bool InitTextureResourceInfo (GrD3DGpu *gpu, const D3D12_RESOURCE_DESC &desc, D3D12_RESOURCE_STATES initialState, GrProtected, D3D12_CLEAR_VALUE *, GrD3DTextureResourceInfo *)
 
static std::pair< GrD3DTextureResourceInfo, sk_sp< GrD3DResourceState > > CreateMSAA (GrD3DGpu *gpu, SkISize dimensions, int sampleCnt, const GrD3DTextureResourceInfo &info, SkColor4f clearColor)
 

Protected Member Functions

 GrD3DTexture (GrD3DGpu *, SkISize dimensions, const GrD3DTextureResourceInfo &, sk_sp< GrD3DResourceState >, const GrD3DDescriptorHeap::CPUHandle &shaderResourceView, GrMipmapStatus, std::string_view label)
 
GrD3DGpugetD3DGpu () const
 
void onAbandon () override
 
void onRelease () override
 
bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
 
void onSetLabel () override
 
- Protected Member Functions inherited from GrTexture
 GrTexture (GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
 
virtual bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *)=0
 
void computeScratchKey (skgpu::ScratchKey *) const override
 
- 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
 
- Protected Member Functions inherited from GrD3DTextureResource
void releaseResource (GrD3DGpu *gpu)
 

Additional Inherited Members

- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 
- Protected Attributes inherited from GrD3DTextureResource
GrD3DTextureResourceInfo fInfo
 
sk_sp< GrD3DResourceStatefState
 

Detailed Description

Definition at line 18 of file GrD3DTexture.h.

Constructor & Destructor Documentation

◆ ~GrD3DTexture()

GrD3DTexture::~GrD3DTexture ( )
inlineoverride

Definition at line 40 of file GrD3DTexture.h.

40{}

◆ GrD3DTexture()

GrD3DTexture::GrD3DTexture ( GrD3DGpu gpu,
SkISize  dimensions,
const GrD3DTextureResourceInfo info,
sk_sp< GrD3DResourceState state,
const GrD3DDescriptorHeap::CPUHandle shaderResourceView,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
protected

Definition at line 54 of file GrD3DTexture.cpp.

61 : GrSurface(gpu, dimensions, info.fProtected, label)
63 , INHERITED(gpu, dimensions, info.fProtected, GrTextureType::k2D, mipmapStatus, label)
64 , fShaderResourceView(shaderResourceView) {
65 SkASSERT((GrMipmapStatus::kNotAllocated == mipmapStatus) == (1 == info.fLevelCount));
66}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
GrD3DTextureResource(const GrD3DTextureResourceInfo &info, sk_sp< GrD3DResourceState > state)
D3D12_CPU_DESCRIPTOR_HANDLE shaderResourceView()
Definition: GrD3DTexture.h:45
SkISize dimensions() const
Definition: GrSurface.h:27
GrSurface(GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
Definition: GrSurface.h:140
GrMipmapStatus mipmapStatus() const
Definition: GrTexture.h:66
AtkStateType state

Member Function Documentation

◆ backendFormat()

GrBackendFormat GrD3DTexture::backendFormat ( ) const
inlineoverridevirtual

Implements GrSurface.

Reimplemented in GrD3DTextureRenderTarget.

Definition at line 44 of file GrD3DTexture.h.

44{ return this->getBackendFormat(); }
GrBackendFormat getBackendFormat() const

◆ getBackendTexture()

GrBackendTexture GrD3DTexture::getBackendTexture ( ) const
overridevirtual

Implements GrTexture.

Definition at line 163 of file GrD3DTexture.cpp.

163 {
164 return GrBackendTexture(this->width(), this->height(), fInfo, this->grD3DResourceState());
165}
GrD3DTextureResourceInfo fInfo
sk_sp< GrD3DResourceState > grD3DResourceState() const
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32

◆ getD3DGpu()

GrD3DGpu * GrD3DTexture::getD3DGpu ( ) const
protected

Definition at line 167 of file GrD3DTexture.cpp.

167 {
168 SkASSERT(!this->wasDestroyed());
169 return static_cast<GrD3DGpu*>(this->getGpu());
170}
GrGpu * getGpu() const
bool wasDestroyed() const

◆ MakeAliasingTexture()

sk_sp< GrD3DTexture > GrD3DTexture::MakeAliasingTexture ( GrD3DGpu gpu,
sk_sp< GrD3DTexture originalTexture,
const D3D12_RESOURCE_DESC &  newDesc,
D3D12_RESOURCE_STATES  resourceState 
)
static

Definition at line 119 of file GrD3DTexture.cpp.

122 {
123 GrD3DTextureResourceInfo info = originalTexture->fInfo;
124 info.fResource = gpu->memoryAllocator()->createAliasingResource(info.fAlloc, 0, &newDesc,
125 resourceState, nullptr);
126 if (!info.fResource) {
127 return nullptr;
128 }
129 info.fResourceState = resourceState;
130
132 new GrD3DResourceState(static_cast<D3D12_RESOURCE_STATES>(resourceState)));
133
135 gpu->resourceProvider().createShaderResourceView(info.fResource.get());
136
137 GrD3DTexture* tex = new GrD3DTexture(gpu,
139 originalTexture->dimensions(),
140 info,
141 std::move(state),
143 originalTexture->mipmapStatus(),
144 /*label=*/"AliasingTexture");
145 return sk_sp<GrD3DTexture>(tex);
146}
GrD3DMemoryAllocator * memoryAllocator() const
Definition: GrD3DGpu.h:46
GrD3DResourceProvider & resourceProvider()
Definition: GrD3DGpu.h:38
virtual gr_cp< ID3D12Resource > createAliasingResource(sk_sp< GrD3DAlloc > &allocation, uint64_t localOffset, const D3D12_RESOURCE_DESC *, D3D12_RESOURCE_STATES initialResourceState, const D3D12_CLEAR_VALUE *)=0
GrD3DDescriptorHeap::CPUHandle createShaderResourceView(ID3D12Resource *resource, unsigned int mostDetailedMip=0, unsigned int mipLevels=-1)
GrD3DTexture(GrD3DGpu *, SkISize dimensions, const GrD3DTextureResourceInfo &, sk_sp< GrD3DResourceState >, const GrD3DDescriptorHeap::CPUHandle &shaderResourceView, GrMipmapStatus, std::string_view label)

◆ MakeNewTexture()

sk_sp< GrD3DTexture > GrD3DTexture::MakeNewTexture ( GrD3DGpu gpu,
skgpu::Budgeted  budgeted,
SkISize  dimensions,
const D3D12_RESOURCE_DESC &  desc,
GrProtected  isProtected,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
static

Definition at line 68 of file GrD3DTexture.cpp.

74 {
77 D3D12_RESOURCE_STATE_COPY_DEST,
78 isProtected, nullptr, &info)) {
79 return nullptr;
80 }
81
83 new GrD3DResourceState(static_cast<D3D12_RESOURCE_STATES>(info.fResourceState)));
84
86 gpu->resourceProvider().createShaderResourceView(info.fResource.get());
87
88 GrD3DTexture* tex = new GrD3DTexture(gpu, budgeted, dimensions, info, std::move(state),
91 label);
92
93 return sk_sp<GrD3DTexture>(tex);
94}
static bool InitTextureResourceInfo(GrD3DGpu *gpu, const D3D12_RESOURCE_DESC &desc, D3D12_RESOURCE_STATES initialState, GrProtected, D3D12_CLEAR_VALUE *, GrD3DTextureResourceInfo *)
bool isProtected() const
Definition: GrSurface.h:87

◆ MakeWrappedTexture()

sk_sp< GrD3DTexture > GrD3DTexture::MakeWrappedTexture ( GrD3DGpu gpu,
SkISize  dimensions,
GrWrapCacheable  cacheable,
GrIOType  ioType,
const GrD3DTextureResourceInfo info,
sk_sp< GrD3DResourceState state 
)
static

Definition at line 96 of file GrD3DTexture.cpp.

101 {
102 // TODO: If a client uses their own heap to allocate, how do we manage that?
103 // Adopted textures require both image and allocation because we're responsible for freeing
104 //SkASSERT(info.fTexture &&
105 // (kBorrow_GrWrapOwnership == wrapOwnership || VK_NULL_HANDLE != info.fAlloc.fMemory));
106
109
111 gpu->resourceProvider().createShaderResourceView(info.fResource.get());
112
113 return sk_sp<GrD3DTexture>(new GrD3DTexture(gpu, dimensions, info, std::move(state),
115 ioType,
116 /*label=*/"D3DWrappedTexture"));
117}
GrMipmapStatus
Definition: GrTypesPriv.h:523

◆ onAbandon()

void GrD3DTexture::onAbandon ( )
overrideprotectedvirtual

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 GrGpuResource.

Reimplemented in GrD3DTextureRenderTarget.

Definition at line 156 of file GrD3DTexture.cpp.

156 {
157 GrD3DGpu* gpu = this->getD3DGpu();
158 gpu->resourceProvider().recycleShaderView(fShaderResourceView);
159 this->releaseResource(gpu);
161}
void recycleShaderView(const GrD3DDescriptorHeap::CPUHandle &)
void releaseResource(GrD3DGpu *gpu)
GrD3DGpu * getD3DGpu() const
void onAbandon() override
Definition: GrSurface.cpp:86

◆ onRelease()

void GrD3DTexture::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Reimplemented in GrD3DTextureRenderTarget.

Definition at line 148 of file GrD3DTexture.cpp.

148 {
149 GrD3DGpu* gpu = this->getD3DGpu();
150 gpu->resourceProvider().recycleShaderView(fShaderResourceView);
151 this->releaseResource(gpu);
152
154}
void onRelease() override
Definition: GrSurface.cpp:81

◆ onSetLabel()

void GrD3DTexture::onSetLabel ( )
overrideprotectedvirtual

Implements GrGpuResource.

Definition at line 172 of file GrD3DTexture.cpp.

172 {
173 SkASSERT(this->d3dResource());
174 if (!this->getLabel().empty()) {
175 const std::wstring label = L"_Skia_" + GrD3DMultiByteToWide(this->getLabel());
176 this->d3dResource()->SetName(label.c_str());
177 }
178}
std::wstring GrD3DMultiByteToWide(const std::string &str)
Definition: GrD3DUtil.cpp:25
ID3D12Resource * d3dResource() const
std::string getLabel() const
EMSCRIPTEN_KEEPALIVE void empty()

◆ onStealBackendTexture()

bool GrD3DTexture::onStealBackendTexture ( GrBackendTexture ,
SkImages::BackendTextureReleaseProc  
)
inlineoverrideprotectedvirtual

Implements GrTexture.

Definition at line 63 of file GrD3DTexture.h.

63 {
64 return false;
65 }

◆ shaderResourceView()

D3D12_CPU_DESCRIPTOR_HANDLE GrD3DTexture::shaderResourceView ( )
inline

Definition at line 45 of file GrD3DTexture.h.

45{ return fShaderResourceView.fHandle; }
D3D12_CPU_DESCRIPTOR_HANDLE fHandle

◆ textureParamsModified()

void GrD3DTexture::textureParamsModified ( )
inlineoverridevirtual

This function indicates that the texture parameters (wrap mode, filtering, ...) have been changed externally to Skia.

Implements GrTexture.

Definition at line 47 of file GrD3DTexture.h.

47{}

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