Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vulkan] Fix GGUI and vulkan swapchain on AMD drivers #7382

Merged
merged 3 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions taichi/rhi/vulkan/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,6 +2646,12 @@ void VulkanSurface::create_swap_chain() {
VkSurfaceCapabilitiesKHR capabilities;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device_->vk_physical_device(),
surface_, &capabilities);
if (capabilities.maxImageCount == 0) {
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSurfaceCapabilitiesKHR.html
// When maxImageCount is 0, there is no limit on the number of images.
capabilities.maxImageCount =
std::max<uint32_t>(capabilities.minImageCount, 3);
}

VkBool32 supported = false;
vkGetPhysicalDeviceSurfaceSupportKHR(device_->vk_physical_device(),
Expand Down Expand Up @@ -2689,8 +2695,9 @@ void VulkanSurface::create_swap_chain() {
std::min(capabilities.maxImageExtent.height, extent.height));
{
char msg_buf[512];
RHI_DEBUG_SNPRINTF(msg_buf, sizeof(msg_buf), "Creating suface of %u x %u",
extent.width, extent.height);
RHI_DEBUG_SNPRINTF(msg_buf, sizeof(msg_buf),
"Creating suface of %u x %u, present mode %d",
extent.width, extent.height, present_mode);
RHI_LOG_DEBUG(msg_buf);
}
VkImageUsageFlags usage =
Expand Down Expand Up @@ -2799,9 +2806,10 @@ StreamSemaphore VulkanSurface::acquire_next_image() {
image_index_ = (image_index_ + 1) % uint32_t(swapchain_images_.size());
return nullptr;
} else {
vkAcquireNextImageKHR(device_->vk_device(), swapchain_, UINT64_MAX,
image_available_->semaphore, VK_NULL_HANDLE,
&image_index_);
VkResult res = vkAcquireNextImageKHR(
device_->vk_device(), swapchain_, uint64_t(4 * 1e9),
image_available_->semaphore, VK_NULL_HANDLE, &image_index_);
BAIL_ON_VK_BAD_RESULT_NO_RETURN(res, "vkAcquireNextImageKHR failed");
return std::make_shared<VulkanStreamSemaphoreObject>(image_available_);
}
}
Expand Down
5 changes: 5 additions & 0 deletions taichi/rhi/vulkan/vulkan_device_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ VulkanQueueFamilyIndices find_queue_families(VkPhysicalDevice device,
VkBool32 present_support = false;
vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface,
&present_support);
char msg_buf[128];
RHI_DEBUG_SNPRINTF(msg_buf, sizeof(msg_buf),
"Queue %d %s support for presenting", i,
present_support ? "has" : "does NOT have");
RHI_LOG_DEBUG(msg_buf);

if (present_support) {
indices.present_family = i;
Expand Down