vulkan: Add scale to push constants

This way, it can be pushed to the shaders
This commit is contained in:
Benjamin Otte 2023-05-12 03:59:44 +02:00
parent b3c1284382
commit 57222cc64c
4 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,7 @@ struct _GskVulkanPushConstantsWire
struct {
float mvp[16];
float clip[12];
float scale[2];
} common;
};
@ -23,22 +24,25 @@ G_STATIC_ASSERT (sizeof (GskVulkanPushConstantsWire) <= 128);
static void
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
const graphene_vec2_t *scale,
const graphene_matrix_t *mvp,
const GskRoundedRect *clip)
{
graphene_matrix_to_float (mvp, wire->common.mvp);
gsk_rounded_rect_to_float (clip, graphene_point_zero (), wire->common.clip);
graphene_vec2_to_float (scale, wire->common.scale);
}
void
gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout,
const graphene_vec2_t *scale,
const graphene_matrix_t *mvp,
const GskRoundedRect *clip)
{
GskVulkanPushConstantsWire wire;
gsk_vulkan_push_constants_wire_init (&wire, mvp, clip);
gsk_vulkan_push_constants_wire_init (&wire, scale, mvp, clip);
vkCmdPushConstants (command_buffer,
pipeline_layout,

View File

@ -12,6 +12,7 @@ uint32_t gsk_vulkan_push_constants_get_range_count (void) G
void gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout,
const graphene_vec2_t *scale,
const graphene_matrix_t *mvp,
const GskRoundedRect *clip);

View File

@ -99,6 +99,7 @@ struct _GskVulkanOpPushConstants
{
GskVulkanOpType type;
GskRenderNode *node; /* node that's the source of this op */
graphene_vec2_t scale;
graphene_matrix_t mvp;
GskRoundedRect clip;
};
@ -250,6 +251,7 @@ gsk_vulkan_render_pass_append_push_constants (GskVulkanRenderPass *self,
GskVulkanOp op = {
.constants.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS,
.constants.node = node,
.constants.scale= state->scale,
.constants.mvp = state->mvp,
.constants.clip = state->clip.rect,
};
@ -2268,6 +2270,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
for (int j = 0; j < layout_count; j++)
gsk_vulkan_push_constants_push (command_buffer,
pipeline_layout[j],
&op->constants.scale,
&op->constants.mvp,
&op->constants.clip);

View File

@ -6,6 +6,7 @@ layout(push_constant) uniform PushConstants {
vec4 clip_bounds;
vec4 clip_widths;
vec4 clip_heights;
vec2 scale;
} push;
#endif