render: unify getter for texture formats

Instead of having separate getters for shm formats and DMA-BUF
formats, use the same pattern as wlr_output_impl.get_primary_formats
with a single function which takes buffer caps as input.
This commit is contained in:
Simon Ser 2024-04-12 11:27:57 +02:00 committed by Kenny Levinsen
parent c63275d75e
commit 85c1eda721
12 changed files with 78 additions and 67 deletions

View file

@ -623,9 +623,8 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
size_t max_fmts;
const struct wlr_vk_format *fmts = vulkan_get_format_list(&max_fmts);
dev->shm_formats = calloc(max_fmts, sizeof(*dev->shm_formats));
dev->format_props = calloc(max_fmts, sizeof(*dev->format_props));
if (!dev->shm_formats || !dev->format_props) {
if (!dev->format_props) {
wlr_log_errno(WLR_ERROR, "allocation failed");
goto error;
}
@ -657,12 +656,12 @@ void vulkan_device_destroy(struct wlr_vk_device *dev) {
wlr_drm_format_set_finish(&dev->dmabuf_render_formats);
wlr_drm_format_set_finish(&dev->dmabuf_texture_formats);
wlr_drm_format_set_finish(&dev->shm_texture_formats);
for (unsigned i = 0u; i < dev->format_prop_count; ++i) {
vulkan_format_props_finish(&dev->format_props[i]);
}
free(dev->shm_formats);
free(dev->format_props);
free(dev);
}