Flutter Engine
The Flutter Engine
GrD3DTexture.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
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 GrD3DTexture_DEFINED
9#define GrD3DTexture_DEFINED
10
12#include "src/core/SkLRUCache.h"
17
18class GrD3DTexture : public GrTexture, public virtual GrD3DTextureResource {
19public:
23 const D3D12_RESOURCE_DESC&,
26 std::string_view label);
27
34
37 const D3D12_RESOURCE_DESC& newDesc,
38 D3D12_RESOURCE_STATES);
39
40 ~GrD3DTexture() override {}
41
42 GrBackendTexture getBackendTexture() const override;
43
44 GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
45 D3D12_CPU_DESCRIPTOR_HANDLE shaderResourceView() { return fShaderResourceView.fHandle; }
46
47 void textureParamsModified() override {}
48
49protected:
56 std::string_view label);
57
58 GrD3DGpu* getD3DGpu() const;
59
60 void onAbandon() override;
61 void onRelease() override;
62
64 return false;
65 }
66
67 void onSetLabel() override;
68
69private:
77 std::string_view label);
84 std::string_view label);
85
86 // In D3D we call the release proc after we are finished with the underlying
87 // GrSurfaceResource::Resource object (which occurs after the GPU has finished all work on it).
88 void onSetRelease(sk_sp<RefCntedReleaseProc> releaseHelper) override {
89 // Forward the release proc on to GrSurfaceResource
90 this->setResourceRelease(std::move(releaseHelper));
91 }
92
93 struct SamplerHash {
94 uint32_t operator()(GrSamplerState state) const {
95 // In D3D anisotropic filtering uses the same field (D3D12_SAMPLER_DESC::Filter) as
96 // min/mag/mip settings and so is not orthogonal to them.
97 return state.asKey(/*anisoIsOrthogonal=*/false);
98 }
99 };
100
101 GrD3DDescriptorHeap::CPUHandle fShaderResourceView;
102
103 using INHERITED = GrTexture;
104};
105
106#endif
GrWrapCacheable
Definition: GrTypesPriv.h:85
GrIOType
Definition: GrTypesPriv.h:402
GrMipmapStatus
Definition: GrTypesPriv.h:523
GrBackendFormat getBackendFormat() const
void setResourceRelease(sk_sp< GrSurface::RefCntedReleaseProc > releaseHelper)
GrD3DTexture(GrD3DGpu *, SkISize dimensions, const GrD3DTextureResourceInfo &, sk_sp< GrD3DResourceState >, const GrD3DDescriptorHeap::CPUHandle &shaderResourceView, GrMipmapStatus, std::string_view label)
GrD3DGpu * getD3DGpu() const
void onRelease() override
static sk_sp< GrD3DTexture > MakeNewTexture(GrD3DGpu *, skgpu::Budgeted, SkISize dimensions, const D3D12_RESOURCE_DESC &, GrProtected, GrMipmapStatus, std::string_view label)
static sk_sp< GrD3DTexture > MakeAliasingTexture(GrD3DGpu *, sk_sp< GrD3DTexture >, const D3D12_RESOURCE_DESC &newDesc, D3D12_RESOURCE_STATES)
GrBackendTexture getBackendTexture() const override
~GrD3DTexture() override
Definition: GrD3DTexture.h:40
static sk_sp< GrD3DTexture > MakeWrappedTexture(GrD3DGpu *, SkISize dimensions, GrWrapCacheable, GrIOType, const GrD3DTextureResourceInfo &, sk_sp< GrD3DResourceState >)
D3D12_CPU_DESCRIPTOR_HANDLE shaderResourceView()
Definition: GrD3DTexture.h:45
void onSetLabel() override
void textureParamsModified() override
Definition: GrD3DTexture.h:47
void onAbandon() override
bool onStealBackendTexture(GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
Definition: GrD3DTexture.h:63
GrBackendFormat backendFormat() const override
Definition: GrD3DTexture.h:44
SkISize dimensions() const
Definition: GrSurface.h:27
GrTexture(GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
Definition: GrTexture.cpp:42
AtkStateType state
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Definition: SkImageGanesh.h:43
Budgeted
Definition: GpuTypes.h:35
Protected
Definition: GpuTypes.h:61
D3D12_CPU_DESCRIPTOR_HANDLE fHandle
Definition: SkSize.h:16