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 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
12 | 12 |
13 #include "GrVkResource.h" | 13 #include "GrVkResource.h" |
14 | 14 |
15 #include "vk/GrVkDefines.h" | 15 #include "vk/GrVkDefines.h" |
16 | 16 |
17 class GrProcessorKeyBuilder; | 17 class GrProcessorKeyBuilder; |
18 class GrVkGpu; | 18 class GrVkGpu; |
19 class GrVkRenderTarget; | 19 class GrVkRenderTarget; |
20 | 20 |
21 class GrVkRenderPass : public GrVkResource { | 21 class GrVkRenderPass : public GrVkResource { |
22 public: | 22 public: |
23 GrVkRenderPass() : INHERITED(), fRenderPass(VK_NULL_HANDLE) {} | 23 GrVkRenderPass() : INHERITED(), fRenderPass(VK_NULL_HANDLE) {} |
24 | |
25 struct LoadStoreOps { | |
26 VkAttachmentLoadOp fLoadOp; | |
27 VkAttachmentStoreOp fStoreOp; | |
28 | |
29 LoadStoreOps() | |
30 : fLoadOp(VK_ATTACHMENT_LOAD_OP_LOAD) | |
jvanverth1
2016/06/02 21:26:48
This means any time you create any of these struct
egdaniel
2016/06/06 14:14:58
Done.
| |
31 , fStoreOp(VK_ATTACHMENT_STORE_OP_STORE) {} | |
32 | |
33 LoadStoreOps(VkAttachmentLoadOp loadOp, VkAttachmentStoreOp storeOp) | |
34 : fLoadOp(loadOp), | |
35 fStoreOp(storeOp) {} | |
36 | |
37 bool operator==(const LoadStoreOps& right) const { | |
38 return fLoadOp == right.fLoadOp && fStoreOp == right.fStoreOp; | |
39 } | |
40 | |
41 bool operator!=(const LoadStoreOps& right) const { | |
42 return !(*this == right); | |
43 } | |
44 }; | |
45 static const LoadStoreOps kBasicLoadStoreOps; | |
46 | |
24 void initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& target); | 47 void initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& target); |
48 void init(const GrVkGpu* gpu, | |
49 const GrVkRenderTarget& target, | |
50 const LoadStoreOps& colorOp, | |
51 const LoadStoreOps& resolveOp, | |
52 const LoadStoreOps& stencilOp); | |
53 | |
54 void init(const GrVkGpu* gpu, | |
55 const GrVkRenderPass& compatibleRenderPass, | |
56 const LoadStoreOps& colorOp, | |
57 const LoadStoreOps& resolveOp, | |
58 const LoadStoreOps& stencilOp); | |
25 | 59 |
26 struct AttachmentsDescriptor { | 60 struct AttachmentsDescriptor { |
27 struct AttachmentDesc { | 61 struct AttachmentDesc { |
28 VkFormat fFormat; | 62 VkFormat fFormat; |
29 int fSamples; | 63 int fSamples; |
30 VkAttachmentLoadOp fLoadOp; | 64 LoadStoreOps fLoadStoreOps; |
31 VkAttachmentStoreOp fStoreOp; | |
32 | 65 |
33 AttachmentDesc() | 66 AttachmentDesc() |
34 : fFormat(VK_FORMAT_UNDEFINED) | 67 : fFormat(VK_FORMAT_UNDEFINED) |
35 , fSamples(0) | 68 , fSamples(0) |
36 , fLoadOp(VK_ATTACHMENT_LOAD_OP_LOAD) | 69 , fLoadStoreOps() {} |
37 , fStoreOp(VK_ATTACHMENT_STORE_OP_STORE) {} | |
38 bool operator==(const AttachmentDesc& right) const { | 70 bool operator==(const AttachmentDesc& right) const { |
39 return (fFormat == right.fFormat && | 71 return (fFormat == right.fFormat && |
40 fSamples == right.fSamples && | 72 fSamples == right.fSamples && |
41 fLoadOp == right.fLoadOp && | 73 fLoadStoreOps == right.fLoadStoreOps); |
42 fStoreOp == right.fStoreOp); | |
43 } | 74 } |
44 bool operator!=(const AttachmentDesc& right) const { | 75 bool operator!=(const AttachmentDesc& right) const { |
45 return !(*this == right); | 76 return !(*this == right); |
46 } | 77 } |
47 bool isCompatible(const AttachmentDesc& desc) const { | 78 bool isCompatible(const AttachmentDesc& desc) const { |
48 return (fFormat == desc.fFormat && fSamples == desc.fSamples); | 79 return (fFormat == desc.fFormat && fSamples == desc.fSamples); |
49 } | 80 } |
50 }; | 81 }; |
51 AttachmentDesc fColor; | 82 AttachmentDesc fColor; |
52 AttachmentDesc fResolve; | 83 AttachmentDesc fResolve; |
(...skipping 24 matching lines...) Expand all Loading... | |
77 void getBeginInfo(const GrVkRenderTarget& target, | 108 void getBeginInfo(const GrVkRenderTarget& target, |
78 VkRenderPassBeginInfo* beginInfo, | 109 VkRenderPassBeginInfo* beginInfo, |
79 VkSubpassContents* contents) const; | 110 VkSubpassContents* contents) const; |
80 | 111 |
81 // Returns whether or not the structure of a RenderTarget matches that of th e VkRenderPass in | 112 // Returns whether or not the structure of a RenderTarget matches that of th e VkRenderPass in |
82 // this object. Specifically this compares that the number of attachments, f ormat of | 113 // this object. Specifically this compares that the number of attachments, f ormat of |
83 // attachments, and sample counts are all the same. This function is used in the creation of | 114 // attachments, and sample counts are all the same. This function is used in the creation of |
84 // basic RenderPasses that can be used when creating a VkFrameBuffer object. | 115 // basic RenderPasses that can be used when creating a VkFrameBuffer object. |
85 bool isCompatible(const GrVkRenderTarget& target) const; | 116 bool isCompatible(const GrVkRenderTarget& target) const; |
86 | 117 |
118 bool equalLoadStoreOps(const LoadStoreOps& colorOps, | |
119 const LoadStoreOps& resolveOps, | |
120 const LoadStoreOps& stencilOps) const; | |
121 | |
87 VkRenderPass vkRenderPass() const { return fRenderPass; } | 122 VkRenderPass vkRenderPass() const { return fRenderPass; } |
88 | 123 |
89 void genKey(GrProcessorKeyBuilder* b) const; | 124 void genKey(GrProcessorKeyBuilder* b) const; |
90 | 125 |
91 private: | 126 private: |
92 GrVkRenderPass(const GrVkRenderPass&); | 127 GrVkRenderPass(const GrVkRenderPass&); |
93 | 128 |
129 void init(const GrVkGpu* gpu, | |
130 const LoadStoreOps& colorOps, | |
131 const LoadStoreOps& resolveOps, | |
132 const LoadStoreOps& stencilOps); | |
133 | |
94 void freeGPUData(const GrVkGpu* gpu) const override; | 134 void freeGPUData(const GrVkGpu* gpu) const override; |
95 | 135 |
96 VkRenderPass fRenderPass; | 136 VkRenderPass fRenderPass; |
97 AttachmentFlags fAttachmentFlags; | 137 AttachmentFlags fAttachmentFlags; |
98 AttachmentsDescriptor fAttachmentsDescriptor; | 138 AttachmentsDescriptor fAttachmentsDescriptor; |
99 | 139 |
100 typedef GrVkResource INHERITED; | 140 typedef GrVkResource INHERITED; |
101 }; | 141 }; |
102 | 142 |
103 GR_MAKE_BITFIELD_OPS(GrVkRenderPass::AttachmentFlags); | 143 GR_MAKE_BITFIELD_OPS(GrVkRenderPass::AttachmentFlags); |
104 | 144 |
105 #endif | 145 #endif |
OLD | NEW |