Fix dynamic rendering layer clear

The number of layers to clear was not taken into account in
CmdBeginRendering::execute(), causing more layer clears then
requested. This was discovered while testing a fix for the
dEQP-VK.dynamic_rendering.primary_cmd_buff.random.seed* tests,
which are currently failing due to a different issue.

Bug: b/241436291
Change-Id: I9862278f9de2f1d7471078015813d1d4f857fab4
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/67988
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index a33315c..4e32760 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -134,7 +134,9 @@
 
 		if(!executionState.dynamicRendering->resume())
 		{
-			VkRect2D renderArea = executionState.dynamicRendering->getRenderArea();
+			VkClearRect rect = {};
+			rect.rect = executionState.dynamicRendering->getRenderArea();
+			rect.layerCount = executionState.dynamicRendering->getLayerCount();
 			uint32_t viewMask = executionState.dynamicRendering->getViewMask();
 
 			// Vulkan specifies that the attachments' `loadOp` gets executed "at the beginning of the subpass where it is first used."
@@ -148,7 +150,7 @@
 					vk::ImageView *imageView = vk::Cast(colorAttachment->imageView);
 					if(imageView)
 					{
-						imageView->clear(colorAttachment->clearValue, VK_IMAGE_ASPECT_COLOR_BIT, renderArea, viewMask);
+						imageView->clear(colorAttachment->clearValue, VK_IMAGE_ASPECT_COLOR_BIT, rect, viewMask);
 					}
 				}
 			}
@@ -159,7 +161,7 @@
 				vk::ImageView *imageView = vk::Cast(stencilAttachment.imageView);
 				if(imageView)
 				{
-					imageView->clear(stencilAttachment.clearValue, VK_IMAGE_ASPECT_STENCIL_BIT, renderArea, viewMask);
+					imageView->clear(stencilAttachment.clearValue, VK_IMAGE_ASPECT_STENCIL_BIT, rect, viewMask);
 				}
 			}
 
@@ -170,7 +172,7 @@
 
 				if(imageView)
 				{
-					imageView->clear(depthAttachment.clearValue, VK_IMAGE_ASPECT_DEPTH_BIT, renderArea, viewMask);
+					imageView->clear(depthAttachment.clearValue, VK_IMAGE_ASPECT_DEPTH_BIT, rect, viewMask);
 				}
 			}
 		}
@@ -1806,7 +1808,7 @@
 }
 
 template<typename T, typename... Args>
-void CommandBuffer::addCommand(Args &&...args)
+void CommandBuffer::addCommand(Args &&... args)
 {
 	// FIXME (b/119409619): use an allocator here so we can control all memory allocations
 	commands.push_back(std::make_unique<T>(std::forward<Args>(args)...));