Merge branch 'wip/otte/for-main' into 'main'

vulkan: Remove draw semaphore

Closes #6861

See merge request GNOME/gtk!7460
This commit is contained in:
Benjamin Otte
2024-07-14 21:11:06 +00:00
5 changed files with 34 additions and 61 deletions

View File

@@ -368,7 +368,7 @@ gdk_gl_texture_builder_get_context (GdkGLTextureBuilder *self)
/**
* gdk_gl_texture_builder_set_context: (attributes org.gtk.Method.set_property=context)
* @self: a `GdkGLTextureBuilder`
* @context: (nullable): The context the texture beongs to or %NULL to unset
* @context: (nullable): The context the texture belongs to or %NULL to unset
*
* Sets the context to be used for the texture. This is the context that owns
* the texture.

View File

@@ -76,7 +76,6 @@ struct _GdkVulkanContextPrivate {
GdkMemoryDepth current_depth;
VkSwapchainKHR swapchain;
VkSemaphore draw_semaphore;
guint n_images;
VkImage *images;
@@ -367,14 +366,6 @@ gdk_vulkan_context_dispose (GObject *gobject)
device = gdk_vulkan_context_get_device (context);
if (priv->draw_semaphore != VK_NULL_HANDLE)
{
vkDestroySemaphore (device,
priv->draw_semaphore,
NULL);
priv->draw_semaphore = VK_NULL_HANDLE;
}
if (priv->swapchain != VK_NULL_HANDLE)
{
vkDestroySwapchainKHR (device,
@@ -679,7 +670,7 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
priv->swapchain,
UINT64_MAX,
priv->draw_semaphore,
VK_NULL_HANDLE,
VK_NULL_HANDLE,
&priv->draw_index);
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
@@ -751,10 +742,8 @@ gdk_vulkan_context_end_frame (GdkDrawContext *draw_context,
GDK_VK_CHECK (vkQueuePresentKHR, gdk_vulkan_context_get_queue (context),
&(VkPresentInfoKHR) {
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
.waitSemaphoreCount = 1,
.pWaitSemaphores = (VkSemaphore[]) {
priv->draw_semaphore
},
.waitSemaphoreCount = 0,
.pWaitSemaphores = NULL,
.swapchainCount = 1,
.pSwapchains = (VkSwapchainKHR[]) {
priv->swapchain
@@ -973,13 +962,6 @@ gdk_vulkan_context_real_init (GInitable *initable,
if (!gdk_vulkan_context_check_swapchain (context, error))
goto out_surface;
GDK_VK_CHECK (vkCreateSemaphore, gdk_vulkan_context_get_device (context),
&(VkSemaphoreCreateInfo) {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
},
NULL,
&priv->draw_semaphore);
return TRUE;
}
@@ -1385,29 +1367,6 @@ gdk_vulkan_context_get_draw_index (GdkVulkanContext *context)
return priv->draw_index;
}
/**
* gdk_vulkan_context_get_draw_semaphore:
* @context: a `GdkVulkanContext`
*
* Gets the Vulkan semaphore that protects access to the image that is
* currently being drawn.
*
* This function can only be used between [method@Gdk.DrawContext.begin_frame]
* and [method@Gdk.DrawContext.end_frame] calls.
*
* Returns: (transfer none): the VkSemaphore
*/
VkSemaphore
gdk_vulkan_context_get_draw_semaphore (GdkVulkanContext *context)
{
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), VK_NULL_HANDLE);
g_return_val_if_fail (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)), VK_NULL_HANDLE);
return priv->draw_semaphore;
}
static gboolean
gdk_display_create_vulkan_device (GdkDisplay *display,
GError **error)

View File

@@ -99,7 +99,6 @@ uint32_t gdk_vulkan_context_get_n_images (GdkVulk
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
guint id);
uint32_t gdk_vulkan_context_get_draw_index (GdkVulkanContext *context);
VkSemaphore gdk_vulkan_context_get_draw_semaphore (GdkVulkanContext *context);
#else /* !GDK_RENDERING_VULKAN */

View File

@@ -62,17 +62,24 @@ cache_gc_cb (gpointer data)
GskGpuDevice *self = data;
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (self);
gint64 timestamp;
gboolean result = G_SOURCE_CONTINUE;
timestamp = g_get_monotonic_time ();
GSK_DEBUG (CACHE, "Periodic GC (timestamp %lld)", (long long) timestamp);
/* gc can collect the device if all windows are closed and only
* the cache is keeping it alive */
g_object_ref (self);
if (gsk_gpu_device_gc (self, timestamp))
{
priv->cache_gc_source = 0;
return G_SOURCE_REMOVE;
result = G_SOURCE_REMOVE;
}
return G_SOURCE_CONTINUE;
g_object_unref (self);
return result;
}
void

View File

@@ -2047,23 +2047,31 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gsk_rect_round_larger (&clip_bounds);
/* now intersect with actual node bounds */
if (!gsk_rect_intersection (&clip_bounds, &node->bounds, &clip_bounds))
return;
{
g_object_unref (image);
return;
}
clip_bounds.size.width = ceilf (clip_bounds.size.width);
clip_bounds.size.height = ceilf (clip_bounds.size.height);
if (image == NULL)
offscreen = gsk_gpu_get_texture_tiles_as_image (self->frame,
self->ccs,
&clip_bounds,
graphene_vec2_one (),
&node->bounds,
texture,
scaling_filter);
{
offscreen = gsk_gpu_get_texture_tiles_as_image (self->frame,
self->ccs,
&clip_bounds,
graphene_vec2_one (),
&node->bounds,
texture,
scaling_filter);
}
else
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
self->ccs,
graphene_vec2_one (),
&clip_bounds,
node);
{
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
self->ccs,
graphene_vec2_one (),
&clip_bounds,
node);
g_object_unref (image);
}
descriptor = gsk_gpu_node_processor_add_image (self, offscreen, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_texture_op (self->frame,
gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),