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,27 +87,12 @@ 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); + VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, + G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common), + sizeof (wire.common), + &wire.common); } -#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); -} -#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) } }; diff --git a/gsk/gskvulkanpushconstantsprivate.h b/gsk/gskvulkanpushconstantsprivate.h index 4642d526a3..f1652c98af 100644 --- a/gsk/gskvulkanpushconstantsprivate.h +++ b/gsk/gskvulkanpushconstantsprivate.h @@ -8,7 +8,6 @@ G_BEGIN_DECLS typedef struct _GskVulkanPushConstants GskVulkanPushConstants; -typedef struct _GskVulkanPushConstantsWire GskVulkanPushConstantsWire; struct _GskVulkanPushConstants { @@ -16,18 +15,6 @@ struct _GskVulkanPushConstants GskVulkanClip clip; }; -struct _GskVulkanPushConstantsWire -{ - struct { - float mvp[16]; - float clip[12]; - } vertex; -#if 0 - struct { - } fragment; -#endif -}; - const VkPushConstantRange * gst_vulkan_push_constants_get_ranges (void) G_GNUC_PURE; uint32_t gst_vulkan_push_constants_get_range_count (void) G_GNUC_PURE; @@ -49,7 +36,7 @@ gboolean gsk_vulkan_push_constants_intersect_rounded (GskVulk const GskVulkanPushConstants *src, const GskRoundedRect *rect); -void gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self, +void gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self, VkCommandBuffer command_buffer, VkPipelineLayout pipeline_layout); diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c index c92375e30b..619a1172b3 100644 --- a/gsk/gskvulkanrenderpass.c +++ b/gsk/gskvulkanrenderpass.c @@ -886,9 +886,9 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self, break; case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS: - gsk_vulkan_push_constants_push_vertex (&op->constants.constants, - command_buffer, - gsk_vulkan_pipeline_layout_get_pipeline_layout (layout)); + gsk_vulkan_push_constants_push (&op->constants.constants, + command_buffer, + gsk_vulkan_pipeline_layout_get_pipeline_layout (layout)); break; default: diff --git a/gsk/resources/vulkan/blend-clip-rounded.frag.glsl b/gsk/resources/vulkan/blend-clip-rounded.frag.glsl index fb1c14808c..23ef1c83d7 100644 --- a/gsk/resources/vulkan/blend-clip-rounded.frag.glsl +++ b/gsk/resources/vulkan/blend-clip-rounded.frag.glsl @@ -1,5 +1,7 @@ #version 420 core +#include "constants.glsl" + struct RoundedRect { vec4 bounds; vec4 corners; @@ -7,8 +9,6 @@ struct RoundedRect { layout(location = 0) in vec2 inPos; layout(location = 1) in vec2 inTexCoord; -layout(location = 2) in flat vec4 inClipBounds; -layout(location = 3) in flat vec4 inClipWidths; layout(set = 0, binding = 0) uniform sampler2D inTexture; @@ -51,7 +51,7 @@ float clip(vec2 pos, RoundedRect r) { void main() { - RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths); + RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths); color = texture (inTexture, inTexCoord) * clip (inPos, r); } diff --git a/gsk/resources/vulkan/blend-clip-rounded.frag.spv b/gsk/resources/vulkan/blend-clip-rounded.frag.spv index aa407c2d1b..adaa02be72 100644 Binary files a/gsk/resources/vulkan/blend-clip-rounded.frag.spv and b/gsk/resources/vulkan/blend-clip-rounded.frag.spv differ diff --git a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl b/gsk/resources/vulkan/blend-clip-rounded.vert.glsl index 221cbbeeba..0a5f31d79c 100644 --- a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl +++ b/gsk/resources/vulkan/blend-clip-rounded.vert.glsl @@ -7,8 +7,6 @@ layout(location = 1) in vec4 inTexRect; layout(location = 0) out vec2 outPos; layout(location = 1) out vec2 outTexCoord; -layout(location = 2) out flat vec4 outClipBounds; -layout(location = 3) out flat vec4 outClipWidths; out gl_PerVertex { vec4 gl_Position; @@ -37,8 +35,6 @@ void main() { gl_Position = push.mvp * vec4 (pos, 0.0, 1.0); outPos = pos; - outClipBounds = push.clip_bounds; - outClipWidths = push.clip_widths; vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw, rect.zw / inRect.zw); diff --git a/gsk/resources/vulkan/blend-clip-rounded.vert.spv b/gsk/resources/vulkan/blend-clip-rounded.vert.spv index 2a2d7ce9a4..bc82237ef5 100644 Binary files a/gsk/resources/vulkan/blend-clip-rounded.vert.spv and b/gsk/resources/vulkan/blend-clip-rounded.vert.spv differ diff --git a/gsk/resources/vulkan/border-clip-rounded.frag.glsl b/gsk/resources/vulkan/border-clip-rounded.frag.glsl index bf4ad650b1..d31718abb9 100644 --- a/gsk/resources/vulkan/border-clip-rounded.frag.glsl +++ b/gsk/resources/vulkan/border-clip-rounded.frag.glsl @@ -1,5 +1,6 @@ #version 420 core +#include "constants.glsl" #include "rounded-rect.glsl" layout(location = 0) in vec2 inPos; @@ -8,16 +9,13 @@ layout(location = 2) in vec4 inRect; layout(location = 3) in vec4 inCornerWidths; layout(location = 4) in vec4 inCornerHeights; layout(location = 5) in vec4 inBorderWidths; -layout(location = 6) in flat vec4 inClipBounds; -layout(location = 7) in flat vec4 inClipWidths; -layout(location = 8) in flat vec4 inClipHeights; layout(location = 0) out vec4 color; vec4 clip (vec4 color) { - RoundedRect r = RoundedRect (vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths, inClipHeights); + RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths, push.clip_heights); return color * rounded_rect_coverage (r, inPos); } diff --git a/gsk/resources/vulkan/border-clip-rounded.frag.spv b/gsk/resources/vulkan/border-clip-rounded.frag.spv index 401d7ae1c6..3be544337c 100644 Binary files a/gsk/resources/vulkan/border-clip-rounded.frag.spv and b/gsk/resources/vulkan/border-clip-rounded.frag.spv differ diff --git a/gsk/resources/vulkan/border-clip-rounded.vert.glsl b/gsk/resources/vulkan/border-clip-rounded.vert.glsl index a66d7f78dc..8db91a58a4 100644 --- a/gsk/resources/vulkan/border-clip-rounded.vert.glsl +++ b/gsk/resources/vulkan/border-clip-rounded.vert.glsl @@ -14,9 +14,6 @@ layout(location = 2) out flat vec4 outRect; layout(location = 3) out flat vec4 outCornerWidths; layout(location = 4) out flat vec4 outCornerHeights; layout(location = 5) out flat vec4 outBorderWidths; -layout(location = 6) out flat vec4 outClipBounds; -layout(location = 7) out flat vec4 outClipWidths; -layout(location = 8) out flat vec4 outClipHeights; out gl_PerVertex { vec4 gl_Position; @@ -112,7 +109,4 @@ void main() { outCornerWidths = inCornerWidths; outCornerHeights = inCornerHeights; outBorderWidths = inBorderWidths; - outClipBounds = push.clip_bounds; - outClipWidths = push.clip_widths; - outClipHeights = push.clip_heights; } diff --git a/gsk/resources/vulkan/border-clip-rounded.vert.spv b/gsk/resources/vulkan/border-clip-rounded.vert.spv index 5271686167..ce5e85e3dc 100644 Binary files a/gsk/resources/vulkan/border-clip-rounded.vert.spv and b/gsk/resources/vulkan/border-clip-rounded.vert.spv differ diff --git a/gsk/resources/vulkan/color-clip-rounded.frag.glsl b/gsk/resources/vulkan/color-clip-rounded.frag.glsl index 515a9989e7..c1fa5038d5 100644 --- a/gsk/resources/vulkan/color-clip-rounded.frag.glsl +++ b/gsk/resources/vulkan/color-clip-rounded.frag.glsl @@ -1,9 +1,9 @@ #version 420 core +#include "constants.glsl" + layout(location = 0) in vec2 inPos; layout(location = 1) in vec4 inColor; -layout(location = 2) in vec4 inClipBounds; -layout(location = 3) in vec4 inClipWidths; layout(location = 0) out vec4 color; @@ -50,7 +50,7 @@ float clip(vec2 pos, RoundedRect r) { void main() { - RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths); + RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths); - color = vec4(inColor.rgb * inColor.a, inColor.a) * clip (inPos, r); + color = vec4(inColor.rgb * inColor.a, inColor.a) * clip (inPos, r); } diff --git a/gsk/resources/vulkan/color-clip-rounded.frag.spv b/gsk/resources/vulkan/color-clip-rounded.frag.spv index cf650af95c..ce925764d4 100644 Binary files a/gsk/resources/vulkan/color-clip-rounded.frag.spv and b/gsk/resources/vulkan/color-clip-rounded.frag.spv differ diff --git a/gsk/resources/vulkan/color-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-clip-rounded.vert.glsl index 2303d90e70..985a174f97 100644 --- a/gsk/resources/vulkan/color-clip-rounded.vert.glsl +++ b/gsk/resources/vulkan/color-clip-rounded.vert.glsl @@ -7,8 +7,6 @@ layout(location = 1) in vec4 inColor; layout(location = 0) out vec2 outPos; layout(location = 1) out flat vec4 outColor; -layout(location = 2) out flat vec4 outClipBounds; -layout(location = 3) out flat vec4 outClipWidths; out gl_PerVertex { vec4 gl_Position; @@ -26,6 +24,4 @@ void main() { gl_Position = push.mvp * vec4 (pos, 0.0, 1.0); outPos = pos; outColor = inColor; - outClipBounds = push.clip_bounds; - outClipWidths = push.clip_widths; } diff --git a/gsk/resources/vulkan/color-clip-rounded.vert.spv b/gsk/resources/vulkan/color-clip-rounded.vert.spv index b283554467..941189cf44 100644 Binary files a/gsk/resources/vulkan/color-clip-rounded.vert.spv and b/gsk/resources/vulkan/color-clip-rounded.vert.spv differ diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl b/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl index c0e42cac6d..6015aee752 100644 --- a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl +++ b/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl @@ -1,5 +1,7 @@ #version 420 core +#include "constants.glsl" + struct RoundedRect { vec4 bounds; vec4 corners; @@ -7,10 +9,8 @@ struct RoundedRect { layout(location = 0) in vec2 inPos; layout(location = 1) in vec2 inTexCoord; -layout(location = 2) in flat vec4 inClipBounds; -layout(location = 3) in flat vec4 inClipWidths; -layout(location = 4) in flat mat4 inColorMatrix; -layout(location = 8) in flat vec4 inColorOffset; +layout(location = 2) in flat mat4 inColorMatrix; +layout(location = 6) in flat vec4 inColorOffset; layout(set = 0, binding = 0) uniform sampler2D inTexture; @@ -70,7 +70,7 @@ color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset) void main() { - RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths); + RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths); color = color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset) * clip (inPos, r); } diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.spv b/gsk/resources/vulkan/color-matrix-clip-rounded.frag.spv index f4c753aae6..f0a36e010c 100644 Binary files a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.spv and b/gsk/resources/vulkan/color-matrix-clip-rounded.frag.spv differ diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl index 5d3e3400e6..1c7f0a4342 100644 --- a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl +++ b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl @@ -9,10 +9,8 @@ layout(location = 6) in vec4 inColorOffset; layout(location = 0) out vec2 outPos; layout(location = 1) out vec2 outTexCoord; -layout(location = 2) out flat vec4 outClipBounds; -layout(location = 3) out flat vec4 outClipWidths; -layout(location = 4) out flat mat4 outColorMatrix; -layout(location = 8) out flat vec4 outColorOffset; +layout(location = 2) out flat mat4 outColorMatrix; +layout(location = 6) out flat vec4 outColorOffset; out gl_PerVertex { vec4 gl_Position; @@ -41,8 +39,6 @@ void main() { gl_Position = push.mvp * vec4 (pos, 0.0, 1.0); outPos = pos; - outClipBounds = push.clip_bounds; - outClipWidths = push.clip_widths; vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw, rect.zw / inRect.zw); diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv index d4db4839d1..14b85f53ee 100644 Binary files a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv and b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv differ diff --git a/gsk/resources/vulkan/linear-clip-rounded.frag.glsl b/gsk/resources/vulkan/linear-clip-rounded.frag.glsl index 3c5fade7e3..4535a44abb 100644 --- a/gsk/resources/vulkan/linear-clip-rounded.frag.glsl +++ b/gsk/resources/vulkan/linear-clip-rounded.frag.glsl @@ -1,5 +1,7 @@ #version 420 core +#include "constants.glsl" + struct ColorStop { float offset; vec4 color; @@ -14,9 +16,7 @@ layout(location = 0) in vec2 inPos; layout(location = 1) in float inGradientPos; layout(location = 2) in flat int inRepeating; layout(location = 3) in flat int inStopCount; -layout(location = 4) in flat vec4 inClipBounds; -layout(location = 5) in flat vec4 inClipWidths; -layout(location = 6) in flat ColorStop inStops[8]; +layout(location = 4) in flat ColorStop inStops[8]; layout(location = 0) out vec4 outColor; @@ -57,7 +57,7 @@ float clip(vec2 pos, RoundedRect r) { void main() { - RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths); + RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths); float pos; if (inRepeating != 0) diff --git a/gsk/resources/vulkan/linear-clip-rounded.frag.spv b/gsk/resources/vulkan/linear-clip-rounded.frag.spv index ce8a52a43d..4a018c0414 100644 Binary files a/gsk/resources/vulkan/linear-clip-rounded.frag.spv and b/gsk/resources/vulkan/linear-clip-rounded.frag.spv differ diff --git a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl b/gsk/resources/vulkan/linear-clip-rounded.vert.glsl index c06021d3cf..fd50e26f55 100644 --- a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl +++ b/gsk/resources/vulkan/linear-clip-rounded.vert.glsl @@ -27,9 +27,7 @@ layout(location = 0) out vec2 outPos; layout(location = 1) out float outGradientPos; layout(location = 2) out flat int outRepeating; layout(location = 3) out flat int outStopCount; -layout(location = 4) out flat vec4 outClipBounds; -layout(location = 5) out flat vec4 outClipWidths; -layout(location = 6) out flat ColorStop outStops[8]; +layout(location = 4) out flat ColorStop outStops[8]; out gl_PerVertex { vec4 gl_Position; @@ -56,8 +54,6 @@ void main() { gl_Position = push.mvp * vec4 (pos, 0.0, 1.0); outPos = pos; outGradientPos = get_gradient_pos (pos); - outClipBounds = push.clip_bounds; - outClipWidths = push.clip_widths; outRepeating = inRepeating; outStopCount = inStopCount; outStops[0].offset = inOffsets0[0]; diff --git a/gsk/resources/vulkan/linear-clip-rounded.vert.spv b/gsk/resources/vulkan/linear-clip-rounded.vert.spv index 800e090e91..421516f7ef 100644 Binary files a/gsk/resources/vulkan/linear-clip-rounded.vert.spv and b/gsk/resources/vulkan/linear-clip-rounded.vert.spv differ