Take the feedback-layout images back to GENERAL before the contact shadows' march

vk_contact_exec ended the pass and recorded a memory barrier only. Once a G-buffer draw samples the linear depth or the
scene colour in its own pass, those images stay in ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT across passes
(vk_exec_draw.c, feedback loops), and the march then bound them in GENERAL as a sampled and a storage image. The Vulkan
validation layer reported it on every frame with contact shadows on (vkCmdDispatch imageLayout-00344, followed by
barrier, BeginRendering and QueueSubmit layout errors: 40 per run at Lookout Landing, 0 with contact_shadows = 0).
vk_exec_barrier ends the pass and moves those images back to GENERAL in the same full barrier, as every other
barrier does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
itaskaev2andClaude Opus 5.5 committed 2026-11-10 14:59:34 +01:00
1 parent 1503b17f7d
commit f804facd8b
1 file changed
+4 -2
+4 -2
View File
@@ -163,7 +163,10 @@ void vk_contact_exec(VkExec *ex, const VkExecJob *j) {
VkImageView out = vk_exec_target_view(j->scene.img, VK_FORMAT_B10G11R11_UFLOAT_PACK32, VK_IMAGE_VIEW_TYPE_2D,
VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1, 0);
if (!in || !out) return;
vk_exec_pass_end(ex);
// A full barrier that also takes the images in the feedback layout back to GENERAL (vk_exec.c barrier_to): the
// G-buffer's linear depth and scene colour are such images once a draw sampled them in their own pass, and the march
// binds them in GENERAL. A memory barrier alone left them in ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT.
vk_exec_barrier(ex);
VkCommandBuffer cb = ex->cb;
float pcv[16];
memcpy(pcv, j->pc, sizeof pcv);
@@ -173,7 +176,6 @@ void vk_contact_exec(VkExec *ex, const VkExecJob *j) {
rt_log("vk: contact shadows on a %ux%u scene, sun toward %.3f %.3f %.3f (view space), far %g", j->scene.width, j->scene.height,
pcv[4], pcv[5], pcv[6], pcv[2]);
}
mem_barrier(cb); // the compose passes' writes, before the march reads and writes them
VkDescriptorImageInfo ii = {C.sampler, in, VK_IMAGE_LAYOUT_GENERAL}, oi = {VK_NULL_HANDLE, out, VK_IMAGE_LAYOUT_GENERAL};
VkWriteDescriptorSet w[2] = {
{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 0, .descriptorCount = 1,