[gtk+] vulkan: Rename blend pipeline to texture



commit 5577fde990c7ca36eb64fd179965c4782f33bad8
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Sep 29 22:24:53 2017 -0400

    vulkan: Rename blend pipeline to texture
    
    This is what it does, and the name blend is easily
    confused with blend-mode.

 gsk/gskvulkanblendpipeline.c                       |  122 --------------------
 gsk/gskvulkanblendpipelineprivate.h                |   33 ------
 gsk/gskvulkanrender.c                              |    8 +-
 gsk/gskvulkanrenderpass.c                          |   26 ++--
 gsk/gskvulkanrenderprivate.h                       |    6 +-
 gsk/gskvulkantexturepipeline.c                     |  122 ++++++++++++++++++++
 gsk/gskvulkantexturepipelineprivate.h              |   33 ++++++
 gsk/meson.build                                    |    2 +-
 gsk/resources/vulkan/meson.build                   |    4 +-
 ...nded.frag.spv => texture-clip-rounded.frag.spv} |  Bin 8268 -> 8268 bytes
 ...nded.vert.spv => texture-clip-rounded.vert.spv} |  Bin 4868 -> 4868 bytes
 .../{blend-clip.frag.spv => texture-clip.frag.spv} |  Bin 1328 -> 1328 bytes
 .../{blend-clip.vert.spv => texture-clip.vert.spv} |  Bin 4868 -> 4868 bytes
 gsk/resources/vulkan/{blend.frag => texture.frag}  |    0
 .../vulkan/{blend.frag.glsl => texture.frag.glsl}  |    0
 .../vulkan/{blend.frag.spv => texture.frag.spv}    |  Bin 1328 -> 1328 bytes
 gsk/resources/vulkan/{blend.vert => texture.vert}  |    0
 .../vulkan/{blend.vert.glsl => texture.vert.glsl}  |    0
 .../vulkan/{blend.vert.spv => texture.vert.spv}    |  Bin 3136 -> 3136 bytes
 19 files changed, 178 insertions(+), 178 deletions(-)
---
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index c7aedd1..0dc0056 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -11,7 +11,6 @@
 #include "gskvulkanrenderpassprivate.h"
 
 #include "gskvulkanblendmodepipelineprivate.h"
-#include "gskvulkanblendpipelineprivate.h"
 #include "gskvulkanblurpipelineprivate.h"
 #include "gskvulkanborderpipelineprivate.h"
 #include "gskvulkanboxshadowpipelineprivate.h"
@@ -21,6 +20,7 @@
 #include "gskvulkaneffectpipelineprivate.h"
 #include "gskvulkanlineargradientpipelineprivate.h"
 #include "gskvulkantextpipelineprivate.h"
+#include "gskvulkantexturepipelineprivate.h"
 #include "gskvulkanpushconstantsprivate.h"
 
 #define DESCRIPTOR_POOL_MAXSETS 128
@@ -366,9 +366,9 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender       *self,
     guint num_textures;
     GskVulkanPipeline * (* create_func) (GdkVulkanContext *context, VkPipelineLayout layout, const char 
*name, VkRenderPass render_pass);
   } pipeline_info[GSK_VULKAN_N_PIPELINES] = {
-    { "blend",                      1, gsk_vulkan_blend_pipeline_new },
-    { "blend-clip",                 1, gsk_vulkan_blend_pipeline_new },
-    { "blend-clip-rounded",         1, gsk_vulkan_blend_pipeline_new },
+    { "texture",                    1, gsk_vulkan_texture_pipeline_new },
+    { "texture-clip",               1, gsk_vulkan_texture_pipeline_new },
+    { "texture-clip-rounded",       1, gsk_vulkan_texture_pipeline_new },
     { "color",                      0, gsk_vulkan_color_pipeline_new },
     { "color-clip",                 0, gsk_vulkan_color_pipeline_new },
     { "color-clip-rounded",         0, gsk_vulkan_color_pipeline_new },
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index 77f4fcd..1c2d05a 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -9,7 +9,6 @@
 #include "gskrendererprivate.h"
 #include "gskroundedrectprivate.h"
 #include "gskvulkanblendmodepipelineprivate.h"
-#include "gskvulkanblendpipelineprivate.h"
 #include "gskvulkanblurpipelineprivate.h"
 #include "gskvulkanborderpipelineprivate.h"
 #include "gskvulkanboxshadowpipelineprivate.h"
@@ -20,6 +19,7 @@
 #include "gskvulkaneffectpipelineprivate.h"
 #include "gskvulkanlineargradientpipelineprivate.h"
 #include "gskvulkantextpipelineprivate.h"
+#include "gskvulkantexturepipelineprivate.h"
 #include "gskvulkanimageprivate.h"
 #include "gskvulkanpushconstantsprivate.h"
 #include "gskvulkanrendererprivate.h"
@@ -338,11 +338,11 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass           *self,
       if (gsk_cairo_node_get_surface (node) == NULL)
         return;
       if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
-        pipeline_type = GSK_VULKAN_PIPELINE_BLEND;
+        pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE;
       else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
-        pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP;
+        pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP;
       else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
-        pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP_ROUNDED;
+        pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED;
       else
         FALLBACK ("Cairo nodes can't deal with clip type %u\n", constants->clip.type);
       op.type = GSK_VULKAN_OP_SURFACE;
@@ -423,11 +423,11 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass           *self,
 
     case GSK_TEXTURE_NODE:
       if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
-        pipeline_type = GSK_VULKAN_PIPELINE_BLEND;
+        pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE;
       else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
-        pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP;
+        pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP;
       else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
-        pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP_ROUNDED;
+        pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED;
       else
         FALLBACK ("Texture nodes can't deal with clip type %u\n", constants->clip.type);
       op.type = GSK_VULKAN_OP_TEXTURE;
@@ -622,7 +622,7 @@ fallback:
         g_assert_not_reached ();
         return;
     }
-  op.render.pipeline = gsk_vulkan_render_get_pipeline (render, GSK_VULKAN_PIPELINE_BLEND);
+  op.render.pipeline = gsk_vulkan_render_get_pipeline (render, GSK_VULKAN_PIPELINE_TEXTURE);
   g_array_append_val (self->render_ops, op);
 }
 #undef FALLBACK
@@ -959,7 +959,7 @@ gsk_vulkan_render_pass_count_vertex_data (GskVulkanRenderPass *self)
         case GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP:
         case GSK_VULKAN_OP_SURFACE:
         case GSK_VULKAN_OP_TEXTURE:
-          op->render.vertex_count = gsk_vulkan_blend_pipeline_count_vertex_data (GSK_VULKAN_BLEND_PIPELINE 
(op->render.pipeline));
+          op->render.vertex_count = gsk_vulkan_texture_pipeline_count_vertex_data 
(GSK_VULKAN_TEXTURE_PIPELINE (op->render.pipeline));
           n_bytes += op->render.vertex_count;
           break;
 
@@ -1053,7 +1053,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_TEXTURE:
           {
             op->render.vertex_offset = offset + n_bytes;
-            gsk_vulkan_blend_pipeline_collect_vertex_data (GSK_VULKAN_BLEND_PIPELINE (op->render.pipeline),
+            gsk_vulkan_texture_pipeline_collect_vertex_data (GSK_VULKAN_TEXTURE_PIPELINE 
(op->render.pipeline),
                                                            data + n_bytes + offset,
                                                            &op->render.node->bounds,
                                                            &op->render.node->bounds);
@@ -1391,9 +1391,9 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass     *self,
                                    0,
                                    NULL);
 
-          current_draw_index += gsk_vulkan_blend_pipeline_draw (GSK_VULKAN_BLEND_PIPELINE (current_pipeline),
-                                                                command_buffer,
-                                                                current_draw_index, 1);
+          current_draw_index += gsk_vulkan_texture_pipeline_draw (GSK_VULKAN_TEXTURE_PIPELINE 
(current_pipeline),
+                                                                  command_buffer,
+                                                                  current_draw_index, 1);
           break;
 
         case GSK_VULKAN_OP_TEXT:
diff --git a/gsk/gskvulkanrenderprivate.h b/gsk/gskvulkanrenderprivate.h
index d390c3c..c764763 100644
--- a/gsk/gskvulkanrenderprivate.h
+++ b/gsk/gskvulkanrenderprivate.h
@@ -12,9 +12,9 @@
 G_BEGIN_DECLS
 
 typedef enum {
-  GSK_VULKAN_PIPELINE_BLEND,
-  GSK_VULKAN_PIPELINE_BLEND_CLIP,
-  GSK_VULKAN_PIPELINE_BLEND_CLIP_ROUNDED,
+  GSK_VULKAN_PIPELINE_TEXTURE,
+  GSK_VULKAN_PIPELINE_TEXTURE_CLIP,
+  GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED,
   GSK_VULKAN_PIPELINE_COLOR,
   GSK_VULKAN_PIPELINE_COLOR_CLIP,
   GSK_VULKAN_PIPELINE_COLOR_CLIP_ROUNDED,
diff --git a/gsk/gskvulkantexturepipeline.c b/gsk/gskvulkantexturepipeline.c
new file mode 100644
index 0000000..83dae29
--- /dev/null
+++ b/gsk/gskvulkantexturepipeline.c
@@ -0,0 +1,122 @@
+#include "config.h"
+
+#include "gskvulkantexturepipelineprivate.h"
+
+struct _GskVulkanTexturePipeline
+{
+  GObject parent_instance;
+};
+
+typedef struct _GskVulkanTextureInstance GskVulkanTextureInstance;
+
+struct _GskVulkanTextureInstance
+{
+  float rect[4];
+  float tex_rect[4];
+};
+
+G_DEFINE_TYPE (GskVulkanTexturePipeline, gsk_vulkan_texture_pipeline, GSK_TYPE_VULKAN_PIPELINE)
+
+static const VkPipelineVertexInputStateCreateInfo *
+gsk_vulkan_texture_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
+{
+  static const VkVertexInputBindingDescription vertexBindingDescriptions[] = {
+      {
+          .binding = 0,
+          .stride = sizeof (GskVulkanTextureInstance),
+          .inputRate = VK_VERTEX_INPUT_RATE_INSTANCE
+      }
+  };
+  static const VkVertexInputAttributeDescription vertexInputAttributeDescription[] = {
+      {
+          .location = 0,
+          .binding = 0,
+          .format = VK_FORMAT_R32G32B32A32_SFLOAT,
+          .offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, rect),
+      },
+      {
+          .location = 1,
+          .binding = 0,
+          .format = VK_FORMAT_R32G32B32A32_SFLOAT,
+          .offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, tex_rect),
+      }
+  };
+  static const VkPipelineVertexInputStateCreateInfo info = {
+      .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
+      .vertexBindingDescriptionCount = G_N_ELEMENTS (vertexBindingDescriptions),
+      .pVertexBindingDescriptions = vertexBindingDescriptions,
+      .vertexAttributeDescriptionCount = G_N_ELEMENTS (vertexInputAttributeDescription),
+      .pVertexAttributeDescriptions = vertexInputAttributeDescription
+  };
+
+  return &info;
+}
+
+static void
+gsk_vulkan_texture_pipeline_finalize (GObject *gobject)
+{
+  //GskVulkanTexturePipeline *self = GSK_VULKAN_TEXTURE_PIPELINE (gobject);
+
+  G_OBJECT_CLASS (gsk_vulkan_texture_pipeline_parent_class)->finalize (gobject);
+}
+
+static void
+gsk_vulkan_texture_pipeline_class_init (GskVulkanTexturePipelineClass *klass)
+{
+  GskVulkanPipelineClass *pipeline_class = GSK_VULKAN_PIPELINE_CLASS (klass);
+
+  G_OBJECT_CLASS (klass)->finalize = gsk_vulkan_texture_pipeline_finalize;
+
+  pipeline_class->get_input_state_create_info = gsk_vulkan_texture_pipeline_get_input_state_create_info;
+}
+
+static void
+gsk_vulkan_texture_pipeline_init (GskVulkanTexturePipeline *self)
+{
+}
+
+GskVulkanPipeline *
+gsk_vulkan_texture_pipeline_new (GdkVulkanContext *context,
+                                 VkPipelineLayout  layout,
+                                 const char       *shader_name,
+                                 VkRenderPass      render_pass)
+{
+  return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_TEXTURE_PIPELINE, context, layout, shader_name, 
render_pass);
+}
+
+gsize
+gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipeline)
+{
+  return sizeof (GskVulkanTextureInstance);
+}
+
+void
+gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
+                                                 guchar                   *data,
+                                                 const graphene_rect_t    *rect,
+                                                 const graphene_rect_t    *tex_rect)
+{
+  GskVulkanTextureInstance *instance = (GskVulkanTextureInstance *) data;
+
+  instance->rect[0] = rect->origin.x;
+  instance->rect[1] = rect->origin.y;
+  instance->rect[2] = rect->size.width;
+  instance->rect[3] = rect->size.height;
+  instance->tex_rect[0] = (rect->origin.x - tex_rect->origin.x)/tex_rect->size.width;
+  instance->tex_rect[1] = (rect->origin.y - tex_rect->origin.y)/tex_rect->size.height;
+  instance->tex_rect[2] = (rect->size.width + rect->origin.x - tex_rect->origin.x)/tex_rect->size.width;
+  instance->tex_rect[3] = (rect->size.height + rect->origin.y - tex_rect->origin.y)/tex_rect->size.height;
+}
+
+gsize
+gsk_vulkan_texture_pipeline_draw (GskVulkanTexturePipeline *pipeline,
+                                  VkCommandBuffer           command_buffer,
+                                  gsize                     offset,
+                                  gsize                     n_commands)
+{
+  vkCmdDraw (command_buffer,
+             6, n_commands,
+             0, offset);
+
+  return n_commands;
+}
diff --git a/gsk/gskvulkantexturepipelineprivate.h b/gsk/gskvulkantexturepipelineprivate.h
new file mode 100644
index 0000000..c6435c4
--- /dev/null
+++ b/gsk/gskvulkantexturepipelineprivate.h
@@ -0,0 +1,33 @@
+#ifndef __GSK_VULKAN_TEXTURE_PIPELINE_PRIVATE_H__
+#define __GSK_VULKAN_TEXTURE_PIPELINE_PRIVATE_H__
+
+#include <graphene.h>
+
+#include "gskvulkanpipelineprivate.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GskVulkanTexturePipelineLayout GskVulkanTexturePipelineLayout;
+
+#define GSK_TYPE_VULKAN_TEXTURE_PIPELINE (gsk_vulkan_texture_pipeline_get_type ())
+
+G_DECLARE_FINAL_TYPE (GskVulkanTexturePipeline, gsk_vulkan_texture_pipeline, GSK, VULKAN_TEXTURE_PIPELINE, 
GskVulkanPipeline)
+
+GskVulkanPipeline *     gsk_vulkan_texture_pipeline_new                 (GdkVulkanContext         *context,
+                                                                         VkPipelineLayout          layout,
+                                                                         const char               
*shader_name,
+                                                                         VkRenderPass              
render_pass);
+
+gsize                   gsk_vulkan_texture_pipeline_count_vertex_data   (GskVulkanTexturePipeline *pipeline);
+void                    gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
+                                                                         guchar                   *data,
+                                                                         const graphene_rect_t    *rect,
+                                                                         const graphene_rect_t    *tex_rect);
+gsize                   gsk_vulkan_texture_pipeline_draw                (GskVulkanTexturePipeline *pipeline,
+                                                                         VkCommandBuffer           
command_buffer,
+                                                                         gsize                     offset,
+                                                                         gsize                     
n_commands);
+
+G_END_DECLS
+
+#endif /* __GSK_VULKAN_TEXTURE_PIPELINE_PRIVATE_H__ */
diff --git a/gsk/meson.build b/gsk/meson.build
index e91985a..a86e156 100644
--- a/gsk/meson.build
+++ b/gsk/meson.build
@@ -55,7 +55,6 @@ gsk_private_vulkan_compiled_shaders_deps = []
 if have_vulkan
   gsk_private_sources += files([
     'gskvulkanblendmodepipeline.c',
-    'gskvulkanblendpipeline.c',
     'gskvulkanblurpipeline.c',
     'gskvulkanborderpipeline.c',
     'gskvulkanboxshadowpipeline.c',
@@ -70,6 +69,7 @@ if have_vulkan
     'gskvulkanlineargradientpipeline.c',
     'gskvulkanimage.c',
     'gskvulkantextpipeline.c',
+    'gskvulkantexturepipeline.c',
     'gskvulkanmemory.c',
     'gskvulkanpipeline.c',
     'gskvulkanpushconstants.c',
diff --git a/gsk/resources/vulkan/meson.build b/gsk/resources/vulkan/meson.build
index 160bc0d..3486a88 100644
--- a/gsk/resources/vulkan/meson.build
+++ b/gsk/resources/vulkan/meson.build
@@ -7,7 +7,6 @@
 #]
 
 gsk_private_vulkan_fragment_shaders = [
-  'blend.frag',
   'blendmode.frag',
   'blur.frag',
   'border.frag',
@@ -18,10 +17,10 @@ gsk_private_vulkan_fragment_shaders = [
   'linear.frag',
   'mask.frag',
   'outset-shadow.frag',
+  'texture.frag',
 ]
 
 gsk_private_vulkan_vertex_shaders = [
-  'blend.vert',
   'blendmode.vert',
   'blur.vert',
   'border.vert',
@@ -32,6 +31,7 @@ gsk_private_vulkan_vertex_shaders = [
   'linear.vert',
   'mask.vert',
   'outset-shadow.vert',
+  'texture.vert',
 ]
 
 gsk_private_vulkan_shaders += gsk_private_vulkan_fragment_shaders
diff --git a/gsk/resources/vulkan/blend.frag b/gsk/resources/vulkan/texture.frag
similarity index 100%
rename from gsk/resources/vulkan/blend.frag
rename to gsk/resources/vulkan/texture.frag
diff --git a/gsk/resources/vulkan/blend.frag.glsl b/gsk/resources/vulkan/texture.frag.glsl
similarity index 100%
rename from gsk/resources/vulkan/blend.frag.glsl
rename to gsk/resources/vulkan/texture.frag.glsl
diff --git a/gsk/resources/vulkan/blend.vert b/gsk/resources/vulkan/texture.vert
similarity index 100%
rename from gsk/resources/vulkan/blend.vert
rename to gsk/resources/vulkan/texture.vert
diff --git a/gsk/resources/vulkan/blend.vert.glsl b/gsk/resources/vulkan/texture.vert.glsl
similarity index 100%
rename from gsk/resources/vulkan/blend.vert.glsl
rename to gsk/resources/vulkan/texture.vert.glsl


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