Explicitly initialize VkSpecializationInfo fields

vk::allocate() zero-initializes its memory, which was nulling the
VkSpecializationInfo::pMapEntries field in case the mapEntryCount is 0.

We'll be changing vk::allocate() to not zero-initialize, to catch cases
where applications might incorrectly be relying on it, with
MemorySanitizer. So we have to also not be relying on it.

Bug: b/140991626
Change-Id: I5917c902c0af27985556340dfc1dbae79010a125
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/54468
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkSpecializationInfo.cpp b/src/Vulkan/VkSpecializationInfo.cpp
index bda5f43..b20a6a0 100644
--- a/src/Vulkan/VkSpecializationInfo.cpp
+++ b/src/Vulkan/VkSpecializationInfo.cpp
@@ -21,12 +21,15 @@
 {
 	if(specializationInfo)
 	{
-		auto ptr = reinterpret_cast<VkSpecializationInfo *>(
+		auto *ptr = reinterpret_cast<VkSpecializationInfo *>(
 		    allocate(sizeof(VkSpecializationInfo), REQUIRED_MEMORY_ALIGNMENT, DEVICE_MEMORY));
-
 		info = std::shared_ptr<VkSpecializationInfo>(ptr, Deleter());
 
 		info->mapEntryCount = specializationInfo->mapEntryCount;
+		info->pMapEntries = nullptr;
+		info->dataSize = specializationInfo->dataSize;
+		info->pData = nullptr;
+
 		if(specializationInfo->mapEntryCount > 0)
 		{
 			size_t entriesSize = specializationInfo->mapEntryCount * sizeof(VkSpecializationMapEntry);
@@ -36,17 +39,12 @@
 			info->pMapEntries = mapEntries;
 		}
 
-		info->dataSize = specializationInfo->dataSize;
 		if(specializationInfo->dataSize > 0)
 		{
 			void *data = allocate(specializationInfo->dataSize, REQUIRED_MEMORY_ALIGNMENT, DEVICE_MEMORY);
 			memcpy(data, specializationInfo->pData, specializationInfo->dataSize);
 			info->pData = data;
 		}
-		else
-		{
-			info->pData = nullptr;
-		}
 	}
 }