Index: vulkan-game.cpp
===================================================================
--- vulkan-game.cpp	(revision adcd252eb53f4e8b018b4f9a42de8c52c66240a6)
+++ vulkan-game.cpp	(revision 69dccfe34b6cde8a4c5753321f9d610fb25a1ee7)
@@ -110,4 +110,9 @@
 
 const vector<Vertex> vertices = {
+   {{-0.5f, -0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
+   {{ 0.5f, -0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
+   {{ 0.5f,  0.5f, -0.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
+   {{-0.5f,  0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
+
    {{-0.5f, -0.5f,  0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
    {{ 0.5f, -0.5f,  0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
@@ -115,13 +120,14 @@
    {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
 
-   {{-0.5f, -0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
-   {{ 0.5f, -0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
-   {{ 0.5f,  0.5f, -0.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
-   {{-0.5f,  0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
+   {{-1.0f,  1.0f,  0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
+   {{ 1.0f,  1.0f,  0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
+   {{ 1.0f, -1.0f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
+   {{-1.0f, -1.0f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
 };
 
 const vector<uint16_t> indices = {
-   0, 1, 2, 2, 3, 0,
-   4, 5, 6, 6, 7, 4
+    0,  1,  2,  2,  3,  0,
+    4,  5,  6,  6,  7,  4,
+    8,  9, 10, 10, 11,  8
 };
 
@@ -198,4 +204,9 @@
       VkDeviceMemory textureImageMemory;
       VkImageView textureImageView;
+
+      VkImage overlayImage;
+      VkDeviceMemory overlayImageMemory;
+      VkImageView overlayImageView;
+
       VkSampler textureSampler;
 
@@ -249,6 +260,6 @@
          createDepthResources();
          createFramebuffers();
-         createTextureImage();
-         createTextureImageView();
+         createImageResources("textures/texture.jpg", textureImage, textureImageMemory, textureImageView);
+         createImageResources("textures/space.jpg", overlayImage, overlayImageMemory, overlayImageView);
          createTextureSampler();
          createVertexBuffer();
@@ -684,5 +695,12 @@
          samplerLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
 
-         array<VkDescriptorSetLayoutBinding, 2> bindings = { uboLayoutBinding, samplerLayoutBinding };
+         VkDescriptorSetLayoutBinding overlaySamplerLayoutBinding = {};
+         overlaySamplerLayoutBinding.binding = 2;
+         overlaySamplerLayoutBinding.descriptorCount = 1;
+         overlaySamplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+         overlaySamplerLayoutBinding.pImmutableSamplers = nullptr;
+         overlaySamplerLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
+
+         array<VkDescriptorSetLayoutBinding, 3> bindings = { uboLayoutBinding, samplerLayoutBinding, overlaySamplerLayoutBinding };
          VkDescriptorSetLayoutCreateInfo layoutInfo = {};
          layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
@@ -768,5 +786,11 @@
          VkPipelineColorBlendAttachmentState colorBlendAttachment = {};
          colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
-         colorBlendAttachment.blendEnable = VK_FALSE;
+         colorBlendAttachment.blendEnable = VK_TRUE;
+         colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD;
+         colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
+         colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
+         colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
+         colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
+         colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
 
          VkPipelineColorBlendStateCreateInfo colorBlending = {};
@@ -952,8 +976,8 @@
       }
 
-      void createTextureImage() {
+      void createImageResources(string filename, VkImage& image, VkDeviceMemory& imageMemory, VkImageView& view) {
          int texWidth, texHeight, texChannels;
 
-         stbi_uc* pixels = stbi_load("textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
+         stbi_uc* pixels = stbi_load(filename.c_str(), &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
          VkDeviceSize imageSize = texWidth * texHeight * 4;
 
@@ -979,12 +1003,14 @@
          createImage(texWidth, texHeight, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TILING_OPTIMAL,
             VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
-            VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, textureImage, textureImageMemory);
-
-         transitionImageLayout(textureImage, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
-         copyBufferToImage(stagingBuffer, textureImage, static_cast<uint32_t>(texWidth), static_cast<uint32_t>(texHeight));
-         transitionImageLayout(textureImage, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+            VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, image, imageMemory);
+
+         transitionImageLayout(image, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
+         copyBufferToImage(stagingBuffer, image, static_cast<uint32_t>(texWidth), static_cast<uint32_t>(texHeight));
+         transitionImageLayout(image, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 
          vkDestroyBuffer(device, stagingBuffer, nullptr);
          vkFreeMemory(device, stagingBufferMemory, nullptr);
+
+         view = createImageView(image, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT);
       }
 
@@ -1114,8 +1140,4 @@
       }
 
-      void createTextureImageView() {
-         textureImageView = createImageView(textureImage, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT);
-      }
-
       VkImageView createImageView(VkImage image, VkFormat format, VkImageAspectFlags aspectFlags) {
          VkImageViewCreateInfo viewInfo = {};
@@ -1312,9 +1334,11 @@
 
       void createDescriptorPool() {
-         array<VkDescriptorPoolSize, 2> poolSizes = {};
+         array<VkDescriptorPoolSize, 3> poolSizes = {};
          poolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
          poolSizes[0].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
          poolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
          poolSizes[1].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
+         poolSizes[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+         poolSizes[2].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
 
          VkDescriptorPoolCreateInfo poolInfo = {};
@@ -1354,5 +1378,10 @@
             imageInfo.sampler = textureSampler;
 
-            array<VkWriteDescriptorSet, 2> descriptorWrites = {};
+            VkDescriptorImageInfo overlayImageInfo = {};
+            overlayImageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+            overlayImageInfo.imageView = overlayImageView;
+            overlayImageInfo.sampler = textureSampler;
+
+            array<VkWriteDescriptorSet, 3> descriptorWrites = {};
 
             descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -1375,4 +1404,14 @@
             descriptorWrites[1].pImageInfo = &imageInfo;
             descriptorWrites[1].pTexelBufferView = nullptr;
+
+            descriptorWrites[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+            descriptorWrites[2].dstSet = descriptorSets[i];
+            descriptorWrites[2].dstBinding = 2;
+            descriptorWrites[2].dstArrayElement = 0;
+            descriptorWrites[2].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+            descriptorWrites[2].descriptorCount = 1;
+            descriptorWrites[2].pBufferInfo = nullptr;
+            descriptorWrites[2].pImageInfo = &overlayImageInfo;
+            descriptorWrites[2].pTexelBufferView = nullptr;
 
             vkUpdateDescriptorSets(device, static_cast<uint32_t>(descriptorWrites.size()), descriptorWrites.data(), 0, nullptr);
@@ -1606,7 +1645,12 @@
 
          vkDestroySampler(device, textureSampler, nullptr);
+
          vkDestroyImageView(device, textureImageView, nullptr);
          vkDestroyImage(device, textureImage, nullptr);
          vkFreeMemory(device, textureImageMemory, nullptr);
+
+         vkDestroyImageView(device, overlayImageView, nullptr);
+         vkDestroyImage(device, overlayImage, nullptr);
+         vkFreeMemory(device, overlayImageMemory, nullptr);
 
          vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
