|
|
|
@ -9,12 +9,23 @@ Application::Application() { |
|
|
|
|
instance = new Instance; |
|
|
|
|
swapchain = new Swapchain(instance); |
|
|
|
|
pipeline = new Pipeline(instance, swapchain->renderPass); |
|
|
|
|
stagingBuffer = Buffer::createStagingBuffer(instance); |
|
|
|
|
vertexBuffer = new Buffer(instance, stagingBuffer->size, |
|
|
|
|
auto stagedVertexBuffer = Buffer::createStagedVertexBuffer(instance); |
|
|
|
|
vertexBuffer = new Buffer(instance, stagedVertexBuffer->size, |
|
|
|
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, |
|
|
|
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); |
|
|
|
|
|
|
|
|
|
auto stagedIndexBuffer = Buffer::createStagedIndexBuffer(instance); |
|
|
|
|
indexBuffer = new Buffer(instance, stagedIndexBuffer->size, |
|
|
|
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, |
|
|
|
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); |
|
|
|
|
|
|
|
|
|
commandPool = new CommandPool(instance); |
|
|
|
|
stagingBuffer->copyTo(vertexBuffer, commandPool); |
|
|
|
|
|
|
|
|
|
stagedVertexBuffer->copyTo(vertexBuffer, commandPool); |
|
|
|
|
stagedIndexBuffer->copyTo(indexBuffer, commandPool); |
|
|
|
|
|
|
|
|
|
delete stagedVertexBuffer; |
|
|
|
|
delete stagedIndexBuffer; |
|
|
|
|
|
|
|
|
|
createSyncObjects(); |
|
|
|
|
|
|
|
|
@ -137,7 +148,9 @@ void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t im |
|
|
|
|
VkDeviceSize offsets[] = {0}; |
|
|
|
|
vkCmdBindVertexBuffers(commandBuffer, 0, 1, buffers, offsets); |
|
|
|
|
|
|
|
|
|
vkCmdDraw(commandBuffer, 3, 1, 0, 0); |
|
|
|
|
vkCmdBindIndexBuffer(commandBuffer, indexBuffer->handle, 0, VK_INDEX_TYPE_UINT32); |
|
|
|
|
|
|
|
|
|
vkCmdDrawIndexed(commandBuffer, indices.size(), 1, 0, 0, 0); |
|
|
|
|
|
|
|
|
|
vkCmdEndRenderPass(commandBuffer); |
|
|
|
|
vkEndCommandBuffer(commandBuffer); |
|
|
|
@ -151,8 +164,8 @@ Application::~Application() { |
|
|
|
|
vkDestroyFence(instance->device, inFlightFences[i], nullptr); |
|
|
|
|
} |
|
|
|
|
delete commandPool; |
|
|
|
|
delete stagingBuffer; |
|
|
|
|
delete vertexBuffer; |
|
|
|
|
delete indexBuffer; |
|
|
|
|
delete pipeline; |
|
|
|
|
delete instance; |
|
|
|
|
} |
|
|
|
|