|
|
@ -46,49 +46,7 @@ private: |
|
|
|
Buffer* buffer = nullptr; |
|
|
|
Buffer* buffer = nullptr; |
|
|
|
CommandPool* commandPool = nullptr; |
|
|
|
CommandPool* commandPool = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex){ |
|
|
|
void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex); |
|
|
|
VkCommandBufferBeginInfo beginInfo {}; |
|
|
|
|
|
|
|
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vkBeginCommandBuffer(commandBuffer, &beginInfo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkRenderPassBeginInfo renderPassInfo {}; |
|
|
|
|
|
|
|
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
|
|
|
|
|
|
|
renderPassInfo.renderPass = swapchain->renderPass; |
|
|
|
|
|
|
|
renderPassInfo.framebuffer = swapchain->frameBuffers[imageIndex]; |
|
|
|
|
|
|
|
renderPassInfo.renderArea.offset = {0, 0}; |
|
|
|
|
|
|
|
renderPassInfo.renderArea.extent = swapchain->extent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkClearValue clearColor = {{{0, 0, 0, 1}}}; |
|
|
|
|
|
|
|
renderPassInfo.clearValueCount = 1; |
|
|
|
|
|
|
|
renderPassInfo.pClearValues = &clearColor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE); |
|
|
|
|
|
|
|
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->graphicsPipeline); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkViewport viewport {}; |
|
|
|
|
|
|
|
viewport.x = 0; |
|
|
|
|
|
|
|
viewport.y = 0; |
|
|
|
|
|
|
|
viewport.width = static_cast<float>(swapchain->extent.width); |
|
|
|
|
|
|
|
viewport.height = static_cast<float>(swapchain->extent.height); |
|
|
|
|
|
|
|
viewport.minDepth = 0; |
|
|
|
|
|
|
|
viewport.maxDepth = 1; |
|
|
|
|
|
|
|
vkCmdSetViewport(commandBuffer, 0, 1, &viewport); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkRect2D scissor {}; |
|
|
|
|
|
|
|
scissor.offset = {0, 0}; |
|
|
|
|
|
|
|
scissor.extent = swapchain->extent; |
|
|
|
|
|
|
|
vkCmdSetScissor(commandBuffer, 0, 1, &scissor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkBuffer buffers[] = {buffer->vertexHandle}; |
|
|
|
|
|
|
|
VkDeviceSize offsets[] = {0}; |
|
|
|
|
|
|
|
vkCmdBindVertexBuffers(commandBuffer, 0, 1, buffers, offsets); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vkCmdDraw(commandBuffer, 3, 1, 0, 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vkCmdEndRenderPass(commandBuffer); |
|
|
|
|
|
|
|
vkEndCommandBuffer(commandBuffer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<VkSemaphore> imageAvailableSemaphores; |
|
|
|
std::vector<VkSemaphore> imageAvailableSemaphores; |
|
|
|
std::vector<VkSemaphore> renderFinishedSemaphores; |
|
|
|
std::vector<VkSemaphore> renderFinishedSemaphores; |
|
|
|