gpu: Use existing frame in render_texture()

Instead of recreating frames from scratch every time, use an existing one.

This ensures that renderers don't need to recreate GPU resources every
time (like buffers and everything else that frames manage). It also
speeds up occasional render_texture() calls in default renderers.

This speeds up in particular the Vulkan renderer.
This commit is contained in:
Benjamin Otte 2024-09-15 00:01:32 +02:00
parent c3d9f4a9ac
commit fa86bfcb55

View File

@ -152,7 +152,7 @@ gsk_gpu_renderer_dmabuf_downloader_download (GdkDmabufDownloader *downloader,
gsk_gpu_renderer_make_current (self);
frame = gsk_gpu_renderer_create_frame (self);
frame = gsk_gpu_renderer_get_frame (self);
gsk_gpu_frame_download_texture (frame,
g_get_monotonic_time (),
@ -162,7 +162,7 @@ gsk_gpu_renderer_dmabuf_downloader_download (GdkDmabufDownloader *downloader,
data,
stride);
g_object_unref (frame);
gsk_gpu_frame_wait (frame);
}
static void
@ -310,7 +310,7 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image)
});
frame = gsk_gpu_renderer_create_frame (self);
frame = gsk_gpu_renderer_get_frame (self);
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
@ -322,7 +322,7 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
image_width,
image_height),
&texture);
g_object_unref (frame);
gsk_gpu_frame_wait (frame);
g_assert (texture);
gdk_texture_downloader_init (&downloader, texture);
@ -381,7 +381,7 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
else
color_state = GDK_COLOR_STATE_SRGB;
frame = gsk_gpu_renderer_create_frame (self);
frame = gsk_gpu_renderer_get_frame (self);
clip_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
0, 0,
@ -399,7 +399,7 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
&rounded_viewport,
&texture);
g_object_unref (frame);
gsk_gpu_frame_wait (frame);
g_object_unref (image);
gsk_gpu_device_queue_gc (priv->device);