diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-29 23:01:34 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-29 23:08:14 -0400 |
commit | 31d8fe3a6a25a7770344f9b0ab3e3a088667d66a (patch) | |
tree | 9f8c01eab135f6ad5a2926d459712596b46b145c | |
parent | e382f956f3d31ac48317daecb453ab759fe06ecf (diff) | |
download | gtk+-31d8fe3a6a25a7770344f9b0ab3e3a088667d66a.tar.gz |
vulkan: Add a repeating sampler
None of the render ops use it, yet.
-rw-r--r-- | gsk/gskvulkanrender.c | 33 | ||||
-rw-r--r-- | gsk/gskvulkanrenderpass.c | 8 | ||||
-rw-r--r-- | gsk/gskvulkanrenderprivate.h | 3 |
3 files changed, 35 insertions, 9 deletions
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c index 27ee71ff31..6c0ab98f7c 100644 --- a/gsk/gskvulkanrender.c +++ b/gsk/gskvulkanrender.c @@ -53,6 +53,7 @@ struct _GskVulkanRender GskVulkanImage *target; VkSampler sampler; + VkSampler repeating_sampler; GList *render_passes; GSList *cleanup_images; @@ -224,6 +225,21 @@ gsk_vulkan_render_new (GskRenderer *renderer, NULL, &self->sampler); + GSK_VK_CHECK (vkCreateSampler, device, + &(VkSamplerCreateInfo) { + .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + .magFilter = VK_FILTER_LINEAR, + .minFilter = VK_FILTER_LINEAR, + .addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT, + .addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT, + .addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT, + .borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, + .unnormalizedCoordinates = VK_FALSE, + .maxAnisotropy = 1.0, + }, + NULL, + &self->repeating_sampler); + self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool); #ifdef G_ENABLE_DEBUG @@ -446,6 +462,7 @@ gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self, typedef struct { gsize index; GskVulkanImage *image; + gboolean repeat; } HashDescriptorSetIndexEntry; static guint @@ -453,7 +470,7 @@ desc_set_index_hash (gconstpointer v) { const HashDescriptorSetIndexEntry *e = v; - return GPOINTER_TO_UINT (e->image); + return GPOINTER_TO_UINT (e->image) + e->repeat; } static gboolean @@ -462,12 +479,13 @@ desc_set_index_equal (gconstpointer v1, gconstpointer v2) const HashDescriptorSetIndexEntry *e1 = v1; const HashDescriptorSetIndexEntry *e2 = v2; - return e1->image == e2->image; + return e1->image == e2->image && e1->repeat == e2->repeat; } gsize gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self, - GskVulkanImage *source) + GskVulkanImage *source, + gboolean repeat) { HashDescriptorSetIndexEntry lookup; HashDescriptorSetIndexEntry *entry; @@ -475,6 +493,7 @@ gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self, g_assert (source != NULL); lookup.image = source; + lookup.repeat = repeat; entry = g_hash_table_lookup (self->descriptor_set_indexes, &lookup); if (entry) @@ -482,6 +501,7 @@ gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self, entry = g_new (HashDescriptorSetIndexEntry, 1); entry->image = source; + entry->repeat = repeat; entry->index = g_hash_table_size (self->descriptor_set_indexes); g_hash_table_add (self->descriptor_set_indexes, entry); @@ -563,6 +583,7 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self) HashDescriptorSetIndexEntry *entry = key; GskVulkanImage *image = entry->image; gsize id = entry->index; + gboolean repeat = entry->repeat; vkUpdateDescriptorSets (device, 1, @@ -575,7 +596,7 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self) .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .pImageInfo = &(VkDescriptorImageInfo) { - .sampler = self->sampler, + .sampler = repeat ? self->repeating_sampler : self->sampler, .imageView = gsk_vulkan_image_get_image_view (image), .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL } @@ -739,6 +760,10 @@ gsk_vulkan_render_free (GskVulkanRender *self) self->sampler, NULL); + vkDestroySampler (device, + self->repeating_sampler, + NULL); + gsk_vulkan_command_pool_free (self->command_pool); g_slice_free (GskVulkanRender, self); diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c index 1c2d05a9b7..ad767ec74b 100644 --- a/gsk/gskvulkanrenderpass.c +++ b/gsk/gskvulkanrenderpass.c @@ -1309,18 +1309,18 @@ gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self, case GSK_VULKAN_OP_OPACITY: case GSK_VULKAN_OP_BLUR: case GSK_VULKAN_OP_COLOR_MATRIX: - op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source); + op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source, FALSE); 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); + op->text.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->text.source, FALSE); break; case GSK_VULKAN_OP_CROSS_FADE: case GSK_VULKAN_OP_BLEND_MODE: - op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source); - op->render.descriptor_set_index2 = gsk_vulkan_render_reserve_descriptor_set (render, 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); break; default: diff --git a/gsk/gskvulkanrenderprivate.h b/gsk/gskvulkanrenderprivate.h index 553699b46e..09751cb064 100644 --- a/gsk/gskvulkanrenderprivate.h +++ b/gsk/gskvulkanrenderprivate.h @@ -84,7 +84,8 @@ GskVulkanPipeline * gsk_vulkan_render_get_pipeline (GskVulk VkDescriptorSet gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self, gsize id); gsize gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self, - GskVulkanImage *source); + GskVulkanImage *source, + gboolean repeat); void gsk_vulkan_render_draw (GskVulkanRender *self); void gsk_vulkan_render_submit (GskVulkanRender *self); |