struct _GskVulkanCrossFadeInstance
{
float rect[4];
+ float start_rect[4];
+ float end_rect[4];
float start_tex_rect[4];
float end_tex_rect[4];
- float start_tex_id;
- float end_tex_id;
+ guint32 start_tex_id;
+ guint32 end_tex_id;
float progress;
};
.location = 1,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
- .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_rect),
+ .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_rect),
},
{
.location = 2,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
- .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_rect),
+ .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_rect),
},
{
.location = 3,
.binding = 0,
+ .format = VK_FORMAT_R32G32B32A32_SFLOAT,
+ .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_rect),
+ },
+ {
+ .location = 4,
+ .binding = 0,
+ .format = VK_FORMAT_R32G32B32A32_SFLOAT,
+ .offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_rect),
+ },
+ {
+ .location = 5,
+ .binding = 0,
.format = VK_FORMAT_R32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_id),
},
{
- .location = 4,
+ .location = 6,
.binding = 0,
.format = VK_FORMAT_R32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_id),
},
{
- .location = 5,
+ .location = 7,
.binding = 0,
.format = VK_FORMAT_R32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, progress),
guint32 end_tex_id,
const graphene_point_t *offset,
const graphene_rect_t *bounds,
+ const graphene_rect_t *start_bounds,
+ const graphene_rect_t *end_bounds,
const graphene_rect_t *start_tex_rect,
const graphene_rect_t *end_tex_rect,
double progress)
instance->rect[2] = bounds->size.width;
instance->rect[3] = bounds->size.height;
+ instance->start_rect[0] = start_bounds->origin.x + offset->x;
+ instance->start_rect[1] = start_bounds->origin.y + offset->y;
+ instance->start_rect[2] = start_bounds->size.width;
+ instance->start_rect[3] = start_bounds->size.height;
+
+ instance->end_rect[0] = end_bounds->origin.x + offset->x;
+ instance->end_rect[1] = end_bounds->origin.y + offset->y;
+ instance->end_rect[2] = end_bounds->size.width;
+ instance->end_rect[3] = end_bounds->size.height;
+
instance->start_tex_rect[0] = start_tex_rect->origin.x;
instance->start_tex_rect[1] = start_tex_rect->origin.y;
instance->start_tex_rect[2] = start_tex_rect->size.width;
const graphene_rect_t *bounds,
const graphene_rect_t *start_bounds,
const graphene_rect_t *end_bounds,
+ const graphene_rect_t *start_tex_rect,
+ const graphene_rect_t *end_tex_rect,
double progress);
gsize gsk_vulkan_cross_fade_pipeline_draw (GskVulkanCrossFadePipeline *pipeline,
VkCommandBuffer command_buffer,
op->render.descriptor_set_index2,
&op->render.offset,
&op->render.node->bounds,
+ &gsk_cross_fade_node_get_start_child (op->render.node)->bounds,
+ &gsk_cross_fade_node_get_end_child (op->render.node)->bounds,
&op->render.source_rect,
&op->render.source2_rect,
gsk_cross_fade_node_get_progress (op->render.node));
#include "common.frag.glsl"
#include "clip.frag.glsl"
+#include "rect.frag.glsl"
layout(location = 0) in vec2 inPos;
-layout(location = 1) in vec2 inStartTexCoord;
-layout(location = 2) in vec2 inEndTexCoord;
-layout(location = 3) flat in uint inStartTexId;
-layout(location = 4) flat in uint inEndTexId;
-layout(location = 5) in float inProgress;
+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 = 7) in float inProgress;
layout(location = 0) out vec4 color;
void main()
{
- vec4 start = texture (textures[inStartTexId], inStartTexCoord);
- vec4 end = texture (textures[inEndTexId], inEndTexCoord);
+ float start_alpha = rect_coverage (inStartRect, inPos);
+ vec4 start = texture (textures[inStartTexId], inStartTexCoord) * start_alpha;
+ float end_alpha = rect_coverage (inEndRect, inPos);
+ vec4 end = texture (textures[inEndTexId], inEndTexCoord) * end_alpha;
- color = clip (inPos, mix (start, end, inProgress));
+ color = clip_scaled (inPos, mix (start, end, inProgress));
}
#version 420 core
-#include "clip.vert.glsl"
+#include "common.vert.glsl"
+#include "rect.vert.glsl"
layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inStartTexRect;
-layout(location = 2) in vec4 inEndTexRect;
-layout(location = 3) in uint inStartTexId;
-layout(location = 4) in uint inEndTexId;
-layout(location = 5) in float inProgress;
+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 = 7) in float inProgress;
layout(location = 0) out vec2 outPos;
-layout(location = 1) out vec2 outStartTexCoord;
-layout(location = 2) out vec2 outEndTexCoord;
-layout(location = 3) flat out uint outStartTexId;
-layout(location = 4) flat out uint outEndTexId;
-layout(location = 5) flat out float outProgress;
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
- vec2(1.0, 0.0),
- vec2(0.0, 1.0),
- vec2(0.0, 1.0),
- vec2(1.0, 0.0),
- vec2(1.0, 1.0) };
+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 = 7) flat out float outProgress;
void main() {
- vec4 rect = clip (inRect);
- vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
- gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
+ Rect r = rect_from_gsk (inRect);
+ vec2 pos = set_position_from_rect (r);
outPos = pos;
-
- vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
- rect.zw / inRect.zw);
- vec4 starttexrect = vec4(inStartTexRect.xy + inStartTexRect.zw * texrect.xy,
- inStartTexRect.zw * texrect.zw);
- vec4 endtexrect = vec4(inEndTexRect.xy + inEndTexRect.zw * texrect.xy,
- inEndTexRect.zw * texrect.zw);
-
- outStartTexCoord = starttexrect.xy + starttexrect.zw * offsets[gl_VertexIndex];
- outEndTexCoord = endtexrect.xy + endtexrect.zw * offsets[gl_VertexIndex];
+ outStartRect = rect_from_gsk (inStartRect);
+ outEndRect = rect_from_gsk (inEndRect);
+ outStartTexCoord = scale_tex_coord (pos, r, inStartTexRect);
+ outEndTexCoord = scale_tex_coord (pos, r, inEndTexRect);
outStartTexId = inStartTexId;
outEndTexId = inEndTexId;
outProgress = inProgress;