vulkan: Split textures and samplers
authorBenjamin Otte <otte@redhat.com>
Tue, 23 May 2023 03:08:13 +0000 (05:08 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 4 Jun 2023 17:42:01 +0000 (19:42 +0200)
The idea here is that we can do more complex combinations and use that
to support texture-scale nodes or use fancy texture formats (suc as
YUV).

I'm not sure this is actually necessary, but for now it gives more
flexibility.

30 files changed:
gsk/vulkan/gskvulkanblendmodepipeline.c
gsk/vulkan/gskvulkanblendmodepipelineprivate.h
gsk/vulkan/gskvulkanblurpipeline.c
gsk/vulkan/gskvulkanblurpipelineprivate.h
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/gskvulkantexturepipeline.c
gsk/vulkan/gskvulkantexturepipelineprivate.h
gsk/vulkan/resources/blendmode.frag
gsk/vulkan/resources/blendmode.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/crossfade.frag
gsk/vulkan/resources/crossfade.vert
gsk/vulkan/resources/mask.frag
gsk/vulkan/resources/mask.vert
gsk/vulkan/resources/texture.frag
gsk/vulkan/resources/texture.vert

index 01e9ad214da1a0bb439b63898586c8b2df2d52da..b592efa52b73a30d4dea84c9129d932626258c6e 100644 (file)
@@ -16,8 +16,8 @@ struct _GskVulkanBlendModeInstance
   float bottom_rect[4];
   float top_tex_rect[4];
   float bottom_tex_rect[4];
-  guint32 top_tex_id;
-  guint32 bottom_tex_id;
+  guint32 top_tex_id[2];
+  guint32 bottom_tex_id[2];
   guint32 blend_mode;
 };
 
@@ -73,13 +73,13 @@ gsk_vulkan_blend_mode_pipeline_get_input_state_create_info (GskVulkanPipeline *s
       {
           .location = 6,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_tex_id),
       },
       {
           .location = 7,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, blend_mode),
       }
   };
@@ -129,8 +129,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,
-                                                    guint32                     bottom_tex_id,
+                                                    guint32                     top_tex_id[2],
+                                                    guint32                     bottom_tex_id[2],
                                                     const graphene_point_t     *offset,
                                                     const graphene_rect_t      *bounds,
                                                     const graphene_rect_t      *top_bounds,
@@ -166,8 +166,10 @@ 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 = top_tex_id;
-  instance->bottom_tex_id = bottom_tex_id;
+  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->blend_mode = blend_mode;
 }
 
index e06f28ae90252b5e03eb06775516037f2773c254..088068f1b3649e8cac8da8832968bae63fbe0d1e 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,
-                                                                        guint32                     bottom_tex_id,
+                                                                        guint32                     top_tex_id[2],
+                                                                        guint32                     bottom_tex_id[2],
                                                                         const graphene_point_t     *offset,
                                                                         const graphene_rect_t      *bounds,
                                                                         const graphene_rect_t      *top_bounds,
index 462d8c50459a2025cb1087d5041f44757e552e77..8893794b11fae780c9585f38fba2ed4cd2983254 100644 (file)
@@ -14,7 +14,7 @@ struct _GskVulkanBlurInstance
   float rect[4];
   float tex_rect[4];
   float blur_radius;
-  guint32 tex_id;
+  guint32 tex_id[2];
 };
 
 G_DEFINE_TYPE (GskVulkanBlurPipeline, gsk_vulkan_blur_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -51,7 +51,7 @@ gsk_vulkan_blur_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
       {
           .location = 3,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanBlurInstance, tex_id),
       }
   };
@@ -101,7 +101,7 @@ gsk_vulkan_blur_pipeline_new (GdkVulkanContext        *context,
 void
 gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline  *pipeline,
                                               guchar                 *data,
-                                              guint32                 tex_id,
+                                              guint32                 tex_id[2],
                                               const graphene_point_t *offset,
                                               const graphene_rect_t  *rect,
                                               const graphene_rect_t  *tex_rect,
@@ -118,7 +118,8 @@ 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->blur_radius = blur_radius;
-  instance->tex_id = tex_id;
+  instance->tex_id[0] = tex_id[0];
+  instance->tex_id[1] = tex_id[1];
 }
 
 gsize
index 5e7435aba63ce598a0057d0d71fcc14336292552..f77f99013a8623cd3d248ea3bfd0395a227c4ee8 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,
+                                                                        guint32                  tex_id[2],
                                                                         const graphene_point_t  *offset,
                                                                         const graphene_rect_t   *rect,
                                                                         const graphene_rect_t   *tex_rect,
index 1a8515b9429de39ff0a4510fd39f113aac1c818e..022ab0812f19a529ef956fcd8f76b5054e7f6cce 100644 (file)
@@ -13,7 +13,7 @@ struct _GskVulkanColorTextInstance
 {
   float rect[4];
   float tex_rect[4];
-  guint32 tex_id;
+  guint32 tex_id[2];
 };
 
 G_DEFINE_TYPE (GskVulkanColorTextPipeline, gsk_vulkan_color_text_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -44,7 +44,7 @@ gsk_vulkan_color_text_pipeline_get_input_state_create_info (GskVulkanPipeline *s
       {
           .location = 2,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanColorTextInstance, tex_id),
       }
   };
@@ -96,7 +96,7 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
                                                     guchar                     *data,
                                                     GskVulkanRenderer          *renderer,
                                                     const graphene_rect_t      *rect,
-                                                    guint                       tex_id,
+                                                    guint                       tex_id[2],
                                                     PangoFont                  *font,
                                                     guint                       total_glyphs,
                                                     const PangoGlyphInfo       *glyphs,
@@ -141,7 +141,8 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
           instance->tex_rect[2] = glyph->tw;
           instance->tex_rect[3] = glyph->th;
 
-          instance->tex_id = tex_id;
+          instance->tex_id[0] = tex_id[0];
+          instance->tex_id[1] = tex_id[1];
 
           count++;
        }
index 00943987852aaf55a321b28a9d4885cb05ca255f..083977cc2995a191e81bbbf2672732c8254ceaa3 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,
+                                                                              guint                           tex_id[2],
                                                                               PangoFont                      *font,
                                                                               guint                           total_glyphs,
                                                                               const PangoGlyphInfo           *glyphs,
index 514b6886d5bb5800f17e6602db1f570898486dc0..889634df89b81e55d7a10c38cc947f4470b36f66 100644 (file)
@@ -16,8 +16,8 @@ struct _GskVulkanCrossFadeInstance
   float end_rect[4];
   float start_tex_rect[4];
   float end_tex_rect[4];
-  guint32 start_tex_id;
-  guint32 end_tex_id;
+  guint32 start_tex_id[2];
+  guint32 end_tex_id[2];
   float progress;
 };
 
@@ -67,13 +67,13 @@ gsk_vulkan_cross_fade_pipeline_get_input_state_create_info (GskVulkanPipeline *s
       {
           .location = 5,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_id),
       },
       {
           .location = 6,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_id),
       },
       {
@@ -129,8 +129,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,
-                                                    guint32                     end_tex_id,
+                                                    guint32                     start_tex_id[2],
+                                                    guint32                     end_tex_id[2],
                                                     const graphene_point_t     *offset,
                                                     const graphene_rect_t      *bounds,
                                                     const graphene_rect_t      *start_bounds,
@@ -166,8 +166,10 @@ 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 = start_tex_id;
-  instance->end_tex_id = end_tex_id;
+  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->progress = progress;
 }
 
index 858e6dcad49d3b87fa00e34bc560d0d7bc4d70de..7c806122791a8ed2ea3b4974cc3ecbb7499c0a7c 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,
-                                                                        guint32                     end_tex_id,
+                                                                        guint32                     start_tex_id[2],
+                                                                        guint32                     end_tex_id[2],
                                                                         const graphene_point_t     *offset,
                                                                         const graphene_rect_t      *bounds,
                                                                         const graphene_rect_t      *start_bounds,
index 578a47d44c01769d6f1b48aa725f054b2f8080a6..dcbf35626d2a4b642e5e70a4bbbe80e591a9dcd1 100644 (file)
@@ -15,7 +15,7 @@ struct _GskVulkanEffectInstance
   float tex_rect[4];
   float color_matrix[16];
   float color_offset[4];
-  guint32 tex_id;
+  guint32 tex_id[2];
 };
 
 G_DEFINE_TYPE (GskVulkanEffectPipeline, gsk_vulkan_effect_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -76,7 +76,7 @@ gsk_vulkan_effect_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
       {
           .location = 7,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanEffectInstance, tex_id),
       }
   };
@@ -126,7 +126,7 @@ gsk_vulkan_effect_pipeline_new (GdkVulkanContext        *context,
 void
 gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
                                                 guchar                  *data,
-                                                guint32                  tex_id,
+                                                guint32                  tex_id[2],
                                                 const graphene_point_t  *offset,
                                                 const graphene_rect_t   *rect,
                                                 const graphene_rect_t   *tex_rect,
@@ -145,7 +145,8 @@ 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 = tex_id;
+  instance->tex_id[0] = tex_id[0];
+  instance->tex_id[1] = tex_id[1];
 }
 
 gsize
index f7239386bdfe74cee302967104202a8e900888c0..328e04de902ba3a9f8e637a42ae8068877c1d040 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,
+                                                                         guint32                         tex_id[2],
                                                                          const graphene_point_t         *offset,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_rect_t          *tex_rect,
index 441e0f6a6b84295f9f30d20958e3e8369e86a049..12b84cb8c5b8dbb563b83766db8c72ecccf8d163 100644 (file)
@@ -50,15 +50,15 @@ struct _GskVulkanRender
   VkPipelineLayout pipeline_layout;
   GskVulkanUploader *uploader;
 
-  GskDescriptorImageInfos descriptor_image_infos;
+  GskDescriptorImageInfos descriptor_images;
+  GskDescriptorImageInfos descriptor_samplers;
   VkDescriptorPool descriptor_pool;
   VkDescriptorSet descriptor_set;
   GskVulkanPipeline *pipelines[GSK_VULKAN_N_PIPELINES];
 
   GskVulkanImage *target;
 
-  VkSampler sampler;
-  VkSampler repeating_sampler;
+  VkSampler samplers[2];
 
   GList *render_passes;
   GSList *cleanup_images;
@@ -120,7 +120,8 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
   self->vulkan = context;
   self->renderer = renderer;
   self->framebuffers = g_hash_table_new (g_direct_hash, g_direct_equal);
-  gsk_descriptor_image_infos_init (&self->descriptor_image_infos);
+  gsk_descriptor_image_infos_init (&self->descriptor_images);
+  gsk_descriptor_image_infos_init (&self->descriptor_samplers);
 
   device = gdk_vulkan_context_get_device (self->vulkan);
 
@@ -138,10 +139,14 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                             .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
                                             .flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT,
                                             .maxSets = 1,
-                                            .poolSizeCount = 1,
-                                            .pPoolSizes = (VkDescriptorPoolSize[1]) {
+                                            .poolSizeCount = 2,
+                                            .pPoolSizes = (VkDescriptorPoolSize[2]) {
                                                 {
-                                                    .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+                                                    .type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
+                                                    .descriptorCount = DESCRIPTOR_POOL_MAXITEMS
+                                                },
+                                                {
+                                                    .type = VK_DESCRIPTOR_TYPE_SAMPLER,
                                                     .descriptorCount = DESCRIPTOR_POOL_MAXITEMS
                                                 }
                                             }
@@ -192,20 +197,29 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
   GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
                                              &(VkDescriptorSetLayoutCreateInfo) {
                                                  .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
-                                                 .bindingCount = 1,
+                                                 .bindingCount = 2,
                                                  .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT,
-                                                 .pBindings = (VkDescriptorSetLayoutBinding[1]) {
+                                                 .pBindings = (VkDescriptorSetLayoutBinding[2]) {
                                                      {
                                                          .binding = 0,
-                                                         .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+                                                         .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
+                                                         .descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
+                                                         .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
+                                                     },
+                                                     {
+                                                         .binding = 1,
+                                                         .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
                                                          .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) {
+                                                   .bindingCount = 2,
+                                                   .pBindingFlags = (VkDescriptorBindingFlags[2]) {
+                                                     VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
+                                                     | VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
+                                                     | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
                                                      VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
                                                      | VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
                                                      | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
@@ -241,7 +255,7 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                      .maxAnisotropy = 1.0,
                                  },
                                  NULL,
-                                 &self->sampler);
+                                 &self->samplers[GSK_VULKAN_SAMPLER_DEFAULT]);
 
   GSK_VK_CHECK (vkCreateSampler, device,
                                  &(VkSamplerCreateInfo) {
@@ -256,7 +270,8 @@ gsk_vulkan_render_new (GskRenderer      *renderer,
                                      .maxAnisotropy = 1.0,
                                  },
                                  NULL,
-                                 &self->repeating_sampler);
+                                 &self->samplers[GSK_VULKAN_SAMPLER_REPEAT]);
+  
 
   self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
 
@@ -442,19 +457,42 @@ gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self)
 }
 
 gsize
-gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
-                                          GskVulkanImage  *source,
-                                          gboolean         repeat)
+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)
 {
-  VkDescriptorImageInfo info = {
-    .sampler = repeat ? self->repeating_sampler : self->sampler,
-    .imageView = gsk_vulkan_image_get_image_view (source),
-    .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
-  };
   gsize result;
 
-  result = gsk_descriptor_image_infos_get_size (&self->descriptor_image_infos);
-  gsk_descriptor_image_infos_append (&self->descriptor_image_infos, &info);
+  result = gsk_descriptor_image_infos_get_size (&self->descriptor_images);
+  gsk_descriptor_image_infos_append (&self->descriptor_images,
+                                     &(VkDescriptorImageInfo) {
+                                       .sampler = VK_NULL_HANDLE,
+                                       .imageView = gsk_vulkan_image_get_image_view (image),
+                                       .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
+                                     });
 
   g_assert (result < DESCRIPTOR_POOL_MAXITEMS);
 
@@ -475,7 +513,8 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
       gsk_vulkan_render_pass_reserve_descriptor_sets (pass, self);
     }
   
-  if (gsk_descriptor_image_infos_get_size (&self->descriptor_image_infos) == 0)
+  if (gsk_descriptor_image_infos_get_size (&self->descriptor_samplers) == 0 &&
+      gsk_descriptor_image_infos_get_size (&self->descriptor_images) == 0)
     return;
 
   GSK_VK_CHECK (vkAllocateDescriptorSets, device,
@@ -488,23 +527,33 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
                                                 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO,
                                                 .descriptorSetCount = 1,
                                                 .pDescriptorCounts = (uint32_t[1]) {
-                                                  gsk_descriptor_image_infos_get_size (&self->descriptor_image_infos)
+                                                  gsk_descriptor_image_infos_get_size (&self->descriptor_images)
+                                                  + gsk_descriptor_image_infos_get_size (&self->descriptor_samplers)
                                                 }
                                               }
                                           },
                                           &self->descriptor_set);
 
   vkUpdateDescriptorSets (device,
-                          1,
-                          (VkWriteDescriptorSet[1]) {
+                          2,
+                          (VkWriteDescriptorSet[2]) {
                               {
                                   .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
                                   .dstSet = self->descriptor_set,
                                   .dstBinding = 0,
                                   .dstArrayElement = 0,
-                                  .descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_image_infos),
-                                  .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
-                                  .pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_image_infos)
+                                  .descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_images),
+                                  .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
+                                  .pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_images)
+                              },
+                              {
+                                  .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
+                                  .dstSet = self->descriptor_set,
+                                  .dstBinding = 1,
+                                  .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)
                               }
                           },
                           0, NULL);
@@ -600,7 +649,8 @@ gsk_vulkan_render_cleanup (GskVulkanRender *self)
   GSK_VK_CHECK (vkResetDescriptorPool, device,
                                        self->descriptor_pool,
                                        0);
-  gsk_descriptor_image_infos_set_size (&self->descriptor_image_infos, 0);
+  gsk_descriptor_image_infos_set_size (&self->descriptor_images, 0);
+  gsk_descriptor_image_infos_set_size (&self->descriptor_samplers, 0);
 
   g_list_free_full (self->render_passes, (GDestroyNotify) gsk_vulkan_render_pass_free);
   self->render_passes = NULL;
@@ -654,7 +704,8 @@ gsk_vulkan_render_free (GskVulkanRender *self)
   vkDestroyDescriptorPool (device,
                            self->descriptor_pool,
                            NULL);
-  gsk_descriptor_image_infos_clear (&self->descriptor_image_infos);
+  gsk_descriptor_image_infos_clear (&self->descriptor_images);
+  gsk_descriptor_image_infos_clear (&self->descriptor_samplers);
 
   vkDestroyDescriptorSetLayout (device,
                                 self->descriptor_set_layout,
@@ -664,13 +715,12 @@ gsk_vulkan_render_free (GskVulkanRender *self)
                   self->fence,
                   NULL);
 
-  vkDestroySampler (device,
-                    self->sampler,
-                    NULL);
-
-  vkDestroySampler (device,
-                    self->repeating_sampler,
-                    NULL);
+  for (i = 0; i < G_N_ELEMENTS (self->samplers); i++)
+    {
+      vkDestroySampler (device,
+                        self->samplers[i],
+                        NULL);
+    }
 
   gsk_vulkan_command_pool_free (self->command_pool);
 
index 58987fd9aa5776d63ba4b5a72c62d79036b27463..1dc2e6286b34fa6474359338c479879efa1d9f51 100644 (file)
@@ -74,8 +74,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 */
-  gsize                descriptor_set_index; /* index into descriptor sets array for the right descriptor set to bind */
-  gsize                descriptor_set_index2; /* descriptor index for the second source (if relevant) */
+  guint32              image_descriptor[2]; /* index into descriptor for the (image, sampler) */
+  guint32              image_descriptor2[2]; /* index into descriptor for the 2nd image (if relevant) */
   graphene_rect_t      source_rect; /* area that source maps to */
   graphene_rect_t      source2_rect; /* area that source2 maps to */
 };
@@ -89,7 +89,7 @@ struct _GskVulkanOpText
   GskRoundedRect       clip; /* clip rect (or random memory if not relevant) */
   GskVulkanImage      *source; /* source image to render */
   gsize                vertex_offset; /* offset into vertex buffer */
-  gsize                descriptor_set_index; /* index into descriptor sets array for the right descriptor set to bind */
+  guint32              image_descriptor[2]; /* 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 */
@@ -1818,7 +1818,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_TEXTURE:
           gsk_vulkan_texture_pipeline_collect_vertex_data (GSK_VULKAN_TEXTURE_PIPELINE (op->render.pipeline),
                                                            data + op->render.vertex_offset,
-                                                           op->render.descriptor_set_index,
+                                                           op->render.image_descriptor,
                                                            &op->render.offset,
                                                            &op->render.node->bounds,
                                                            &op->render.source_rect);
@@ -1827,7 +1827,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_REPEAT:
           gsk_vulkan_texture_pipeline_collect_vertex_data (GSK_VULKAN_TEXTURE_PIPELINE (op->render.pipeline),
                                                            data + op->render.vertex_offset,
-                                                           op->render.descriptor_set_index,
+                                                           op->render.image_descriptor,
                                                            &op->render.offset,
                                                            &op->render.node->bounds,
                                                            &op->render.source_rect);
@@ -1838,7 +1838,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
                                                         data + op->text.vertex_offset,
                                                         GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render)),
                                                         &op->text.node->bounds,
-                                                        op->text.descriptor_set_index,
+                                                        op->text.image_descriptor,
                                                         (PangoFont *)gsk_text_node_get_font (op->text.node),
                                                         gsk_text_node_get_num_glyphs (op->text.node),
                                                         gsk_text_node_get_glyphs (op->text.node, NULL),
@@ -1857,7 +1857,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
                                                               data + op->text.vertex_offset,
                                                               GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render)),
                                                               &op->text.node->bounds,
-                                                              op->text.descriptor_set_index,
+                                                              op->text.image_descriptor,
                                                               (PangoFont *)gsk_text_node_get_font (op->text.node),
                                                               gsk_text_node_get_num_glyphs (op->text.node),
                                                               gsk_text_node_get_glyphs (op->text.node, NULL),
@@ -1906,7 +1906,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
 
             gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline),
                                                             data + op->render.vertex_offset,
-                                                            op->render.descriptor_set_index,
+                                                            op->render.image_descriptor,
                                                             &op->render.offset,
                                                             &op->render.node->bounds,
                                                             &op->render.source_rect,
@@ -1918,7 +1918,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_BLUR:
           gsk_vulkan_blur_pipeline_collect_vertex_data (GSK_VULKAN_BLUR_PIPELINE (op->render.pipeline),
                                                         data + op->render.vertex_offset,
-                                                        op->render.descriptor_set_index,
+                                                        op->render.image_descriptor,
                                                         &op->render.offset,
                                                         &op->render.node->bounds,
                                                         &op->render.source_rect,
@@ -1928,7 +1928,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_COLOR_MATRIX:
           gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline),
                                                           data + op->render.vertex_offset,
-                                                          op->render.descriptor_set_index,
+                                                          op->render.image_descriptor,
                                                           &op->render.offset,
                                                           &op->render.node->bounds,
                                                           &op->render.source_rect,
@@ -1972,8 +1972,8 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_CROSS_FADE:
           gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GSK_VULKAN_CROSS_FADE_PIPELINE (op->render.pipeline),
                                                               data + op->render.vertex_offset,
-                                                              op->render.descriptor_set_index,
-                                                              op->render.descriptor_set_index2,
+                                                              op->render.image_descriptor,
+                                                              op->render.image_descriptor2,
                                                               &op->render.offset,
                                                               &op->render.node->bounds,
                                                               &gsk_cross_fade_node_get_start_child (op->render.node)->bounds,
@@ -1986,8 +1986,8 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_BLEND_MODE:
           gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GSK_VULKAN_BLEND_MODE_PIPELINE (op->render.pipeline),
                                                               data + op->render.vertex_offset,
-                                                              op->render.descriptor_set_index,
-                                                              op->render.descriptor_set_index2,
+                                                              op->render.image_descriptor,
+                                                              op->render.image_descriptor2,
                                                               &op->render.offset,
                                                               &op->render.node->bounds,
                                                               &gsk_blend_node_get_top_child (op->render.node)->bounds,
@@ -2065,25 +2065,34 @@ gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self,
         case GSK_VULKAN_OP_BLUR:
         case GSK_VULKAN_OP_COLOR_MATRIX:
           if (op->render.source)
-            op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source, FALSE);
+            {
+              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);
+            }
           break;
 
         case GSK_VULKAN_OP_REPEAT:
           if (op->render.source)
-            op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source, TRUE);
+            {
+              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_REPEAT);
+            }
           break;
 
         case GSK_VULKAN_OP_TEXT:
         case GSK_VULKAN_OP_COLOR_TEXT:
-          op->text.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->text.source, FALSE);
+          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);
           break;
 
         case GSK_VULKAN_OP_CROSS_FADE:
         case GSK_VULKAN_OP_BLEND_MODE:
           if (op->render.source && op->render.source2)
             {
-              op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source, FALSE);
-              op->render.descriptor_set_index2 = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source2, FALSE);
+              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];
             }
           break;
 
index 457c587e5b3fc5436e08d93f8f7602cfed37681a..51a9f00f876a96c3eeae6ee5b40e0582ab7d0d35 100644 (file)
@@ -51,6 +51,11 @@ typedef enum {
   GSK_VULKAN_N_PIPELINES
 } GskVulkanPipelineType;
 
+typedef enum {
+  GSK_VULKAN_SAMPLER_DEFAULT,
+  GSK_VULKAN_SAMPLER_REPEAT
+} GskVulkanRenderSampler;
+
 GskVulkanRender *       gsk_vulkan_render_new                           (GskRenderer            *renderer,
                                                                          GdkVulkanContext       *context);
 void                    gsk_vulkan_render_free                          (GskVulkanRender        *self);
@@ -76,9 +81,10 @@ void                    gsk_vulkan_render_upload                        (GskVulk
 
 GskVulkanPipeline *     gsk_vulkan_render_get_pipeline                  (GskVulkanRender        *self,
                                                                          GskVulkanPipelineType   pipeline_type);
-gsize                   gsk_vulkan_render_reserve_descriptor_set        (GskVulkanRender        *self,
-                                                                         GskVulkanImage         *source,
-                                                                         gboolean                repeat);
+gsize                   gsk_vulkan_render_get_sampler_descriptor        (GskVulkanRender        *self,
+                                                                         GskVulkanRenderSampler  render_sampler);
+gsize                   gsk_vulkan_render_get_image_descriptor          (GskVulkanRender        *self,
+                                                                         GskVulkanImage         *source);
 VkDescriptorSet         gsk_vulkan_render_get_descriptor_set            (GskVulkanRender        *self);
 
 void                    gsk_vulkan_render_draw                          (GskVulkanRender        *self);
index ed810b7f683f7f29af6226b1f770acdf2be62aa0..60cdd16bd5d6230529cd32e512be9f5c0221566b 100644 (file)
@@ -14,7 +14,7 @@ struct _GskVulkanTextInstance
   float rect[4];
   float tex_rect[4];
   float color[4];
-  guint32 tex_id;
+  guint32 tex_id[2];
 };
 
 G_DEFINE_TYPE (GskVulkanTextPipeline, gsk_vulkan_text_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -51,7 +51,7 @@ gsk_vulkan_text_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
       {
           .location = 3,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanTextInstance, tex_id),
       }
   };
@@ -103,7 +103,7 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline  *pipeline,
                                               guchar                 *data,
                                               GskVulkanRenderer      *renderer,
                                               const graphene_rect_t  *rect,
-                                              guint                   tex_id,
+                                              guint                   tex_id[2],
                                               PangoFont              *font,
                                               guint                   total_glyphs,
                                               const PangoGlyphInfo   *glyphs,
@@ -154,7 +154,8 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline  *pipeline,
           instance->color[2] = color->blue;
           instance->color[3] = color->alpha;
 
-          instance->tex_id = tex_id;
+          instance->tex_id[0] = tex_id[0];
+          instance->tex_id[1] = tex_id[1];
 
           count++;
         }
index 8f05e4350067cba09f422374a3f608b89c7a9652..0cc560c25f25507ea8fb0744e8a44b4ded196d37 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,
+                                                                        guint32                        tex_id[2],
                                                                         PangoFont                     *font,
                                                                         guint                          total_glyphs,
                                                                         const PangoGlyphInfo          *glyphs,
index dc01cca9c3c7d0e41c488892bdeb0fb8ad0be54a..2b9e07520dff7f66dd3a5806502140e586882a53 100644 (file)
@@ -13,7 +13,7 @@ struct _GskVulkanTextureInstance
 {
   float rect[4];
   float tex_rect[4];
-  guint32 tex_id;
+  guint32 tex_id[2];
 };
 
 G_DEFINE_TYPE (GskVulkanTexturePipeline, gsk_vulkan_texture_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -44,7 +44,7 @@ gsk_vulkan_texture_pipeline_get_input_state_create_info (GskVulkanPipeline *self
       {
           .location = 2,
           .binding = 0,
-          .format = VK_FORMAT_R32_UINT,
+          .format = VK_FORMAT_R32G32_UINT,
           .offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, tex_id),
       }
   };
@@ -94,7 +94,7 @@ gsk_vulkan_texture_pipeline_new (GdkVulkanContext *context,
 void
 gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
                                                  guchar                   *data,
-                                                 guint32                   tex_id,
+                                                 guint32                   tex_id[2],
                                                  const graphene_point_t   *offset,
                                                  const graphene_rect_t    *rect,
                                                  const graphene_rect_t    *tex_rect)
@@ -109,7 +109,8 @@ 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 = tex_id;
+  instance->tex_id[0] = tex_id[0];
+  instance->tex_id[1] = tex_id[1];
 }
 
 gsize
index d837e4d9d2bd921ac570848fd0b1962c1ddd94f9..69e3fde2cddbfce71bdd7e039a7102bfb05c70f2 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,
+                                                                         guint32                   tex_id[2],
                                                                          const graphene_point_t   *offset,
                                                                          const graphene_rect_t    *rect,
                                                                          const graphene_rect_t    *tex_rect);
index 56ae22e7a3533c30687b52d617493a917f7c67c9..7cc88d972a29d2ee0d9c21542f2c3962d0b77e12 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 uint inTopTexId;
-layout(location = 6) flat in uint inBottomTexId;
+layout(location = 5) flat in uvec2 inTopTexId;
+layout(location = 6) flat in uvec2 inBottomTexId;
 layout(location = 7) flat in uint inBlendMode;
 
 layout(location = 0) out vec4 color;
@@ -275,11 +275,9 @@ luminosity (vec4 Cs, vec4 Cb)
 void main()
 {
   float source_alpha = rect_coverage (inTopRect, inPos);
-  vec4 source = texture (textures[inTopTexId], inTopTexCoord) * source_alpha;
-  //source=vec4(1); //inTopTexCoord * 100 + 100) / 255, 0, 1);
+  vec4 source = texture (get_sampler (inTopTexId), inTopTexCoord) * source_alpha;
   float backdrop_alpha = rect_coverage (inBottomRect, inPos);
-  vec4 backdrop = texture (textures[inBottomTexId], inBottomTexCoord) * backdrop_alpha;
-  //backdrop=vec4(1, 0, 0, 1) * backdrop_alpha;
+  vec4 backdrop = texture (get_sampler (inBottomTexId), inBottomTexCoord) * backdrop_alpha;
   vec4 result;
 
   if (inBlendMode == 0)
index 338d4900e6c206dd302562eb42c5f86dcfb4fdf1..e25a7c947d7c01a26ec619aef8ffb3c446754afa 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 uint inTopTexId;
-layout(location = 6) in uint inBottomTexId;
+layout(location = 5) in uvec2 inTopTexId;
+layout(location = 6) in uvec2 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 uint outTopTexId;
-layout(location = 6) flat out uint outBottomTexId;
+layout(location = 5) flat out uvec2 outTopTexId;
+layout(location = 6) flat out uvec2 outBottomTexId;
 layout(location = 7) flat out uint outBlendMode;
 
 void main() {
index c67063bb8ca6702ae4ba4462216cd2d2b9c08ad4..5d2039a5084fd8b23be54d69efcb8cbbb48d40c3 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 uint inTexId;
+layout(location = 4) in flat uvec2 inTexId;
 
 layout(location = 0) out vec4 color;
 
@@ -38,7 +38,7 @@ vec4 blur_pixel (in vec2 uv)
           float fx = Gaussian (inRadius, float(x) - float(half_samples_x));
           float offset_x = float(x - half_samples_x) * pixel_size_x;
           total += fx * fy;
-          ret += texture(textures[inTexId], uv + vec2(offset_x, offset_y)) * fx * fy;
+          ret += texture(get_sampler (inTexId), uv + vec2(offset_x, offset_y)) * fx * fy;
         }
     }
   return ret / total;
index 5a5fd6cbcec38a17096fd6f5a11e7d7725283167..e097683731bd6d76912e36f5009181c1dc6af73d 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 uint inTexId;
+layout(location = 3) in uvec2 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 uint outTexId;
+layout(location = 4) out flat uvec2 outTexId;
 
 vec2 offsets[6] = { vec2(0.0, 0.0),
                     vec2(1.0, 0.0),
index ebed0638afffde6f0beba8bc2573a193adc11946..047aaaa5730a8e49494aaecada82fa38b25b0d76 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 uint inTexId;
+layout(location = 7) in flat uvec2 inTexId;
 
 layout(location = 0) out vec4 color;
 
@@ -29,5 +29,5 @@ color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset)
 
 void main()
 {
-  color = clip (inPos, color_matrix (texture (textures[inTexId], inTexCoord), inColorMatrix, inColorOffset));
+  color = clip (inPos, color_matrix (texture (get_sampler (inTexId), inTexCoord), inColorMatrix, inColorOffset));
 }
index 8f92fff2314f04c257b6424c11ef386af3c71261..d892ac6427c059a3c9a55a6f338740104c8e7dd3 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 uint inTexId;
+layout(location = 7) in uvec2 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 uint outTexId;
+layout(location = 7) out flat uvec2 outTexId;
 
 vec2 offsets[6] = { vec2(0.0, 0.0),
                     vec2(1.0, 0.0),
index 239691d7be49db7176ddfc08237f3b743d5627c3..326406296e80c274b028bc2e0fba0c0b2aed821c 100644 (file)
@@ -1,2 +1,6 @@
 
-layout(set = 0, binding = 0) uniform sampler2D textures[50000];
+layout(set = 0, binding = 0) uniform texture2D textures[50000];
+layout(set = 0, binding = 1) uniform sampler samplers[50000];
+
+#define get_sampler(id) sampler2D(textures[id.x], samplers[id.y])
+
index 0b571c45e0b525f25d55b0b65e7d673bbcee3a0e..fc631f091fc18632d3a2c94e69da167887c81cf0 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 uint inStartTexId;
-layout(location = 6) flat in uint inEndTexId;
+layout(location = 5) flat in uvec2 inStartTexId;
+layout(location = 6) flat in uvec2 inEndTexId;
 layout(location = 7) in float inProgress;
 
 layout(location = 0) out vec4 color;
@@ -18,9 +18,9 @@ layout(location = 0) out vec4 color;
 void main()
 {
   float start_alpha = rect_coverage (inStartRect, inPos);
-  vec4 start = texture (textures[inStartTexId], inStartTexCoord) * start_alpha;
+  vec4 start = texture (get_sampler (inStartTexId), inStartTexCoord) * start_alpha;
   float end_alpha = rect_coverage (inEndRect, inPos);
-  vec4 end = texture (textures[inEndTexId], inEndTexCoord) * end_alpha;
+  vec4 end = texture (get_sampler (inEndTexId), inEndTexCoord) * end_alpha;
 
   color = clip_scaled (inPos, mix (start, end, inProgress));
 }
index a670fcef101275596ebf684e56a021b5933d79b4..579e38fef15134efd57af427756c3be775e145e8 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 uint inStartTexId;
-layout(location = 6) in uint inEndTexId;
+layout(location = 5) in uvec2 inStartTexId;
+layout(location = 6) in uvec2 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 uint outStartTexId;
-layout(location = 6) flat out uint outEndTexId;
+layout(location = 5) flat out uvec2 outStartTexId;
+layout(location = 6) flat out uvec2 outEndTexId;
 layout(location = 7) flat out float outProgress;
 
 void main() {
index 08d3ec57704f6151ca08d3e6c1841736c88a86c9..a0a4ee9982aa7fb75b7c8de5f4882f49cd1c8dca 100644 (file)
@@ -6,11 +6,11 @@
 layout(location = 0) in vec2 inPos;
 layout(location = 1) in vec2 inTexCoord;
 layout(location = 2) in vec4 inColor;
-layout(location = 3) flat in uint inTexId;
+layout(location = 3) flat in uvec2 inTexId;
 
 layout(location = 0) out vec4 color;
 
 void main()
 {
-  color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * texture(textures[inTexId], inTexCoord).a);
+  color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * texture(get_sampler (inTexId), inTexCoord).a);
 }
index 09bc2a9909d38b59056cddb647b5ffe24375f95a..e37669170a23915db596d879015ac0bc6776f73a 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 uint inTexId;
+layout(location = 3) in uvec2 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 uint outTexId;
+layout(location = 3) out flat uvec2 outTexId;
 
 vec2 offsets[6] = { vec2(0.0, 0.0),
                     vec2(1.0, 0.0),
index eaaba70fbd6d66b4464f0b10e249eb1b777c5c0c..9f5dfdcc02310fda33c9ec9de2877dca3757b7f1 100644 (file)
@@ -7,12 +7,12 @@
 layout(location = 0) in vec2 inPos;
 layout(location = 1) in Rect inRect;
 layout(location = 2) in vec2 inTexCoord;
-layout(location = 3) flat in uint inTexId;
+layout(location = 3) flat in uvec2 inTexId;
 
 layout(location = 0) out vec4 color;
 
 void main()
 {
   float alpha = rect_coverage (inRect, inPos);
-  color = clip_scaled (inPos, texture (textures[inTexId], inTexCoord) * alpha);
+  color = clip_scaled (inPos, texture (get_sampler (inTexId), inTexCoord) * alpha);
 }
index 69d5a4937d68cba50e872f6f90d94a3613199ec0..ff66519320204ddb6bff08a943c2903f6fe65051 100644 (file)
@@ -5,12 +5,12 @@
 
 layout(location = 0) in vec4 inRect;
 layout(location = 1) in vec4 inTexRect;
-layout(location = 2) in uint inTexId;
+layout(location = 2) in uvec2 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 uint outTexId;
+layout(location = 3) out flat uvec2 outTexId;
 
 void main() {
   Rect r = rect_from_gsk (inRect);