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"
|
2021-03-06 00:35:04 +00:00
|
|
|
#include "gsktransform.h"
|
2016-12-14 06:21:21 +00:00
|
|
|
|
2017-01-17 04:20:07 +00:00
|
|
|
typedef struct _GskVulkanPushConstantsWire GskVulkanPushConstantsWire;
|
|
|
|
|
|
|
|
struct _GskVulkanPushConstantsWire
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
float mvp[16];
|
|
|
|
float clip[12];
|
2023-05-12 01:59:44 +00:00
|
|
|
float scale[2];
|
2017-01-17 04:20:07 +00:00
|
|
|
} common;
|
|
|
|
};
|
|
|
|
|
2023-05-10 15:55:56 +00:00
|
|
|
/* This is the value we know every conformant GPU must provide.
|
|
|
|
* See value for maxPushConstantsSize in table 55 of
|
|
|
|
* https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#limits-minmax
|
|
|
|
*/
|
|
|
|
G_STATIC_ASSERT (sizeof (GskVulkanPushConstantsWire) <= 128);
|
|
|
|
|
2016-12-24 03:10:00 +00:00
|
|
|
static void
|
2023-05-11 19:36:44 +00:00
|
|
|
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
2023-05-12 01:59:44 +00:00
|
|
|
const graphene_vec2_t *scale,
|
2023-05-11 19:36:44 +00:00
|
|
|
const graphene_matrix_t *mvp,
|
|
|
|
const GskRoundedRect *clip)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2023-05-11 19:36:44 +00:00
|
|
|
graphene_matrix_to_float (mvp, wire->common.mvp);
|
|
|
|
gsk_rounded_rect_to_float (clip, graphene_point_zero (), wire->common.clip);
|
2023-05-12 01:59:44 +00:00
|
|
|
graphene_vec2_to_float (scale, wire->common.scale);
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-05-11 19:36:44 +00:00
|
|
|
gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
|
|
|
|
VkPipelineLayout pipeline_layout,
|
2023-05-12 01:59:44 +00:00
|
|
|
const graphene_vec2_t *scale,
|
2023-05-11 19:36:44 +00:00
|
|
|
const graphene_matrix_t *mvp,
|
|
|
|
const GskRoundedRect *clip)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2016-12-24 03:10:00 +00:00
|
|
|
GskVulkanPushConstantsWire wire;
|
|
|
|
|
2023-05-12 01:59:44 +00:00
|
|
|
gsk_vulkan_push_constants_wire_init (&wire, scale, mvp, clip);
|
2016-12-24 03:10:00 +00:00
|
|
|
|
2016-12-14 06:21:21 +00:00
|
|
|
vkCmdPushConstants (command_buffer,
|
|
|
|
pipeline_layout,
|
2017-01-17 04:20:07 +00:00
|
|
|
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common),
|
|
|
|
sizeof (wire.common),
|
|
|
|
&wire.common);
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2017-09-23 17:15:30 +00:00
|
|
|
gsk_vulkan_push_constants_get_range_count (void)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2017-01-04 17:37:02 +00:00
|
|
|
return 1;
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const VkPushConstantRange *
|
2017-09-23 17:15:30 +00:00
|
|
|
gsk_vulkan_push_constants_get_ranges (void)
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2017-01-04 17:37:02 +00:00
|
|
|
static const VkPushConstantRange ranges[1] = {
|
2016-12-14 06:21:21 +00:00
|
|
|
{
|
2017-01-17 04:20:07 +00:00
|
|
|
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
.offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common),
|
|
|
|
.size = sizeof (((GskVulkanPushConstantsWire *) 0)->common)
|
2016-12-14 06:21:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return ranges;
|
|
|
|
}
|