xref: /aosp_15_r20/external/skia/src/gpu/ganesh/d3d/GrD3DAttachment.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 GrD3DAttachment_DEFINED
9 #define GrD3DAttachment_DEFINED
10 
11 #include "src/gpu/ganesh/GrAttachment.h"
12 
13 #include "include/gpu/ganesh/d3d/GrD3DTypes.h"
14 #include "src/gpu/ganesh/d3d/GrD3DDescriptorHeap.h"
15 #include "src/gpu/ganesh/d3d/GrD3DTextureResource.h"
16 
17 class GrD3DGpu;
18 
19 class GrD3DAttachment : public GrAttachment, public GrD3DTextureResource {
20 public:
21     static sk_sp<GrD3DAttachment> MakeStencil(GrD3DGpu* gpu,
22                                               SkISize dimensions,
23                                               int sampleCnt,
24                                               DXGI_FORMAT format);
25 
~GrD3DAttachment()26     ~GrD3DAttachment() override {}
27 
backendFormat()28     GrBackendFormat backendFormat() const override { return GrBackendFormat::MakeDxgi(fFormat); }
29 
view()30     D3D12_CPU_DESCRIPTOR_HANDLE view() const { return fView.fHandle; }
31 
32 protected:
33     void onRelease() override;
34     void onAbandon() override;
35 
36 private:
37     GrD3DAttachment(GrD3DGpu* gpu,
38                     SkISize dimensions,
39                     UsageFlags supportedUsages,
40                     DXGI_FORMAT format,
41                     const D3D12_RESOURCE_DESC&,
42                     const GrD3DTextureResourceInfo&,
43                     sk_sp<GrD3DResourceState>,
44                     const GrD3DDescriptorHeap::CPUHandle& view,
45                     std::string_view label);
46 
47     GrD3DGpu* getD3DGpu() const;
48 
49     void onSetLabel() override;
50 
51     GrD3DDescriptorHeap::CPUHandle fView;
52     DXGI_FORMAT fFormat;
53 };
54 
55 #endif
56