[gtk+/wip/otte/vulkan: 27/28] vulkan: Don't create more than one render object
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/vulkan: 27/28] vulkan: Don't create more than one render object
- Date: Fri, 9 Dec 2016 06:29:19 +0000 (UTC)
commit afc3e58abc60130428c8d1f068339913e04753f8
Author: Benjamin Otte <otte redhat com>
Date: Fri Dec 9 06:13:14 2016 +0100
vulkan: Don't create more than one render object
By creating unlimited render objects, we would never wait on the GPU.
This would mean that if the GPU was the bottleneck, we would fill its
queue with render commands faster than it could process them.
And because the nvidia binary driver and my code work surprisingly well
and bugfree, this lead to exhaustion of RAM. I had 50GB of swap
configured and my hard disk was quicker as swap storage than my GPU was
at processing the commands, so stuff still filled up.
At that point my computer became rather unresponsive and I decided to
reboot it, so I that could write this patch.
gsk/gskvulkanrenderer.c | 24 ++++--------------------
1 files changed, 4 insertions(+), 20 deletions(-)
---
diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c
index 488b8f4..2f71dc0 100644
--- a/gsk/gskvulkanrenderer.c
+++ b/gsk/gskvulkanrenderer.c
@@ -33,7 +33,7 @@ struct _GskVulkanRenderer
VkSampler sampler;
- GSList *renders;
+ GskVulkanRender *render;
#ifdef G_ENABLE_DEBUG
ProfileTimers profile_timers;
@@ -123,8 +123,7 @@ gsk_vulkan_renderer_realize (GskRenderer *renderer,
self);
gsk_vulkan_renderer_update_images_cb (self->vulkan, self);
- /* We will need at least one render object, so create it early where we can still fail fine */
- self->renders = g_slist_prepend (self->renders, gsk_vulkan_render_new (renderer, self->vulkan));
+ self->render = gsk_vulkan_render_new (renderer, self->vulkan);
return TRUE;
}
@@ -135,8 +134,7 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
VkDevice device;
- g_slist_free_full (self->renders, (GDestroyNotify) gsk_vulkan_render_free);
- self->renders = NULL;
+ g_clear_pointer (&self->render, gsk_vulkan_render_free);
device = gdk_vulkan_context_get_device (self->vulkan);
@@ -159,7 +157,6 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
{
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
GskVulkanRender *render;
- GSList *l;
#ifdef G_ENABLE_DEBUG
GskProfiler *profiler;
gint64 cpu_time;
@@ -170,20 +167,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
gsk_profiler_timer_begin (profiler, self->profile_timers.cpu_time);
#endif
- for (l = self->renders; l; l = l->next)
- {
- if (!gsk_vulkan_render_is_busy (l->data))
- break;
- }
- if (l)
- {
- render = l->data;
- }
- else
- {
- render = gsk_vulkan_render_new (renderer, self->vulkan);
- self->renders = g_slist_prepend (self->renders, render);
- }
+ render = self->render;
gsk_vulkan_render_reset (render, self->targets[gdk_vulkan_context_get_draw_index (self->vulkan)]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]