Debian Codegraph @

src/gpu/ganesh/d3d/GrD3DTexture.h

raw
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
11 #include "include/gpu/ganesh/SkImageGanesh.h"
12 #include "src/core/SkLRUCache.h"
13 #include "src/gpu/ganesh/GrSamplerState.h"
14 #include "src/gpu/ganesh/GrTexture.h"
15 #include "src/gpu/ganesh/d3d/GrD3DDescriptorHeap.h"
16 #include "src/gpu/ganesh/d3d/GrD3DTextureResource.h"
17
18 class GrD3DTexture : public GrTexture, public virtual GrD3DTextureResource {
19 public:
20 static sk_sp<GrD3DTexture> MakeNewTexture(GrD3DGpu*,
21 skgpu::Budgeted,
22 SkISize dimensions,
23 const D3D12_RESOURCE_DESC&,
24 GrProtected,
25 GrMipmapStatus,
26 std::string_view label);
27
28 static sk_sp<GrD3DTexture> MakeWrappedTexture(GrD3DGpu*,
29 SkISize dimensions,
30 GrWrapCacheable,
31 GrIOType,
32 const GrD3DTextureResourceInfo&,
33 sk_sp<GrD3DResourceState>);
34
35 static sk_sp<GrD3DTexture> MakeAliasingTexture(GrD3DGpu*,
36 sk_sp<GrD3DTexture>,
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
49 protected:
50 GrD3DTexture(GrD3DGpu*,
51 SkISize dimensions,
52 const GrD3DTextureResourceInfo&,
53 sk_sp<GrD3DResourceState>,
54 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView,
55 GrMipmapStatus,
56 std::string_view label);
57
58 GrD3DGpu* getD3DGpu() const;
59
60 void onAbandon() override;
61 void onRelease() override;
62
63 bool onStealBackendTexture(GrBackendTexture*, SkImages::BackendTextureReleaseProc*) override {
64 return false;
65 }
66
67 void onSetLabel() override;
68
69 private:
70 GrD3DTexture(GrD3DGpu*,
71 skgpu::Budgeted,
72 SkISize dimensions,
73 const GrD3DTextureResourceInfo&,
74 sk_sp<GrD3DResourceState>,
75 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView,
76 GrMipmapStatus,
77 std::string_view label);
78 GrD3DTexture(GrD3DGpu*, SkISize dimensions, const GrD3DTextureResourceInfo&,
79 sk_sp<GrD3DResourceState>,
80 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView,
81 GrMipmapStatus,
82 GrWrapCacheable,
83 GrIOType,
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