Skip to content

Commit 38d40b5

Browse files
authored
Fix possible undef values in storeOp trackers (#162)
Prior to this change depth and stencil storeOp values reported in the state tracker could have an undefined value for a read-only attachment that was using a storeOp other than STORE_OP_STORE.
1 parent bb91123 commit 38d40b5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

source_common/trackers/render_pass.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ RenderPass::RenderPass(VkRenderPass _handle, const VkRenderPassCreateInfo& creat
124124
auto& attachDesc = createInfo.pAttachments[attachRef.attachment];
125125

126126
// Canonicalize read-only attachments as storeOp=NONE
127-
VkAttachmentStoreOp depthStoreOp;
127+
VkAttachmentStoreOp depthStoreOp = attachDesc.storeOp;
128128
switch (attachRef.layout)
129129
{
130130
case VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL:
@@ -136,14 +136,13 @@ RenderPass::RenderPass(VkRenderPass _handle, const VkRenderPassCreateInfo& creat
136136
}
137137
break;
138138
default:
139-
depthStoreOp = attachDesc.storeOp;
140139
break;
141140
}
142141

143142
attachments.emplace_back(RenderPassAttachName::DEPTH, attachDesc.loadOp, depthStoreOp, false);
144143

145144
// Canonicalize read-only attachments as storeOp=NONE
146-
VkAttachmentStoreOp stencilStoreOp;
145+
VkAttachmentStoreOp stencilStoreOp = attachDesc.stencilStoreOp;
147146
switch (attachRef.layout)
148147
{
149148
case VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL:
@@ -155,7 +154,6 @@ RenderPass::RenderPass(VkRenderPass _handle, const VkRenderPassCreateInfo& creat
155154
}
156155
break;
157156
default:
158-
stencilStoreOp = attachDesc.stencilStoreOp;
159157
break;
160158
}
161159

@@ -214,7 +212,7 @@ RenderPass::RenderPass(VkRenderPass _handle, const VkRenderPassCreateInfo2& crea
214212
auto& attachDesc = createInfo.pAttachments[attachRef.attachment];
215213

216214
// Canonicalize read-only attachments as storeOp=NONE
217-
VkAttachmentStoreOp depthStoreOp;
215+
VkAttachmentStoreOp depthStoreOp = attachDesc.storeOp;
218216
switch (attachRef.layout)
219217
{
220218
case VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL:
@@ -226,14 +224,13 @@ RenderPass::RenderPass(VkRenderPass _handle, const VkRenderPassCreateInfo2& crea
226224
}
227225
break;
228226
default:
229-
depthStoreOp = attachDesc.storeOp;
230227
break;
231228
}
232229

233230
attachments.emplace_back(RenderPassAttachName::DEPTH, attachDesc.loadOp, depthStoreOp, false);
234231

235232
// Canonicalize read-only attachments as storeOp=NONE
236-
VkAttachmentStoreOp stencilStoreOp;
233+
VkAttachmentStoreOp stencilStoreOp = attachDesc.stencilStoreOp;
237234
switch (attachRef.layout)
238235
{
239236
case VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL:
@@ -245,7 +242,6 @@ RenderPass::RenderPass(VkRenderPass _handle, const VkRenderPassCreateInfo2& crea
245242
}
246243
break;
247244
default:
248-
stencilStoreOp = attachDesc.stencilStoreOp;
249245
break;
250246
}
251247

@@ -294,7 +290,7 @@ RenderPass::RenderPass(const VkRenderingInfo& createInfo)
294290
auto& attachRef = *createInfo.pDepthAttachment;
295291

296292
// Canonicalize read-only attachments as storeOp=NONE
297-
VkAttachmentStoreOp depthStoreOp;
293+
VkAttachmentStoreOp depthStoreOp = attachRef.storeOp;
298294
switch (attachRef.imageLayout)
299295
{
300296
case VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL:
@@ -306,7 +302,6 @@ RenderPass::RenderPass(const VkRenderingInfo& createInfo)
306302
}
307303
break;
308304
default:
309-
depthStoreOp = attachRef.storeOp;
310305
break;
311306
}
312307

@@ -328,7 +323,7 @@ RenderPass::RenderPass(const VkRenderingInfo& createInfo)
328323
auto& attachRef = *createInfo.pStencilAttachment;
329324

330325
// Canonicalize read-only attachments as storeOp=NONE
331-
VkAttachmentStoreOp stencilStoreOp;
326+
VkAttachmentStoreOp stencilStoreOp = attachRef.storeOp;
332327
switch (attachRef.imageLayout)
333328
{
334329
case VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL:
@@ -340,7 +335,6 @@ RenderPass::RenderPass(const VkRenderingInfo& createInfo)
340335
}
341336
break;
342337
default:
343-
stencilStoreOp = attachRef.storeOp;
344338
break;
345339
}
346340

0 commit comments

Comments
 (0)