Flutter Engine
The Flutter Engine
GrD3DRenderTarget.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
9#ifndef GrD3DRenderTarget_DEFINED
10#define GrD3DRenderTarget_DEFINED
11
14
19
20class GrD3DGpu;
22
24
26public:
30 ~GrD3DRenderTarget() override;
31
32 GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
33
34 /**
35 * If this render target is multisampled, this returns the MSAA texture for rendering. This
36 * will be different than *this* when we have separate render/resolve images. If not
37 * multisampled returns nullptr.
38 */
41
42 bool canAttemptStencilAttachment(bool useMSAASurface) const override {
43 SkASSERT(useMSAASurface == (this->numSamples() > 1));
44 return true;
45 }
46
48
49 D3D12_CPU_DESCRIPTOR_HANDLE colorRenderTargetView() const {
50 return fColorRenderTargetView.fHandle;
51 }
52
53 DXGI_FORMAT stencilDxgiFormat() const;
54
55 // Key used for the program desc
56 void genKey(skgpu::KeyBuilder* b) const;
57
58protected:
63 const GrD3DTextureResourceInfo& msaaInfo,
66 const GrD3DDescriptorHeap::CPUHandle& resolveRenderTargetView,
67 std::string_view label);
68
73 const GrD3DDescriptorHeap::CPUHandle& renderTargetView,
74 std::string_view label);
75
76 void onAbandon() override;
77 void onRelease() override;
78
79 // This accounts for the texture's memory and any MSAA renderbuffer's memory.
80 size_t onGpuMemorySize() const override {
81 int numColorSamples = this->numSamples();
82 if (numColorSamples > 1) {
83 // Add one to account for the resolved VkImage.
84 numColorSamples += 1;
85 }
87 this->backendFormat(), this->dimensions(), numColorSamples, skgpu::Mipmapped::kNo);
88 }
89
90 void onSetLabel() override;
91
92private:
93 // Extra param to disambiguate from constructor used by subclasses.
94 enum Wrapped { kWrapped };
99 const GrD3DTextureResourceInfo& msaaInfo,
102 const GrD3DDescriptorHeap::CPUHandle& resolveRenderTargetView,
103 Wrapped,
104 std::string_view label);
105
110 const GrD3DDescriptorHeap::CPUHandle& renderTargetView,
111 Wrapped,
112 std::string_view label);
113
114 GrD3DGpu* getD3DGpu() const;
115
116 bool completeStencilAttachment(GrAttachment* stencil, bool useMSAASurface) override {
117 SkASSERT(useMSAASurface == (this->numSamples() > 1));
118 return true;
119 }
120
121 // In Direct3D we call the release proc after we are finished with the underlying
122 // GrD3DTextureResource::Resource object (which occurs after the GPU finishes all work on it).
123 void onSetRelease(sk_sp<RefCntedReleaseProc> releaseHelper) override {
124 // Forward the release proc on to GrD3DTextureResource
125 this->setResourceRelease(std::move(releaseHelper));
126 }
127
128 void releaseInternalObjects();
129
130 std::unique_ptr<GrD3DTextureResource> fMSAATextureResource;
131
132 GrD3DDescriptorHeap::CPUHandle fColorRenderTargetView;
133 GrD3DDescriptorHeap::CPUHandle fResolveRenderTargetView;
134};
135
136#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool canAttemptStencilAttachment(bool useMSAASurface) const override
void genKey(skgpu::KeyBuilder *b) const
DXGI_FORMAT stencilDxgiFormat() const
void onRelease() override
size_t onGpuMemorySize() const override
static sk_sp< GrD3DRenderTarget > MakeWrappedRenderTarget(GrD3DGpu *, SkISize, int sampleCnt, const GrD3DTextureResourceInfo &, sk_sp< GrD3DResourceState >)
const GrD3DTextureResource * msaaTextureResource() const
GrBackendFormat backendFormat() const override
GrBackendRenderTarget getBackendRenderTarget() const override
void onAbandon() override
D3D12_CPU_DESCRIPTOR_HANDLE colorRenderTargetView() const
void onSetLabel() override
GrBackendFormat getBackendFormat() const
void setResourceRelease(sk_sp< GrSurface::RefCntedReleaseProc > releaseHelper)
int numSamples() const
SkISize dimensions() const
Definition: GrSurface.h:27
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
Definition: GrSurface.cpp:21
static bool b
AtkStateType state
D3D12_CPU_DESCRIPTOR_HANDLE fHandle
Definition: SkSize.h:16