Define generic memory type.

Generic system memory is cached on all known ARMv8 and x86 CPUs, so
advertise it as such.

Bug b/118383648

Change-Id: Ic757206a497fc299e1e76a939220092f7c0a124d
Reviewed-on: https://swiftshader-review.googlesource.com/c/22448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkBuffer.cpp b/src/Vulkan/VkBuffer.cpp
index 57c6870..bde3352 100644
--- a/src/Vulkan/VkBuffer.cpp
+++ b/src/Vulkan/VkBuffer.cpp
@@ -43,7 +43,7 @@
 {
 	VkMemoryRequirements memoryRequirements = {};
 	memoryRequirements.alignment = vk::REQUIRED_MEMORY_ALIGNMENT;
-	memoryRequirements.memoryTypeBits = vk::REQUIRED_MEMORY_TYPE_BITS;
+	memoryRequirements.memoryTypeBits = vk::MEMORY_TYPE_GENERIC_BIT;
 	memoryRequirements.size = size; // TODO: also reserve space for a header containing
 		                            // the size of the buffer (for robust buffer access)
 	return memoryRequirements;
diff --git a/src/Vulkan/VkConfig.h b/src/Vulkan/VkConfig.h
index 7646a74..e9541ff 100644
--- a/src/Vulkan/VkConfig.h
+++ b/src/Vulkan/VkConfig.h
@@ -38,7 +38,7 @@
 enum
 {
 	REQUIRED_MEMORY_ALIGNMENT = 8, // For 64 bit formats on ARM64
-	REQUIRED_MEMORY_TYPE_BITS = 1,
+	MEMORY_TYPE_GENERIC_BIT = 0x1, // Generic system memory.
 };
 
 enum
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 91637d2..d97278a 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -446,13 +446,23 @@
 	static const VkPhysicalDeviceMemoryProperties properties
 	{
 		1, // memoryTypeCount
-		{{VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
-		  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-		  VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-		  0}}, // heapIndex
+		{
+			// vk::MEMORY_TYPE_GENERIC_BIT
+			{
+				VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
+				VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+				VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
+				VK_MEMORY_PROPERTY_HOST_CACHED_BIT, // propertyFlags
+				0 // heapIndex
+			},
+		},
 		1, // memoryHeapCount
-		{{1ull << 31, // size, FIXME(sugoi): This could be configurable based on available RAM
-		  VK_MEMORY_HEAP_DEVICE_LOCAL_BIT}},
+		{
+			{
+				1ull << 31, // size, FIXME(sugoi): This should be configurable based on available RAM
+				VK_MEMORY_HEAP_DEVICE_LOCAL_BIT // flags
+			},
+		}
 	};
 
 	return properties;