1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
int Vulkan_Render(float color)
{
	VkResult res;

	//vkDeviceWaitIdle(_VkSystem.device);
	vkWaitForFences(_VkSystem.device, 1, &_VkSystem.fence, 1, -1);
	vkResetFences(_VkSystem.device, 1, &_VkSystem.fence);

	res = vkAcquireNextImageKHR(_VkSystem.device, _VkSystem.swapchainKHR, -1, _VkSystem.semaphoreNextImage, VK_NULL_HANDLE, &_VkSystem.imageIndex);

	VkCommandBufferBeginInfo beginInfo = {};
	beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;

	// Begin CommandBuffer Recording
	vkBeginCommandBuffer(_VkSystem.commandBuffer, &beginInfo);

	// Begin RenderPass
	BeginRenderPass(_VkSystem.renderPass, _VkSystem.frameBuffers[_VkSystem.imageIndex].frameBuffer,
		_VkSystem.commandBuffer, color, color, color);


	//VkGraphicsPipelineCreateInfo pipelineInfo = {};
	//pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
	//pipelineInfo.renderPass = _VkSystem.renderPass;
	//pipelineInfo.
	//vkCreateGraphicsPipelines(device,0,1,)


	// End RenderPass
	vkCmdEndRenderPass(_VkSystem.commandBuffer);

	// End CommandBuffer Recording
	res = vkEndCommandBuffer(_VkSystem.commandBuffer);
	if (res != VK_SUCCESS)
		return 1;

	if (SubmitToQueue(_VkSystem.queue.queue, _VkSystem.commandBuffer, _VkSystem.fence,
		_VkSystem.semaphoreNextImage, _VkSystem.queue.semaphoreSubmit) != VK_SUCCESS)
		return 1;

	VkPresentInfoKHR presentInfo = {};
	presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
	presentInfo.pSwapchains = &_VkSystem.swapchainKHR;
	presentInfo.swapchainCount = 1;
	presentInfo.pWaitSemaphores = &_VkSystem.queue.semaphoreSubmit;
	presentInfo.waitSemaphoreCount = 1;
	presentInfo.pImageIndices = &_VkSystem.imageIndex;

	res = vkQueuePresentKHR(_VkSystem.queue.queue, &presentInfo);
	if (res != VK_SUCCESS)
		return 1;

	//vkDestroySemaphore(_VkSystem.device, semaphore, 0);

}