OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrVkRenderPass_DEFINED | 8 #ifndef GrVkRenderPass_DEFINED |
9 #define GrVkRenderPass_DEFINED | 9 #define GrVkRenderPass_DEFINED |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 bool operator!=(const LoadStoreOps& right) const { | 37 bool operator!=(const LoadStoreOps& right) const { |
38 return !(*this == right); | 38 return !(*this == right); |
39 } | 39 } |
40 }; | 40 }; |
41 | 41 |
42 void initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& target); | 42 void initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& target); |
43 void init(const GrVkGpu* gpu, | 43 void init(const GrVkGpu* gpu, |
44 const GrVkRenderTarget& target, | 44 const GrVkRenderTarget& target, |
45 const LoadStoreOps& colorOp, | 45 const LoadStoreOps& colorOp, |
46 const LoadStoreOps& resolveOp, | |
47 const LoadStoreOps& stencilOp); | 46 const LoadStoreOps& stencilOp); |
48 | 47 |
49 void init(const GrVkGpu* gpu, | 48 void init(const GrVkGpu* gpu, |
50 const GrVkRenderPass& compatibleRenderPass, | 49 const GrVkRenderPass& compatibleRenderPass, |
51 const LoadStoreOps& colorOp, | 50 const LoadStoreOps& colorOp, |
52 const LoadStoreOps& resolveOp, | |
53 const LoadStoreOps& stencilOp); | 51 const LoadStoreOps& stencilOp); |
54 | 52 |
55 struct AttachmentsDescriptor { | 53 struct AttachmentsDescriptor { |
56 struct AttachmentDesc { | 54 struct AttachmentDesc { |
57 VkFormat fFormat; | 55 VkFormat fFormat; |
58 int fSamples; | 56 int fSamples; |
59 LoadStoreOps fLoadStoreOps; | 57 LoadStoreOps fLoadStoreOps; |
60 | 58 |
61 AttachmentDesc() | 59 AttachmentDesc() |
62 : fFormat(VK_FORMAT_UNDEFINED) | 60 : fFormat(VK_FORMAT_UNDEFINED) |
63 , fSamples(0) | 61 , fSamples(0) |
64 , fLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_
OP_STORE) {} | 62 , fLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_
OP_STORE) {} |
65 bool operator==(const AttachmentDesc& right) const { | 63 bool operator==(const AttachmentDesc& right) const { |
66 return (fFormat == right.fFormat && | 64 return (fFormat == right.fFormat && |
67 fSamples == right.fSamples && | 65 fSamples == right.fSamples && |
68 fLoadStoreOps == right.fLoadStoreOps); | 66 fLoadStoreOps == right.fLoadStoreOps); |
69 } | 67 } |
70 bool operator!=(const AttachmentDesc& right) const { | 68 bool operator!=(const AttachmentDesc& right) const { |
71 return !(*this == right); | 69 return !(*this == right); |
72 } | 70 } |
73 bool isCompatible(const AttachmentDesc& desc) const { | 71 bool isCompatible(const AttachmentDesc& desc) const { |
74 return (fFormat == desc.fFormat && fSamples == desc.fSamples); | 72 return (fFormat == desc.fFormat && fSamples == desc.fSamples); |
75 } | 73 } |
76 }; | 74 }; |
77 AttachmentDesc fColor; | 75 AttachmentDesc fColor; |
78 AttachmentDesc fResolve; | |
79 AttachmentDesc fStencil; | 76 AttachmentDesc fStencil; |
80 uint32_t fAttachmentCount; | 77 uint32_t fAttachmentCount; |
81 }; | 78 }; |
82 | 79 |
83 enum AttachmentFlags { | 80 enum AttachmentFlags { |
84 kColor_AttachmentFlag = 0x1, | 81 kColor_AttachmentFlag = 0x1, |
85 kResolve_AttachmentFlag = 0x2, | 82 kStencil_AttachmentFlag = 0x2, |
86 kStencil_AttachmentFlag = 0x4, | |
87 }; | 83 }; |
88 GR_DECL_BITFIELD_OPS_FRIENDS(AttachmentFlags); | 84 GR_DECL_BITFIELD_OPS_FRIENDS(AttachmentFlags); |
89 | 85 |
90 // The following return the index of the render pass attachment array for th
e given attachment. | 86 // The following return the index of the render pass attachment array for th
e given attachment. |
91 // If the render pass does not have the given attachment it will return fals
e and not set the | 87 // If the render pass does not have the given attachment it will return fals
e and not set the |
92 // index value. | 88 // index value. |
93 bool colorAttachmentIndex(uint32_t* index) const; | 89 bool colorAttachmentIndex(uint32_t* index) const; |
94 bool resolveAttachmentIndex(uint32_t* index) const; | |
95 bool stencilAttachmentIndex(uint32_t* index) const; | 90 bool stencilAttachmentIndex(uint32_t* index) const; |
96 | 91 |
97 // Sets the VkRenderPassBeginInfo and VkRenderPassContents need to begin a r
ender pass. | 92 // Sets the VkRenderPassBeginInfo and VkRenderPassContents need to begin a r
ender pass. |
98 // TODO: In the future I expect this function will also take an optional ren
der area instead of | 93 // TODO: In the future I expect this function will also take an optional ren
der area instead of |
99 // defaulting to the entire render target. | 94 // defaulting to the entire render target. |
100 // TODO: Figure out if load clear values should be passed into this function
or should be stored | 95 // TODO: Figure out if load clear values should be passed into this function
or should be stored |
101 // on the GrVkRenderPass at create time since we'll know at that point if we
want to do a load | 96 // on the GrVkRenderPass at create time since we'll know at that point if we
want to do a load |
102 // clear. | 97 // clear. |
103 void getBeginInfo(const GrVkRenderTarget& target, | 98 void getBeginInfo(const GrVkRenderTarget& target, |
104 VkRenderPassBeginInfo* beginInfo, | 99 VkRenderPassBeginInfo* beginInfo, |
105 VkSubpassContents* contents) const; | 100 VkSubpassContents* contents) const; |
106 | 101 |
107 // Returns whether or not the structure of a RenderTarget matches that of th
e VkRenderPass in | 102 // Returns whether or not the structure of a RenderTarget matches that of th
e VkRenderPass in |
108 // this object. Specifically this compares that the number of attachments, f
ormat of | 103 // this object. Specifically this compares that the number of attachments, f
ormat of |
109 // attachments, and sample counts are all the same. This function is used in
the creation of | 104 // attachments, and sample counts are all the same. This function is used in
the creation of |
110 // basic RenderPasses that can be used when creating a VkFrameBuffer object. | 105 // basic RenderPasses that can be used when creating a VkFrameBuffer object. |
111 bool isCompatible(const GrVkRenderTarget& target) const; | 106 bool isCompatible(const GrVkRenderTarget& target) const; |
112 | 107 |
113 bool isCompatible(const GrVkRenderPass& renderPass) const; | 108 bool isCompatible(const GrVkRenderPass& renderPass) const; |
114 | 109 |
115 bool equalLoadStoreOps(const LoadStoreOps& colorOps, | 110 bool equalLoadStoreOps(const LoadStoreOps& colorOps, |
116 const LoadStoreOps& resolveOps, | |
117 const LoadStoreOps& stencilOps) const; | 111 const LoadStoreOps& stencilOps) const; |
118 | 112 |
119 VkRenderPass vkRenderPass() const { return fRenderPass; } | 113 VkRenderPass vkRenderPass() const { return fRenderPass; } |
120 | 114 |
121 const VkExtent2D& granularity() const { return fGranularity; } | 115 const VkExtent2D& granularity() const { return fGranularity; } |
122 | 116 |
123 void genKey(GrProcessorKeyBuilder* b) const; | 117 void genKey(GrProcessorKeyBuilder* b) const; |
124 | 118 |
125 #ifdef SK_TRACE_VK_RESOURCES | 119 #ifdef SK_TRACE_VK_RESOURCES |
126 void dumpInfo() const override { | 120 void dumpInfo() const override { |
127 SkDebugf("GrVkRenderPass: %d (%d refs)\n", fRenderPass, this->getRefCnt(
)); | 121 SkDebugf("GrVkRenderPass: %d (%d refs)\n", fRenderPass, this->getRefCnt(
)); |
128 } | 122 } |
129 #endif | 123 #endif |
130 | 124 |
131 private: | 125 private: |
132 GrVkRenderPass(const GrVkRenderPass&); | 126 GrVkRenderPass(const GrVkRenderPass&); |
133 | 127 |
134 void init(const GrVkGpu* gpu, | 128 void init(const GrVkGpu* gpu, |
135 const LoadStoreOps& colorOps, | 129 const LoadStoreOps& colorOps, |
136 const LoadStoreOps& resolveOps, | |
137 const LoadStoreOps& stencilOps); | 130 const LoadStoreOps& stencilOps); |
138 | 131 |
139 bool isCompatible(const AttachmentsDescriptor&, const AttachmentFlags&) cons
t; | 132 bool isCompatible(const AttachmentsDescriptor&, const AttachmentFlags&) cons
t; |
140 | 133 |
141 void freeGPUData(const GrVkGpu* gpu) const override; | 134 void freeGPUData(const GrVkGpu* gpu) const override; |
142 | 135 |
143 VkRenderPass fRenderPass; | 136 VkRenderPass fRenderPass; |
144 AttachmentFlags fAttachmentFlags; | 137 AttachmentFlags fAttachmentFlags; |
145 AttachmentsDescriptor fAttachmentsDescriptor; | 138 AttachmentsDescriptor fAttachmentsDescriptor; |
146 VkExtent2D fGranularity; | 139 VkExtent2D fGranularity; |
147 | 140 |
148 typedef GrVkResource INHERITED; | 141 typedef GrVkResource INHERITED; |
149 }; | 142 }; |
150 | 143 |
151 GR_MAKE_BITFIELD_OPS(GrVkRenderPass::AttachmentFlags); | 144 GR_MAKE_BITFIELD_OPS(GrVkRenderPass::AttachmentFlags); |
152 | 145 |
153 #endif | 146 #endif |
OLD | NEW |