Index: end-ref.cpp
===================================================================
--- blend-ref.cpp	(revision bba12e780ad69819ef680fe90385139da9b372d1)
+++ 	(revision )
@@ -1,140 +1,0 @@
-# Create graphic pipeline
-vertex_input_create = VkPipelineVertexInputStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
-   flags = 0,
-   vertexBindingDescriptionCount = 1,
-   pVertexBindingDescriptions = buffers.standard.description,
-   vertexAttributeDescriptionCount = len(buffers.standard.attributes),
-   pVertexAttributeDescriptions = buffers.standard.attributes);
-
-input_assembly_create = VkPipelineInputAssemblyStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
-   flags = 0,
-   topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
-   primitiveRestartEnable = VK_FALSE);
-viewport = VkViewport(
-   x = 0., y = 0., width = float(self.extent.width), height = float(self.extent.height),
-   minDepth = 0., maxDepth = 1.);
-
-scissor_offset = VkOffset2D(x = 0, y = 0);
-scissor = VkRect2D(offset = scissor_offset, extent = self.extent);
-viewport_state_create = VkPipelineViewportStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
-   flags = 0,
-   viewportCount = 1,
-   pViewports = [viewport],
-   scissorCount = 1,
-   pScissors = [scissor]);
-
-rasterizer_create = VkPipelineRasterizationStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
-   flags = 0,
-   depthClampEnable = VK_FALSE,
-   rasterizerDiscardEnable = VK_FALSE,
-   polygonMode = VK_POLYGON_MODE_FILL,
-   lineWidth = 1,
-   cullMode = VK_CULL_MODE_NONE, #VK_CULL_MODE_BACK_BIT,
-   frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE, #VK_FRONT_FACE_CLOCKWISE,
-   depthBiasEnable = VK_FALSE,
-   depthBiasConstantFactor = 0.,
-   depthBiasClamp = 0.,
-   depthBiasSlopeFactor = 0.);
-
-multisample_create = VkPipelineMultisampleStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
-   flags = 0,
-   sampleShadingEnable = VK_TRUE,
-   rasterizationSamples = 2 * *self.config["multisamplelevel"],
-   minSampleShading = 1,
-   pSampleMask = None,
-   alphaToCoverageEnable = VK_FALSE,
-   alphaToOneEnable = VK_FALSE);
-
-color_blend_attachement = VkPipelineColorBlendAttachmentState(
-   colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
-   blendEnable = VK_FALSE,
-   srcColorBlendFactor = VK_BLEND_FACTOR_SRC_COLOR,
-   dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
-   colorBlendOp = VK_BLEND_OP_ADD,
-   #srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
-   #dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
-   alphaBlendOp = VK_BLEND_OP_ADD);
-
-color_blend_create = VkPipelineColorBlendStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
-   flags = 0,
-   logicOpEnable = VK_FALSE,
-   logicOp = VK_LOGIC_OP_COPY,
-   attachmentCount = 1,
-   pAttachments = [color_blend_attachement],
-   blendConstants = [0, 0, 0, 0]);
-
-push_constant_ranges = VkPushConstantRange(
-   stageFlags = 0,
-   offset = 0,
-   size = 0);
-
-samplerlayoutbinding = VkDescriptorSetLayoutBinding(
-   binding = 1,
-   descriptorCount = 1,
-   descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
-   pImmutableSamplers = None,
-   stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
-
-   );
-
-layoutbindings = [ubo.descriptor, samplerlayoutbinding];
-
-layoutinfo = VkDescriptorSetLayoutCreateInfo(
-   VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
-   bindingCount = len(layoutbindings),
-   pBindings = layoutbindings,
-
-   );
-self.descriptorsetlayout = vkCreateDescriptorSetLayout(self.logical_device, layoutinfo, None);
-
-
-
-pipeline_layout_create = VkPipelineLayoutCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
-   flags = 0,
-   setLayoutCount = 1,
-   pSetLayouts = [self.descriptorsetlayout],
-   pushConstantRangeCount = 0,
-   pPushConstantRanges = [push_constant_ranges]);
-
-self.pipeline_layout = vkCreatePipelineLayout(self.logical_device, pipeline_layout_create, None);
-
-depthstencil = VkPipelineDepthStencilStateCreateInfo(
-   sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
-   depthTestEnable = VK_TRUE,
-   depthWriteEnable = VK_TRUE,
-   depthCompareOp = VK_COMPARE_OP_LESS,
-   depthBoundsTestEnable = VK_FALSE,
-   minDepthBounds = 0,
-   maxDepthBounds = 1,
-   stencilTestEnable = VK_FALSE,
-   );
-
-# Finally create graphic pipeline
-pipeline_create = VkGraphicsPipelineCreateInfo(
-   sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
-   flags = 0,
-   stageCount = 2,
-   pStages = [shaders.shaderlibrary["orthogonal_vert"].pipelinebit, shaders.shaderlibrary["generic_frag"].pipelinebit],
-   pVertexInputState = vertex_input_create,
-   pInputAssemblyState = input_assembly_create,
-   pTessellationState = None,
-   pViewportState = viewport_state_create,
-   pRasterizationState = rasterizer_create,
-   pMultisampleState = multisample_create,
-   pDepthStencilState = depthstencil,
-   pColorBlendState = color_blend_create,
-   pDynamicState = None,
-   layout = self.pipeline_layout,
-   renderPass = self.render_pass.render_pass,
-   subpass = 0,
-   basePipelineHandle = None,
-   basePipelineIndex = -1);
-
-self.pipeline = vkCreateGraphicsPipelines(self.logical_device, None, 1, [pipeline_create], None);
Index: shaders/shader.frag
===================================================================
--- shaders/shader.frag	(revision bba12e780ad69819ef680fe90385139da9b372d1)
+++ shaders/shader.frag	(revision 69dccfe34b6cde8a4c5753321f9d610fb25a1ee7)
@@ -3,11 +3,17 @@
 
 layout(binding = 1) uniform sampler2D texSampler;
+layout(binding = 2) uniform sampler2D uiTexSampler;
 
 layout(location = 0) in vec3 fragColor;
 layout(location = 1) in vec2 fragTexCoord;
+layout(location = 2) flat in uint isOverlay;
 
 layout(location = 0) out vec4 outColor;
 
 void main() {
-   outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb, 1.0);
+   if (isOverlay == 1) {
+      outColor = vec4(fragColor * texture(uiTexSampler, fragTexCoord).rgb, 0.3);
+   } else {
+      outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb, 1.0);
+   }
 }
Index: shaders/shader.vert
===================================================================
--- shaders/shader.vert	(revision bba12e780ad69819ef680fe90385139da9b372d1)
+++ shaders/shader.vert	(revision 69dccfe34b6cde8a4c5753321f9d610fb25a1ee7)
@@ -14,8 +14,17 @@
 layout(location = 0) out vec3 fragColor;
 layout(location = 1) out vec2 fragTexCoord;
+layout(location = 2) out uint isOverlay;
 
 void main() {
-   gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0);
-   fragColor = inColor;
+   if (gl_VertexIndex < 8 ) {
+      gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0);
+      fragColor = inColor;
+      isOverlay = 0;
+   } else {
+      gl_Position = vec4(inPosition, 1.0);
+      fragColor = vec3(0.0, 1.0, 1.0);
+      isOverlay = 1;
+   }
+
    fragTexCoord = inTexCoord;
 }
Index: vulkan-game.cpp
===================================================================
--- vulkan-game.cpp	(revision bba12e780ad69819ef680fe90385139da9b372d1)
+++ 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);
