Assert reserved binding entries aren't accessed

The spec for VkDescriptorSetLayoutBinding states that
"If descriptorCount is zero this binding entry is reserved and the
resource must not be accessed from any stage via this binding within any
pipeline using the set layout."

This restores the debug validation that existed at https://swiftshader-review.googlesource.com/c/SwiftShader/+/44308/4/src/Pipeline/SpirvShaderMemory.cpp#b405

Bug: b/157915024
Change-Id: I5e6798b0cc87f564a3c6f13963995822660b5111
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45468
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/SpirvShaderMemory.cpp b/src/Pipeline/SpirvShaderMemory.cpp
index df16f0c..ec82813 100644
--- a/src/Pipeline/SpirvShaderMemory.cpp
+++ b/src/Pipeline/SpirvShaderMemory.cpp
@@ -387,6 +387,7 @@
 			const auto &d = descriptorDecorations.at(id);
 			ASSERT(d.DescriptorSet >= 0 && d.DescriptorSet < vk::MAX_BOUND_DESCRIPTOR_SETS);
 			ASSERT(d.Binding >= 0);
+			ASSERT(routine->pipelineLayout->getDescriptorCount(d.DescriptorSet, d.Binding) != 0);  // "If descriptorCount is zero this binding entry is reserved and the resource must not be accessed from any stage via this binding within any pipeline using the set layout."
 
 			uint32_t bindingOffset = routine->pipelineLayout->getBindingOffset(d.DescriptorSet, d.Binding);
 			uint32_t descriptorSize = routine->pipelineLayout->getDescriptorSize(d.DescriptorSet, d.Binding);
diff --git a/src/Vulkan/VkPipelineLayout.cpp b/src/Vulkan/VkPipelineLayout.cpp
index 96a84a7..da5a921 100644
--- a/src/Vulkan/VkPipelineLayout.cpp
+++ b/src/Vulkan/VkPipelineLayout.cpp
@@ -44,6 +44,7 @@
 			descriptorSets[i].bindings[j].descriptorType = setLayout->getDescriptorType(j);
 			descriptorSets[i].bindings[j].offset = setLayout->getBindingOffset(j);
 			descriptorSets[i].bindings[j].dynamicOffsetIndex = dynamicOffsetIndex;
+			descriptorSets[i].bindings[j].descriptorCount = setLayout->getDescriptorCount(j);
 
 			if(DescriptorSetLayout::IsDescriptorDynamic(descriptorSets[i].bindings[j].descriptorType))
 			{
@@ -97,6 +98,12 @@
 	return descriptorSets[setNumber].bindings[bindingNumber].dynamicOffsetIndex;
 }
 
+uint32_t PipelineLayout::getDescriptorCount(uint32_t setNumber, uint32_t bindingNumber) const
+{
+	ASSERT(setNumber < descriptorSetCount && bindingNumber < descriptorSets[setNumber].bindingCount);
+	return descriptorSets[setNumber].bindings[bindingNumber].descriptorCount;
+}
+
 uint32_t PipelineLayout::getBindingOffset(uint32_t setNumber, uint32_t bindingNumber) const
 {
 	ASSERT(setNumber < descriptorSetCount && bindingNumber < descriptorSets[setNumber].bindingCount);
diff --git a/src/Vulkan/VkPipelineLayout.hpp b/src/Vulkan/VkPipelineLayout.hpp
index 6f68dc8..d48d937 100644
--- a/src/Vulkan/VkPipelineLayout.hpp
+++ b/src/Vulkan/VkPipelineLayout.hpp
@@ -34,7 +34,7 @@
 	// Returns the index into the pipeline's dynamic offsets array for
 	// the given descriptor set and binding number.
 	uint32_t getDynamicOffsetIndex(uint32_t setNumber, uint32_t bindingNumber) const;
-
+	uint32_t getDescriptorCount(uint32_t setNumber, uint32_t bindingNumber) const;
 	uint32_t getBindingOffset(uint32_t setNumber, uint32_t bindingNumber) const;
 	VkDescriptorType getDescriptorType(uint32_t setNumber, uint32_t bindingNumber) const;
 	uint32_t getDescriptorSize(uint32_t setNumber, uint32_t bindingNumber) const;
@@ -49,8 +49,9 @@
 	struct Binding
 	{
 		VkDescriptorType descriptorType;
-		uint32_t offset;              // Offset in bytes in the descriptor set data.
-		uint32_t dynamicOffsetIndex;  // TODO(b/154914395): Debug only.
+		uint32_t offset;  // Offset in bytes in the descriptor set data.
+		uint32_t dynamicOffsetIndex;
+		uint32_t descriptorCount;
 	};
 
 	struct DescriptorSet