[gtk+/wip/matthiasc/renderpasses] wip: dump textures



commit beddaad527b45f0b53fbc1af6ecd337750da8ad4
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 27 11:29:59 2017 -0400

    wip: dump textures
    
    Doesn't work yet.

 gsk/gskvulkanrender.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index fc5f381..d6f134a 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -22,6 +22,7 @@
 #include "gskvulkanlineargradientpipelineprivate.h"
 #include "gskvulkantextpipelineprivate.h"
 #include "gskvulkanpushconstantsprivate.h"
+#include "gsktextureprivate.h"
 
 #define ORTHO_NEAR_PLANE        -10000
 #define ORTHO_FAR_PLANE          10000
@@ -690,6 +691,46 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self,
     }
 }
 
+static void
+dump_target_image (GskVulkanRender *self,
+                   GskVulkanImage *target,
+                   const char     *basename)
+{
+  GskTexture *texture;
+  cairo_surface_t *surface;
+
+  texture = gsk_vulkan_image_download (target, self->uploader);
+  surface = gsk_texture_download_surface (texture);
+  cairo_surface_write_to_png (surface, basename);
+
+  cairo_surface_destroy (surface);
+  g_object_unref (texture);
+}
+
+static void
+dump_target_images (GskVulkanRender *self)
+{
+  GList *l;
+  GskProfiler *profiler;
+  gint64 frame;
+  gint pass;
+
+  profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (self));
+  frame = gsk_profiler_counter_get (profiler, g_quark_from_static_string ("frames"));
+
+  for (l = self->render_passes, pass = 0; l; l = l->next, pass++)
+    {
+      RenderPassData *data = l->data;
+      char basename[256];
+
+      if (l->next == NULL)
+        break; // skip the last one, thats the full window
+
+      g_snprintf (basename, sizeof(basename), "frame-%ld-pass-%d.png", frame, pass);
+      dump_target_image (self, data->target, basename);
+    }
+}
+
 void
 gsk_vulkan_render_draw (GskVulkanRender   *self,
                         VkSampler          sampler)
@@ -774,6 +815,8 @@ gsk_vulkan_render_draw (GskVulkanRender   *self,
                                    &self->fence,
                                    VK_TRUE,
                                    INT64_MAX);
+
+  dump_target_images (self);
 }
 
 GskTexture *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]