|
|
|
@ -277,7 +277,7 @@ VkResult create_logical_device(
|
|
|
|
graphics_queue->family = idx;
|
|
|
|
graphics_queue->family = idx;
|
|
|
|
graphics_queue->index = 0;
|
|
|
|
graphics_queue->index = 0;
|
|
|
|
} else if (present_support && (present_queue->family == 0xFFFFFFFF)) {
|
|
|
|
} else if (present_support && (present_queue->family == 0xFFFFFFFF)) {
|
|
|
|
graphics_queue->family = idx;
|
|
|
|
present_queue->family = idx;
|
|
|
|
present_queue->index = 0;
|
|
|
|
present_queue->index = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -358,10 +358,10 @@ VkResult create_logical_device(
|
|
|
|
queue_create_info[1].queueCount = 1;
|
|
|
|
queue_create_info[1].queueCount = 1;
|
|
|
|
queue_create_info[1].pQueuePriorities = &default_queue_priority;
|
|
|
|
queue_create_info[1].pQueuePriorities = &default_queue_priority;
|
|
|
|
|
|
|
|
|
|
|
|
queue_create_info[1].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
|
|
|
queue_create_info[2].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
|
|
|
queue_create_info[1].queueFamilyIndex = transfer_queue->family;
|
|
|
|
queue_create_info[2].queueFamilyIndex = transfer_queue->family;
|
|
|
|
queue_create_info[1].queueCount = 1;
|
|
|
|
queue_create_info[2].queueCount = 1;
|
|
|
|
queue_create_info[1].pQueuePriorities = &default_queue_priority;
|
|
|
|
queue_create_info[2].pQueuePriorities = &default_queue_priority;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering = {
|
|
|
|
VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering = {
|
|
|
|
@ -538,8 +538,20 @@ VkPresentModeKHR choose_present_mode(SwapchainDetails swapchain_details) {
|
|
|
|
return VK_PRESENT_MODE_FIFO_KHR;
|
|
|
|
return VK_PRESENT_MODE_FIFO_KHR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VkExtent2D choose_swapchain_extent(SwapchainDetails swapchain_details) {
|
|
|
|
VkExtent2D choose_swapchain_extent(SwapchainDetails swapchain_details, VkExtent2D framebuffer_size) {
|
|
|
|
return swapchain_details.capabilities.currentExtent;
|
|
|
|
VkSurfaceCapabilitiesKHR caps = swapchain_details.capabilities;
|
|
|
|
|
|
|
|
// 0xFFFFFFFF means "app chooses" (common on Wayland). Fall back to the
|
|
|
|
|
|
|
|
// caller-supplied framebuffer size and clamp to the surface's allowed range.
|
|
|
|
|
|
|
|
if(caps.currentExtent.width != 0xFFFFFFFF) {
|
|
|
|
|
|
|
|
return caps.currentExtent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkExtent2D extent = framebuffer_size;
|
|
|
|
|
|
|
|
if(extent.width < caps.minImageExtent.width) extent.width = caps.minImageExtent.width;
|
|
|
|
|
|
|
|
if(extent.height < caps.minImageExtent.height) extent.height = caps.minImageExtent.height;
|
|
|
|
|
|
|
|
if(extent.width > caps.maxImageExtent.width) extent.width = caps.maxImageExtent.width;
|
|
|
|
|
|
|
|
if(extent.height > caps.maxImageExtent.height) extent.height = caps.maxImageExtent.height;
|
|
|
|
|
|
|
|
return extent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VkResult create_swapchain(
|
|
|
|
VkResult create_swapchain(
|
|
|
|
@ -570,7 +582,7 @@ VkResult create_swapchain(
|
|
|
|
.imageArrayLayers = 1,
|
|
|
|
.imageArrayLayers = 1,
|
|
|
|
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
|
|
|
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
|
|
|
.preTransform = capabilities.currentTransform,
|
|
|
|
.preTransform = capabilities.currentTransform,
|
|
|
|
.compositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR,
|
|
|
|
.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
|
|
|
.presentMode = present_mode,
|
|
|
|
.presentMode = present_mode,
|
|
|
|
.clipped = VK_TRUE,
|
|
|
|
.clipped = VK_TRUE,
|
|
|
|
.oldSwapchain = old_swapchain,
|
|
|
|
.oldSwapchain = old_swapchain,
|
|
|
|
@ -874,6 +886,11 @@ VkResult init_vulkan(GLFWwindow* window, RenderContext* context) {
|
|
|
|
GLFWmonitor** monitors = glfwGetMonitors(&monitor_count);
|
|
|
|
GLFWmonitor** monitors = glfwGetMonitors(&monitor_count);
|
|
|
|
glfwGetMonitorContentScale(monitors[0], &context->window_scale[0], &context->window_scale[1]);
|
|
|
|
glfwGetMonitorContentScale(monitors[0], &context->window_scale[0], &context->window_scale[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int fb_width, fb_height;
|
|
|
|
|
|
|
|
glfwGetFramebufferSize(window, &fb_width, &fb_height);
|
|
|
|
|
|
|
|
context->framebuffer_size.width = (uint32_t)fb_width;
|
|
|
|
|
|
|
|
context->framebuffer_size.height = (uint32_t)fb_height;
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_instance(&context->instance));
|
|
|
|
VK_RESULT(create_instance(&context->instance));
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_debug_messenger(context->instance, &context->debug_messenger));
|
|
|
|
VK_RESULT(create_debug_messenger(context->instance, &context->debug_messenger));
|
|
|
|
@ -916,7 +933,7 @@ VkResult init_vulkan(GLFWwindow* window, RenderContext* context) {
|
|
|
|
|
|
|
|
|
|
|
|
context->swapchain_format = choose_swapchain_format(context->swapchain_details);
|
|
|
|
context->swapchain_format = choose_swapchain_format(context->swapchain_details);
|
|
|
|
context->swapchain_present_mode = choose_present_mode(context->swapchain_details);
|
|
|
|
context->swapchain_present_mode = choose_present_mode(context->swapchain_details);
|
|
|
|
context->swapchain_extent = choose_swapchain_extent(context->swapchain_details);
|
|
|
|
context->swapchain_extent = choose_swapchain_extent(context->swapchain_details, context->framebuffer_size);
|
|
|
|
context->framebuffer_recreated = true;
|
|
|
|
context->framebuffer_recreated = true;
|
|
|
|
context->swapchain = VK_NULL_HANDLE;
|
|
|
|
context->swapchain = VK_NULL_HANDLE;
|
|
|
|
VK_RESULT(create_swapchain(
|
|
|
|
VK_RESULT(create_swapchain(
|
|
|
|
@ -1277,7 +1294,7 @@ VkResult recreate_framebuffer(RenderContext* gpu) {
|
|
|
|
&gpu->swapchain_details))
|
|
|
|
&gpu->swapchain_details))
|
|
|
|
gpu->swapchain_format = choose_swapchain_format(gpu->swapchain_details);
|
|
|
|
gpu->swapchain_format = choose_swapchain_format(gpu->swapchain_details);
|
|
|
|
gpu->swapchain_present_mode = choose_present_mode(gpu->swapchain_details);
|
|
|
|
gpu->swapchain_present_mode = choose_present_mode(gpu->swapchain_details);
|
|
|
|
gpu->swapchain_extent = choose_swapchain_extent(gpu->swapchain_details);
|
|
|
|
gpu->swapchain_extent = choose_swapchain_extent(gpu->swapchain_details, gpu->framebuffer_size);
|
|
|
|
VK_RESULT(create_swapchain(
|
|
|
|
VK_RESULT(create_swapchain(
|
|
|
|
gpu->device,
|
|
|
|
gpu->device,
|
|
|
|
gpu->swapchain_format,
|
|
|
|
gpu->swapchain_format,
|
|
|
|
|