vulkan: Combine textures and samplers again
authorBenjamin Otte <otte@redhat.com>
Wed, 28 Jun 2023 18:50:43 +0000 (20:50 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 16 Jul 2023 10:12:36 +0000 (12:12 +0200)
This reverts most of commit f420c143e0d8947a433704969bab02aea47d82f5
again because it turns out GPUs like combined images and samplers.

But: The one thing we don't revert is allowing the C code to select any
combination of sampler and image:
gsk_vulkan_render_get_image_descriptor() now takes a 2nd argument
specifying the sampler.

This allows the same flexibility as before, we just combine things
early.

This change was inspired by
https://developer.nvidia.com/blog/vulkan-dos-donts/

32 files changed:
gsk/vulkan/gskvulkanblendmodepipeline.c
gsk/vulkan/gskvulkanblendmodepipelineprivate.h
gsk/vulkan/gskvulkanblurpipeline.c
gsk/vulkan/gskvulkanblurpipelineprivate.h
gsk/vulkan/gskvulkancolormatrixop.c
gsk/vulkan/gskvulkancolortextpipeline.c
gsk/vulkan/gskvulkancolortextpipelineprivate.h
gsk/vulkan/gskvulkancrossfadepipeline.c
gsk/vulkan/gskvulkancrossfadepipelineprivate.h
gsk/vulkan/gskvulkaneffectpipeline.c
gsk/vulkan/gskvulkaneffectpipelineprivate.h
gsk/vulkan/gskvulkanrender.c
gsk/vulkan/gskvulkanrenderpass.c
gsk/vulkan/gskvulkanrenderprivate.h
gsk/vulkan/gskvulkantextpipeline.c
gsk/vulkan/gskvulkantextpipelineprivate.h
gsk/vulkan/gskvulkantextureop.c
gsk/vulkan/gskvulkantexturepipeline.c
gsk/vulkan/gskvulkantexturepipelineprivate.h
gsk/vulkan/resources/blend-mode.frag
gsk/vulkan/resources/blend-mode.vert
gsk/vulkan/resources/blur.frag
gsk/vulkan/resources/blur.vert
gsk/vulkan/resources/color-matrix.frag
gsk/vulkan/resources/color-matrix.vert
gsk/vulkan/resources/common.frag.glsl
gsk/vulkan/resources/cross-fade.frag
gsk/vulkan/resources/cross-fade.vert
gsk/vulkan/resources/mask.frag
gsk/vulkan/resources/mask.vert
gsk/vulkan/resources/texture.frag
gsk/vulkan/resources/texture.vert

index fb71b3b846e3e9d4049bf5d367ce58443d5988a8..2bd18bc587ca84a7e91a44e301eb3e1779d655b0 100644 (file)
@@ -54,8 +54,8 @@ gsk_vulkan_blend_mode_pipeline_new (GdkVulkanContext        *context,
 void
 gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
                                                     guchar                     *data,
-                                                    guint32                     top_tex_id[2],
-                                                    guint32                     bottom_tex_id[2],
+                                                    guint32                     top_tex_id,
+                                                    guint32                     bottom_tex_id,
                                                     const graphene_point_t     *offset,
                                                     const graphene_rect_t      *bounds,
                                                     const graphene_rect_t      *top_bounds,
@@ -91,10 +91,8 @@ gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *
   instance->bottom_tex_rect[2] = bottom_tex_rect->size.width;
   instance->bottom_tex_rect[3] = bottom_tex_rect->size.height;
 
-  instance->top_tex_id[0] = top_tex_id[0];
-  instance->top_tex_id[1] = top_tex_id[1];
-  instance->bottom_tex_id[0] = bottom_tex_id[0];
-  instance->bottom_tex_id[1] = bottom_tex_id[1];
+  instance->top_tex_id = top_tex_id;
+  instance->bottom_tex_id = bottom_tex_id;
   instance->blend_mode = blend_mode;
 }
 
index 088068f1b3649e8cac8da8832968bae63fbe0d1e..e06f28ae90252b5e03eb06775516037f2773c254 100644 (file)
@@ -20,8 +20,8 @@ GskVulkanPipeline * gsk_vulkan_blend_mode_pipeline_new                 (GdkVulka
 
 void                gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
                                                                         guchar                     *data,
-                                                                        guint32                     top_tex_id[2],
-                                                                        guint32                     bottom_tex_id[2],
+                                                                        guint32                     top_tex_id,
+                                                                        guint32                     bottom_tex_id,
                                                                         const graphene_point_t     *offset,
                                                                         const graphene_rect_t      *bounds,
                                                                         const graphene_rect_t      *top_bounds,
index 5b9352908a1d43d1387a6fd315d222f5ce57669b..5f46c7edde385832baa9ce1f224fa8a87137f36b 100644 (file)
@@ -52,7 +52,7 @@ gsk_vulkan_blur_pipeline_new (GdkVulkanContext        *context,
 void
 gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline  *pipeline,
                                               guchar                 *data,
-                                              guint32                 tex_id[2],
+                                              guint32                 tex_id,
                                               const graphene_point_t *offset,
                                               const graphene_rect_t  *rect,
                                               const graphene_rect_t  *tex_rect,
@@ -69,8 +69,7 @@ gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline  *pipeline,
   instance->tex_rect[2] = tex_rect->size.width;
   instance->tex_rect[3] = tex_rect->size.height;
   instance->radius = radius;
-  instance->tex_id[0] = tex_id[0];
-  instance->tex_id[1] = tex_id[1];
+  instance->tex_id = tex_id;
 }
 
 gsize
index f77f99013a8623cd3d248ea3bfd0395a227c4ee8..5e7435aba63ce598a0057d0d71fcc14336292552 100644 (file)
@@ -19,7 +19,7 @@ GskVulkanPipeline *     gsk_vulkan_blur_pipeline_new                   (GdkVulka
 
 void                    gsk_vulkan_blur_pipeline_collect_vertex_data   (GskVulkanBlurPipeline   *pipeline,
                                                                         guchar                  *data,
-                                                                        guint32                  tex_id[2],
+                                                                        guint32                  tex_id,
                                                                         const graphene_point_t  *offset,
                                                                         const graphene_rect_t   *rect,
                                                                         const graphene_rect_t   *tex_rect,
index 2fcd151f1d94f382e058a3fc5b5d64a60a3bf1d2..d202f70fa1b1285997838d4a03c98a61929a8828 100644 (file)
@@ -17,7 +17,6 @@ struct _GskVulkanColorMatrixOp
   graphene_rect_t tex_rect;
 
   guint32 image_descriptor;
-  guint32 sampler_descriptor;
   GskVulkanPipeline *pipeline;
   gsize vertex_offset;
 };
@@ -70,10 +69,7 @@ gsk_vulkan_color_matrix_op_collect_vertex_data (GskVulkanOp         *op,
 
   gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (self->pipeline),
                                                   data + self->vertex_offset,
-                                                  (guint32[2]) {
-                                                   self->image_descriptor,
-                                                   self->sampler_descriptor,
-                                                  },
+                                                  self->image_descriptor,
                                                   graphene_point_zero (),
                                                   &self->rect,
                                                   &self->tex_rect,
@@ -87,8 +83,9 @@ gsk_vulkan_color_matrix_op_reserve_descriptor_sets (GskVulkanOp     *op,
 {
   GskVulkanColorMatrixOp *self = (GskVulkanColorMatrixOp *) op;
 
-  self->image_descriptor = gsk_vulkan_render_get_image_descriptor (render, self->image);
-  self->sampler_descriptor = gsk_vulkan_render_get_sampler_descriptor (render, GSK_VULKAN_SAMPLER_DEFAULT);
+  self->image_descriptor = gsk_vulkan_render_get_image_descriptor (render,
+                                                                   self->image,
+                                                                   GSK_VULKAN_SAMPLER_DEFAULT);
 }
 
 static VkPipeline
index 6e45cfe01e015114fc580f3d8d5dd5b1010ebc18..26b102f9d58336feacb1ccc3e97a46f28b477a85 100644 (file)
@@ -54,7 +54,7 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
                                                     guchar                     *data,
                                                     GskVulkanRenderer          *renderer,
                                                     const graphene_rect_t      *rect,
-                                                    guint                       tex_id[2],
+                                                    guint                       tex_id,
                                                     PangoFont                  *font,
                                                     guint                       total_glyphs,
                                                     const PangoGlyphInfo       *glyphs,
@@ -99,8 +99,7 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
           instance->tex_rect[2] = glyph->tw;
           instance->tex_rect[3] = glyph->th;
 
-          instance->tex_id[0] = tex_id[0];
-          instance->tex_id[1] = tex_id[1];
+          instance->tex_id = tex_id;
 
           count++;
        }
index 083977cc2995a191e81bbbf2672732c8254ceaa3..00943987852aaf55a321b28a9d4885cb05ca255f 100644 (file)
@@ -22,7 +22,7 @@ void                    gsk_vulkan_color_text_pipeline_collect_vertex_data   (Gs
                                                                               guchar                         *data,
                                                                               GskVulkanRenderer              *renderer,
                                                                               const graphene_rect_t          *rect,
-                                                                              guint                           tex_id[2],
+                                                                              guint                           tex_id,
                                                                               PangoFont                      *font,
                                                                               guint                           total_glyphs,
                                                                               const PangoGlyphInfo           *glyphs,
index 1ad42cbcd14dc04b995db52a7ce815bdf083aa31..165982557b96b3e9b6faa5428af8bde317ffbafc 100644 (file)
@@ -52,8 +52,8 @@ gsk_vulkan_cross_fade_pipeline_new (GdkVulkanContext        *context,
 void
 gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
                                                     guchar                     *data,
-                                                    guint32                     start_tex_id[2],
-                                                    guint32                     end_tex_id[2],
+                                                    guint32                     start_tex_id,
+                                                    guint32                     end_tex_id,
                                                     const graphene_point_t     *offset,
                                                     const graphene_rect_t      *bounds,
                                                     const graphene_rect_t      *start_bounds,
@@ -89,10 +89,8 @@ gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *
   instance->end_tex_rect[2] = end_tex_rect->size.width;
   instance->end_tex_rect[3] = end_tex_rect->size.height;
 
-  instance->start_tex_id[0] = start_tex_id[0];
-  instance->start_tex_id[1] = start_tex_id[1];
-  instance->end_tex_id[0] = end_tex_id[0];
-  instance->end_tex_id[1] = end_tex_id[1];
+  instance->start_tex_id = start_tex_id;
+  instance->end_tex_id = end_tex_id;
   instance->progress = progress;
 }
 
index 7c806122791a8ed2ea3b4974cc3ecbb7499c0a7c..858e6dcad49d3b87fa00e34bc560d0d7bc4d70de 100644 (file)
@@ -19,8 +19,8 @@ GskVulkanPipeline * gsk_vulkan_cross_fade_pipeline_new                 (GdkVulka
 
 void                gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
                                                                         guchar                     *data,
-                                                                        guint32                     start_tex_id[2],
-                                                                        guint32                     end_tex_id[2],
+                                                                        guint32                     start_tex_id,
+                                                                        guint32                     end_tex_id,
                                                                         const graphene_point_t     *offset,
                                                                         const graphene_rect_t      *bounds,
                                                                         const graphene_rect_t      *start_bounds,
index b611502e016b0d2c9aed5711f77180cbbd6f69d5..173f8bb986f74880993b875e0bedb559e71a1f69 100644 (file)
@@ -52,7 +52,7 @@ gsk_vulkan_effect_pipeline_new (GdkVulkanContext        *context,
 void
 gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
                                                 guchar                  *data,
-                                                guint32                  tex_id[2],
+                                                guint32                  tex_id,
                                                 const graphene_point_t  *offset,
                                                 const graphene_rect_t   *rect,
                                                 const graphene_rect_t   *tex_rect,
@@ -71,8 +71,7 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
   instance->tex_rect[3] = tex_rect->size.height;
   graphene_matrix_to_float (color_matrix, instance->color_matrix);
   graphene_vec4_to_float (color_offset, instance->color_offset);
-  instance->tex_id[0] = tex_id[0];
-  instance->tex_id[1] = tex_id[1];
+  instance->tex_id = tex_id;
 }
 
 gsize
index 328e04de902ba3a9f8e637a42ae8068877c1d040..f7239386bdfe74cee302967104202a8e900888c0 100644 (file)
@@ -19,7 +19,7 @@ GskVulkanPipeline *     gsk_vulkan_effect_pipeline_new                  (GdkVulk
 
 void                    gsk_vulkan_effect_pipeline_collect_vertex_data  (GskVulkanEffectPipeline        *pipeline,
                                                                          guchar                         *data,
-                                                                         guint32                         tex_id[2],
+                                                                         guint32                         tex_id,
                                                                          const graphene_point_t         *offset,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_rect_t          *tex_rect,
index c6ef70a4a6f289590c16d1248b1840dd4ab3eb83..923c271ae3e98e67d36b867859e10d14fdd9748a 100644 (file)
@@ -41,7 +41,7 @@
 #define GDK_ARRAY_NO_MEMSET 1
 #include "gdk/gdkarrayimpl.c"
 
-#define N_DESCRIPTOR_SETS 3
+#define N_DESCRIPTOR_SETS 2
 
 struct _GskVulkanRender
 {
@@ -59,7 +59,6 @@ struct _GskVulkanRender
   GskVulkanUploader *uploader;
 
   GskDescriptorImageInfos descriptor_images;
-  GskDescriptorImageInfos descriptor_samplers;
   GskDescriptorBufferInfos descriptor_buffers;
   VkDescriptorPool descriptor_pool;
   VkDescriptorSet descriptor_sets[N_DESCRIPTOR_SETS];
@@ -132,7 +131,6 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
   self->vulkan = context;
   self->renderer = renderer;
   gsk_descriptor_image_infos_init (&self->descriptor_images);
-  gsk_descriptor_image_infos_init (&self->descriptor_samplers);
   gsk_descriptor_buffer_infos_init (&self->descriptor_buffers);
 
   device = gdk_vulkan_context_get_device (self->vulkan);
@@ -154,11 +152,7 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                             .poolSizeCount = N_DESCRIPTOR_SETS,
                                             .pPoolSizes = (VkDescriptorPoolSize[N_DESCRIPTOR_SETS]) {
                                                 {
-                                                    .type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
-                                                    .descriptorCount = DESCRIPTOR_POOL_MAXITEMS
-                                                },
-                                                {
-                                                    .type = VK_DESCRIPTOR_TYPE_SAMPLER,
+                                                    .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                                                     .descriptorCount = DESCRIPTOR_POOL_MAXITEMS
                                                 },
                                                 {
@@ -170,32 +164,6 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                         NULL,
                                         &self->descriptor_pool);
 
-  GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
-                                             &(VkDescriptorSetLayoutCreateInfo) {
-                                                 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
-                                                 .bindingCount = 1,
-                                                 .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT,
-                                                 .pBindings = (VkDescriptorSetLayoutBinding[3]) {
-                                                     {
-                                                         .binding = 0,
-                                                         .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
-                                                         .descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
-                                                         .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
-                                                     }
-                                                 },
-                                                 .pNext = &(VkDescriptorSetLayoutBindingFlagsCreateInfo) {
-                                                   .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
-                                                   .bindingCount = 1,
-                                                   .pBindingFlags = (VkDescriptorBindingFlags[1]) {
-                                                     VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
-                                                     | VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
-                                                     | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
-                                                   },
-                                                 }
-                                             },
-                                             NULL,
-                                             &self->descriptor_set_layouts[0]);
-
   GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
                                              &(VkDescriptorSetLayoutCreateInfo) {
                                                  .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
@@ -204,7 +172,7 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                                  .pBindings = (VkDescriptorSetLayoutBinding[1]) {
                                                      {
                                                          .binding = 0,
-                                                         .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
+                                                         .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                                                          .descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
                                                          .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
                                                      }
@@ -220,7 +188,7 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                                  }
                                              },
                                              NULL,
-                                             &self->descriptor_set_layouts[1]);
+                                             &self->descriptor_set_layouts[0]);
 
   GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
                                              &(VkDescriptorSetLayoutCreateInfo) {
@@ -246,7 +214,7 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                                  }
                                              },
                                              NULL,
-                                             &self->descriptor_set_layouts[2]);
+                                             &self->descriptor_set_layouts[1]);
 
   GSK_VK_CHECK (vkCreatePipelineLayout, device,
                                         &(VkPipelineLayoutCreateInfo) {
@@ -445,46 +413,23 @@ gsk_vulkan_render_bind_descriptor_sets (GskVulkanRender *self,
                            VK_PIPELINE_BIND_POINT_GRAPHICS,
                            self->pipeline_layout,
                            0,
-                           3,
+                           N_DESCRIPTOR_SETS,
                            self->descriptor_sets,
                            0,
                            NULL);
 }
 
 gsize
-gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender        *self,
-                                          GskVulkanRenderSampler  render_sampler)
-{
-  VkSampler sampler = self->samplers[render_sampler];
-  gsize i;
-
-  /* If this ever shows up in profiles, add a hash table */
-  for (i = 0; i < gsk_descriptor_image_infos_get_size (&self->descriptor_samplers); i++)
-    {
-      if (gsk_descriptor_image_infos_get (&self->descriptor_samplers, i)->sampler == sampler)
-        return i;
-    }
-
-  g_assert (i < DESCRIPTOR_POOL_MAXITEMS);
-
-  gsk_descriptor_image_infos_append (&self->descriptor_samplers,
-                                     &(VkDescriptorImageInfo) {
-                                       .sampler = sampler,
-                                     });
-
-  return i;
-}
-
-gsize
-gsk_vulkan_render_get_image_descriptor (GskVulkanRender *self,
-                                        GskVulkanImage  *image)
+gsk_vulkan_render_get_image_descriptor (GskVulkanRender        *self,
+                                        GskVulkanImage         *image,
+                                        GskVulkanRenderSampler  render_sampler)
 {
   gsize result;
 
   result = gsk_descriptor_image_infos_get_size (&self->descriptor_images);
   gsk_descriptor_image_infos_append (&self->descriptor_images,
                                      &(VkDescriptorImageInfo) {
-                                       .sampler = VK_NULL_HANDLE,
+                                       .sampler = self->samplers[render_sampler],
                                        .imageView = gsk_vulkan_image_get_image_view (image),
                                        .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
                                      });
@@ -567,7 +512,7 @@ static void
 gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
 {
   VkDevice device;
-  VkWriteDescriptorSet descriptor_sets[3];
+  VkWriteDescriptorSet descriptor_sets[N_DESCRIPTOR_SETS];
   gsize n_descriptor_sets;
   GList *l;
 
@@ -597,7 +542,6 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
                                                 .descriptorSetCount = N_DESCRIPTOR_SETS,
                                                 .pDescriptorCounts = (uint32_t[N_DESCRIPTOR_SETS]) {
                                                   MAX (1, gsk_descriptor_image_infos_get_size (&self->descriptor_images)),
-                                                  MAX (1, gsk_descriptor_image_infos_get_size (&self->descriptor_samplers)),
                                                   MAX (1, gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers))
                                                 }
                                               }
@@ -613,27 +557,15 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
           .dstBinding = 0,
           .dstArrayElement = 0,
           .descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_images),
-          .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
+          .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
           .pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_images)
       };
     }
-  if (gsk_descriptor_image_infos_get_size (&self->descriptor_samplers) > 0)
-    {
-      descriptor_sets[n_descriptor_sets++] = (VkWriteDescriptorSet) {
-          .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
-          .dstSet = self->descriptor_sets[1],
-          .dstBinding = 0,
-          .dstArrayElement = 0,
-          .descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_samplers),
-          .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
-          .pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_samplers)
-      };
-    }
   if (gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers) > 0)
     {
       descriptor_sets[n_descriptor_sets++] = (VkWriteDescriptorSet) {
           .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
-          .dstSet = self->descriptor_sets[2],
+          .dstSet = self->descriptor_sets[1],
           .dstBinding = 0,
           .dstArrayElement = 0,
           .descriptorCount = gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers),
@@ -748,7 +680,6 @@ gsk_vulkan_render_cleanup (GskVulkanRender *self)
                                        self->descriptor_pool,
                                        0);
   gsk_descriptor_image_infos_set_size (&self->descriptor_images, 0);
-  gsk_descriptor_image_infos_set_size (&self->descriptor_samplers, 0);
   gsk_descriptor_buffer_infos_set_size (&self->descriptor_buffers, 0);
 
   g_list_free_full (self->render_passes, (GDestroyNotify) gsk_vulkan_render_pass_free);
@@ -784,7 +715,6 @@ gsk_vulkan_render_free (GskVulkanRender *self)
                            self->descriptor_pool,
                            NULL);
   gsk_descriptor_image_infos_clear (&self->descriptor_images);
-  gsk_descriptor_image_infos_clear (&self->descriptor_samplers);
   gsk_descriptor_buffer_infos_clear (&self->descriptor_buffers);
 
   for (i = 0; i < N_DESCRIPTOR_SETS; i++)
index 0f6a236ea9d6f493283169b7906ccff0a978efeb..cdd2d3eddcbbe12091efdcfef7710ca9aef60310 100644 (file)
@@ -78,8 +78,8 @@ struct _GskVulkanOpRender
   GskVulkanImage      *source; /* source image to render */
   GskVulkanImage      *source2; /* second source image to render (if relevant) */
   gsize                vertex_offset; /* offset into vertex buffer */
-  guint32              image_descriptor[2]; /* index into descriptor for the (image, sampler) */
-  guint32              image_descriptor2[2]; /* index into descriptor for the 2nd image (if relevant) */
+  guint32              image_descriptor; /* index into descriptor for the image */
+  guint32              image_descriptor2; /* index into descriptor for the 2nd image (if relevant) */
   gsize                buffer_offset; /* offset into buffer */
   graphene_rect_t      source_rect; /* area that source maps to */
   graphene_rect_t      source2_rect; /* area that source2 maps to */
@@ -94,7 +94,7 @@ struct _GskVulkanOpText
   GskVulkanPipeline   *pipeline; /* pipeline to use */
   GskVulkanImage      *source; /* source image to render */
   gsize                vertex_offset; /* offset into vertex buffer */
-  guint32              image_descriptor[2]; /* index into descriptor for the (image, sampler) */
+  guint32              image_descriptor; /* index into descriptor for the (image, sampler) */
   guint                texture_index; /* index of the texture in the glyph cache */
   guint                start_glyph; /* the first glyph in nodes glyphstring that we render */
   guint                num_glyphs; /* number of *non-empty* glyphs (== instances) we render */
@@ -2079,25 +2079,29 @@ gsk_vulkan_render_op_reserve_descriptor_sets (GskVulkanOp     *op_,
         case GSK_VULKAN_OP_BLUR:
           if (op->render.source)
             {
-              op->render.image_descriptor[0] = gsk_vulkan_render_get_image_descriptor (render, op->render.source);
-              op->render.image_descriptor[1] = gsk_vulkan_render_get_sampler_descriptor (render, GSK_VULKAN_SAMPLER_DEFAULT);
+              op->render.image_descriptor = gsk_vulkan_render_get_image_descriptor (render,
+                                                                                    op->render.source,
+                                                                                    GSK_VULKAN_SAMPLER_DEFAULT);
             }
           break;
 
         case GSK_VULKAN_OP_TEXT:
         case GSK_VULKAN_OP_COLOR_TEXT:
-          op->text.image_descriptor[0] = gsk_vulkan_render_get_image_descriptor (render, op->text.source);
-          op->text.image_descriptor[1] = gsk_vulkan_render_get_sampler_descriptor (render, GSK_VULKAN_SAMPLER_DEFAULT);
+          op->text.image_descriptor = gsk_vulkan_render_get_image_descriptor (render,
+                                                                              op->text.source,
+                                                                              GSK_VULKAN_SAMPLER_DEFAULT);
           break;
 
         case GSK_VULKAN_OP_CROSS_FADE:
         case GSK_VULKAN_OP_BLEND_MODE:
           if (op->render.source && op->render.source2)
             {
-              op->render.image_descriptor[0] = gsk_vulkan_render_get_image_descriptor (render, op->render.source);
-              op->render.image_descriptor[1] = gsk_vulkan_render_get_sampler_descriptor (render, GSK_VULKAN_SAMPLER_DEFAULT);
-              op->render.image_descriptor2[0] = gsk_vulkan_render_get_image_descriptor (render, op->render.source2);
-              op->render.image_descriptor2[1] = op->render.image_descriptor2[1];
+              op->render.image_descriptor = gsk_vulkan_render_get_image_descriptor (render,
+                                                                                    op->render.source,
+                                                                                    GSK_VULKAN_SAMPLER_DEFAULT);
+              op->render.image_descriptor2 = gsk_vulkan_render_get_image_descriptor (render,
+                                                                                     op->render.source2,
+                                                                                     GSK_VULKAN_SAMPLER_DEFAULT);
             }
           break;
 
index 731e5a4e3c517f961a8eefa9ab9d0b6fd0b82e50..4a206238e92cba9244806d9ce9e1c27b85afae6a 100644 (file)
@@ -83,10 +83,9 @@ void                    gsk_vulkan_render_upload                        (GskVulk
 GskVulkanPipeline *     gsk_vulkan_render_get_pipeline                  (GskVulkanRender        *self,
                                                                          GskVulkanPipelineType   pipeline_type,
                                                                          VkRenderPass            render_pass);
-gsize                   gsk_vulkan_render_get_sampler_descriptor        (GskVulkanRender        *self,
-                                                                         GskVulkanRenderSampler  render_sampler);
 gsize                   gsk_vulkan_render_get_image_descriptor          (GskVulkanRender        *self,
-                                                                         GskVulkanImage         *source);
+                                                                         GskVulkanImage         *source,
+                                                                         GskVulkanRenderSampler  render_sampler);
 gsize                   gsk_vulkan_render_get_buffer_descriptor         (GskVulkanRender        *self,
                                                                          GskVulkanBuffer        *buffer);
 guchar *                gsk_vulkan_render_get_buffer_memory             (GskVulkanRender        *self,
index c7eed9386f73e1806a05983ad6a97679187b3fe2..80b920034197898586c66ca515471346b2c4d4c6 100644 (file)
@@ -54,7 +54,7 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline  *pipeline,
                                               guchar                 *data,
                                               GskVulkanRenderer      *renderer,
                                               const graphene_rect_t  *rect,
-                                              guint                   tex_id[2],
+                                              guint                   tex_id,
                                               PangoFont              *font,
                                               guint                   total_glyphs,
                                               const PangoGlyphInfo   *glyphs,
@@ -105,8 +105,7 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline  *pipeline,
           instance->color[2] = color->blue;
           instance->color[3] = color->alpha;
 
-          instance->tex_id[0] = tex_id[0];
-          instance->tex_id[1] = tex_id[1];
+          instance->tex_id = tex_id;
 
           count++;
         }
index 0cc560c25f25507ea8fb0744e8a44b4ded196d37..8f05e4350067cba09f422374a3f608b89c7a9652 100644 (file)
@@ -22,7 +22,7 @@ void                    gsk_vulkan_text_pipeline_collect_vertex_data   (GskVulka
                                                                         guchar                        *data,
                                                                         GskVulkanRenderer             *renderer,
                                                                         const graphene_rect_t         *rect,
-                                                                        guint32                        tex_id[2],
+                                                                        guint32                        tex_id,
                                                                         PangoFont                     *font,
                                                                         guint                          total_glyphs,
                                                                         const PangoGlyphInfo          *glyphs,
index e798d85619c4cae39116aab1b652d7456511b977..84d427c130395610f4421437ce48b2eaa3016936 100644 (file)
@@ -16,7 +16,6 @@ struct _GskVulkanTextureOp
   graphene_rect_t tex_rect;
 
   guint32 image_descriptor;
-  guint32 sampler_descriptor;
   GskVulkanPipeline *pipeline;
   gsize vertex_offset;
 };
@@ -69,10 +68,7 @@ gsk_vulkan_texture_op_collect_vertex_data (GskVulkanOp         *op,
 
   gsk_vulkan_texture_pipeline_collect_vertex_data (GSK_VULKAN_TEXTURE_PIPELINE (self->pipeline),
                                                    data + self->vertex_offset,
-                                                   (guint32[2]) {
-                                                    self->image_descriptor,
-                                                    self->sampler_descriptor,
-                                                   },
+                                                   self->image_descriptor,
                                                    graphene_point_zero (),
                                                    &self->rect,
                                                    &self->tex_rect);
@@ -84,8 +80,7 @@ gsk_vulkan_texture_op_reserve_descriptor_sets (GskVulkanOp     *op,
 {
   GskVulkanTextureOp *self = (GskVulkanTextureOp *) op;
 
-  self->image_descriptor = gsk_vulkan_render_get_image_descriptor (render, self->image);
-  self->sampler_descriptor = gsk_vulkan_render_get_sampler_descriptor (render, self->sampler);
+  self->image_descriptor = gsk_vulkan_render_get_image_descriptor (render, self->image, self->sampler);
 }
 
 static VkPipeline
index 19b5e5339efa749572f75a872cf1e7db4bc61061..620097ae8afa4cbd230dc226dfcce2f25da2f290 100644 (file)
@@ -52,7 +52,7 @@ gsk_vulkan_texture_pipeline_new (GdkVulkanContext *context,
 void
 gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
                                                  guchar                   *data,
-                                                 guint32                   tex_id[2],
+                                                 guint32                   tex_id,
                                                  const graphene_point_t   *offset,
                                                  const graphene_rect_t    *rect,
                                                  const graphene_rect_t    *tex_rect)
@@ -67,8 +67,7 @@ gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipel
   instance->tex_rect[1] = tex_rect->origin.y;
   instance->tex_rect[2] = tex_rect->size.width;
   instance->tex_rect[3] = tex_rect->size.height;
-  instance->tex_id[0] = tex_id[0];
-  instance->tex_id[1] = tex_id[1];
+  instance->tex_id = tex_id;
 }
 
 gsize
index 69e3fde2cddbfce71bdd7e039a7102bfb05c70f2..d837e4d9d2bd921ac570848fd0b1962c1ddd94f9 100644 (file)
@@ -19,7 +19,7 @@ GskVulkanPipeline *     gsk_vulkan_texture_pipeline_new                 (GdkVulk
 
 void                    gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
                                                                          guchar                   *data,
-                                                                         guint32                   tex_id[2],
+                                                                         guint32                   tex_id,
                                                                          const graphene_point_t   *offset,
                                                                          const graphene_rect_t    *rect,
                                                                          const graphene_rect_t    *tex_rect);
index d8179c2932274d95a987f64a0294df949977578a..48d868ff02537b7f16f34e0125826ba2e527dc64 100644 (file)
@@ -9,8 +9,8 @@ layout(location = 1) in Rect inTopRect;
 layout(location = 2) in Rect inBottomRect;
 layout(location = 3) in vec2 inTopTexCoord;
 layout(location = 4) in vec2 inBottomTexCoord;
-layout(location = 5) flat in uvec2 inTopTexId;
-layout(location = 6) flat in uvec2 inBottomTexId;
+layout(location = 5) flat in uint inTopTexId;
+layout(location = 6) flat in uint inBottomTexId;
 layout(location = 7) flat in uint inBlendMode;
 
 layout(location = 0) out vec4 color;
index 4a8581afedc18db1bd9e429b50c44293b13e4068..1216b0a15288a9bad375ce7ca98d56e7ed9a0eaa 100644 (file)
@@ -8,8 +8,8 @@ layout(location = 1) in vec4 inTopRect;
 layout(location = 2) in vec4 inBottomRect;
 layout(location = 3) in vec4 inTopTexRect;
 layout(location = 4) in vec4 inBottomTexRect;
-layout(location = 5) in uvec2 inTopTexId;
-layout(location = 6) in uvec2 inBottomTexId;
+layout(location = 5) in uint inTopTexId;
+layout(location = 6) in uint inBottomTexId;
 layout(location = 7) in uint inBlendMode;
 
 layout(location = 0) out vec2 outPos;
@@ -17,8 +17,8 @@ layout(location = 1) flat out Rect outTopRect;
 layout(location = 2) flat out Rect outBottomRect;
 layout(location = 3) out vec2 outTopTexCoord;
 layout(location = 4) out vec2 outBottomTexCoord;
-layout(location = 5) flat out uvec2 outTopTexId;
-layout(location = 6) flat out uvec2 outBottomTexId;
+layout(location = 5) flat out uint outTopTexId;
+layout(location = 6) flat out uint outBottomTexId;
 layout(location = 7) flat out uint outBlendMode;
 
 void main() {
index b3acac9e2668ba9671357afb9bbc9fc04d333865..67f4e336619d1b4d414fa822c4d5c33b415a8bff 100644 (file)
@@ -7,7 +7,7 @@ layout(location = 0) in vec2 inPos;
 layout(location = 1) in flat vec2 inSize;
 layout(location = 2) in vec2 inTexCoord;
 layout(location = 3) in float inRadius;
-layout(location = 4) in flat uvec2 inTexId;
+layout(location = 4) in flat uint inTexId;
 
 layout(location = 0) out vec4 color;
 
index 4b2b8e0f7ee263a92a8595bbff5c1e7517aca75d..58c71bad77e6d1ccd3635b38186bff7fed851038 100644 (file)
@@ -6,13 +6,13 @@
 layout(location = 0) in vec4 inRect;
 layout(location = 1) in vec4 inTexRect;
 layout(location = 2) in float inRadius;
-layout(location = 3) in uvec2 inTexId;
+layout(location = 3) in uint inTexId;
 
 layout(location = 0) out vec2 outPos;
 layout(location = 1) out flat vec2 outSize;
 layout(location = 2) out vec2 outTexCoord;
 layout(location = 3) out flat float outRadius;
-layout(location = 4) out flat uvec2 outTexId;
+layout(location = 4) out flat uint outTexId;
 
 vec2 offsets[6] = { vec2(0.0, 0.0),
                     vec2(1.0, 0.0),
index c52eb272263c95572852f5899df5bd89a79bd9d1..9db8af257316af366ea270a6324fefd040de42af 100644 (file)
@@ -7,7 +7,7 @@ layout(location = 0) in vec2 inPos;
 layout(location = 1) in vec2 inTexCoord;
 layout(location = 2) in flat mat4 inColorMatrix;
 layout(location = 6) in flat vec4 inColorOffset;
-layout(location = 7) in flat uvec2 inTexId;
+layout(location = 7) in flat uint inTexId;
 
 layout(location = 0) out vec4 color;
 
index c62a7287205379e49a9faaebba9087f8cf499532..979ae9692e9bad7434bb1c246cc80fe79981fad4 100644 (file)
@@ -6,13 +6,13 @@ layout(location = 0) in vec4 inRect;
 layout(location = 1) in vec4 inTexRect;
 layout(location = 2) in mat4 inColorMatrix;
 layout(location = 6) in vec4 inColorOffset;
-layout(location = 7) in uvec2 inTexId;
+layout(location = 7) in uint inTexId;
 
 layout(location = 0) out vec2 outPos;
 layout(location = 1) out vec2 outTexCoord;
 layout(location = 2) out flat mat4 outColorMatrix;
 layout(location = 6) out flat vec4 outColorOffset;
-layout(location = 7) out flat uvec2 outTexId;
+layout(location = 7) out flat uint outTexId;
 
 vec2 offsets[6] = { vec2(0.0, 0.0),
                     vec2(1.0, 0.0),
index 314477f6971345be7bd81ecbe6aae00ee2123a8c..49ae98a12043cb4f5c46ce9bfa869a02d5c9ebd8 100644 (file)
@@ -1,10 +1,9 @@
-layout(set = 0, binding = 0) uniform texture2D textures[50000];
-layout(set = 1, binding = 0) uniform sampler samplers[50000];
-layout(set = 2, binding = 0) readonly buffer FloatBuffers {
+layout(set = 0, binding = 0) uniform sampler2D textures[50000];
+layout(set = 1, binding = 0) readonly buffer FloatBuffers {
   float floats[];
 } buffers[50000];
 
-#define get_sampler(id) sampler2D(textures[id.x], samplers[id.y])
+#define get_sampler(id) textures[id]
 #define get_buffer(id) buffers[id]
 #define get_float(id) get_buffer(0).floats[id]
 
index 9cb3939a31cfb87ed96675988ec0a8b96cb8ca09..ba5e3921649063322d81f9cdd2a59521c0cf6406 100644 (file)
@@ -9,8 +9,8 @@ layout(location = 1) in Rect inStartRect;
 layout(location = 2) in Rect inEndRect;
 layout(location = 3) in vec2 inStartTexCoord;
 layout(location = 4) in vec2 inEndTexCoord;
-layout(location = 5) flat in uvec2 inStartTexId;
-layout(location = 6) flat in uvec2 inEndTexId;
+layout(location = 5) flat in uint inStartTexId;
+layout(location = 6) flat in uint inEndTexId;
 layout(location = 7) in float inProgress;
 
 layout(location = 0) out vec4 color;
index ffa99217608881a7cce2f41121ac236f27378487..1eb87bab131f923ef29f035557af3e7f88529379 100644 (file)
@@ -8,8 +8,8 @@ layout(location = 1) in vec4 inStartRect;
 layout(location = 2) in vec4 inEndRect;
 layout(location = 3) in vec4 inStartTexRect;
 layout(location = 4) in vec4 inEndTexRect;
-layout(location = 5) in uvec2 inStartTexId;
-layout(location = 6) in uvec2 inEndTexId;
+layout(location = 5) in uint inStartTexId;
+layout(location = 6) in uint inEndTexId;
 layout(location = 7) in float inProgress;
 
 layout(location = 0) out vec2 outPos;
@@ -17,8 +17,8 @@ layout(location = 1) flat out Rect outStartRect;
 layout(location = 2) flat out Rect outEndRect;
 layout(location = 3) out vec2 outStartTexCoord;
 layout(location = 4) out vec2 outEndTexCoord;
-layout(location = 5) flat out uvec2 outStartTexId;
-layout(location = 6) flat out uvec2 outEndTexId;
+layout(location = 5) flat out uint outStartTexId;
+layout(location = 6) flat out uint outEndTexId;
 layout(location = 7) flat out float outProgress;
 
 void main() {
index 7a72cf6db91f4a31ea7df8ae804a382ee05ad10e..db4df18e04f3abeaccda7386c59d76f09588a1c6 100644 (file)
@@ -6,7 +6,7 @@
 layout(location = 0) in vec2 inPos;
 layout(location = 1) in vec2 inTexCoord;
 layout(location = 2) in vec4 inColor;
-layout(location = 3) flat in uvec2 inTexId;
+layout(location = 3) flat in uint inTexId;
 
 layout(location = 0) out vec4 color;
 
index 3c89f159bbb497df1fc8570d73d5288a78e48f4a..f7875939933d6303a735ea9a2eb3d8efb3672c12 100644 (file)
@@ -5,12 +5,12 @@
 layout(location = 0) in vec4 inRect;
 layout(location = 1) in vec4 inTexRect;
 layout(location = 2) in vec4 inColor;
-layout(location = 3) in uvec2 inTexId;
+layout(location = 3) in uint inTexId;
 
 layout(location = 0) out vec2 outPos;
 layout(location = 1) out vec2 outTexCoord;
 layout(location = 2) out flat vec4 outColor;
-layout(location = 3) out flat uvec2 outTexId;
+layout(location = 3) out flat uint outTexId;
 
 vec2 offsets[6] = { vec2(0.0, 0.0),
                     vec2(1.0, 0.0),
index dea157332a50d5e928ccd2e6224871e89cd4a337..f7f8f0ffc688db7e439c51126cb92e2042d0cd55 100644 (file)
@@ -7,7 +7,7 @@
 layout(location = 0) in vec2 inPos;
 layout(location = 1) in Rect inRect;
 layout(location = 2) in vec2 inTexCoord;
-layout(location = 3) flat in uvec2 inTexId;
+layout(location = 3) flat in uint inTexId;
 
 layout(location = 0) out vec4 color;
 
index 739f32e3b626cfe684be408f71f784577587dd4d..a76c4bad3ab53825e689ed5c43bd5d7ee084153c 100644 (file)
@@ -5,12 +5,12 @@
 
 layout(location = 0) in vec4 inRect;
 layout(location = 1) in vec4 inTexRect;
-layout(location = 2) in uvec2 inTexId;
+layout(location = 2) in uint inTexId;
 
 layout(location = 0) out vec2 outPos;
 layout(location = 1) out flat Rect outRect;
 layout(location = 2) out vec2 outTexCoord;
-layout(location = 3) out flat uvec2 outTexId;
+layout(location = 3) out flat uint outTexId;
 
 void main() {
   Rect r = rect_from_gsk (inRect);