mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 06:08:05 +02:00
Merge branch 'fix-simple-vulkan' into 'main'
clients/simple-(dmabuf-)vulkan: some minor fixes See merge request wayland/weston!2006
This commit is contained in:
commit
3668e8e627
2 changed files with 27 additions and 42 deletions
|
|
@ -459,8 +459,11 @@ find_memory_type(struct display *display, uint32_t allowed, VkMemoryPropertyFlag
|
|||
VkPhysicalDeviceMemoryProperties mem_properties;
|
||||
vkGetPhysicalDeviceMemoryProperties(display->vk.phys_dev, &mem_properties);
|
||||
|
||||
for (unsigned i = 0; (1u << i) <= allowed && i <= mem_properties.memoryTypeCount; ++i) {
|
||||
if ((allowed & (1u << i)) && (mem_properties.memoryTypes[i].propertyFlags & properties))
|
||||
for (unsigned i = 0; i < mem_properties.memoryTypeCount; ++i) {
|
||||
bool is_allowed = allowed & (1u << i);
|
||||
bool has_properties =
|
||||
(mem_properties.memoryTypes[i].propertyFlags & properties) == properties;
|
||||
if (is_allowed && has_properties)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -1578,6 +1581,17 @@ destroy_display(struct display *display)
|
|||
free(display);
|
||||
}
|
||||
|
||||
static bool
|
||||
check_extension(const VkExtensionProperties *avail, uint32_t avail_len, const char *name)
|
||||
{
|
||||
for (size_t i = 0; i < avail_len; i++) {
|
||||
if (strcmp(avail[i].extensionName, name) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
load_device_proc(struct display *display, const char *func, void *proc_ptr)
|
||||
{
|
||||
|
|
@ -1614,13 +1628,7 @@ create_instance(struct display *display)
|
|||
inst_extns[num_inst_extns++] = VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME;
|
||||
|
||||
for (uint32_t i = 0; i < num_inst_extns; i++) {
|
||||
uint32_t j;
|
||||
for (j = 0; j < num_avail_inst_extns; j++) {
|
||||
if (strcmp(inst_extns[i], avail_inst_extns[j].extensionName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == num_avail_inst_extns) {
|
||||
if (!check_extension(avail_inst_extns, num_avail_inst_extns, inst_extns[i])) {
|
||||
fprintf(stderr, "Unsupported instance extension: %s\n", inst_extns[i]);
|
||||
abort();
|
||||
}
|
||||
|
|
@ -1741,13 +1749,7 @@ create_device(struct display *display)
|
|||
device_extns[num_device_extns++] = VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME;
|
||||
|
||||
for (uint32_t i = 0; i < num_device_extns; i++) {
|
||||
uint32_t j;
|
||||
for (j = 0; j < num_avail_device_extns; j++) {
|
||||
if (strcmp(device_extns[i], avail_device_extns[j].extensionName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == num_avail_device_extns) {
|
||||
if (!check_extension(avail_device_extns, num_avail_device_extns, device_extns[i])) {
|
||||
fprintf(stderr, "Unsupported device extension: %s\n", device_extns[i]);
|
||||
abort();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,8 +525,11 @@ find_memory_type(struct window *window, uint32_t allowed, VkMemoryPropertyFlags
|
|||
VkPhysicalDeviceMemoryProperties mem_properties;
|
||||
vkGetPhysicalDeviceMemoryProperties(window->vk.phys_dev, &mem_properties);
|
||||
|
||||
for (unsigned i = 0; (1u << i) <= allowed && i <= mem_properties.memoryTypeCount; ++i) {
|
||||
if ((allowed & (1u << i)) && (mem_properties.memoryTypes[i].propertyFlags & properties))
|
||||
for (unsigned i = 0; i < mem_properties.memoryTypeCount; ++i) {
|
||||
bool is_allowed = allowed & (1u << i);
|
||||
bool has_properties =
|
||||
(mem_properties.memoryTypes[i].propertyFlags & properties) == properties;
|
||||
if (is_allowed && has_properties)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -905,13 +908,7 @@ create_instance(struct window *window)
|
|||
inst_extns[num_inst_extns++] = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
|
||||
|
||||
for (uint32_t i = 0; i < num_inst_extns; i++) {
|
||||
uint32_t j;
|
||||
for (j = 0; j < num_avail_inst_extns; j++) {
|
||||
if (strcmp(inst_extns[i], avail_inst_extns[j].extensionName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == num_avail_inst_extns) {
|
||||
if (!check_extension(avail_inst_extns, num_avail_inst_extns, inst_extns[i])) {
|
||||
fprintf(stderr, "Unsupported instance extension: %s\n", inst_extns[i]);
|
||||
abort();
|
||||
}
|
||||
|
|
@ -1028,13 +1025,7 @@ create_device(struct window *window)
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < num_device_extns; i++) {
|
||||
uint32_t j;
|
||||
for (j = 0; j < num_avail_device_extns; j++) {
|
||||
if (strcmp(device_extns[i], avail_device_extns[j].extensionName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == num_avail_device_extns) {
|
||||
if (!check_extension(avail_device_extns, num_avail_device_extns, device_extns[i])) {
|
||||
fprintf(stderr, "Unsupported device extension: %s\n", device_extns[i]);
|
||||
abort();
|
||||
}
|
||||
|
|
@ -1613,20 +1604,12 @@ redraw(struct window *window)
|
|||
.pRegions = ®ion,
|
||||
};
|
||||
pnext(&present_info, &present_regions);
|
||||
|
||||
result = vkQueuePresentKHR(window->vk.queue, &present_info);
|
||||
} else {
|
||||
result = vkQueuePresentKHR(window->vk.queue, &present_info);
|
||||
}
|
||||
|
||||
result = vkQueuePresentKHR(window->vk.queue, &present_info);
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) {
|
||||
recreate_swapchain(window);
|
||||
return;
|
||||
} else if (result != VK_SUCCESS) {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
window->frames++;
|
||||
window->vk.frame_index = (window->vk.frame_index + 1) % MAX_CONCURRENT_FRAMES;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue