diff --git a/gdk/wayland/gdksubsurface-wayland.c b/gdk/wayland/gdksubsurface-wayland.c index 424f9ec354..47db77f5d2 100644 --- a/gdk/wayland/gdksubsurface-wayland.c +++ b/gdk/wayland/gdksubsurface-wayland.c @@ -568,8 +568,9 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub, } GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD, - "[%p] %s Attaching texture (%dx%d) at %d %d %d %d%s%s%s", + "[%p] %s Attaching %s (%dx%d) at %d %d %d %d%s%s%s", self, + G_OBJECT_TYPE_NAME (texture), will_be_above ? (has_background ? "▲" : "△") : (has_background ? "▼" : "▽"), diff --git a/gsk/gpu/gskvulkanframe.c b/gsk/gpu/gskvulkanframe.c index 84832df7bd..9c7184d44e 100644 --- a/gsk/gpu/gskvulkanframe.c +++ b/gsk/gpu/gskvulkanframe.c @@ -162,10 +162,18 @@ gsk_vulkan_frame_upload_texture (GskGpuFrame *frame, #ifdef HAVE_DMABUF if (GDK_IS_DMABUF_TEXTURE (texture)) { - GskGpuImage *image = gsk_vulkan_image_new_for_dmabuf (GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame)), - texture); + GskGpuImage *image; + + image = gsk_vulkan_image_new_for_dmabuf (GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame)), + gdk_texture_get_width (texture), + gdk_texture_get_height (texture), + gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture)), + gdk_memory_format_alpha (gdk_texture_get_format (texture)) == GDK_MEMORY_ALPHA_PREMULTIPLIED); if (image) - return image; + { + gsk_gpu_image_toggle_ref_texture (image, texture); + return image; + } } #endif diff --git a/gsk/gpu/gskvulkanimage.c b/gsk/gpu/gskvulkanimage.c index 2db4a218ff..5215dd98a6 100644 --- a/gsk/gpu/gskvulkanimage.c +++ b/gsk/gpu/gskvulkanimage.c @@ -763,7 +763,10 @@ gsk_vulkan_image_new_dmabuf (GskVulkanDevice *device, GskGpuImage * gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device, - GdkTexture *texture) + gsize width, + gsize height, + const GdkDmabuf *dmabuf, + gboolean premultiplied) { GskVulkanImage *self; VkDevice vk_device; @@ -773,9 +776,8 @@ gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device, PFN_vkGetMemoryFdPropertiesKHR func_vkGetMemoryFdPropertiesKHR; gsize i; int fd; - gsize width, height; - const GdkDmabuf *dmabuf; VkResult res; + GdkMemoryFormat format; GskGpuImageFlags flags; gboolean is_yuv; @@ -785,9 +787,12 @@ gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device, return NULL; } - width = gdk_texture_get_width (texture); - height = gdk_texture_get_height (texture); - dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture)); + if (!gdk_dmabuf_get_memory_format (dmabuf->fourcc, premultiplied, &format)) + { + /* We should never get dmabufs with fourccs we've never checked we support */ + g_return_val_if_reached (NULL); + } + vk_device = gsk_vulkan_device_get_vk_device (device); func_vkGetMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR) vkGetDeviceProcAddr (vk_device, "vkGetMemoryFdPropertiesKHR"); @@ -887,12 +892,11 @@ gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device, gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags | - (gdk_memory_format_alpha (gdk_texture_get_format (texture)) == GDK_MEMORY_ALPHA_STRAIGHT ? GSK_GPU_IMAGE_STRAIGHT_ALPHA : 0) | + (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT ? GSK_GPU_IMAGE_STRAIGHT_ALPHA : 0) | (is_yuv ? (GSK_GPU_IMAGE_EXTERNAL | GSK_GPU_IMAGE_NO_BLIT) : 0) | (gsk_component_mapping_is_framebuffer_compatible (&vk_components) ? 0 : GSK_GPU_IMAGE_NO_BLIT), - gdk_texture_get_format (texture), + format, width, height); - gsk_gpu_image_toggle_ref_texture (GSK_GPU_IMAGE (self), texture); self->allocator = gsk_vulkan_device_get_external_allocator (device); gsk_vulkan_allocator_ref (self->allocator); diff --git a/gsk/gpu/gskvulkanimageprivate.h b/gsk/gpu/gskvulkanimageprivate.h index 2a4a1502e1..a861e11522 100644 --- a/gsk/gpu/gskvulkanimageprivate.h +++ b/gsk/gpu/gskvulkanimageprivate.h @@ -37,7 +37,10 @@ GskGpuImage * gsk_vulkan_image_new_dmabuf (GskVulk gsize width, gsize height); GskGpuImage * gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device, - GdkTexture *texture); + gsize width, + gsize height, + const GdkDmabuf *dmabuf, + gboolean premultiplied); GdkTexture * gsk_vulkan_image_to_dmabuf_texture (GskVulkanImage *self); #endif