vulkan: Make the GskVulkanRender struct private

This commit is contained in:
Benjamin Otte 2016-12-08 17:55:32 +01:00
parent eb94153a2c
commit 9635598124
4 changed files with 44 additions and 31 deletions

View File

@ -10,6 +10,23 @@
#define ORTHO_NEAR_PLANE -10000
#define ORTHO_FAR_PLANE 10000
struct _GskVulkanRender
{
GskRenderer *renderer;
GdkVulkanContext *vulkan;
graphene_matrix_t mvp;
int scale_factor;
VkExtent2D size;
VkRect2D scissor;
VkCommandPool command_pool;
VkCommandBuffer command_buffer;
GSList *render_passes;
GSList *cleanup_images;
};
static void
gsk_vulkan_render_compute_mvp (GskVulkanRender *self)
{
@ -95,7 +112,7 @@ gsk_vulkan_render_upload (GskVulkanRender *self)
for (l = self->render_passes; l; l = l->next)
{
gsk_vulkan_render_pass_upload (l->data, self);
gsk_vulkan_render_pass_upload (l->data, self, self->command_buffer);
}
}
@ -219,7 +236,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self,
for (l = self->render_passes; l; l = l->next)
{
gsk_vulkan_render_pass_draw (l->data, self);
gsk_vulkan_render_pass_draw (l->data, self, self->command_buffer);
}
vkCmdEndRenderPass (self->command_buffer);
@ -275,3 +292,9 @@ gsk_vulkan_render_free (GskVulkanRender *self)
g_slice_free (GskVulkanRender, self);
}
GskRenderer *
gsk_vulkan_render_get_renderer (GskVulkanRender *self)
{
return self->renderer;
}

View File

@ -64,8 +64,10 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
}
static void
gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
GskVulkanRender *render)
gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
GskVulkanRenderOp *op,
GskVulkanRender *render,
VkCommandBuffer command_buffer)
{
graphene_rect_t bounds;
GskRenderer *fallback;
@ -80,7 +82,7 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
cr = cairo_create (surface);
cairo_translate (cr, bounds.origin.x, bounds.origin.y);
fallback = gsk_renderer_create_fallback (render->renderer,
fallback = gsk_renderer_create_fallback (gsk_vulkan_render_get_renderer (render),
&bounds,
cr);
gsk_renderer_render (fallback, op->node, NULL);
@ -88,8 +90,8 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
cairo_destroy (cr);
op->source = gsk_vulkan_image_new_from_data (render->vulkan,
render->command_buffer,
op->source = gsk_vulkan_image_new_from_data (self->vulkan,
command_buffer,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface),
@ -102,7 +104,8 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
void
gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
GskVulkanRender *render)
GskVulkanRender *render,
VkCommandBuffer command_buffer)
{
GskVulkanRenderOp *op;
guint i;
@ -114,7 +117,7 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
switch (op->type)
{
case GSK_VULKAN_OP_FALLBACK:
gsk_vulkan_render_pass_upload_fallback (op, render);
gsk_vulkan_render_pass_upload_fallback (self, op, render, command_buffer);
break;
default:
@ -217,7 +220,8 @@ gsk_vulkan_render_pass_update_descriptor_sets (GskVulkanRenderPass *self,
void
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render)
GskVulkanRender *render,
VkCommandBuffer command_buffer)
{
GskVulkanRenderOp *op;
guint i;
@ -226,7 +230,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
{
op = &g_array_index (self->render_ops, GskVulkanRenderOp, i);
vkCmdDraw (render->command_buffer,
vkCmdDraw (command_buffer,
op->vertex_count, 1,
op->vertex_offset, 0);
}

View File

@ -18,7 +18,8 @@ void gsk_vulkan_render_pass_add_node (GskVulk
GskRenderNode *node);
void gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
GskVulkanRender *render);
GskVulkanRender *render,
VkCommandBuffer command_buffer);
gsize gsk_vulkan_render_pass_count_vertices (GskVulkanRenderPass *self);
gsize gsk_vulkan_render_pass_collect_vertices (GskVulkanRenderPass *self,
@ -30,7 +31,8 @@ void gsk_vulkan_render_pass_update_descriptor_sets (GskVulk
VkDescriptorSet descriptor_set,
VkSampler sampler);
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render);
GskVulkanRender *render,
VkCommandBuffer command_buffer);
G_END_DECLS

View File

@ -12,24 +12,6 @@ G_BEGIN_DECLS
typedef struct _GskVulkanRender GskVulkanRender;
typedef struct _GskVulkanVertex GskVulkanVertex;
struct _GskVulkanRender
{
GskRenderer *renderer;
GdkVulkanContext *vulkan;
graphene_matrix_t mvp;
int scale_factor;
VkExtent2D size;
VkRect2D scissor;
VkCommandPool command_pool;
VkCommandBuffer command_buffer;
GSList *render_passes;
GSList *cleanup_images;
};
struct _GskVulkanVertex
{
float x;
@ -43,6 +25,8 @@ GskVulkanRender * gsk_vulkan_render_new (GskRend
VkCommandPool command_pool);
void gsk_vulkan_render_free (GskVulkanRender *self);
GskRenderer * gsk_vulkan_render_get_renderer (GskVulkanRender *self);
void gsk_vulkan_render_add_cleanup_image (GskVulkanRender *self,
GskVulkanImage *image);