VulkanBenchmarks: add validation layers and load via ICD

In DEBUG builds, enable validation layers: VK_LAYER_KHRONOS_validation
and VK_LAYER_LUNARG_standard_validation. Also register the debug utils
messenger ext callback for when validation layers report a problem. We
can force validation layers in non-DEBUG by defining
ENABLE_VALIDATION_LAYERS to 1.

In order to be able to use validation layers, load the Vulkan driver via
ICD, rather than directly. To load SwiftShader, generate a temp icd.json
file pointing at the driver path, and temporarily set the
VK_ICD_FILENAMES env var to point at it when we load the ICD. This also
allows us to load the native GPU driver by defining LOAD_NATIVE_DRIVER
to 1 (default is 0).

Fixed errors reported by enabling validation layers:
* TriangleSampleTexture had a mismatched binding number for the sampler2D
* Correctly set memoryTypeIndex for allocations instead of 0

Bug: b/176981107
Change-Id: I3c791086acea048b73d3568d6d7a45d8e0100c17
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52749
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/tests/VulkanWrapper/Image.cpp b/tests/VulkanWrapper/Image.cpp
index 0ffc69b..c5cbad6 100644
--- a/tests/VulkanWrapper/Image.cpp
+++ b/tests/VulkanWrapper/Image.cpp
@@ -13,8 +13,9 @@
 // limitations under the License.
 
 #include "Image.hpp"
+#include "Util.hpp"
 
-Image::Image(vk::Device device, uint32_t width, uint32_t height, vk::Format format, vk::SampleCountFlagBits sampleCount /*= vk::SampleCountFlagBits::e1*/)
+Image::Image(vk::Device device, vk::PhysicalDevice physicalDevice, uint32_t width, uint32_t height, vk::Format format, vk::SampleCountFlagBits sampleCount /*= vk::SampleCountFlagBits::e1*/)
     : device(device)
 {
 	vk::ImageCreateInfo imageInfo;
@@ -34,7 +35,7 @@
 
 	vk::MemoryAllocateInfo allocateInfo;
 	allocateInfo.allocationSize = memoryRequirements.size;
-	allocateInfo.memoryTypeIndex = 0;  //getMemoryTypeIndex(memoryRequirements.memoryTypeBits, vk::MemoryPropertyFlagBits::eDeviceLocal);
+	allocateInfo.memoryTypeIndex = Util::getMemoryTypeIndex(physicalDevice, memoryRequirements.memoryTypeBits);
 
 	imageMemory = device.allocateMemory(allocateInfo);