2016-12-14 06:21:21 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gskvulkanpushconstantsprivate.h"
|
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
#include "gskroundedrectprivate.h"
|
2016-12-14 06:21:21 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
|
2016-12-24 03:58:51 +00:00
|
|
|
const graphene_matrix_t *mvp,
|
|
|
|
const graphene_rect_t *viewport)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2016-12-24 03:10:00 +00:00
|
|
|
graphene_matrix_init_from_matrix (&constants->mvp, mvp);
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_vulkan_clip_init_empty (&constants->clip, viewport);
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
|
|
|
|
const GskVulkanPushConstants *src)
|
|
|
|
{
|
|
|
|
*self = *src;
|
|
|
|
}
|
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
gboolean
|
|
|
|
gsk_vulkan_push_constants_transform (GskVulkanPushConstants *self,
|
|
|
|
const GskVulkanPushConstants *src,
|
|
|
|
const graphene_matrix_t *transform,
|
|
|
|
const graphene_rect_t *viewport)
|
2016-12-24 03:10:00 +00:00
|
|
|
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2016-12-24 03:58:51 +00:00
|
|
|
if (!gsk_vulkan_clip_transform (&self->clip, &src->clip, transform, viewport))
|
|
|
|
return FALSE;
|
|
|
|
|
2016-12-24 03:10:00 +00:00
|
|
|
graphene_matrix_multiply (transform, &src->mvp, &self->mvp);
|
2016-12-24 03:58:51 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gsk_vulkan_push_constants_intersect_rect (GskVulkanPushConstants *self,
|
|
|
|
const GskVulkanPushConstants *src,
|
|
|
|
const graphene_rect_t *rect)
|
|
|
|
{
|
|
|
|
if (!gsk_vulkan_clip_intersect_rect (&self->clip, &src->clip, rect))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
graphene_matrix_init_from_matrix (&self->mvp, &src->mvp);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gsk_vulkan_push_constants_intersect_rounded (GskVulkanPushConstants *self,
|
|
|
|
const GskVulkanPushConstants *src,
|
|
|
|
const GskRoundedRect *rect)
|
|
|
|
{
|
|
|
|
if (!gsk_vulkan_clip_intersect_rounded_rect (&self->clip, &src->clip, rect))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
graphene_matrix_init_from_matrix (&self->mvp, &src->mvp);
|
|
|
|
return TRUE;
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
2016-12-24 03:10:00 +00:00
|
|
|
static void
|
|
|
|
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
|
|
|
const GskVulkanPushConstants *self)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2016-12-24 03:10:00 +00:00
|
|
|
graphene_matrix_to_float (&self->mvp, wire->vertex.mvp);
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_rounded_rect_to_float (&self->clip.rect, wire->vertex.clip);
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-12-24 03:10:00 +00:00
|
|
|
gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self,
|
|
|
|
VkCommandBuffer command_buffer,
|
|
|
|
VkPipelineLayout pipeline_layout)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2016-12-24 03:10:00 +00:00
|
|
|
GskVulkanPushConstantsWire wire;
|
|
|
|
|
|
|
|
gsk_vulkan_push_constants_wire_init (&wire, self);
|
|
|
|
|
2016-12-14 06:21:21 +00:00
|
|
|
vkCmdPushConstants (command_buffer,
|
|
|
|
pipeline_layout,
|
|
|
|
VK_SHADER_STAGE_VERTEX_BIT,
|
2016-12-24 03:10:00 +00:00
|
|
|
G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex),
|
|
|
|
sizeof (wire.vertex),
|
|
|
|
&wire.vertex);
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 06:07:02 +00:00
|
|
|
#if 0
|
2016-12-14 06:21:21 +00:00
|
|
|
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);
|
|
|
|
}
|
2016-12-18 06:07:02 +00:00
|
|
|
#endif
|
2016-12-14 06:21:21 +00:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
gst_vulkan_push_constants_get_range_count (void)
|
|
|
|
{
|
2017-01-04 17:37:02 +00:00
|
|
|
return 1;
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const VkPushConstantRange *
|
|
|
|
gst_vulkan_push_constants_get_ranges (void)
|
|
|
|
{
|
2017-01-04 17:37:02 +00:00
|
|
|
static const VkPushConstantRange ranges[1] = {
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
|
|
|
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
2016-12-24 03:10:00 +00:00
|
|
|
.offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex),
|
|
|
|
.size = sizeof (((GskVulkanPushConstantsWire *) 0)->vertex)
|
2016-12-18 06:07:02 +00:00
|
|
|
#if 0
|
2016-12-14 06:21:21 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
.offset = G_STRUCT_OFFSET (GskVulkanPushConstants, fragment),
|
|
|
|
.size = sizeof (((GskVulkanPushConstants *) 0)->fragment)
|
2016-12-18 06:07:02 +00:00
|
|
|
#endif
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return ranges;
|
|
|
|
}
|