mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
vulkan: Change handling of push constants
Instead of storing the wire format, store the true structs and only convert to the wire format when needed.
This commit is contained in:
parent
b11b7dfb1a
commit
18b65a2378
@ -8,7 +8,7 @@ void
|
|||||||
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
|
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
|
||||||
const graphene_matrix_t *mvp)
|
const graphene_matrix_t *mvp)
|
||||||
{
|
{
|
||||||
gsk_vulkan_push_constants_set_mvp (constants, mvp);
|
graphene_matrix_init_from_matrix (&constants->mvp, mvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -19,34 +19,36 @@ gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gsk_vulkan_push_constants_set_mvp (GskVulkanPushConstants *self,
|
gsk_vulkan_push_constants_init_transform (GskVulkanPushConstants *self,
|
||||||
const graphene_matrix_t *mvp)
|
const GskVulkanPushConstants *src,
|
||||||
|
const graphene_matrix_t *transform)
|
||||||
|
|
||||||
{
|
{
|
||||||
graphene_matrix_to_float (mvp, self->vertex.mvp);
|
graphene_matrix_multiply (transform, &src->mvp, &self->mvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
||||||
|
const GskVulkanPushConstants *self)
|
||||||
|
{
|
||||||
|
graphene_matrix_to_float (&self->mvp, wire->vertex.mvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gsk_vulkan_push_constants_multiply_mvp (GskVulkanPushConstants *self,
|
gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self,
|
||||||
const graphene_matrix_t *transform)
|
VkCommandBuffer command_buffer,
|
||||||
|
VkPipelineLayout pipeline_layout)
|
||||||
{
|
{
|
||||||
graphene_matrix_t old_mvp, new_mvp;
|
GskVulkanPushConstantsWire wire;
|
||||||
|
|
||||||
graphene_matrix_init_from_float (&old_mvp, self->vertex.mvp);
|
gsk_vulkan_push_constants_wire_init (&wire, self);
|
||||||
graphene_matrix_multiply (transform, &old_mvp, &new_mvp);
|
|
||||||
gsk_vulkan_push_constants_set_mvp (self, &new_mvp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gsk_vulkan_push_constants_push_vertex (GskVulkanPushConstants *self,
|
|
||||||
VkCommandBuffer command_buffer,
|
|
||||||
VkPipelineLayout pipeline_layout)
|
|
||||||
{
|
|
||||||
vkCmdPushConstants (command_buffer,
|
vkCmdPushConstants (command_buffer,
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
VK_SHADER_STAGE_VERTEX_BIT,
|
VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
G_STRUCT_OFFSET (GskVulkanPushConstants, vertex),
|
G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex),
|
||||||
sizeof (self->vertex),
|
sizeof (wire.vertex),
|
||||||
&self->vertex);
|
&wire.vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -76,8 +78,8 @@ gst_vulkan_push_constants_get_ranges (void)
|
|||||||
static const VkPushConstantRange ranges[2] = {
|
static const VkPushConstantRange ranges[2] = {
|
||||||
{
|
{
|
||||||
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
.offset = G_STRUCT_OFFSET (GskVulkanPushConstants, vertex),
|
.offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex),
|
||||||
.size = sizeof (((GskVulkanPushConstants *) 0)->vertex)
|
.size = sizeof (((GskVulkanPushConstantsWire *) 0)->vertex)
|
||||||
#if 0
|
#if 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,14 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GskVulkanPushConstants GskVulkanPushConstants;
|
typedef struct _GskVulkanPushConstants GskVulkanPushConstants;
|
||||||
|
typedef struct _GskVulkanPushConstantsWire GskVulkanPushConstantsWire;
|
||||||
|
|
||||||
struct _GskVulkanPushConstants
|
struct _GskVulkanPushConstants
|
||||||
|
{
|
||||||
|
graphene_matrix_t mvp;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GskVulkanPushConstantsWire
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
float mvp[16];
|
float mvp[16];
|
||||||
@ -27,13 +33,11 @@ void gsk_vulkan_push_constants_init (GskVulk
|
|||||||
const graphene_matrix_t *mvp);
|
const graphene_matrix_t *mvp);
|
||||||
void gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
|
void gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
|
||||||
const GskVulkanPushConstants *src);
|
const GskVulkanPushConstants *src);
|
||||||
|
void gsk_vulkan_push_constants_init_transform (GskVulkanPushConstants *self,
|
||||||
void gsk_vulkan_push_constants_set_mvp (GskVulkanPushConstants *self,
|
const GskVulkanPushConstants *src,
|
||||||
const graphene_matrix_t *mvp);
|
|
||||||
void gsk_vulkan_push_constants_multiply_mvp (GskVulkanPushConstants *self,
|
|
||||||
const graphene_matrix_t *transform);
|
const graphene_matrix_t *transform);
|
||||||
|
|
||||||
void gsk_vulkan_push_constants_push_vertex (GskVulkanPushConstants *self,
|
void gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self,
|
||||||
VkCommandBuffer command_buffer,
|
VkCommandBuffer command_buffer,
|
||||||
VkPipelineLayout pipeline_layout);
|
VkPipelineLayout pipeline_layout);
|
||||||
|
|
||||||
|
@ -156,8 +156,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
|||||||
|
|
||||||
gsk_transform_node_get_transform (node, &transform);
|
gsk_transform_node_get_transform (node, &transform);
|
||||||
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
||||||
gsk_vulkan_push_constants_init_copy (&op.constants.constants, constants);
|
gsk_vulkan_push_constants_init_transform (&op.constants.constants, constants, &transform);
|
||||||
gsk_vulkan_push_constants_multiply_mvp (&op.constants.constants, &transform);
|
|
||||||
g_array_append_val (self->render_ops, op);
|
g_array_append_val (self->render_ops, op);
|
||||||
|
|
||||||
graphene_matrix_transform_bounds (&transform, &clip->rect.bounds, &rect);
|
graphene_matrix_transform_bounds (&transform, &clip->rect.bounds, &rect);
|
||||||
|
Loading…
Reference in New Issue
Block a user