diff options
author | Benjamin Otte <otte@redhat.com> | 2017-01-17 05:20:07 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2017-01-17 06:17:55 +0100 |
commit | 6a60e335cd4e313b025d6294869e1c950700521b (patch) | |
tree | 64a50d876ad541b4009617ed236a1b85df9e7165 /gsk/gskvulkanpushconstants.c | |
parent | c7d899c535afce21e0d2ffea94520a2625e4da80 (diff) | |
download | gtk+-6a60e335cd4e313b025d6294869e1c950700521b.tar.gz |
vulkan: Add push constants to fragment shader
That way we don't need to move the clip rounded rect manually through
the vertex shader into the fragment shader but can just look at the push
constants.
Simplifies shaders a lot.
Diffstat (limited to 'gsk/gskvulkanpushconstants.c')
-rw-r--r-- | gsk/gskvulkanpushconstants.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/gsk/gskvulkanpushconstants.c b/gsk/gskvulkanpushconstants.c index 34574c2532..769f3dbbbb 100644 --- a/gsk/gskvulkanpushconstants.c +++ b/gsk/gskvulkanpushconstants.c @@ -4,6 +4,16 @@ #include "gskroundedrectprivate.h" +typedef struct _GskVulkanPushConstantsWire GskVulkanPushConstantsWire; + +struct _GskVulkanPushConstantsWire +{ + struct { + float mvp[16]; + float clip[12]; + } common; +}; + void gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants, const graphene_matrix_t *mvp, @@ -62,14 +72,14 @@ static void gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire, const GskVulkanPushConstants *self) { - graphene_matrix_to_float (&self->mvp, wire->vertex.mvp); - gsk_rounded_rect_to_float (&self->clip.rect, wire->vertex.clip); + graphene_matrix_to_float (&self->mvp, wire->common.mvp); + gsk_rounded_rect_to_float (&self->clip.rect, wire->common.clip); } void -gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self, - VkCommandBuffer command_buffer, - VkPipelineLayout pipeline_layout) +gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self, + VkCommandBuffer command_buffer, + VkPipelineLayout pipeline_layout) { GskVulkanPushConstantsWire wire; @@ -77,26 +87,11 @@ gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self, vkCmdPushConstants (command_buffer, pipeline_layout, - VK_SHADER_STAGE_VERTEX_BIT, - G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex), - sizeof (wire.vertex), - &wire.vertex); -} - -#if 0 -void -gsk_vulkan_push_constants_push_fragment (GskVulkanPushConstants *self, - VkCommandBuffer command_buffer, - VkPipelineLayout pipeline_layout) -{ - vkCmdPushConstants (command_buffer, - pipeline_layout, - VK_SHADER_STAGE_FRAGMENT_BIT, - G_STRUCT_OFFSET (GskVulkanPushConstants, fragment), - sizeof (self->fragment), - &self->fragment); + VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, + G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common), + sizeof (wire.common), + &wire.common); } -#endif uint32_t gst_vulkan_push_constants_get_range_count (void) @@ -109,16 +104,9 @@ gst_vulkan_push_constants_get_ranges (void) { static const VkPushConstantRange ranges[1] = { { - .stageFlags = VK_SHADER_STAGE_VERTEX_BIT, - .offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex), - .size = sizeof (((GskVulkanPushConstantsWire *) 0)->vertex) -#if 0 - }, - { - .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT, - .offset = G_STRUCT_OFFSET (GskVulkanPushConstants, fragment), - .size = sizeof (((GskVulkanPushConstants *) 0)->fragment) -#endif + .stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, + .offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common), + .size = sizeof (((GskVulkanPushConstantsWire *) 0)->common) } }; |