public Triangle() { InitializeComponent(); InitializeVulkan(); _Bitmap = new Bitmap(640, 480); _Framebuffer = new Framebuffer(_Device, 640, 480); VkPipelineLayout dummyLayout = _Device.CreatePipelineLayout(VkPipelineLayoutCreateFlag.NONE, null, null); _VertexShader = _Device.CreateShaderModule(VkShaderModuleCreateFlag.NONE, System.IO.File.ReadAllBytes("./Shaders/vertexShader.spv")); _FramgemtShader = _Device.CreateShaderModule(VkShaderModuleCreateFlag.NONE, System.IO.File.ReadAllBytes("./Shaders/fragmentShader.spv")); _GraphicsPipeline = new Pipeline(_Framebuffer, dummyLayout, _VertexShader, "main", _FramgemtShader, "main"); // Finally we will need a fence for our submission in order to wait on it _Fence = _Device.CreateFence(VkFenceCreateFlag.NONE); // VkBuffer indexBuffer = _Device.CreateBuffer(0, 3 * sizeof(Int32), VkBufferUsageFlag.VK_BUFFER_USAGE_INDEX_BUFFER, VkSharingMode.VK_SHARING_MODE_CONCURRENT, new VkQueueFamilyProperties[] { _Queue.Family }); // VkBuffer vertexBuffer = _Device.CreateBuffer(0, 3 * sizeof(float), VkBufferUsageFlag.VK_BUFFER_USAGE_VERTEX_BUFFER, VkSharingMode.VK_SHARING_MODE_CONCURRENT, new VkQueueFamilyProperties[] { _Queue.Family }); // Now we need to create a command buffer and we will fill it with a single command: // Fill the image with the color (0.1f, 0.75f, 1.0f, 1.0f) which is a Sky blue. VkClearValue.VkClearColorValue.Float color = new VkClearValue.VkClearColorValue.Float(); color.float32[0] = 0.1f; color.float32[1] = 0.75f; color.float32[2] = 1.0f; color.float32[3] = 1.0f; VkCommandPool Pool = _Device.CreateCommandPool(VkCommandPoolCreateFlag.NONE, _Queue.Family); _CommandBuffer = Pool.AllocateCommandBuffer(VkCommandBufferLevel.VK_COMMAND_BUFFER_LEVEL_PRIMARY); _CommandBuffer.Begin(VkCommandBufferUsageFlag.NONE); _CommandBuffer.CmdBeginRenderPass(_Framebuffer.RenderPass, new VkRect2D(0, 0, (uint)640, (uint)480), _Framebuffer.GetFramebuffer(), new VkClearValue[] { color }, VkSubpassContents.VK_SUBPASS_CONTENTS_INLINE); _GraphicsPipeline.BindPipeline(_CommandBuffer); _CommandBuffer.CmdDraw(3, 1, 0, 0); _CommandBuffer.CmdEndRenderPass(); _CommandBuffer.cmdCopyImageToBuffer(_Framebuffer.FrameBufferColor, VkImageLayout.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, _Framebuffer._TransferBuffer, new VkBufferImageCopy[] { new VkBufferImageCopy() { bufferImageHeight = (uint)_Framebuffer.Height, bufferOffset = 0, bufferRowLength = (uint)_Framebuffer.Width, imageExtent = new VkExtent3D() { depth = 1, width = (uint)_Framebuffer.Width, height = (uint)_Framebuffer.Height }, imageSubresource = new VkImageSubresourceLayers() { aspectMask = VkImageAspectFlag.VK_IMAGE_ASPECT_COLOR_BIT, baseArrayLayer = 0, layerCount = 1, mipLevel = 0 } } }); _CommandBuffer.End(); }