• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GrD3DTypesMinimal_DEFINED
9 #define GrD3DTypesMinimal_DEFINED
10 
11 // Minimal definitions of Direct3D types, without including d3d12.h
12 
13 #include "include/core/SkRefCnt.h"
14 
15 #include <dxgiformat.h>
16 
17 #include "include/gpu/GrTypes.h"
18 
19 struct ID3D12Resource;
20 class GrD3DResourceState;
21 typedef int GrD3DResourceStateEnum;
22 struct GrD3DSurfaceInfo;
23 struct GrD3DTextureResourceInfo;
24 struct GrD3DTextureResourceSpec;
25 struct GrD3DFenceInfo;
26 
27 // This struct is to used to store the the actual information about the Direct3D backend image on
28 // GrBackendTexture and GrBackendRenderTarget. When a client calls getD3DTextureInfo on a
29 // GrBackendTexture/RenderTarget, we use the GrD3DBackendSurfaceInfo to create a snapshot
30 // GrD3DTextureResourceInfo object. Internally, this uses a ref count GrD3DResourceState object to
31 // track the current D3D12_RESOURCE_STATES which can be shared with an internal GrD3DTextureResource
32 // so that state updates can be seen by all users of the texture.
33 struct GrD3DBackendSurfaceInfo {
34     GrD3DBackendSurfaceInfo(const GrD3DTextureResourceInfo& info, GrD3DResourceState* state);
35 
36     void cleanup();
37 
38     GrD3DBackendSurfaceInfo& operator=(const GrD3DBackendSurfaceInfo&) = delete;
39 
40     // Assigns the passed in GrD3DBackendSurfaceInfo to this object. if isValid is true we will also
41     // attempt to unref the old fLayout on this object.
42     void assign(const GrD3DBackendSurfaceInfo&, bool isValid);
43 
44     void setResourceState(GrD3DResourceStateEnum state);
45 
46     sk_sp<GrD3DResourceState> getGrD3DResourceState() const;
47 
48     GrD3DTextureResourceInfo snapTextureResourceInfo() const;
49 
50     bool isProtected() const;
51 #if GR_TEST_UTILS
52     bool operator==(const GrD3DBackendSurfaceInfo& that) const;
53 #endif
54 
55 private:
56     GrD3DTextureResourceInfo* fTextureResourceInfo;
57     GrD3DResourceState* fResourceState;
58 };
59 
60 struct GrD3DTextureResourceSpecHolder {
61 public:
62     GrD3DTextureResourceSpecHolder(const GrD3DSurfaceInfo&);
63 
64     void cleanup();
65 
66     GrD3DSurfaceInfo getSurfaceInfo(uint32_t sampleCount,
67                                     uint32_t levelCount,
68                                     GrProtected isProtected) const;
69 
70 private:
71     GrD3DTextureResourceSpec* fSpec;
72 };
73 
74 #endif
75