Bug report: Image pipeline barrier failing

GPU: GEForce 1660 Ti
Driver: Game Ready Driver 512.15
OS: Windows 10

Shadow maps are sometimes displaying a one-frame lag, even through a memory barrier is in use. The video shows a box light moving back and forth. Its shadow refreshes each time it moves:

Demo:
https://www.ultraengine.com/files/pipelinebarrierbug.zip

Shadow rendering is first recorded in a command buffer, followed by a memory barrier, followed by scene rendering that uses the shadowmap.

This is the code for the memory barrier after shadow rendering:

vector<VkImageMemoryBarrier> barriers;
VkImageMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
barrier.subresourceRange.levelCount = 1;
barrier.subresourceRange.layerCount = 1;
for (auto pair : visset->cameravislists)
{
	auto light = pair.first->As<RenderLight>();
	if (light == NULL) continue;
	barrier.oldLayout = light->shadowbuffer[0]->depthtexture->GetLayout();
	light->shadowbuffer[0]->depthtexture->imagelayout[0][0] = barrier.newLayout;
	barrier.image = light->shadowbuffer[0]->depthtexture->vkimage;
	barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
	switch (light->shadowbuffer[0]->depthtexture->format)
	{
	case VK_FORMAT_D24_UNORM_S8_UINT:
	case VK_FORMAT_D32_SFLOAT_S8_UINT:
	case VK_FORMAT_D16_UNORM_S8_UINT:
		barrier.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
		break;
	}
	barriers.push_back(barrier);
}
if (!barriers.empty())
{
	vkCmdPipelineBarrier(
		commandbuffers[currentFrame]->commandbuffer,
		VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
		VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
		0, 0, NULL, 0, NULL, barriers.size(), barriers.data());
}

This should be sufficient to prevent the behavior in the video above, but the undesired behavior shown in the above video remains.

The VK_LAYER_KHRONOS_validation validation layer is enabled, and no validation errors occur. VkPhysicalDeviceSynchronization2Features is also enabled.

I should point out the shadow of the small box is the bug. At some angles, the corners of the light will be cut away. This is a consequences of the lighting approach I am using, and having the culling take place on a separate thread. This image explains what I mean:

Issue is resolved.